/* SystemBlueprint — layout + components. Built on tokens.css. Enterprise-grade visual system. */

*, *::before, *::after { box-sizing: border-box; }
/* Base size set to 16px (100%) so every rem-based font and
   spacing value across the portal scales uniformly. */
html { font-size: 100%; scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

body {
  margin: 0;
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--step-0);
  font-weight: 400;
  line-height: 1.65;
  letter-spacing: -0.006em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
/* Dark theme keeps its dark canvas on the root element, because the body has no background. */
[data-theme="dark"] { background-color: var(--bg); }

h1, h2, h3, h4 { font-family: var(--font-display); line-height: 1.2; font-weight: 600; letter-spacing: -0.02em; color: var(--text-strong); }
strong, b { font-weight: 600; color: var(--text-strong); }
a { color: var(--accent); text-decoration: none; transition: color var(--transition); }
a:hover { color: color-mix(in oklab, var(--accent) 72%, var(--text)); }

:focus-visible { outline: none; box-shadow: var(--ring); border-radius: 8px; }
::selection { background: color-mix(in oklab, var(--accent) 32%, transparent); color: var(--text-strong); }

.skip-link { position: absolute; left: -999px; top: 0; z-index: 100; background: var(--accent); color: var(--accent-ink); padding: var(--sp-2) var(--sp-4); border-radius: 0 0 10px 0; font-weight: 600; }
.skip-link:focus { left: 0; }
.noscript { padding: var(--sp-5); text-align: center; color: var(--muted); }

/* ---------- Topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  /* Secondary chrome: sits on the gray canvas, no border, no solid fill */
  background: color-mix(in oklab, var(--bg) 70%, transparent);
  backdrop-filter: saturate(120%) blur(12px); -webkit-backdrop-filter: saturate(120%) blur(12px);
}
/* Left padding equals the logo's top/bottom gap so it sits symmetrically at
   the extreme left; right side keeps the normal shell padding. */
.topbar__inner { max-width: 100%; margin: 0; height: var(--topbar-h); display: flex; align-items: center; gap: var(--sp-5); padding: 0 var(--shell-pad) 0 calc((var(--topbar-h) - 34px) / 2); }
.brand { display: flex; align-items: center; gap: var(--sp-3); color: var(--text-strong); font-family: var(--font-display); font-weight: 600; }
.brand:hover { color: var(--text-strong); }
.brand__mark { width: 34px; height: 34px; display: inline-flex; border-radius: 10px; overflow: hidden; box-shadow: var(--shadow-sm); }
.brand__mark svg { width: 100%; height: 100%; }
.brand__name { font-size: var(--step-1); letter-spacing: -0.02em; font-weight: 600; }

/* Sticky page title — appears in the menu bar once the page h1 scrolls away.
   A touch bigger than the nav links so it reads as the current context. */
.topbar-title {
  font-family: var(--font-display);
  font-size: var(--step-0);
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text-strong);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 0;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 200ms ease, transform 200ms ease, max-width 220ms var(--ease-out);
  pointer-events: none;
}
.topbar-title.is-visible { opacity: 1; transform: translateY(0); max-width: 44ch; }

.nav { display: flex; gap: 2px; margin-left: auto; align-items: stretch; align-self: stretch; }
.nav > a { align-self: center; }
/* Category with a horizontal sub-menu. The item stretches the full bar height so
   the pointer can move from the label down into the panel without closing it. */
.navitem { position: relative; display: flex; align-items: center; }
.navitem__btn { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); padding: 7px var(--sp-4); border: 0; border-radius: 999px; background: none; font: inherit; font-size: var(--step--1); font-weight: 360; cursor: pointer; transition: color var(--transition), background var(--transition); }
.navitem__btn:hover, .navitem.is-open > .navitem__btn { color: var(--text-strong); background: var(--bg-elev-3); }
.navitem__btn:focus-visible { outline: none; box-shadow: var(--ring); }
.navitem:has([aria-current="page"]) > .navitem__btn { color: var(--accent); background: var(--accent-soft); }
.navitem__chev { font-size: 0.72em; transition: transform 160ms ease; }
.navitem.is-open .navitem__chev { transform: rotate(180deg); }
/* Panel opens below its own category button, sized to its columns (no full-width band).
   Only the JavaScript sets .is-open, so one panel is visible at a time. */
.navmenu { display: none; position: absolute; top: 100%; left: 0; width: max-content; max-width: calc(100vw - 32px); background: var(--bg-elev); border-radius: 0 0 var(--radius) var(--radius); box-shadow: var(--shadow-lg); padding: var(--sp-4) var(--sp-5); z-index: 70; }
.navmenu--end { left: auto; right: 0; }
.navitem.is-open .navmenu { display: block; }
.navmenu__inner { display: flex; flex-wrap: wrap; gap: var(--sp-5) var(--sp-6); align-items: flex-start; max-width: 720px; }
.navmenu__col { min-width: 150px; max-width: 200px; }
.navmenu__title { margin: 0 0 var(--sp-3); font-family: var(--font-display); font-weight: 600; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-strong); }
.navmenu__list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.navmenu__list a { display: block; color: var(--text); padding: 6px var(--sp-3); margin-left: calc(var(--sp-3) * -1); border-radius: 8px; font-size: var(--step--1); font-weight: 360; transition: background var(--transition), color var(--transition); }
.navmenu__list a:hover { color: var(--text-strong); background: var(--bg-elev-3); }
.navmenu__list a[aria-current="page"] { color: var(--accent); background: var(--accent-soft); font-weight: 500; }

/* Two-level menu (AI): topics on the left, the active topic's pages on the right. */
.navmenu--flyout { padding: var(--sp-3); }
.flyout { display: flex; gap: var(--sp-4); align-items: stretch; width: min(760px, calc(100vw - 48px)); }
.flyout__tabs { list-style: none; margin: 0; padding: 0 var(--sp-3) 0 0; border-right: 1px solid var(--line-soft); display: grid; gap: 2px; align-content: start; flex: 0 0 230px; }
.flyout__tab { display: grid; gap: 2px; width: 100%; text-align: left; font: inherit; background: none; border: 0; border-radius: 10px; padding: 8px 12px; cursor: pointer; color: var(--text); }
.flyout__tab:hover, .flyout__tab.is-active { background: var(--bg-elev-3); }
.flyout__tab.is-active .flyout__tabtitle { color: var(--accent); }
.flyout__tab:focus-visible { outline: none; box-shadow: var(--ring); }
.flyout__tabtitle { font-size: var(--step--1); font-weight: 500; color: var(--text-strong); }
.flyout__blurb { font-size: 0.72rem; color: var(--muted); line-height: 1.4; }
.flyout__panes { flex: 1 1 auto; min-width: 0; }
.flyout__pane { padding: var(--sp-2) var(--sp-2) var(--sp-2) 0; min-height: 100%; }
.flyout__list--cols { display: block; columns: 2; column-gap: var(--sp-5); }
.flyout__list--cols li { break-inside: avoid; }
.flyout__overview { font-weight: 500 !important; color: var(--accent) !important; }
.nav a { color: var(--muted); padding: 7px var(--sp-4); border-radius: 999px; font-size: var(--step--1); font-weight: 300; transition: color var(--transition), background var(--transition); }
.nav a:hover { color: var(--text-strong); background: var(--bg-elev-3); }
.nav a[aria-current="page"] { color: var(--accent); background: var(--accent-soft); }

.topbar__actions { display: flex; align-items: center; gap: var(--sp-2); }
.theme-toggle { width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg-elev); color: var(--text); cursor: pointer; font-size: 1rem; display: inline-flex; align-items: center; justify-content: center; transition: background var(--transition), transform var(--transition), border-color var(--transition); }
.theme-toggle:hover { background: var(--bg-elev-3); transform: translateY(-1px); border-color: var(--accent); }

.nav-toggle { display: none; background: var(--bg-elev); border: 1px solid var(--line); border-radius: 12px; width: 44px; height: 40px; cursor: pointer; flex-direction: column; gap: 4px; align-items: center; justify-content: center; margin-left: auto; }
.nav-toggle span { display: block; width: 18px; height: 2px; background: var(--text); border-radius: 2px; transition: transform 200ms var(--ease-out), opacity 150ms ease; }
.nav-toggle:focus-visible { outline: none; box-shadow: var(--ring); }
/* Hamburger becomes an X while the menu is open. */
.nav-toggle[aria-expanded="true"] span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.nav-toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.nav-toggle[aria-expanded="true"] span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

