/* Component: Page sub-nav (About pages first; reusable for any section with sibling pages)
   Kept (staging .wnmd-subnav): a light bar of page links directly under the hero, the
   current page emphasized; on mobile the "Currently viewing" disclosure.
   New: a rounded bar at the floating header's width, on the stone sheet that tucks over
   the hero. It docks under the floating header and hands off with it (js/subnav.js):
   scrolling down, the header slides away and the bar takes its slot; scrolling up, the
   header returns with the bar right under it. Both move with one transform, duration and
   easing (--dur-tuck / --ease-tuck). The docked look (glass + shadow) is paint only.
   Reduced motion: the same states, applied instantly. Without JS: a plain sticky bar.
   Brand cap (WO-22, approved): while the header is tucked, a dark block with the network
   logo sits at the bar's left edge (below). Demo toggle ?subnav=plain removes it.
   Alternative (demo toggle ?subnav=switcher): the header never hides, the bar stays in the
   page, and a bottom "Currently viewing" pill (.pageswitch) appears once it scrolls away. */

/* One fixed landing offset, only where a sub-nav exists (including pages without a manifest).
   Header footprint = floating bar + 12px top inset + 8px gap; then sub-nav + 16px. */
html:has([data-subnav]) {
  --anchor-offset: calc(12px + var(--header-float-h) + 8px + var(--subnav-h) + 16px + var(--wp-admin--admin-bar--height, 0px));
  scroll-padding-top: var(--anchor-offset);
}

/* ---- Header tuck (applied only by subnav.js, only on pages with a sub-nav) ---- */
.site-header { transition: transform var(--dur-tuck) var(--ease-tuck); }
.site-header.is-tucked { transform: translateY(calc(-100% - 32px)); }

/* ---- The sticky strip ------------------------------------------------------ */
.subnav {
  --subnav-gap: 8px;
  --subnav-pad: calc(var(--sheet-overlap) + 12px);                          /* stone above the bar at rest */
  --subnav-dock: calc(12px + var(--header-float-h) + var(--subnav-gap) + var(--wp-admin--admin-bar--height, 0px));    /* bar top under the floating header (84px; + the admin bar when logged in) */
  --subnav-shift: calc(-1 * (var(--header-float-h) + var(--subnav-gap)));   /* into the header's slot (12px) */
  position: sticky; top: calc(var(--subnav-dock) - var(--subnav-pad));
  z-index: 60;
  margin-top: calc(-1 * var(--sheet-overlap));
  padding-top: var(--subnav-pad);
  border-radius: var(--sheet-overlap) var(--sheet-overlap) 0 0;
  background: var(--color-surface-1);
  pointer-events: none;
  transition: transform var(--dur-tuck) var(--ease-tuck);
}
.subnav.is-stuck { background: transparent; }
.subnav.is-tucked { transform: translateY(var(--subnav-shift)); }

.subnav__bar {
  pointer-events: auto;
  position: relative;
  width: min(var(--rail-max) + 48px, 100% - 24px);
  height: var(--subnav-h);
  margin-inline: auto;
  display: flex; align-items: center;
  padding-inline: 24px;
  border: 1px solid var(--color-border);
  border-radius: var(--r-md);
  background: var(--color-surface-2);
  color: var(--c-ink);
  transition: background-color var(--dur-base) linear, box-shadow var(--dur-base) var(--ease-out);
}
.subnav.is-stuck .subnav__bar {
  background: color-mix(in srgb, var(--color-surface-2) 95%, transparent); /* paper; 0.95 keeps muted links AA over the ink band */
  -webkit-backdrop-filter: blur(16px) saturate(1.2);
  backdrop-filter: blur(16px) saturate(1.2);
  box-shadow: 0 14px 34px -16px color-mix(in srgb, var(--c-ink) 32%, transparent);
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .subnav.is-stuck .subnav__bar { background: var(--color-surface-2); }
}

