/* ===================================================================
   Site navigation — Atomic Object 2026 Design System
   Two coordinated surfaces sharing one structure:
   • Full nav  — collapsed by default everywhere; a "Contents" trigger
     opens a slide-in drawer of every chapter (grouped by Part) with
     its sections nested beneath.
   • Local rail — wide screens only; a sticky sidebar pairing the
     Contents trigger with the current page title and section list.
   Narrow viewports drop the rail and show a fixed Contents trigger.
   =================================================================== */

:root {
  --doc-rail-width: 250px;
  --doc-rail-gap: 48px;
}

/* Content frame spans the full width — no permanent rail offset. */
.site-content-frame {
  position: relative;
  min-height: 100vh;
}

/* ── "Contents" trigger ───────────────────────────────────────────── */

.nav-trigger {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--ao-heading-black);
  font-family: var(--font-heading);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  line-height: 1;
  cursor: pointer;
  transition:
    border-color var(--duration-normal) var(--ease-out),
    color var(--duration-normal) var(--ease-out);
}

.nav-trigger:hover {
  border-color: var(--primary);
  color: var(--ao-dark-red);
}

.nav-trigger:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
}

.nav-trigger__icon {
  display: inline-grid;
  gap: 3px;
  width: 16px;
}

.nav-trigger__icon span {
  display: block;
  height: 2px;
  background: currentColor;
}

/* Fixed trigger — narrow viewports only (the rail's trigger is used wide). */
.nav-trigger--fixed {
  display: none;
  position: fixed;
  top: 14px;
  left: 14px;
  z-index: 10030;
  box-shadow: 0 4px 14px rgba(45, 45, 45, 0.12);
}

/* ── Full-nav drawer ──────────────────────────────────────────────── */

.nav-scrim {
  position: fixed;
  inset: 0;
  z-index: 10040;
  background: rgba(45, 45, 45, 0.32);
}

.nav-scrim[hidden] {
  display: none;
}

.full-nav {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 10050;
  display: flex;
  flex-direction: column;
  width: min(360px, 86vw);
  background: var(--ao-white);
  border-right: 1px solid var(--border);
  transform: translateX(-104%);
  transition: transform var(--duration-normal) var(--ease-out);
}

.nav-open .full-nav {
  transform: translateX(0);
  box-shadow: 16px 0 40px rgba(45, 45, 45, 0.14);
}

/* Drawer header doubles as the book masthead (title / subtitle / author). */
.full-nav__head {
  position: relative;
  flex: 0 0 auto;
  padding: 20px 22px 18px;
  border-bottom: 1px solid var(--border);
}

.full-nav__title {
  display: block;
  margin: 0;
  padding-right: 56px; /* clear the Close button on the first line */
  color: var(--ao-heading-black);
  font-family: var(--font-heading);
  font-size: 1.3rem;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.01em;
  text-decoration: none;
}

.full-nav__title:hover {
  color: var(--ao-dark-red);
}

.full-nav__title:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
}

.full-nav__subtitle {
  margin: 8px 0 0;
  color: var(--foreground);
  font-size: 0.84rem;
  line-height: 1.4;
}

.full-nav__author {
  margin: 9px 0 0;
  color: var(--foreground);
  font-size: 0.8rem;
  line-height: 1.3;
}

.nav-close {
  position: absolute;
  top: 18px;
  right: 18px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  background: var(--muted);
  color: var(--ao-body-black);
  font-family: var(--font-heading);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
}

.nav-close:hover {
  border-color: var(--primary);
  color: var(--ao-dark-red);
}

.nav-close:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
}

.full-nav__body {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 10px 14px 28px;
}