@keyframes navIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

/* ---------- Back to top (scroll-top.js) ----------
   Small, in the bottom-right corner, clear of the reading column. When hidden it takes
   no clicks, so it can never block content underneath. */
.scrolltop {
  position: fixed; z-index: 40;
  right: max(var(--sp-4), env(safe-area-inset-right)); bottom: max(var(--sp-5), calc(env(safe-area-inset-bottom) + var(--sp-3)));
  width: 42px; height: 42px; border-radius: 50%;
  display: grid; place-items: center; cursor: pointer;
  color: var(--text-strong); background: color-mix(in oklab, var(--bg-elev) 88%, transparent);
  border: 1px solid var(--line); box-shadow: var(--shadow);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  opacity: 0; transform: translateY(10px) scale(0.92); pointer-events: none;
  transition: opacity 200ms ease, transform 220ms var(--ease-out), border-color var(--transition), background var(--transition);
}
.scrolltop.is-visible { opacity: 0.92; transform: none; pointer-events: auto; }
.scrolltop:hover { opacity: 1; border-color: var(--accent); color: var(--accent); }
.scrolltop:focus-visible { outline: none; opacity: 1; box-shadow: var(--ring); }
body.nav-open .scrolltop, body.rail-open .scrolltop { opacity: 0; pointer-events: none; }
@media (max-width: 720px) { .scrolltop { width: 40px; height: 40px; } }

.reading-progress { height: 2px; background: transparent; }
.reading-progress > span { display: block; height: 100%; width: 0; background: var(--accent); transition: width 80ms linear; }

@media (max-width: 860px) {
  .nav-toggle { display: inline-flex; order: 3; flex: none; }
  .topbar__inner { padding: 0 var(--sp-3); gap: var(--sp-3); }
  .topbar__actions { margin-left: 0; order: 2; gap: var(--sp-1); }
  .topbar-title { flex: 1 1 auto; min-width: 0; }
  .topbar-title.is-visible { max-width: none; }
  /* Full-height, scrollable panel under the bar; the page behind is locked (body.nav-open). */
  /* Absolute under the sticky bar (its blur makes it the containing block, so fixed would
     be clipped to the bar). The height is set from the viewport instead. */
  .nav {
    position: absolute; top: 100%; left: 0; right: 0; z-index: 60;
    height: calc(100vh - var(--topbar-h)); height: calc(100dvh - var(--topbar-h));
    display: none; flex-direction: column; align-items: stretch; gap: 2px; margin: 0;
    padding: var(--sp-3) var(--sp-3) calc(var(--sp-7) + env(safe-area-inset-bottom));
    overflow-y: auto; overscroll-behavior: contain;
    background: var(--bg); border-top: 1px solid var(--line-soft);
  }
  .nav.open { display: flex; animation: navIn 180ms var(--ease-out); }
  body.nav-open { overflow: hidden; }
  .nav > a, .nav a { padding: 12px var(--sp-4); border-radius: var(--radius-sm); font-size: var(--step-0); align-self: stretch; }
  /* Categories become an accordion: tap a heading to show its pages. */
  .navitem { display: block; border-bottom: 1px solid var(--line-soft); }
  .navitem__btn { width: 100%; justify-content: space-between; padding: 14px var(--sp-4); border-radius: var(--radius-sm); font-size: var(--step-0); color: var(--text-strong); }
  .navitem__chev { display: inline-block; transition: transform 200ms var(--ease-out); }
  .navitem.is-open .navitem__chev { transform: rotate(180deg); }
  .navmenu, .navmenu--flyout { position: static; width: auto; max-width: none; background: none; box-shadow: none; border-radius: 0; padding: 0 0 var(--sp-3) var(--sp-2); left: auto !important; }
  .navitem.is-open .navmenu { display: block; }
  .navmenu__inner { display: block; max-width: none; }
  .navmenu__col { max-width: none; margin-bottom: var(--sp-3); }
  .navmenu__title { margin: var(--sp-3) 0 var(--sp-1) var(--sp-4); }
  .navmenu__list a { margin-left: 0; }
  /* Two-level AI menu: sections become a swipeable chip row; the chosen section's pages list below. */
  .flyout { display: block; width: auto; }
  .flyout__tabs { display: flex; flex-wrap: nowrap; gap: 6px; overflow-x: auto; border-right: 0; padding: var(--sp-1) var(--sp-2) var(--sp-3); scrollbar-width: none; }
  .flyout__tabs::-webkit-scrollbar { display: none; }
  .flyout__tabs li { flex: none; }
  .flyout__tab { width: auto; padding: 7px 14px; border: 1px solid var(--line); border-radius: 999px; white-space: nowrap; }
  .flyout__tab.is-active { border-color: var(--accent); background: var(--accent-soft); }
  .flyout__blurb { display: none; }
  .flyout__pane { padding: 0; min-height: 0; }
  .flyout__panetitle { display: none; }
  .flyout__list--cols { columns: 1; }
}

/* ---------- Main + page transitions ---------- */
/* Landing/state pages use a centered max-width; doc pages use the full app shell. */
.main { max-width: 100%; margin: 0 auto; padding: 0; min-height: 62vh; }
/* page fade/slide is driven by JS on #main for smooth AJAX-style transitions */
/* Opacity only: a will-change or leftover transform on #main would make it the containing
   block for position: fixed children, and the Topics drawer would grow to the page height. */
#main { will-change: opacity; }

/* Landing + state pages get a readable centered container; doc pages go full width */
.page--landing { max-width: 84rem; margin: 0 auto; padding: 0 var(--shell-pad) var(--sp-8); }
.page.state { max-width: 84rem; margin: 0 auto; padding: var(--sp-6) var(--shell-pad) var(--sp-8); }

/* ---------- Full-width app-shell content layout ---------- */
.doc {
  display: grid;
  /* Default: left rail + wide content + a thin outline toggle strip.
     The outline only reserves its full width when the user opens it. */
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr) var(--outline-tab);
  align-items: start;
  width: 100%;
}
/* Outline expanded */
body.outline-open .doc { grid-template-columns: var(--sidebar-w) minmax(0, 1fr) var(--outline-w); }
/* Left rail collapsed: keep a thin gutter (matching the right outline tab)
   so the central panel doesn't touch the window frame. */
body.rail-collapsed .doc { grid-template-columns: var(--outline-tab) minmax(0, 1fr) var(--outline-tab); }
body.rail-collapsed.outline-open .doc { grid-template-columns: var(--outline-tab) minmax(0, 1fr) var(--outline-w); }
.doc__rail {
  position: sticky; top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
  font-size: var(--step--1);
  padding: var(--sp-6) var(--sp-4) var(--sp-6) var(--shell-pad);
  /* No surface or edge: the rail sits directly on the page background. */
  background: transparent;
  border-radius: 0;
  /* Scrollbar hidden by default; revealed only on hover (see below). */
  scrollbar-width: none;            /* Firefox */
  -ms-overflow-style: none;          /* old Edge */
  color: var(--muted-2);
}
/* WebKit: thumb is transparent until the rail is hovered. */
.doc__rail::-webkit-scrollbar { width: 8px; }
.doc__rail::-webkit-scrollbar-thumb { background: transparent; border-radius: 999px; transition: background 160ms ease; }
.doc__rail:hover { scrollbar-width: thin; }
.doc__rail:hover::-webkit-scrollbar-thumb { background: var(--line); }
.doc__rail:hover::-webkit-scrollbar-thumb:hover { background: var(--muted-2); }

.doc__article {
  /* Fill the whole grid cell so the white panel genuinely stretches when the
     side rails collapse. Prose keeps its own comfortable measure (--readw). */
  max-width: none;
  width: 100%;
  min-width: 0;
  margin: 0;
  --art-px: clamp(1.5rem, 4vw, 4rem);   /* side padding, shared with the sticky breadcrumb bar */
  padding: var(--sp-7) var(--art-px) var(--sp-8);
  /* No surface: the article sits directly on the page background. */
  background: transparent;
  border-radius: var(--radius-lg);
  box-shadow: none;
  margin: var(--sp-5) auto var(--sp-7);
  min-height: calc(100vh - var(--topbar-h) - var(--sp-6));
}
/* Prose and header fill the panel width so paragraphs stretch as it widens. */
.doc__article .prose { max-width: none; }
.doc__article .art-head { max-width: none; }

