/* ============================================================================
   Base — reset, typography, layout primitives, nav, footer, scroll reveal.
   Loaded on every page after tokens.css.
   ========================================================================== */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* overflow-x lives on html, not body: setting it on body computes body's
   overflow-y to auto, which turns body into its own scroll container and
   stops window scrolling (and every IntersectionObserver with it). */
/* Anchor targets must clear the fixed nav, or in-page links land beneath it. */
[id] { scroll-margin-top: calc(var(--nav-h) + 1.2rem); }

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; overflow-x: hidden; }

body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  font-size: var(--t-body);
  line-height: 1.7;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* Faint ink-grid behind everything. Fixed + painted once; no scroll cost. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(35, 44, 61, 0.35) 1px, transparent 1px),
    linear-gradient(90deg, rgba(35, 44, 61, 0.35) 1px, transparent 1px);
  background-size: 64px 64px;
  mask-image: radial-gradient(ellipse 80% 60% at 50% 0%, #000 20%, transparent 78%);
  -webkit-mask-image: radial-gradient(ellipse 80% 60% at 50% 0%, #000 20%, transparent 78%);
}
body > * { position: relative; z-index: 1; }

a { color: inherit; text-decoration: none; }
img, svg, video { max-width: 100%; height: auto; display: block; }
::selection { background: var(--accent-dim); color: var(--accent-hi); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

/* --- layout primitives ------------------------------------------------- */
.shell { max-width: var(--max); margin: 0 auto; padding: 0 var(--gut); }
.shell-narrow { max-width: 880px; margin: 0 auto; padding: 0 var(--gut); }

.section { padding: clamp(3rem, 2rem + 4vw, 5.5rem) 0; }
.section-tight { padding: clamp(2rem, 1.4rem + 2.4vw, 3.2rem) 0; }

.divider {
  height: 1px;
  border: 0;
  background: linear-gradient(90deg, transparent, var(--border) 18%, var(--border) 82%, transparent);
}

/* --- type -------------------------------------------------------------- */
h1, h2, h3, h4 { font-weight: 700; letter-spacing: -0.015em; line-height: 1.2; }
h1 { font-size: var(--t-h1); }
h2 { font-size: var(--t-h2); }
h3 { font-size: var(--t-h3); letter-spacing: -0.01em; }
p { max-width: 72ch; }
/* That measure makes a paragraph narrower than its container, so inside a
   centred block it would sit flush left with only its text centred. Auto
   margins keep the box itself centred. */
:is(.text-center, .cta-panel, .loading, [align="center"]) > p { margin-inline: auto; }

.eyebrow {
  font-family: var(--mono);
  font-size: var(--t-eyebrow);
  letter-spacing: var(--track-wide);
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 0.9rem;
}
.eyebrow-cyan { color: var(--at-cyan); }
.eyebrow-blue { color: var(--at-blue); }

.lede { color: var(--muted); font-size: var(--t-lede); max-width: 68ch; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); }
.tabular { font-variant-numeric: tabular-nums; }
.good { color: var(--good); } .warn { color: var(--warn); } .crit { color: var(--crit); }

.section-head { margin-bottom: 2.2rem; }
.section-num {
  font-family: var(--mono);
  color: var(--accent);
  font-weight: 500;
  font-size: var(--t-small);
  margin-right: 0.6rem;
}

/* Terminal cursor — the one always-on motion, borrowed from the report. */
.cursor {
  display: inline-block;
  color: var(--accent);
  font-weight: 700;
  animation: blink 1s steps(1) infinite;
}
@keyframes blink { 0%, 49% { opacity: 1 } 50%, 100% { opacity: 0 } }

/* --- scroll reveal ------------------------------------------------------
   Each block fades up the first time it enters the viewport, then is left
   alone. reveal.js unobserves on fire and sets a session flag, so scrolling
   back up — or reloading mid-session — never replays it.                  */
.reveal {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity var(--d-slow) var(--ease), transform var(--d-slow) var(--ease);
  will-change: opacity, transform;
}
.reveal.in-view { opacity: 1; transform: none; }
.reveal.no-anim { opacity: 1; transform: none; transition: none; }

/* Stagger children of a revealed group without per-element markup. */
.reveal-stagger > .reveal:nth-child(2) { transition-delay: 0.07s }
.reveal-stagger > .reveal:nth-child(3) { transition-delay: 0.14s }
.reveal-stagger > .reveal:nth-child(4) { transition-delay: 0.21s }
.reveal-stagger > .reveal:nth-child(5) { transition-delay: 0.28s }
.reveal-stagger > .reveal:nth-child(6) { transition-delay: 0.35s }

/* --- nav ---------------------------------------------------------------- */
.nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  height: var(--nav-h);
  padding: 0 var(--gut);
  background: rgba(10, 14, 20, 0.82);
  backdrop-filter: blur(12px) saturate(1.4);
  -webkit-backdrop-filter: blur(12px) saturate(1.4);
  border-bottom: 1px solid var(--border);
  transition: border-color var(--d-mid) var(--ease), background var(--d-mid) var(--ease);
}
.nav.is-scrolled { border-bottom-color: var(--border-hi); background: rgba(10, 14, 20, 0.94); }