/* ---- Links: a row on desktop ---------------------------------------------- */
.subnav__links { display: flex; align-items: stretch; height: 100%; margin: 0 0 0 -14px; padding: 0; list-style: none; }
.subnav__links a {
  position: relative;
  display: inline-flex; align-items: center; gap: 12px; height: 100%;
  padding: 0 14px;
  font-size: 15px; font-weight: 500; line-height: 1.2; letter-spacing: -0.005em; white-space: nowrap;
  color: var(--c-ink-muted);
  transition: color var(--dur-fast) linear;
}
.subnav__links a::after {
  content: ""; position: absolute; left: 14px; right: 14px; bottom: 0; height: 2px; border-radius: 2px;
  background: var(--color-accent); opacity: 0.45;
  transform: scaleX(0); transform-origin: left center;
  transition: transform var(--dur-base) var(--ease-out);
}
.subnav__links a:hover, .subnav__links a:focus-visible { color: var(--c-ink); }
.subnav__links a:hover::after { transform: scaleX(1); }
.subnav__links a[aria-current="page"] { color: var(--c-ink); font-weight: 600; }
.subnav__links a[aria-current="page"]::after { transform: scaleX(1); opacity: 1; }
.subnav__links a:focus-visible { outline-offset: -6px; border-radius: var(--r-sm); }

/* ---- Mobile: the "Currently viewing" disclosure ----------------------------- */
.subnav__trigger { display: none; }
.subnav__eyebrow {
  display: block;
  font-family: var(--font-body); font-weight: 500; font-size: 11px; line-height: 1.2;
  letter-spacing: var(--tr-eyebrow); text-transform: uppercase; color: var(--c-ink-muted);
}
.subnav__current { display: block; margin-top: 3px; font-size: 16px; font-weight: 600; line-height: 1.2; }
.subnav__caret {
  width: var(--circle-sm); height: var(--circle-sm); flex: none; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--c-ink); color: var(--c-light);
  transition: transform var(--dur-base) var(--ease-out);
}
.subnav__caret svg { width: 10px; height: 10px; }

@media (max-width: 1023px) {
  .subnav__bar { padding-inline: 16px; }
  .js .subnav__trigger {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    width: 100%; height: 100%; text-align: left;
  }
  .subnav.is-open .subnav__caret { transform: rotate(180deg); }
  .subnav__trigger:focus-visible { outline-offset: -4px; border-radius: var(--r-sm); }

  /* Without JS the six links simply wrap inside the bar's area as a list */
  .subnav__links { flex-direction: column; height: auto; margin: 0; }
  .js .subnav__links {
    position: absolute; top: calc(100% + 8px); left: -1px; right: -1px;
    padding: 8px;
    border: 1px solid var(--color-border); border-radius: var(--r-md);
    background: var(--color-surface-2); box-shadow: var(--shadow-float);
    opacity: 0; visibility: hidden; transform: translateY(-8px);
    transition: opacity 200ms linear, transform var(--dur-base) var(--ease-out), visibility 0s linear var(--dur-base);
  }
  .js .subnav.is-open .subnav__links { opacity: 1; visibility: visible; transform: none; transition-delay: 0s; }
  .subnav__links a { display: flex; width: 100%; height: 48px; justify-content: space-between; padding: 0 12px; border-radius: var(--r-sm); font-size: 17px; }
  .subnav__links a:hover { background: color-mix(in srgb, var(--c-ink) 5%, transparent); }
  /* Current page: a green dot at the right (staging's "↳ here" marker) */
  .subnav__links a::after { left: auto; right: 14px; top: 50%; bottom: auto; width: 8px; height: 8px; margin-top: -4px; border-radius: 50%; opacity: 0; transform: none; }
  .subnav__links a[aria-current="page"]::after { opacity: 1; }
  .subnav__links a:hover::after { transform: none; }
  html:not(.js) .subnav__bar { height: auto; padding-block: 8px; }
  html:not(.js) .subnav { position: relative; top: auto; } /* a six-row list must not stick */
}