.doc__outline {
  position: sticky; top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h));
  overflow: hidden;
  font-size: var(--step--1); color: var(--muted-2);
  padding: var(--sp-6) var(--sp-2) var(--sp-6) var(--sp-2);
}
body.outline-open .doc__outline { padding-left: var(--sp-4); padding-right: var(--shell-pad); }
/* Head: the toggle sits in the thin strip; the label only reads when open */
.outline-head { display: flex; align-items: center; gap: var(--sp-2); margin-bottom: var(--sp-3); }
.outline-head .rail-head__label { white-space: nowrap; opacity: 0; transition: opacity 160ms ease; }
body.outline-open .outline-head .rail-head__label { opacity: 1; }
.outline-collapse { width: 26px; height: 26px; border-radius: 7px; border: 1px solid var(--line); background: var(--bg-elev); color: var(--muted); cursor: pointer; display: grid; place-items: center; font-size: 1rem; line-height: 1; flex: none; transition: background var(--transition), color var(--transition); }
.outline-collapse:hover { background: var(--bg-elev-3); color: var(--text-strong); }

/* Body hidden until opened; reveal reclaims nothing from the central panel
   because the strip is always only --outline-tab wide when closed. */
.outline-body { opacity: 0; pointer-events: none; overflow-y: auto; max-height: calc(100vh - var(--topbar-h) - 80px); transition: opacity 160ms ease; }
body.outline-open .outline-body { opacity: 1; pointer-events: auto; }
.doc__outline a { color: var(--muted-2); display: block; padding: 5px 0 5px var(--sp-3); border-left: 2px solid transparent; margin-left: -1px; font-weight: 300; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; transition: color var(--transition), border-color var(--transition); }
.doc__outline a:hover { color: var(--text); }
.doc__outline a.active { color: var(--accent); border-left-color: var(--accent); font-weight: 500; }
/* When closed, hide the empty outline entirely on narrow screens */
.doc__outline.is-empty { display: none; }

@media (max-width: 1280px) {
  .doc, body.outline-open .doc { grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }
  body.rail-collapsed .doc, body.rail-collapsed.outline-open .doc { grid-template-columns: var(--outline-tab) minmax(0, 1fr); }
  .doc__outline { display: none; }
}
/* Tablets and phones: the article takes the full width and the left rail becomes a
   slide-in drawer opened from the "Topics" button in the breadcrumb bar. */
@media (max-width: 1000px) {
  .doc, body.outline-open .doc,
  body.rail-collapsed .doc, body.rail-collapsed.outline-open .doc { grid-template-columns: minmax(0, 1fr); }
  .doc__article { --art-px: var(--shell-pad); padding: var(--sp-5) var(--art-px) var(--sp-8); margin-top: 0; max-width: 100%; }
}
/* The topics drawer rules live at the end of this file so they win over the rail defaults. */

.rail-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--sp-2); }
/* Collapse toggle + search bar on one row (toggle first, search fills the rest) */
.rail-head--bare { justify-content: flex-start; gap: var(--sp-2); margin-bottom: var(--sp-4); }
.rail-head--bare .rail-collapse { flex: none; }
.rail-head--bare .rail-search { flex: 1 1 auto; margin: 0; }
.rail-head__label { text-transform: uppercase; letter-spacing: 0.1em; font-size: 0.66rem; font-weight: 600; color: var(--muted-2); opacity: 0.85; }
.rail-collapse { width: 26px; height: 26px; border-radius: 7px; border: 1px solid var(--line); background: var(--bg-elev); color: var(--muted); cursor: pointer; display: grid; place-items: center; font-size: 1rem; line-height: 1; transition: background var(--transition), color var(--transition); }
.rail-collapse:hover { background: var(--bg-elev-3); color: var(--text-strong); }



/* Collapsed state: the rail stays put (its column is the thin strip, set in
   the grid above). Only the BODY (search + links) hides; the toggle head
   remains, exactly like the right-side outline toggle — so the button never
   moves vertically between states. */
body.rail-collapsed .rail-body { opacity: 0; pointer-events: none; }
body.rail-collapsed .rail-head--bare .rail-search { display: none; }
body.rail-collapsed .doc__rail { padding-left: 0; padding-right: 0; overflow: hidden; }
body.rail-collapsed .rail-head--bare { justify-content: center; }
.rail-body { transition: opacity 180ms ease; }
.doc { transition: grid-template-columns 220ms var(--ease-out); }

.rail-group__title { text-transform: uppercase; letter-spacing: 0.1em; font-size: 0.66rem; font-weight: 600; color: var(--muted); margin: var(--sp-5) 0 var(--sp-2); }
.rail-group__title:first-child { margin-top: 0; }
.rail a { display: block; color: var(--text); padding: 6px var(--sp-3); border-radius: 8px; font-weight: 360; transition: color var(--transition), background var(--transition); }
.rail a:hover { color: var(--text-strong); background: color-mix(in oklab, var(--text) 6%, transparent); }
.rail a[aria-current="page"] { color: var(--accent); background: var(--accent-soft); font-weight: 500; }

/* ---------- Article typography ---------- */
.art-head { margin-bottom: var(--sp-6); padding-bottom: var(--sp-2); }

/* ---------- Breadcrumb bar (central panel, pinned under the top nav) ----------
   Spans the full width of the central panel (negative margins cancel the article padding),
   so text never shows through either side of it while pinned. */
.crumbs-bar {
  position: sticky; top: var(--topbar-h); z-index: 30;
  display: flex; align-items: center; gap: var(--sp-3); min-height: 44px;
  margin: 0 calc(var(--art-px, 0px) * -1) var(--sp-3);
  padding: var(--sp-2) var(--art-px, 0px);
  background: var(--bg);   /* solid, so scrolled text never shows through */
  border-bottom: 1px solid transparent;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}
.crumbs-bar.is-stuck { border-bottom-color: var(--line-soft); box-shadow: 0 8px 18px -14px rgb(0 0 0 / 0.55); }
.crumbs-bar .crumbs { margin: 0; min-width: 0; }
.crumbs-bar__topics {
  display: none; align-items: center; gap: 6px; flex: none;
  height: 32px; padding: 0 12px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--bg-elev); color: var(--text);
  font: inherit; font-size: var(--step--1); font-weight: 500; cursor: pointer;
}
.crumbs-bar__topics:hover { border-color: var(--accent); color: var(--text-strong); }
.crumbs-bar__topics:focus-visible { outline: none; box-shadow: var(--ring); }
.crumbs-bar__topics[aria-expanded="true"] { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.crumbs-bar__icon { font-size: 0.95em; line-height: 1; }
/* Static (prerendered) pages have no article padding variable; keep the bar flush. */
.static-article .crumbs-bar { margin-left: 0; margin-right: 0; padding-left: 0; padding-right: 0; }
.crumbs { margin: 0 0 var(--sp-3); font-size: var(--step--1); line-height: 1.4; }
.crumbs__list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: nowrap; align-items: center; gap: 2px 0; min-width: 0; overflow: hidden; }
.crumbs__item:last-child { min-width: 0; }
.crumbs__item { display: inline-flex; align-items: center; min-width: 0; }
.crumbs__item + .crumbs__item::before {
  content: ""; width: 6px; height: 6px; margin: 0 10px 0 8px; flex: none;
  border-top: 1.5px solid var(--muted-2); border-right: 1.5px solid var(--muted-2);
  transform: rotate(45deg); opacity: 0.8;
}
.crumbs__link { color: var(--muted); text-decoration: none; border-radius: 6px; padding: 2px 4px; margin: 0 -4px; transition: color var(--transition), background var(--transition); }
.crumbs__link:hover { color: var(--accent); background: var(--accent-soft); }
.crumbs__link:focus-visible { outline: none; box-shadow: var(--ring); }
.crumbs__text { color: var(--muted-2); }
.crumbs__current { color: var(--text-strong); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 42ch; }
/* Phones: hide middle crumbs behind an ellipsis so the trail stays on one or two lines. */
@media (max-width: 640px) {
  .crumbs__item--mid { display: none; }
  .crumbs__item:first-child::after { content: "\2026"; color: var(--muted-2); margin-left: 8px; }
  .crumbs__list:not(:has(.crumbs__item--mid)) .crumbs__item:first-child::after { content: none; }
  .crumbs__current { max-width: 60vw; }
}
.art-head h1 { font-size: var(--step-3); margin: 0 0 var(--sp-3); letter-spacing: -0.025em; font-weight: 600; line-height: 1.15; }
.art-head .subtitle { color: var(--muted); font-size: var(--step-1); margin: 0; line-height: 1.5; font-weight: 400; }
/* Tertiary meta line: tiny, very light, no chips — just a quiet caption. */
.art-meta { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-1) 0; margin-top: var(--sp-3); }
.art-meta .pill { background: none; border: none; padding: 0; border-radius: 0; font-size: 0.72rem; letter-spacing: 0.01em; color: var(--muted-2); font-weight: 200; }
.art-meta .pill:first-child { background: none; border: none; color: var(--muted-2); font-weight: 200; }
.art-meta .pill + .pill::before { content: "·"; margin: 0 8px; color: var(--muted-2); opacity: 0.6; }