.nav-logo {
  font-family: var(--mono);
  font-size: 17px;
  letter-spacing: 0.02em;
  color: var(--fg-hi);
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  white-space: nowrap;
}
.nav-logo b { font-weight: 500; }

/* The mark is pre-tinted to --accent with a transparent ground, so it needs no
   blend mode and sits cleanly on any surface. */
.nav-logo .mark {
  width: 52px; height: 52px;
  flex: 0 0 auto;
  display: block;
  /* The mark's dark areas are the page background, so it reads as negative
     space; a soft light halo keeps its silhouette off the nav surface. */
  filter: drop-shadow(0 1px 6px rgba(216, 222, 233, 0.16));
  transition: transform var(--d-mid) var(--ease-out), filter var(--d-mid) var(--ease);
}
.nav-logo:hover .mark {
  transform: rotate(-5deg) scale(1.05);
  filter: drop-shadow(0 1px 10px rgba(232, 163, 61, 0.4));
}

/* The header mark keeps the tilt on hover but drops the amber bloom: behind
   line art at 52px it read as a smudge rather than a glow. Scoped to .nav, so
   the footer mark is untouched. The soft light halo stays -- it is what keeps
   the silhouette off the nav surface. */
.nav .nav-logo:hover .mark {
  filter: drop-shadow(0 1px 6px rgba(216, 222, 233, 0.16));
}

.nav-links { display: flex; align-items: center; gap: 1.6rem; }
.navlink {
  position: relative;
  font-family: var(--mono);
  font-size: var(--t-eyebrow);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0.25rem 0;
  transition: color var(--d-fast) var(--ease);
}
.navlink::after {
  content: "";
  position: absolute;
  left: 0; bottom: 0;
  width: 100%; height: 1px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform var(--d-mid) var(--ease-out);
}
.navlink:hover { color: var(--fg-hi); }
.navlink:hover::after, .navlink[aria-current="page"]::after { transform: scaleX(1); }
.navlink[aria-current="page"] { color: var(--fg-hi); }
.navlink.is-action { color: var(--accent); }

/* Sign-out is a form button so the request is a POST, but it has to read as a
   menu item. Reset the chrome and inherit the sublink styling. */
.nav-signout {
  width: 100%;
  background: none;
  border: 0;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.nav-sub form { margin: 0; }

/* --- nav disclosure group ------------------------------------------------ */
/* The trigger is a real <button>, so it needs its chrome reset back to look
   like the links either side of it. */
.nav-group { position: relative; }
.nav-group-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: none;
  border: 0;
  margin: 0;
  cursor: pointer;
  font: inherit;
  font-family: var(--mono);
  font-size: var(--t-eyebrow);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.nav-group-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.nav-group-btn[aria-expanded="true"] { color: var(--fg-hi); }
.nav-group-btn[aria-expanded="true"]::after { transform: scaleX(1); }

/* Caret points down, and flips when the group is open. State comes from
   aria-expanded, so the glyph can never disagree with what is announced. */
.nav-caret {
  width: 0; height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid currentColor;
  transition: transform var(--d-fast) var(--ease);
}
.nav-group-btn[aria-expanded="true"] .nav-caret { transform: rotate(180deg); }

.nav-sub {
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  margin: 0.7rem 0 0;
  padding: 0.35rem 0;
  min-width: 210px;
  list-style: none;
  background: var(--bg-raised);
  border: 1px solid var(--border-hi);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.5);
}
.nav-sub[hidden] { display: none; }
/* Invisible bridge across the gap, so moving the pointer from the trigger down
   into the panel does not cross dead space and close it. */
.nav-sub::before {
  content: "";
  position: absolute;
  top: -0.8rem; left: 0; right: 0;
  height: 0.8rem;
}
.nav-sublink {
  display: block;
  padding: 0.6rem 1.1rem;
  font-family: var(--mono);
  font-size: var(--t-eyebrow);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
  transition: color var(--d-fast) var(--ease), background var(--d-fast) var(--ease);
}
.nav-sublink:hover { color: var(--fg-hi); background: var(--bg-raised-2); }
.nav-sublink:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
  color: var(--fg-hi);
}
.nav-sublink[aria-current="page"] { color: var(--fg-hi); }

@media (prefers-reduced-motion: reduce) {
  .nav-caret { transition: none; }
}

