/* ==========================================================================
   base.css — base typography, focus, skip link, reduced motion (spec §7, §26)
   ========================================================================== */

body {
  font-family: var(--font-sora);
  /* font-size-adjust approximates Sora's x-height so the fallback stack
     swaps without layout shift (design D3 — CLS < 0.10). */
  font-size-adjust: 0.52;
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  color: var(--brand-ink);
  background-color: var(--white);
  letter-spacing: var(--tracking-body);
}

h1, h2, h3, h4, h5, h6 {
  font-weight: 700;
  color: var(--brand-ink);
}

h1 {
  font-size: var(--fs-h1);
  line-height: var(--lh-h1);
  letter-spacing: var(--tracking-h1);
  font-weight: 800;
}

h2 {
  font-size: var(--fs-h2);
  line-height: var(--lh-h2);
  letter-spacing: var(--tracking-h2);
  font-weight: 800;
}

h3 {
  font-size: var(--fs-h3);
  line-height: var(--lh-h3);
  letter-spacing: var(--tracking-h3);
}

h4 {
  font-size: var(--fs-h4);
  line-height: var(--lh-h4);
}

/* Paragraph line length (spec §7.5): ideal 50–75 chars, max 680px. */
p {
  max-width: 68ch;
}

/* ---- Focus (B09: two-tone ring from tokens.css) --------------------
   Outer ring --focus-color, inner halo --focus-halo filling the offset gap.
   Components that draw their own focus box-shadow must append
   var(--focus-halo-shadow) to it rather than replace it; the outer ring alone
   still clears 3:1 on its surface if they do not.

   Measured (WCAG relative luminance):
     Blue 700 #1537B3 ring: 8.6:1 white, 8.1:1 paper #F7F8FA, 8.0:1 mist
       #F5F7FB; halo white vs ring 8.6:1.
     White ring: 17.9:1 Ink #0F172A, 19.0:1 partners ink #08101F / #0A1220,
       5.4:1 Kuneo Blue #2457FF; halo Blue 700 vs white ring 8.6:1, halo Ink
       vs white ring 17.9:1.
   The ring follows the element's outline, so it also wraps <summary>, form
   fields and links inside rails. */
:focus-visible {
  outline: var(--focus-ring);
  outline-offset: var(--focus-offset);
  box-shadow: var(--focus-halo-shadow);
}

/* <main tabindex="-1"> is only a programmatic focus target: the skip link moves
   focus there so assistive tech starts reading at the content. A ring around
   the whole page region would mean nothing, so it is suppressed. */
main:focus,
main:focus-visible {
  outline: none;
  box-shadow: none;
}

/* ---- Focus on dark surfaces -------------------------------------------
   One opt-in list for every band painted Ink or Kuneo Blue. Custom
   properties that reference other custom properties are resolved where they
   are declared, so the composed tokens are re-declared here as well.
   On the Kuneo Blue list the Ink halo also keeps the white ring apart from
   white inverse buttons (Ink vs white 17.9:1). */
.site-footer,
.p-hero--ink,
.p-chapter--ink,
.p-next--ink,
.x-scene--ink,
.x-work.is-dark,
.x-panel--ink,
.pt-hero,
.pt-dark,
.pt-cta,
.hw-hero,
.hw-hours,
.cap-hero,
.wk-hero {
  --focus-color: var(--white);
  --focus-halo: var(--blue-700);
  --focus-ring: var(--focus-width) solid var(--focus-color);
  --focus-halo-shadow: 0 0 0 var(--focus-offset) var(--focus-halo);
}

.p-hero--blue,
.p-chapter--blue,
.x-scene--blue,
.pt-manifesto,
.pt-blue,
.hw-ask,
.wk-proof-s {
  --focus-color: var(--white);
  --focus-halo: var(--brand-ink);
  --focus-ring: var(--focus-width) solid var(--focus-color);
  --focus-halo-shadow: 0 0 0 var(--focus-offset) var(--focus-halo);
}

/* ---- Skip link (spec §12.5): first focusable, hidden until focus --- */
.skip-link {
  position: absolute;
  top: -100%;
  left: var(--space-4);
  z-index: var(--z-toast);
  padding: var(--space-3) var(--space-6);
  background: var(--brand-ink);
  color: var(--white);
  font-size: var(--fs-small);
  font-weight: 600;
  text-decoration: none;
  border-radius: var(--radius-control);
  transition: top var(--duration-fast) var(--ease-standard);
}

.skip-link:focus-visible {
  top: var(--space-4);
}

/* ---- Links (spec §12.3: 180ms L→R underline grows on hover/focus) -- */
.link-underline {
  position: relative;
  text-decoration: none;
}

.link-underline::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -2px;
  width: 100%;
  height: 2px;
  background: var(--kuneo-blue);
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform var(--duration-fast) var(--ease-standard);
}

.link-underline:hover::after,
.link-underline:focus-visible::after {
  transform: scaleX(1);
}

/* ---- Progressive enhancement --------------------------------------- */
/* Reveal (and other JS-driven) states are gated behind the .js class so
   no-JS visitors see full content immediately (design progressive
   enhancement; class added by js/head.js). The hidden state lives here;
   the reveal transition itself (450ms ease-emphasized + 70–100ms sibling
   stagger, spec §10.3) is applied inline by js/reveal.js via CSSOM and
   cleared after the reveal — so elements with their own transitions
   (e.g. .engagement-card hover at 160ms) keep them afterwards.

   FR-01/FR-02/FR-05 (apply pass): the hidden state is scoped with
   :not(.is-visible) so that once revealed, NO reveal rule pins opacity or
   transform — a pinned `.is-visible { transform: translateY(0) }` would
   out-specify (0,3,0 vs 0,2,0) and permanently disable component hover
   transforms (engagement-card lift, process-milestone/premium-item grow). */
.js [data-reveal]:not(.is-visible) {
  opacity: 0;
  transform: translateY(20px);
}

/* ---- Reduced motion (spec §10.4 — mandatory global kill block) ----- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    animation-delay: 0s !important;
    transition-duration: 0.01ms !important;
    transition-delay: 0s !important;
    scroll-behavior: auto !important;
  }

  .js [data-reveal]:not(.is-visible) {
    opacity: 1;
    transform: none;
  }
}