/* ==========================================================================
   Nested section menus in the header nav
   Each primary page row can disclose the sections on that page as route stops.
   Desktop: a quiet city block card hanging under the fixed bar.
   Mobile: the same stops as an indented sub-list inside the full-height sheet.
   Loaded after app.css, so every anchor rule is prefixed with .hdr-nav to beat
   the base `.hdr-nav a` colour and size.
   ========================================================================== */

.nav-caret-label {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.nav-caret {
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
}

/* The two caret faces. Desktop wears the stop dot, the sheet wears the plus;
   each viewport block turns on its own. */
.nav-caret-dot {
  display: none;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--line-hi);
  transition: background 200ms ease, box-shadow 200ms ease, transform 240ms cubic-bezier(0.16, 1, 0.3, 1);
}
.nav-caret-plus {
  position: relative;
  display: none;
  width: 12px;
  height: 12px;
  transition: transform 320ms cubic-bezier(0.16, 1, 0.3, 1);
}
.nav-caret-plus::before,
.nav-caret-plus::after {
  content: "";
  position: absolute;
  left: 0;
  top: 5px;
  width: 12px;
  height: 2px;
  border-radius: 1px;
  background: currentColor;
  transition: transform 320ms cubic-bezier(0.16, 1, 0.3, 1), opacity 200ms ease;
}
.nav-caret-plus::after { transform: rotate(90deg); }

.nav-stops {
  position: relative;
  margin: 0;
  list-style: none;
}
.nav-stops > li { margin: 0; }

/* Redesign 2026-08-07 (Adam: "i hate how it implemented the menus"): the faint
   spine + hollow ring dots read as a timeline widget, and sentence-length
   labels made the panel enormous. Now: no spine, small solid dots that light
   with the gradient on hover, crisp short labels set in the NAV array. */

.hdr-nav .nav-stop {
  position: relative;
  display: flex;
  align-items: center;
  text-decoration: none;
  transition: color 180ms ease, background-color 180ms ease;
}
.nav-stop-dot {
  flex: 0 0 auto;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--line-hi);
  transition: background 180ms ease, box-shadow 180ms ease, transform 180ms ease;
}
.nav-stop-label { min-width: 0; }

/* A reached stop fills with the brand gradient, same as a route stop lighting up. */
.hdr-nav .nav-stop:hover .nav-stop-dot,
.hdr-nav .nav-stop:focus-visible .nav-stop-dot {
  background: var(--grad);
  box-shadow: 0 0 0 3px rgba(73, 121, 239, 0.14);
  transform: scale(1.25);
}
.hdr-nav .nav-stop:hover,
.hdr-nav .nav-stop:focus-visible { color: var(--text); }
.hdr-nav .nav-stop:focus-visible {
  outline: 2px solid var(--royal);
  outline-offset: 1px;
}
.nav-caret:focus-visible {
  outline: 2px solid var(--royal);
  outline-offset: 2px;
}

/* ---------- desktop: the panel under the bar ---------------------------- */

@media (min-width: 981px) {
  /* Stretch the nav to the full bar height so a panel anchored at 100% starts
     exactly at the header's bottom edge rather than mid-bar. */
  .hdr-nav {
    align-self: stretch;
    gap: clamp(14px, 2vw, 30px);
  }
  .nav-item {
    position: relative;
    align-self: stretch;
    display: flex;
    align-items: center;
    gap: 3px;
  }
  /* The active-page gradient underline in app.css is absolute at bottom:-7px, and
     app.css only made a DIRECT child of .hdr-nav its containing block. Without
     this the underline anchors to the full-height .nav-item and drops to the bar's
     bottom edge instead of sitting under the label. */
  .hdr-nav .nav-link {
    position: relative;
    white-space: nowrap;
  }

  .nav-caret {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    padding: 0;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--soft);
    transition: color 180ms ease;
  }
  .nav-caret-dot { display: inline-block; }
  /* Hovering the item warms the stop; the open panel lights it, the same
     grammar as a reached stop on the route. */
  .nav-item:hover > .nav-caret .nav-caret-dot {
    background: var(--soft);
  }
  .nav-item.is-open > .nav-caret .nav-caret-dot {
    background: var(--grad);
    box-shadow: 0 0 0 3px rgba(73, 121, 239, 0.16);
    transform: scale(1.3);
  }

  .nav-drop {
    position: absolute;
    top: 100%;
    left: -8px;
    z-index: 3;
    min-width: 176px;
    max-width: 260px;
    margin-top: 7px;
    padding: 6px;
    border: 1px solid var(--line);
    border-radius: 14px;
    /* Translucent, but opaque enough that hero art behind it cannot read through
       the labels: at 0.94 the phone cluster showed through in both themes. */
    background: rgba(var(--panel-rgb), 0.975);
    -webkit-backdrop-filter: blur(26px) saturate(150%);
    backdrop-filter: blur(26px) saturate(150%);
    box-shadow: var(--lift);
    opacity: 0;
    visibility: hidden;
    transform: translate(var(--drop-x, 0px), -8px);
    transition: opacity 200ms ease, transform 300ms cubic-bezier(0.16, 1, 0.3, 1),
      visibility 0s linear 300ms;
  }
  /* Bridges the gap to the bar so the pointer can travel into the panel. */
  .nav-drop::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: -13px;
    height: 13px;
  }
  .nav-item.is-open > .nav-drop {
    opacity: 1;
    visibility: visible;
    transform: translate(var(--drop-x, 0px), 0);
    transition: opacity 200ms ease, transform 320ms cubic-bezier(0.16, 1, 0.3, 1),
      visibility 0s;
  }

  .nav-stops { padding: 1px 0; }
  .hdr-nav .nav-stop {
    gap: 10px;
    padding: 8px 11px;
    border-radius: 9px;
    color: var(--dim);
    font-size: 13.5px;
    font-weight: 500;
    letter-spacing: -0.008em;
    line-height: 1.3;
    white-space: nowrap;
  }
  .hdr-nav .nav-stop:hover { background-color: var(--row); }
}