/* ---- Brand cap (approved default, WO-22; ?subnav=plain turns it off) ----------
   While the header is tucked away, a dark block (the header's ink) slides in at the
   bar's left edge carrying the network logo, so the brand never leaves the screen.
   Header back = cap gone (no two logos stacked). Same duration and easing as the tuck.
   The cap element is added by subnav.js (a copy of the header logo). */
.subnav { --brand-w: 192px; }                 /* 20px-high wordmark (148px) + 22px each side */
.subnav__brand {
  flex: none; align-self: stretch;
  width: 0; margin: -1px 0;                   /* covers the bar's top/bottom hairline */
  overflow: hidden;
  border-radius: var(--r-md) 0 0 var(--r-md);
  background: var(--c-ink);
  transition: width var(--dur-tuck) var(--ease-tuck), margin var(--dur-tuck) var(--ease-tuck);
}
.subnav.is-tucked .subnav__brand { width: var(--brand-w); margin: -1px 24px -1px -25px; } /* -25 = padding + hairline */
.subnav__brand-link {
  display: flex; align-items: center; justify-content: center;
  width: var(--brand-w); height: 100%;
  opacity: 0;
  transition: opacity var(--dur-base) linear;
}
.subnav.is-tucked .subnav__brand-link { opacity: 1; transition-delay: 80ms; }
.subnav__brand-link img { height: 20px; width: auto; }

/* Desktop is always the row of links (Nolan, 2026-10-02, PORCH-WO-14ag; DECISIONS #143).
   The "Currently viewing" disclosure is the mobile pattern (max-width: 1023px) only, and the
   brand cap (sticky logo) is the desktop pattern only: it always shows on desktop while the
   header is tucked, and never below 1024px. When the links plus the cap don't fit the bar,
   subnav.js (on resize, never mid-scroll) adds .is-scroll: the row scrolls sideways inside
   the bar (edges fade, current link in view). */
@media (min-width: 1024px) {
  .subnav.is-scroll .subnav__links {
    flex: 1 1 auto; min-width: 0;
    margin-right: -24px; padding-right: 24px;              /* the row runs to the bar's edge */
    overflow-x: auto; overscroll-behavior-x: contain;
    scrollbar-width: none;
    -webkit-mask-image: linear-gradient(to right, transparent, var(--c-black) 14px, var(--c-black) calc(100% - 40px), transparent);
    mask-image: linear-gradient(to right, transparent, var(--c-black) 14px, var(--c-black) calc(100% - 40px), transparent);
  }
  .subnav.is-scroll .subnav__links::-webkit-scrollbar { display: none; }
  .subnav.is-scroll .subnav__links > li { flex: none; }
}

/* Legacy, wnm2026 only: the frozen port/site/js/subnav.js still sets .is-condensed (the desktop
   disclosure). The theme's assets/js/subnav.js (wnmbakery) never does since PORCH-WO-14ag (#143):
   on desktop the sub-nav is always the row of links. Kept so wnm2026 renders as before. */
.js .subnav.is-condensed .subnav__trigger {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  width: 100%; height: 100%; min-width: 0; text-align: left;
}
.subnav.is-condensed.is-open .subnav__caret { transform: rotate(180deg); }
.subnav.is-condensed .subnav__trigger:focus-visible { outline-offset: -4px; border-radius: var(--r-sm); }
.js .subnav.is-condensed .subnav__links {
  position: absolute; top: calc(100% + 8px); right: -1px;
  flex-direction: column; width: 320px; height: auto; margin: 0; padding: 8px;
  border: 1px solid var(--color-border); border-radius: var(--r-md);
  background: var(--color-surface-2); box-shadow: var(--shadow-float);
  opacity: 0; visibility: hidden; transform: translateY(-8px);
  transition: opacity 200ms linear, transform var(--dur-base) var(--ease-out), visibility 0s linear var(--dur-base);
}
.js .subnav.is-condensed.is-open .subnav__links { opacity: 1; visibility: visible; transform: none; transition-delay: 0s; }
.subnav.is-condensed .subnav__links a { display: flex; width: 100%; height: 46px; justify-content: space-between; padding: 0 12px; border-radius: var(--r-sm); font-size: 16px; }
.subnav.is-condensed .subnav__links a:hover { background: color-mix(in srgb, var(--c-ink) 5%, transparent); }
.subnav.is-condensed .subnav__links a::after { left: auto; right: 14px; top: 50%; bottom: auto; width: 8px; height: 8px; margin-top: -4px; border-radius: 50%; opacity: 0; transform: none; }
.subnav.is-condensed .subnav__links a[aria-current="page"]::after { opacity: 1; }