.block { margin: var(--sp-6) 0; }
.block h2 { font-size: var(--step-2); margin: var(--sp-8) 0 var(--sp-4); scroll-margin-top: calc(var(--topbar-h) + var(--sp-4)); position: relative; padding-left: var(--sp-4); }
.block h2::before { content: ""; position: absolute; left: 0; top: 0.12em; bottom: 0.12em; width: 4px; border-radius: 999px; background: var(--grad-brand); }
.block h3 { font-size: var(--step-1); margin: var(--sp-6) 0 var(--sp-2); }
.prose p { margin: 0 0 var(--sp-4); font-weight: 400; }
.prose strong { color: var(--text-strong); font-weight: 600; }
.prose code { font-family: var(--font-mono); background: var(--bg-elev-3); border: 1px solid var(--line-soft); padding: 1px 7px; border-radius: 7px; font-size: 0.88em; color: color-mix(in oklab, var(--accent) 55%, var(--text)); }
.prose ul, .prose ol { padding-left: 1.35rem; }
.prose li { margin: var(--sp-2) 0; }
.prose li::marker { color: var(--accent); }

/* soft shadow on feature surfaces */
.prereq, .tldr, .diagram, .lens, .bigpic, .quiz, .mock, .card, .roadmap__step, .tradeoff, .callout { box-shadow: var(--shadow-sm); }

/* ---------- Callout ---------- */
.callout { position: relative; border: 1px solid var(--line); background: var(--bg-elev); border-radius: var(--radius); padding: var(--sp-4) var(--sp-5); overflow: hidden; }
.callout::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--accent); }
.callout--warn::before { background: var(--warn); }
.callout--danger::before { background: var(--danger); }
.callout--ai::before { background: linear-gradient(180deg, var(--accent-2), var(--accent-3)); }
.callout__title { font-family: var(--font-display); font-weight: 600; margin-bottom: var(--sp-2); color: var(--text-strong); }
.callout--ai .callout__title { color: var(--accent-2); }
.callout--warn .callout__title { color: var(--warn); }
.callout--danger .callout__title { color: var(--danger); }

/* ---------- Prerequisites box ---------- */
.prereq { border: 1px solid var(--line); border-radius: var(--radius); background: var(--grad-surface); padding: var(--sp-5); }
.prereq__title { font-family: var(--font-display); font-weight: 700; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--accent); margin-bottom: var(--sp-2); }
.prereq .prose p { margin: 0 0 var(--sp-3); color: var(--muted); }
.prereq__chips { margin-top: var(--sp-2); }
.prereq__newto { margin: var(--sp-3) 0 0; font-size: var(--step--1); color: var(--muted-2); }

/* ---------- TL;DR ---------- */
/* Flat, borderless panel: a neutral surface, no gradient or shadow. */
.tldr { border: 0; border-radius: var(--radius); background: var(--bg-elev-3); box-shadow: none; padding: var(--sp-4) var(--sp-5); }
.tldr__summary { display: flex; align-items: center; gap: var(--sp-3); cursor: pointer; list-style: none; font-family: var(--font-display); }
.tldr__summary::-webkit-details-marker { display: none; }
.tldr__summary::after { content: "\25be"; margin-left: auto; color: var(--muted-2); transition: transform 320ms cubic-bezier(0.33, 1, 0.68, 1); font-size: 1.1rem; }
/* When JS enhances the box, visibility is driven by .is-open; otherwise [open] */
.tldr.is-open .tldr__summary::after,
.tldr:not([data-anim-enhanced])[open] .tldr__summary::after { transform: rotate(180deg); }
.tldr__badge { background: var(--label-bg); color: var(--label-ink); font-size: 0.68rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; padding: 4px 10px; border-radius: 999px; }
.tldr__label { font-weight: 600; color: var(--text-strong); }
.tldr__body ul { margin: 0; padding-left: 1.2rem; }
.tldr__body li { margin: var(--sp-2) 0; }
.tldr__body li::marker { color: var(--accent-2); }
.tldr__body .prose p { margin: 0 0 var(--sp-2); }

/* Smooth expand/collapse via the grid-rows trick (see details-anim.js).
   The body is a 1-row grid that animates 0fr -> 1fr; .anim-clip hides overflow
   so the content slides cleanly without any per-frame layout thrash. */
.tldr__body.anim-grid { display: grid; grid-template-rows: 0fr; transition: grid-template-rows 320ms cubic-bezier(0.33, 1, 0.68, 1); }
.tldr.is-open .tldr__body.anim-grid { grid-template-rows: 1fr; }
.anim-clip { overflow: hidden; min-height: 0; padding-top: var(--sp-4); opacity: 0; transform: translateY(-4px); transition: opacity 240ms ease, transform 320ms cubic-bezier(0.33, 1, 0.68, 1); }
.tldr.is-open .anim-clip { opacity: 1; transform: translateY(0); }

/* ---------- Trade-off table ---------- */
.tradeoff { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg-elev); }
.tradeoff table { border-collapse: collapse; width: 100%; font-size: var(--step--1); }
.tradeoff th, .tradeoff td { text-align: left; padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--line-soft); vertical-align: top; }
.tradeoff th { background: var(--bg-elev-3); font-family: var(--font-display); font-weight: 600; color: var(--text-strong); position: sticky; top: 0; white-space: nowrap; }
.tradeoff tbody tr { transition: background var(--transition); }
.tradeoff tbody tr:hover { background: color-mix(in oklab, var(--accent) 5%, transparent); }
.tradeoff td:first-child { font-weight: 600; color: var(--text-strong); }
.tradeoff tr:last-child td { border-bottom: none; }

/* ---------- Diagram ---------- */
.diagram { border: 1px solid var(--line); background: var(--grad-surface); border-radius: var(--radius-lg); padding: var(--sp-6); }
/* Each diagram caps its own width near its drawn size (diagram.js); centre it in the card. */
.diagram svg { width: 100%; height: auto; display: block; margin: 0 auto; }
.diagram__caption { color: var(--muted); font-size: var(--step--1); margin-top: var(--sp-4); text-align: center; font-style: italic; }

/* ---------- Interview lens ---------- */
/* Flat, borderless tinted panel: the accent-soft surface carries the highlight, no gradient or glow. */
.lens { position: relative; border: 0; border-radius: var(--radius-lg); background: var(--accent-soft); box-shadow: none; padding: var(--sp-6); overflow: hidden; }
.lens::after { content: none; }
.lens__tag { display: inline-block; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.1em; font-weight: 700; color: var(--label-ink); background: var(--label-bg); padding: 4px 10px; border-radius: 999px; margin-bottom: var(--sp-3); position: relative; }
.lens h3 { margin-top: var(--sp-4); margin-bottom: var(--sp-2); position: relative; }
.lens h3:first-of-type { margin-top: 0; }
.lens ul { padding-left: 1.2rem; position: relative; }