/* Part header — divides chapter groups. */
.full-nav__part {
  margin: 16px 14px 5px;
  padding-top: 13px;
  border-top: 1px solid var(--border);
  color: var(--foreground);
  font-family: var(--font-heading);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

/* A Part header leading the list shouldn't carry a top rule. */
.full-nav__body > .full-nav__part:first-child {
  margin-top: 4px;
  padding-top: 0;
  border-top: 0;
}

.full-nav__item {
  margin: 0;
}

/* Top-level chapters (Introduction, Project Management) are peers of the Part,
   not members of it. A trailing one is closed off from the Part above by a
   rule; the leading one (Introduction) needs none. */
.full-nav__item--standalone:not(:first-child) {
  margin-top: 11px;
  padding-top: 11px;
  border-top: 1px solid var(--border);
}

.full-nav__chapter {
  display: block;
  padding: 5px 14px;
  border-left: 3px solid transparent;
  color: var(--ao-heading-black);
  font-family: var(--font-heading);
  font-size: 0.98rem;
  font-weight: 600;
  line-height: 1.3;
  text-decoration: none;
  transition:
    color var(--duration-normal) var(--ease-out),
    border-color var(--duration-normal) var(--ease-out);
}

.full-nav__chapter:hover {
  color: var(--ao-dark-red);
}

.full-nav__chapter[aria-current="page"] {
  border-left-color: var(--primary);
  color: var(--ao-heading-black);
  font-weight: 700;
}

/* Front matter (Foreword, Acknowledgements) reads lighter, above Introduction. */
.full-nav__chapter--frontmatter {
  font-weight: 500;
  font-size: 0.9rem;
  color: var(--foreground);
}

.full-nav__sections {
  list-style: none;
  margin: 1px 0 4px;
  padding: 0;
}

.full-nav__sections:empty {
  display: none;
}

.full-nav__section {
  display: block;
  padding: 3px 14px 3px 30px;
  color: var(--foreground);
  font-size: 0.84rem;
  line-height: 1.3;
  text-decoration: none;
  transition: color var(--duration-normal) var(--ease-out);
}

.full-nav__section[data-sub] {
  padding-left: 44px;
  font-size: 0.8rem;
}

.full-nav__section:hover {
  color: var(--ao-heading-black);
}

.full-nav a:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: -2px;
}

/* ── Local rail (wide screens) ────────────────────────────────────── */

.doc-rail {
  display: none; /* shown at the nav breakpoint below */
}

.doc-rail__contents {
  width: 100%;
  justify-content: flex-start;
}

.doc-rail__here {
  margin-top: 26px;
}

.doc-rail__here[hidden] {
  display: none;
}

.doc-rail__label {
  margin: 0 0 12px;
  font-family: var(--font-heading);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--foreground);
}

.doc-rail__list,
.doc-rail__list li {
  list-style: none;
  margin: 0;
  padding: 0;
  max-width: none;
}

.doc-rail__list a {
  display: block;
  padding: 6px 0 6px 14px;
  border-left: 2px solid var(--border);
  color: var(--foreground);
  font-size: 0.82rem;
  line-height: 1.4;
  text-decoration: none;
  transition:
    color var(--duration-normal) var(--ease-out),
    border-color var(--duration-normal) var(--ease-out);
}

.doc-rail__list a[data-sub] {
  padding-left: 26px;
  font-size: 0.78rem;
}

.doc-rail__list a:hover {
  color: var(--ao-heading-black);
}

.doc-rail__list a[aria-current="true"] {
  color: var(--ao-heading-black);
  border-left-color: var(--primary);
  font-weight: 700;
}

/* ── Responsive ───────────────────────────────────────────────────── */

@media (min-width: 1025px) {
  .doc-rail {
    display: block;
    align-self: start;
    position: sticky;
    top: 32px;
  }
}

@media (max-width: 1024px) {
  .nav-trigger--fixed {
    display: inline-flex;
  }

  .nav-open .nav-trigger--fixed {
    opacity: 0;
    pointer-events: none;
  }

  /* The fixed Contents trigger (top 80px, ~32px tall) floats over the page;
     drop the content down so the title clears it with breathing room. */
  .has-marketing-chrome .document-shell {
    padding-top: 128px;
  }
}

@media print {
  .nav-trigger,
  .nav-scrim,
  .full-nav,
  .doc-rail {
    display: none !important;
  }
}