/* burger */
.nav-toggle {
  display: none;
  background: none; border: 0; cursor: pointer;
  width: 34px; height: 34px;
  padding: 7px 5px;
  flex-direction: column; justify-content: space-between;
}
.nav-toggle span {
  display: block; height: 1.5px; width: 100%;
  background: var(--fg);
  transition: transform var(--d-mid) var(--ease), opacity var(--d-fast) var(--ease);
}
.nav-toggle[aria-expanded="true"] span:nth-child(1) { transform: translateY(9px) rotate(45deg) }
.nav-toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0 }
.nav-toggle[aria-expanded="true"] span:nth-child(3) { transform: translateY(-9px) rotate(-45deg) }

.nav-mobile {
  position: fixed;
  top: var(--nav-h); left: 0; right: 0;
  z-index: 99;
  background: rgba(10, 14, 20, 0.98);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  padding: 0 var(--gut);
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows var(--d-mid) var(--ease-out);
}
.nav-mobile > div { overflow: hidden; min-height: 0; }
.nav-mobile.is-open { grid-template-rows: 1fr; }
.nav-mobile .navlink {
  display: block;
  padding: 0.95rem 0;
  border-bottom: 1px solid var(--border);
  font-size: var(--t-small);
}
.nav-mobile .navlink:last-child { border-bottom: 0; }
.nav-mobile-head {
  margin: 0;
  padding: 0.95rem 0 0.5rem;
  font-family: var(--mono);
  font-size: var(--t-eyebrow);
  letter-spacing: var(--track-wide);
  text-transform: uppercase;
  color: var(--dim);
}
.nav-mobile .navlink.is-sub { padding-left: 1rem; }
.nav-mobile .navlink::after { display: none; }

main { padding-top: var(--nav-h); }

/* --- footer -------------------------------------------------------------- */
.site-footer .nav-logo { font-size: 16px; }
.site-footer .nav-logo .mark { width: 44px; height: 44px; }

.site-footer {
  border-top: 1px solid var(--border);
  padding: 3rem 0 3.4rem;
  color: var(--muted);
  font-size: var(--t-small);
}
.footer-grid {
  display: grid;
  grid-template-columns: 1.4fr repeat(2, minmax(0, 1fr));
  gap: 2.4rem;
  align-items: start;
}
.footer-col h4 {
  font-family: var(--mono);
  font-size: var(--t-micro);
  letter-spacing: var(--track-mid);
  text-transform: uppercase;
  color: var(--dim);
  margin-bottom: 0.9rem;
  font-weight: 500;
}
.footer-col a { display: block; padding: 0.28rem 0; transition: color var(--d-fast) var(--ease); }
.footer-col a:hover { color: var(--accent); }
.footer-bottom {
  margin-top: 2.6rem;
  padding-top: 1.4rem;
  border-top: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem 1.4rem;
  justify-content: space-between;
  font-family: var(--mono);
  font-size: var(--t-micro);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--dim);
}

/* --- responsive ---------------------------------------------------------- */
@media (max-width: 900px) {
  .footer-grid { grid-template-columns: 1fr 1fr; gap: 1.8rem; }
  .footer-col:first-child { grid-column: 1 / -1; }
}
@media (max-width: 760px) {
  .nav-links { display: none; }
  .nav-toggle { display: flex; }
  .nav-logo { font-size: 15.5px; }
  .nav-logo .mark { width: 44px; height: 44px; }
  p, .lede { max-width: none; }
}
@media (min-width: 761px) {
  .nav-mobile { display: none; }
}

/* --- motion preference ---------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .cursor { animation: none; }
  .reveal, .reveal.in-view { opacity: 1; transform: none; transition: none; }
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

/* --- sample-report banner ------------------------------------------------
 * Sits above every demo report. Lived in tool-theme.css until the enterprise
 * build needed it too -- that page renders its own stylesheet, not a tool's.
 */
.demo-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1.2rem;
  border: 1px solid var(--border-hi);
  border-left: 2px solid var(--at-cyan);
  background: var(--surface);
  padding: 1.1rem 1.3rem;
  margin-bottom: 2rem;
}
.demo-eyebrow {
  font-family: var(--mono);
  font-size: var(--t-eyebrow);
  letter-spacing: var(--track-wide);
  text-transform: uppercase;
  color: var(--at-cyan);
  margin: 0 0 0.35rem;
}
.demo-body {
  margin: 0;
  color: var(--muted);
  font-size: var(--t-small);
  line-height: 1.65;
  max-width: 68ch;
}
.demo-actions { display: flex; flex-wrap: wrap; gap: 0.6rem; }
@media (max-width: 720px) {
  .demo-banner { flex-direction: column; align-items: flex-start; }
}