/* ---------- Big picture ---------- */
.bigpic { border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--bg-elev); padding: var(--sp-6); }
.bigpic__tag { display: inline-block; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--accent); font-family: var(--font-display); font-weight: 700; margin-bottom: var(--sp-3); }
.bigpic__intro { margin: 0 0 var(--sp-5); color: var(--muted); }
.bigpic__grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: var(--sp-4); }
.bigpic__panel { border: 1px solid var(--line-soft); border-radius: var(--radius); padding: var(--sp-4); background: var(--bg-elev-3); border-top: 3px solid var(--accent); transition: transform var(--transition), box-shadow var(--transition); }
.bigpic__panel:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.bigpic__panel--why { border-top-color: var(--accent); }
.bigpic__panel--risk { border-top-color: var(--danger); }
.bigpic__panel--fit { border-top-color: var(--accent-2); }
.bigpic__ptitle { display: flex; align-items: center; gap: var(--sp-2); font-family: var(--font-display); font-weight: 600; margin-bottom: var(--sp-3); font-size: var(--step-0); color: var(--text-strong); }
.bigpic__icon { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 8px; background: var(--accent-soft); color: var(--accent); font-size: 0.85rem; }
.bigpic__panel--risk .bigpic__icon { background: color-mix(in oklab, var(--danger) 16%, transparent); color: var(--danger); }
.bigpic__panel--fit .bigpic__icon { background: color-mix(in oklab, var(--accent-2) 16%, transparent); color: var(--accent-2); }
.bigpic__panel ul { margin: 0; padding-left: 1.1rem; font-size: var(--step--1); }
.bigpic__panel li { margin: var(--sp-2) 0; color: var(--muted); }
.bigpic__conntitle { margin-top: var(--sp-6); }
.bigpic__conn { list-style: none; padding: 0; margin: var(--sp-3) 0 0; display: flex; flex-direction: column; gap: var(--sp-2); }
.bigpic__conn li { display: flex; align-items: baseline; gap: var(--sp-2); flex-wrap: wrap; }
.bigpic__note { color: var(--muted); font-size: var(--step--1); }

/* ---------- Quiz ---------- */
.quiz { border: 1px solid color-mix(in oklab, var(--ok) 26%, var(--line)); border-radius: var(--radius-lg); background: linear-gradient(165deg, color-mix(in oklab, var(--ok) 8%, var(--bg-elev)), var(--bg-elev) 70%); padding: var(--sp-6); }
.quiz__tag { display: inline-block; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--ok); font-family: var(--font-display); font-weight: 700; margin-bottom: var(--sp-3); }
.quiz__intro { color: var(--muted); margin: 0 0 var(--sp-4); }
.quiz__q { border: 1px solid var(--line-soft); border-radius: var(--radius-sm); margin: var(--sp-2) 0; background: var(--bg-elev); overflow: hidden; transition: border-color var(--transition); }
.quiz__q[open] { border-color: color-mix(in oklab, var(--ok) 40%, var(--line)); }
.quiz__question { display: flex; align-items: flex-start; gap: var(--sp-3); cursor: pointer; padding: var(--sp-3) var(--sp-4); font-family: var(--font-display); font-weight: 500; list-style: none; color: var(--text-strong); }
.quiz__question::-webkit-details-marker { display: none; }
.quiz__question::after { content: "+"; margin-left: auto; color: var(--ok); font-size: 1.3rem; line-height: 1; font-weight: 300; }
.quiz__q[open] .quiz__question::after { content: "\2212"; }
.quiz__num { display: inline-grid; place-items: center; min-width: 24px; height: 24px; border-radius: 7px; background: color-mix(in oklab, var(--ok) 18%, transparent); color: var(--ok); font-size: 0.78rem; font-weight: 700; }
.quiz__answer { padding: 0 var(--sp-4) var(--sp-4) calc(var(--sp-4) + 36px); border-top: 1px solid var(--line-soft); }
.quiz__answer .prose p:first-child { margin-top: var(--sp-3); }
.quiz__hint { color: var(--muted); font-size: var(--step--1); }

/* ---------- Mock interview ---------- */
.mock { border: 1px solid color-mix(in oklab, var(--warn) 28%, var(--line)); border-radius: var(--radius-lg); background: linear-gradient(165deg, color-mix(in oklab, var(--warn) 10%, var(--bg-elev)), var(--bg-elev) 70%); padding: var(--sp-6); }
.mock__tag { display: inline-block; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--warn); font-family: var(--font-display); font-weight: 700; margin-bottom: var(--sp-3); }
.mock__prompt { border: 1px dashed color-mix(in oklab, var(--warn) 55%, var(--line)); border-radius: var(--radius-sm); padding: var(--sp-4) var(--sp-5); background: var(--bg-elev); }
.mock__plabel { font-family: var(--font-display); font-weight: 700; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--warn); margin-bottom: var(--sp-2); }
.mock__prompt .prose p { margin: 0; font-size: var(--step-0); }
.mock__timebox { color: var(--muted); font-size: var(--step--1); margin: var(--sp-3) 0; }
.mock__rubric { border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--bg-elev); margin-top: var(--sp-2); }
.mock__rubriclabel { cursor: pointer; padding: var(--sp-3) var(--sp-4); font-family: var(--font-display); font-weight: 600; list-style: none; color: var(--text-strong); }
.mock__rubriclabel::-webkit-details-marker { display: none; }
.mock__rubriclabel::after { content: " \25be"; color: var(--muted-2); }
.mock__rubric[open] .mock__rubriclabel::after { content: " \25b4"; }
.mock__rubricbody { padding: 0 var(--sp-4) var(--sp-4); border-top: 1px solid var(--line-soft); }
.mock__criterion { margin: var(--sp-3) 0; }
.mock__cname { display: flex; align-items: center; gap: var(--sp-2); font-family: var(--font-display); color: var(--text-strong); }
.mock__dot { width: 8px; height: 8px; border-radius: 50%; background: var(--grad-brand); display: inline-block; }
.mock__looks { margin: 2px 0 0 16px; color: var(--muted); font-size: var(--step--1); }
.mock__redlabel { font-family: var(--font-display); font-weight: 700; color: var(--danger); margin-top: var(--sp-4); font-size: var(--step--1); }
.mock__redflags { margin: var(--sp-2) 0 0; padding-left: 1.2rem; }
.mock__redflags li { color: var(--muted); font-size: var(--step--1); margin: 4px 0; }
.mock__redflags li::marker { color: var(--danger); }

/* ---------- Chips ---------- */
.chips { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.chip { display: inline-flex; align-items: center; gap: 6px; background: var(--bg-elev); border: 1px solid var(--line); border-radius: 999px; padding: 6px 14px; font-size: var(--step--1); color: var(--text); font-weight: 500; transition: border-color var(--transition), background var(--transition), transform var(--transition), color var(--transition); }
.chip:hover { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); transform: translateY(-1px); }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; gap: var(--sp-2); font-family: var(--font-display); font-weight: 600; border-radius: 999px; padding: 12px var(--sp-5); cursor: pointer; border: 1px solid var(--line); background: var(--bg-elev); color: var(--text); transition: transform var(--transition), box-shadow var(--transition), background var(--transition), border-color var(--transition); }
.btn:hover { transform: translateY(-2px); color: var(--text); }
.btn--primary { background: var(--grad-brand); color: var(--accent-ink); border-color: transparent; box-shadow: var(--shadow), var(--glow); }
.btn--primary:hover { color: var(--accent-ink); box-shadow: var(--shadow-lg), var(--glow); }
.btn--ghost { background: color-mix(in oklab, var(--text) 4%, transparent); }
.btn--ghost:hover { background: color-mix(in oklab, var(--text) 9%, transparent); border-color: var(--accent); }