/* ---------- mobile: an indented sub-list inside the sheet --------------- */

@media (max-width: 980px) {
  /* app.css staggers the first four sheet rows; the row count grew, so the last
     row and the footer need their own delays or they land before the rest. */
  .hdr-nav.is-open > :nth-child(5) { animation-delay: 0.28s; }
  .hdr-nav.is-open > :nth-child(6) { animation-delay: 0.34s; }
  .nav-item {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    width: 100%;
    border-bottom: 1px solid var(--line);
  }
  .hdr-nav .nav-link {
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    min-width: 0;
    padding: 20px 4px;
    color: var(--text);
    font-size: 22px;
    font-weight: 640;
    letter-spacing: -0.022em;
    text-decoration: none;
  }
  /* Active page keeps the sheet's gradient-text treatment. The caret button is
     the affordance now, so the inherited royal chevron is dropped. */
  .hdr-nav .nav-link[aria-current="page"] {
    color: transparent;
    background: var(--grad);
    -webkit-background-clip: text;
    background-clip: text;
  }
  .hdr-nav .nav-link[aria-current="page"]::after { content: none; display: none; }
  /* Rows with no sections of their own keep a plain go-to chevron. */
  .nav-item:not(.has-sections) > .nav-link::after {
    content: "";
    flex: 0 0 auto;
    width: 7px;
    height: 7px;
    margin-right: 3px;
    border-right: 2px solid var(--dim);
    border-top: 2px solid var(--dim);
    border-radius: 1px;
    transform: rotate(45deg);
  }

  .nav-caret {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    margin-left: 8px;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 50%;
    background: rgba(var(--panel-rgb), 0.5);
    color: var(--dim);
    transition: color 200ms ease, border-color 200ms ease;
  }
  .nav-caret-plus { display: inline-block; }
  /* Plus morphs to minus: the whole glyph quarter-turns while the vertical bar
     folds into the horizontal one. */
  .nav-item.is-open > .nav-caret {
    border-color: var(--line-hi);
    color: var(--text);
  }
  .nav-item.is-open > .nav-caret .nav-caret-plus { transform: rotate(90deg); }
  /* The container quarter-turns, so the surviving bar has to be the one that
     STARTED vertical (::after): it lands horizontal and reads as a minus. */
  .nav-item.is-open > .nav-caret .nav-caret-plus::before {
    transform: scaleX(0);
    opacity: 0;
  }

  /* Collapsed rows must leave the tab order too, not just the layout. */
  .nav-drop {
    flex: 0 0 100%;
    overflow: hidden;
    max-height: var(--drop-h, 0px);
    visibility: hidden;
    transition: max-height 340ms cubic-bezier(0.16, 1, 0.3, 1),
      visibility 0s linear 340ms;
  }
  .nav-item.is-open > .nav-drop {
    visibility: visible;
    transition: max-height 340ms cubic-bezier(0.16, 1, 0.3, 1), visibility 0s;
  }
  .nav-stops { padding: 4px 0 14px 4px; }
  .hdr-nav .nav-stop {
    gap: 14px;
    padding: 13px 4px;
    color: var(--dim);
    font-size: 17px;
    font-weight: 500;
    letter-spacing: -0.012em;
    line-height: 1.35;
  }
  .hdr-nav .nav-stop:hover .nav-stop-dot { box-shadow: none; }
}

/* Reduced motion: the menus still open and close, they just do not slide, and
   in-page jumps land instead of gliding (app.css sets scroll-behavior: smooth
   document-wide). */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .nav-drop,
  .nav-caret,
  .nav-stop-dot,
  .nav-caret-dot,
  .nav-caret-plus,
  .nav-caret-plus::before,
  .nav-caret-plus::after,
  .hdr-nav .nav-stop { transition: none; }
}