/* The brand cap is desktop only (#143): below 1024px the header still hands off, without the logo */
@media (max-width: 1023px) {
  .subnav__brand { display: none; }
}
/* Room for the cap: the current page name truncates instead of pushing the caret out */
.subnav-mode-brand .subnav__trigger, .subnav-mode-brand .subnav__trigger > span:first-child { min-width: 0; }
.subnav-mode-brand .subnav__current { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---- Alternative: page switcher (?subnav=switcher) ------------------------- */
.subnav-mode-switcher .subnav { position: relative; top: auto; }
.pageswitch {
  position: fixed; left: 50%; bottom: calc(16px + env(safe-area-inset-bottom)); z-index: 80;
  transform: translate(-50%, 16px); opacity: 0; visibility: hidden;
  transition: opacity var(--dur-base) linear, transform var(--dur-slow) var(--ease-elastic), visibility 0s linear var(--dur-slow);
}
.pageswitch.is-visible { opacity: 1; visibility: visible; transform: translate(-50%, 0); transition-delay: 0s; }
.pageswitch__trigger {
  display: flex; align-items: center; gap: 18px;
  height: 56px; padding: 6px 8px 6px 22px;
  border: 1px solid var(--color-border-on-dark); border-radius: var(--r-pill);
  background: color-mix(in srgb, var(--c-ink) 86%, transparent); color: var(--c-light); text-align: left;
  -webkit-backdrop-filter: blur(16px) saturate(1.2); backdrop-filter: blur(16px) saturate(1.2);
  box-shadow: var(--shadow-float);
  --focus: var(--color-accent);
}
.pageswitch__trigger .subnav__eyebrow { color: var(--c-light-muted); }
.pageswitch__trigger .subnav__caret { background: var(--color-accent); color: var(--color-on-accent); transform: rotate(180deg); }
.pageswitch.is-open .subnav__caret { transform: none; }
.pageswitch__list {
  position: absolute; bottom: calc(100% + 10px); left: 50%;
  width: max(100%, 300px); margin: 0; padding: 8px; list-style: none;
  border: 1px solid var(--color-border); border-radius: var(--r-md);
  background: var(--color-surface-2); color: var(--c-ink); box-shadow: var(--shadow-float);
  opacity: 0; visibility: hidden; transform: translate(-50%, 8px);
  transition: opacity 200ms linear, transform var(--dur-base) var(--ease-out), visibility 0s linear var(--dur-base);
}
.pageswitch.is-open .pageswitch__list { opacity: 1; visibility: visible; transform: translate(-50%, 0); transition-delay: 0s; }
.pageswitch__list a {
  position: relative; display: flex; align-items: center; justify-content: space-between;
  height: 46px; padding: 0 12px; border-radius: var(--r-sm);
  font-size: 16px; font-weight: 500; color: var(--c-ink-muted);
}
.pageswitch__list a:hover { background: color-mix(in srgb, var(--c-ink) 5%, transparent); color: var(--c-ink); }
.pageswitch__list a[aria-current="page"] { color: var(--c-ink); font-weight: 600; }
.pageswitch__list a[aria-current="page"]::after { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--color-accent); }

@media (prefers-reduced-motion: reduce) {
  .site-header, .subnav, .subnav__bar, .pageswitch, .subnav__brand, .subnav__brand-link { transition: none; }
}