/* ---------- Landing ---------- */
.hero { display: grid; grid-template-columns: 1.25fr 0.75fr; gap: var(--sp-7); align-items: center; padding: var(--sp-6) 0 var(--sp-6); position: relative; min-height: calc(100vh - var(--topbar-h) - var(--sp-8)); }
.hero__eyebrow { display: inline-flex; align-items: center; gap: 8px; color: var(--accent); font-weight: 600; font-size: var(--step--1); background: var(--accent-soft); border: 1px solid color-mix(in oklab, var(--accent) 30%, transparent); padding: 6px 14px; border-radius: 999px; }
.hero h1 { font-size: var(--step-4); margin: var(--sp-4) 0 var(--sp-3); letter-spacing: -0.03em; line-height: 1.08; font-weight: 650; }
.hero h1 strong { font-weight: 650; background: var(--grad-text); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero p.lead { font-size: var(--step-1); color: var(--muted); max-width: 36rem; line-height: 1.5; font-weight: 400; }
.hero__cta { display: flex; gap: var(--sp-3); margin-top: var(--sp-6); flex-wrap: wrap; }
.globe-wrap { position: relative; max-width: 420px; margin-left: auto; opacity: 0.94; filter: drop-shadow(0 20px 34px rgba(50,58,72,0.32)); }
.globe-wrap svg { width: 100%; height: auto; }
@media (max-width: 920px) { .hero { grid-template-columns: 1fr; padding-top: var(--sp-6); } .globe-wrap { max-width: 420px; margin: 0 auto; } }

.section { padding: var(--sp-8) 0 var(--sp-6); border-top: 1px solid var(--line-soft); }
.section__title { font-size: var(--step-2); margin: 0 0 var(--sp-6); letter-spacing: -0.02em; font-weight: 600; }
/* ---------- Split (two-column feature + visual) ---------- */
.split { display: grid; grid-template-columns: 1.15fr 0.85fr; gap: var(--sp-6); align-items: start; }
.split--center { align-items: center; }
.split__col { min-width: 0; }
.split__col--aside .diagram { position: sticky; top: calc(var(--topbar-h) + var(--sp-4)); }
.split .block { margin-top: 0; }
@media (max-width: 920px) { .split { grid-template-columns: 1fr; } .split__col--aside .diagram { position: static; } }

.grid-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: var(--sp-4); }
/* inside a split, cards stack in one column so the visual sits beside them */
.split__col .grid-cards { grid-template-columns: 1fr; }
.card { position: relative; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--bg-elev); padding: var(--sp-5); transition: transform var(--transition), border-color var(--transition), box-shadow var(--transition); overflow: hidden; }
.card::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 3px; background: var(--grad-brand); opacity: 0; transition: opacity var(--transition); }
.card:hover { transform: translateY(-4px); border-color: color-mix(in oklab, var(--accent) 45%, var(--line)); box-shadow: var(--shadow-lg); }
.card:hover::before { opacity: 1; }
a.card { color: var(--text); }
.card h3 { margin: 0 0 var(--sp-2); font-size: var(--step-1); }
.card p { margin: 0; color: var(--muted); font-size: var(--step--1); }
.card__num { font-family: var(--font-display); font-size: var(--step-2); font-weight: 700; background: var(--grad-text); -webkit-background-clip: text; background-clip: text; color: transparent; display: block; margin-bottom: var(--sp-2); }

/* ---------- Path roadmap ---------- */
.roadmap { display: grid; gap: var(--sp-3); }
.roadmap__step { display: grid; grid-template-columns: 48px 1fr; gap: var(--sp-4); align-items: start; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg-elev); padding: var(--sp-4) var(--sp-5); transition: transform var(--transition), border-color var(--transition); }
.roadmap__step:hover { transform: translateX(4px); border-color: color-mix(in oklab, var(--accent) 40%, var(--line)); }
.roadmap__badge { width: 48px; height: 48px; border-radius: 14px; background: var(--grad-brand); color: var(--accent-ink); display: grid; place-items: center; font-family: var(--font-display); font-weight: 700; font-size: var(--step-1); box-shadow: var(--shadow-sm); }
.roadmap__step h3 { margin: 0 0 4px; font-size: var(--step-1); }
.roadmap__step p { margin: 0; color: var(--muted); font-size: var(--step--1); }

/* ---------- States ---------- */
.state { text-align: center; padding: var(--sp-8) var(--sp-4); max-width: 36rem; margin: 0 auto; }
.state__code { font-family: var(--font-display); font-size: var(--step-4); font-weight: 700; background: var(--grad-text); -webkit-background-clip: text; background-clip: text; color: transparent; }
.state h1 { font-size: var(--step-2); margin-top: var(--sp-2); }
.state p { color: var(--muted); margin-bottom: var(--sp-5); }
.loader { display: grid; place-items: center; padding: var(--sp-8); color: var(--muted); }
.spinner { width: 28px; height: 28px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Footer ---------- */
.footer { border-top: 1px solid var(--line-soft); margin-top: var(--sp-8); background: color-mix(in oklab, var(--bg-elev) 50%, transparent); }
.footer__inner { max-width: var(--maxw); margin: 0 auto; padding: var(--sp-7) var(--sp-6) var(--sp-5); color: var(--muted); font-size: var(--step--1); }
.footer__top { display: grid; grid-template-columns: minmax(200px, 1.4fr) repeat(6, minmax(110px, 1fr)); gap: var(--sp-6) var(--sp-5); }
.footer__brandrow { display: inline-flex; align-items: center; gap: var(--sp-2); color: var(--text-strong); font-family: var(--font-display); font-weight: 600; font-size: var(--step-0); text-decoration: none; }
.footer__brandrow:hover { color: var(--text-strong); }
.footer__mark { width: 24px; height: 24px; display: inline-flex; }
.footer__mark svg { width: 100%; height: 100%; }
.footer__desc { margin: var(--sp-3) 0 0; max-width: 36ch; color: var(--muted); line-height: 1.6; }
.footer__social { list-style: none; margin: var(--sp-4) 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: var(--sp-2) var(--sp-4); }
.footer__title { margin: 0 0 var(--sp-3); font-family: var(--font-display); font-weight: 600; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-strong); }
.footer__links, .footer__legal { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--sp-2); }
.footer__legal { display: flex; flex-wrap: wrap; gap: var(--sp-2) var(--sp-5); }
.footer__col a, .footer__social a, .footer__legal a { color: var(--muted); }
.footer__col a:hover, .footer__social a:hover, .footer__legal a:hover { color: var(--text-strong); }
.footer__bottom { margin-top: var(--sp-6); padding-top: var(--sp-4); border-top: 1px solid var(--line-soft); display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: var(--sp-3) var(--sp-5); }
.footer__copy { margin: 0; color: var(--muted); }
.footer__note { margin: var(--sp-1) 0 0; max-width: 80ch; font-size: 0.72rem; color: var(--muted-2); line-height: 1.6; }
@media (max-width: 1100px) { .footer__top { grid-template-columns: repeat(3, minmax(120px, 1fr)); } .footer__brand { grid-column: 1 / -1; } }
@media (max-width: 560px) { .footer__top { grid-template-columns: repeat(2, minmax(120px, 1fr)); } }


/* ===================== Search + autocomplete ===================== */

/* Shared dropdown panel (used by rail search and top search) */
.ac__panel { position: absolute; z-index: 60; left: 0; right: 0; top: calc(100% + 6px); background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); overflow: hidden; max-height: 60vh; overflow-y: auto; }
.ac__panel[hidden] { display: none; }
.ac__list { list-style: none; margin: 0; padding: 4px; }
.ac__item { display: flex; align-items: baseline; justify-content: space-between; gap: var(--sp-3); padding: 8px 10px; border-radius: 8px; cursor: pointer; }
.ac__item.is-active { background: var(--accent-soft); }
.ac__label { color: var(--text); font-weight: 400; font-size: var(--step--1); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ac__item.is-active .ac__label { color: var(--accent); }
.ac__ctx { color: var(--muted-2); font-weight: 300; font-size: 0.74rem; white-space: nowrap; flex: none; }
.ac__kind { color: var(--muted-2); font-weight: 400; font-size: 0.62rem; text-transform: uppercase; letter-spacing: 0.08em; flex: none; }

/* Left-panel search */
/* Collapse button + search on one horizontal row */
.rail-top { display: flex; align-items: center; gap: var(--sp-2); margin: 0 0 var(--sp-4); }
.rail-top .rail-collapse { flex: none; }
.rail-top .rail-search { flex: 1 1 auto; margin: 0; }
.rail-search { position: relative; display: flex; align-items: center; margin: 0 0 var(--sp-4); }
.rail-search__icon { position: absolute; left: 10px; color: var(--muted-2); display: inline-flex; pointer-events: none; }
.rail-search__input { width: 100%; background: var(--bg-elev); border: 1px solid var(--line); border-radius: 999px; padding: 7px 12px 7px 32px; font: inherit; font-size: var(--step--1); font-weight: 360; color: var(--text); transition: border-color var(--transition), box-shadow var(--transition); }
.rail-search__input::placeholder { color: var(--muted); font-weight: 360; }
.rail-search__input,
.rail-search__input:focus,
.rail-search__input:focus-visible { outline: none; box-shadow: none; border-radius: 999px; }
.rail-search__input::-webkit-search-cancel-button { -webkit-appearance: none; }
.rail-search__input[readonly] { cursor: pointer; }

/* Top-menu search (expand on click) */
.topsearch { position: relative; display: flex; align-items: center; }
.topsearch__btn { width: 38px; height: 38px; border-radius: 10px; border: 1px solid transparent; background: transparent; color: var(--muted); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; transition: background var(--transition), color var(--transition); }
.topsearch__btn:hover { background: var(--bg-elev-3); color: var(--text-strong); }
.topsearch__input { width: 0; opacity: 0; padding: 0; border: 1px solid transparent; border-radius: 999px; font: inherit; font-size: var(--step--1); font-weight: 300; color: var(--text); background: var(--bg-elev); transition: width 200ms var(--ease-out), opacity 160ms ease, padding 200ms var(--ease-out), border-color var(--transition); margin-left: 6px; }
.topsearch.is-open .topsearch__input { width: 240px; opacity: 1; padding: 7px 14px; border-color: var(--line); }
.topsearch__input:focus { outline: none; border-color: color-mix(in oklab, var(--accent) 45%, var(--line)); box-shadow: var(--ring); }
.topsearch__input::placeholder { color: var(--muted-2); font-weight: 300; }
.topsearch .ac__panel { left: auto; right: 0; width: 300px; }

@media (max-width: 860px) {
  .topsearch.is-open .topsearch__input { width: 160px; }
  .topsearch .ac__panel { width: 240px; }
}

/* ===================== Prev / Next pager ===================== */
/* Compact, borderless text links hugging their content at each end. */
.pager { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sp-4); margin-top: var(--sp-8); padding-top: var(--sp-5); border-top: 1px solid var(--line-soft); }
.pager__link { display: inline-flex; flex-direction: column; gap: 2px; padding: 0; border: none; border-radius: 0; background: none; text-decoration: none; min-width: 0; max-width: 46%; }
.pager__link--next { text-align: right; align-items: flex-end; margin-left: auto; }
.pager__link--empty { display: none; }
.pager__dir { font-size: 0.64rem; text-transform: uppercase; letter-spacing: 0.1em; font-weight: 400; color: var(--muted-2); }
.pager__title { font-size: var(--step--1); font-weight: 400; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; transition: color var(--transition); }
a.pager__link:hover .pager__title { color: var(--accent); }
a.pager__link:hover .pager__dir { color: var(--muted); }

@media (max-width: 560px) {
  .pager__link { max-width: 48%; }
}

/* ===================== Vertical timeline ===================== */
.timeline { position: relative; display: flex; flex-direction: column; gap: var(--sp-6); padding-left: 6px; }
/* The connecting line runs through the centre of the markers. It "draws" in
   from the top via scaleY once the timeline is revealed. */
.timeline::before { content: ""; position: absolute; left: 19px; top: 8px; bottom: 8px; width: 2px; background: linear-gradient(180deg, var(--accent) 0%, var(--accent-3) 100%); opacity: 0.35; border-radius: 2px; transform: scaleY(0); transform-origin: top; transition: transform 700ms cubic-bezier(0.33, 1, 0.68, 1); }
.timeline.is-revealed::before { transform: scaleY(1); }
.timeline__item { position: relative; display: grid; grid-template-columns: 40px 1fr; align-items: start; gap: var(--sp-3); text-decoration: none; color: inherit; }
.timeline__marker { position: relative; z-index: 1; width: 34px; height: 34px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-family: var(--font-display); font-size: 0.82rem; font-weight: 600; color: var(--accent); background: var(--bg-elev); border: 1.5px solid color-mix(in oklab, var(--accent) 40%, var(--line)); box-shadow: 0 0 0 4px var(--bg); transition: background var(--transition), color var(--transition), border-color var(--transition); }
.timeline__body { padding-top: 4px; min-width: 0; }
.timeline__title { font-size: var(--step-1); margin: 0 0 4px; font-weight: 600; letter-spacing: -0.01em; }
.timeline__text { margin: 0; color: var(--muted); font-size: var(--step--1); line-height: 1.6; font-weight: 300; }
a.timeline__item:hover .timeline__marker { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
a.timeline__item:hover .timeline__title { color: var(--accent); }

/* Staggered reveal: each item starts dimmed + lifted, then eases into place.
   The per-item delay is set inline via --reveal-delay by the reveal observer. */
.timeline__item { opacity: 0; transform: translateY(14px); transition: opacity 520ms cubic-bezier(0.33, 1, 0.68, 1) var(--reveal-delay, 0ms), transform 520ms cubic-bezier(0.33, 1, 0.68, 1) var(--reveal-delay, 0ms); }
.timeline.is-revealed .timeline__item { opacity: 1; transform: translateY(0); }
/* The marker gives a little confident "pop" as its item lands. */
.timeline__item .timeline__marker { transform: scale(0.6); transition: background var(--transition), color var(--transition), border-color var(--transition), transform 520ms cubic-bezier(0.34, 1.56, 0.64, 1) var(--reveal-delay, 0ms); }
.timeline.is-revealed .timeline__item .timeline__marker { transform: scale(1); }

@media (prefers-reduced-motion: reduce) {
  .timeline::before,
  .timeline__item,
  .timeline__item .timeline__marker { transition: none; opacity: 1; transform: none; }
}

/* ===================== Analytics consent bar ===================== */
.consent { position: fixed; left: 50%; bottom: var(--sp-4); transform: translateX(-50%); z-index: 90; display: flex; align-items: center; gap: var(--sp-4); max-width: min(560px, calc(100vw - 2rem)); padding: var(--sp-3) var(--sp-4); background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-lg); }
.consent__body { min-width: 0; }
.consent__title { margin: 0 0 4px; font-size: var(--step--1); font-weight: 600; color: var(--text-strong); }
.consent__text { margin: 0; font-size: var(--step--1); color: var(--muted); font-weight: 300; line-height: 1.45; }
.consent { max-width: min(640px, calc(100vw - 2rem)) !important; }
.footer__privacy { font: inherit; background: none; border: 0; padding: 0; color: var(--muted); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.footer__privacy:hover { color: var(--text-strong); }
.consent__actions { display: flex; gap: var(--sp-2); flex: none; }
.consent__btn { font: inherit; font-size: var(--step--1); padding: 6px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--bg-elev); color: var(--text); cursor: pointer; transition: background var(--transition), border-color var(--transition); }
.consent__btn:hover { background: var(--bg-elev-3); }
.consent__btn--primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.consent__btn--primary:hover { background: var(--accent-2); border-color: var(--accent-2); }
@media (max-width: 560px) { .consent { flex-direction: column; align-items: stretch; text-align: center; } .consent__actions { justify-content: center; } }

/* ===================== Central search dialog ===================== */
.search-dialog { border: none; border-radius: var(--radius-lg); padding: 0; width: min(640px, calc(100vw - 32px)); max-height: min(72vh, 640px); margin: 12vh auto 0; background: var(--bg-elev); color: var(--text); box-shadow: var(--shadow-lg); overflow: hidden; }
.search-dialog[open] { display: flex; flex-direction: column; }
.search-dialog::backdrop { background: color-mix(in oklab, var(--text-strong) 35%, transparent); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.search-dialog__form { display: flex; flex-direction: column; min-height: 0; flex: 1 1 auto; }
.search-dialog__bar { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-4) var(--sp-5); border-bottom: 1px solid var(--line-soft); }
.search-dialog__icon { color: var(--muted-2); flex: none; }
.search-dialog__input { flex: 1; min-width: 0; border: 0; background: transparent; font: inherit; font-size: var(--step-0); font-weight: 400; color: var(--text-strong); padding: 6px 0; }
.search-dialog__input,
.search-dialog__input:focus,
.search-dialog__input:focus-visible { outline: none; box-shadow: none; border-radius: 0; }
.search-dialog__input::-webkit-search-cancel-button { -webkit-appearance: none; }
.search-dialog__input::placeholder { color: var(--muted-2); }
.search-dialog__close { border: 1px solid var(--line); background: var(--bg-elev-3); color: var(--muted); border-radius: 8px; font: inherit; font-size: 0.72rem; padding: 3px 8px; cursor: pointer; }
.search-dialog__close:hover { color: var(--text-strong); }
.search-dialog__results { overflow-y: auto; padding: var(--sp-2) var(--sp-3); }
.search-dialog__results[hidden] { display: none; }
.search-dialog__results .ac__list { padding: 0; }
.search-dialog__quick { overflow-y: auto; padding: var(--sp-4) var(--sp-5); }
.search-dialog__quick[hidden] { display: none; }
.search-dialog__label { margin: 0 0 var(--sp-3); font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted-2); font-weight: 600; }
.search-dialog__qlist { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-2); }
.search-dialog__qlist a { display: block; padding: 9px 12px; border: 1px solid var(--line-soft); border-radius: var(--radius-sm); color: var(--text); font-size: var(--step--1); font-weight: 400; }
.search-dialog__qlist a:hover { border-color: var(--accent); color: var(--text-strong); }
.search-dialog__hint { margin: 0; padding: var(--sp-3) var(--sp-5); border-top: 1px solid var(--line-soft); font-size: 0.72rem; color: var(--muted-2); }
.search-dialog kbd { font-family: var(--font-mono); font-size: 0.7rem; border: 1px solid var(--line); border-radius: 5px; padding: 0 5px; background: var(--bg-elev-3); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
@media (max-width: 560px) { .search-dialog__qlist { grid-template-columns: 1fr; } }

/* ===================== Logo motion ===================== */
/* On load: the links draw in, the nodes settle onto the hub. On hover: the nodes pulse once. */
.brand__mark svg .mk-link { stroke-dasharray: 1; stroke-dashoffset: 1; animation: mk-draw 900ms var(--ease-out) 200ms forwards; }
.brand__mark svg .mk-hub { transform-box: fill-box; transform-origin: center; opacity: 0; animation: mk-in 420ms var(--ease-out) 150ms forwards; }
.brand__mark svg .mk-node { transform-box: fill-box; transform-origin: center; opacity: 0; animation: mk-in 420ms var(--ease-out) calc(700ms + var(--i, 0) * 160ms) forwards; }
/* Outward direction of each node from the hub (SVG user units). Nodes are the first three circles. */
/* Each node has an index (--i) for its turn: 0, 1, 2. Direction is its outward vector from the hub. */
.brand__mark svg .mk-node:nth-of-type(1) { --i: 0; --dx: -1.8px; --dy: -1.7px; }
.brand__mark svg .mk-node:nth-of-type(2) { --i: 1; --dx: 1.8px; --dy: -1.7px; }
.brand__mark svg .mk-node:nth-of-type(3) { --i: 2; --dx: 0px; --dy: 2.5px; }
/* Hover: the nodes take turns, one after another. The load fade-in stays first in the list,
   so leaving the logo does not replay it. */
/* On load (the .is-intro class is set by app.js for about 2 seconds): the same sequence plays once,
   starting after each node has faded in. */
.brand.is-intro .brand__mark svg .mk-node {
  animation:
    mk-in 420ms var(--ease-out) calc(700ms + var(--i) * 160ms) forwards,
    mk-push 980ms cubic-bezier(0.33, 0, 0.2, 1) calc(900ms + var(--i) * 280ms) both;
}
.brand:hover .brand__mark svg .mk-node {
  animation:
    mk-in 420ms var(--ease-out) calc(700ms + var(--i) * 160ms) forwards,
    mk-push 980ms cubic-bezier(0.33, 0, 0.2, 1) calc(var(--i) * 280ms) both;
}
@keyframes mk-draw { to { stroke-dashoffset: 0; } }
@keyframes mk-in { from { opacity: 0; transform: scale(0.4); } to { opacity: 1; transform: scale(1); } }
/* Nodes move away from the hub, come back past it, then settle at their original position. */
@keyframes mk-push {
  0%   { transform: translate(0, 0); }
  40%  { transform: translate(var(--dx), var(--dy)); }
  70%  { transform: translate(calc(var(--dx) * -0.25), calc(var(--dy) * -0.25)); }
  90%  { transform: translate(calc(var(--dx) * 0.05), calc(var(--dy) * 0.05)); }
  100% { transform: translate(0, 0); }
}
@media (prefers-reduced-motion: reduce) {
  .brand__mark svg .mk-link { stroke-dashoffset: 0; animation: none; }
  .brand__mark svg .mk-hub, .brand__mark svg .mk-node { opacity: 1; animation: none; }
  .brand:hover .brand__mark svg .mk-node,
  .brand.is-intro .brand__mark svg .mk-node { animation: none; }
}

/* ===================== Role picker ===================== */
/* A row of small buttons in the page header. The chosen role's notes get a tint and a "For you" tag;
   the other roles' notes fade back, and return to full strength on hover or focus. */
.role-picker { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); margin-top: var(--sp-4); }
.role-picker__label { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.1em; font-weight: 600; color: var(--muted-2); margin-right: var(--sp-1); }
.role-picker__btn { font: inherit; font-size: var(--step--1); font-weight: 400; color: var(--muted); background: var(--bg-elev-3); border: 0; border-radius: 999px; padding: 5px 12px; cursor: pointer; transition: background var(--transition), color var(--transition); }
.role-picker__btn:hover { color: var(--text-strong); }
.role-picker__btn.is-active { background: var(--label-bg); color: var(--label-ink); font-weight: 500; }
.role-picker__jump { font: inherit; font-size: var(--step--1); color: var(--accent); background: none; border: 0; padding: 5px 6px; cursor: pointer; margin-left: var(--sp-1); }
.role-picker__jump[hidden] { display: none; }
.role-picker__jump:hover { text-decoration: underline; }

.callout[data-role] { transition: opacity 200ms ease, background 200ms ease; }
.callout.is-other-role { opacity: 0.45; }
.callout.is-other-role:hover, .callout.is-other-role:focus-within { opacity: 1; }
.callout.is-for-you { background: var(--accent-soft); }
.callout.is-for-you .callout__title::after { content: "For you"; margin-left: var(--sp-2); font-size: 0.64rem; text-transform: uppercase; letter-spacing: 0.1em; font-weight: 700; color: var(--label-ink); background: var(--label-bg); padding: 2px 8px; border-radius: 999px; vertical-align: middle; }
@media (prefers-reduced-motion: reduce) { .callout[data-role] { transition: none; } }

/* Role-tagged blocks: any block can name the roles it matters most to.
   A small label shows who it is for; the role picker highlights or fades it. */
.role-block { margin: var(--sp-6) 0; transition: opacity 200ms ease; }
.role-block > * { margin-top: var(--sp-2); margin-bottom: 0; }
.role-block::before { content: attr(data-role-label); display: inline-block; font-size: 0.64rem; text-transform: uppercase; letter-spacing: 0.1em; font-weight: 600; color: var(--muted-2); padding: 2px 0; }
.role-block.is-for-you::before { color: var(--label-ink); background: var(--label-bg); padding: 2px 8px; border-radius: 999px; }
.role-block.is-for-you > * { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: var(--radius-sm); }
.role-block.is-other-role { opacity: 0.5; }
.role-block.is-other-role:hover, .role-block.is-other-role:focus-within { opacity: 1; }
@media (prefers-reduced-motion: reduce) { .role-block { transition: none; } }

/* ---------- Topics drawer (tablets and phones) ----------
   Kept last so it overrides the desktop rail and collapse rules above. The left rail
   slides in from the left, opened by the "Topics" button in the breadcrumb bar. */
.drawer-backdrop { display: none; }
@media (max-width: 1000px) {
  .doc__rail, body.rail-collapsed .doc__rail {
    position: fixed; top: var(--topbar-h); left: 0; z-index: 46;
    /* Explicit viewport height (dvh follows mobile toolbars) so the list always scrolls to its end. */
    height: calc(100vh - var(--topbar-h)); height: calc(100dvh - var(--topbar-h)); max-height: none;
    width: min(320px, 86vw); overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
    padding: var(--sp-4) var(--sp-4) calc(var(--sp-8) + env(safe-area-inset-bottom));
    background: var(--bg-elev); box-shadow: var(--shadow-lg); scrollbar-width: thin;
    transform: translateX(-102%); visibility: hidden;
    transition: transform 240ms var(--ease-out), visibility 0s linear 240ms;
  }
  body.rail-open .doc__rail { transform: none; visibility: visible; transition: transform 240ms var(--ease-out); }
  /* The desktop "collapsed" preference never hides the drawer's contents. */
  body.rail-collapsed .rail-body { opacity: 1; pointer-events: auto; }
  body.rail-collapsed .rail-head--bare .rail-search { display: flex; }
  body.rail-collapsed .rail-head--bare { justify-content: flex-start; }
  .doc__rail .rail-collapse { display: none; }
  .drawer-backdrop { display: block; position: fixed; inset: var(--topbar-h) 0 0 0; z-index: 45; background: rgb(2 6 16 / 0.55); opacity: 0; pointer-events: none; transition: opacity 200ms ease; }
  body.rail-open .drawer-backdrop { opacity: 1; pointer-events: auto; }
  body.rail-open { overflow: hidden; }
  .crumbs-bar .crumbs-bar__topics { display: inline-flex; }
}
