/* ==========================================================================
   base.css — reset, typography, layout primitives, utilities
   Depends on tokens.css (load tokens first).

   Fonts: load Fraunces + Inter with <link rel="preconnect"> + the Google Fonts
   <link> in each page <head> (see styleguide.html) — NOT via @import, which
   would chain a second blocking request behind this stylesheet.
   Phase 6 swaps this for self-hosted, preloaded woff2 files.
   ========================================================================== */

/* Metric-matched fallback so the swap from Arial → Inter shifts nothing (CLS). */
@font-face {
  font-family: "Inter Fallback";
  src: local("Arial");
  size-adjust: 107.4%;
  ascent-override: 90.2%;
  descent-override: 22.48%;
  line-gap-override: 0%;
}

/* ---------- Reset ---------- */
*,
*::before,
*::after { box-sizing: border-box; }

* { margin: 0; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scrollbar-gutter: stable;                       /* no layout jump when a modal locks scroll */
  scroll-padding-top: calc(var(--header-h) + var(--sp-4));
}

@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

img, picture, video, canvas { display: block; max-width: 100%; }
img, video { height: auto; }
svg { max-width: 100%; }

input, button, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
ul[role="list"], ol[role="list"] { list-style: none; padding: 0; }

[hidden] { display: none !important; }

::selection { background: color-mix(in srgb, var(--accent) 40%, transparent); }

/* ---------- Typography ---------- */
h1, h2, h3, h4, h5, h6,
.h1, .h2, .h3 {
  font-family: var(--font-serif);
  font-weight: 400;
  letter-spacing: var(--ls-heading);
  line-height: var(--lh-heading);
  color: var(--ink);
}

/* .h1/.h2/.h3 decouple visual size from heading level (one <h1> per page). */
h1, .h1 { font-size: var(--fs-h1); }
h2, .h2 { font-size: var(--fs-h2); }
h3, .h3 { font-size: var(--fs-h3); }

h1, h2, h3, .h1, .h2, .h3 { text-wrap: balance; }

h4, h5, h6 {
  font-size: 1.125rem;
  line-height: 1.25;
}

p {
  max-width: var(--measure);
  text-wrap: pretty;
}

strong, b { font-weight: 600; }
small { font-size: var(--fs-sm); }

a { color: inherit; }
a:not([class]) {
  text-decoration-line: underline;
  text-decoration-color: var(--accent);       /* gold only as a hairline — never as text */
  text-decoration-thickness: 2px;
  text-underline-offset: .22em;
  transition: text-decoration-color var(--dur-1) var(--ease);
}
a:not([class]):hover { text-decoration-color: var(--ink); }

/* Numbers: tabular figures so columns of digits never jitter. */
.num,
input[type="number"],
output {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

/* Eyebrow — small, wide-tracked uppercase label. */
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-3);
  font: 600 var(--fs-xs)/1.2 var(--font-sans);
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.eyebrow::before {
  content: "";
  width: var(--sp-5);
  height: 1px;
  background: var(--accent);                  /* tiny gold hairline = the only accent here */
}

/* ---------- Layout primitives ---------- */
.container {
  width: var(--container);
  margin-inline: auto;
}

/* Section rhythm: 64px on phones, scaling to 96–160px on desktop. */
.section { padding-block: clamp(var(--sp-8), 11vw, var(--sp-11)); }
.section--tight { padding-block: clamp(var(--sp-7), 7vw, var(--sp-9)); }

/* Vertical rhythm: .stack-N puts spacing token N between direct children. */
.stack-1  > * + * { margin-block-start: var(--sp-1); }
.stack-2  > * + * { margin-block-start: var(--sp-2); }
.stack-3  > * + * { margin-block-start: var(--sp-3); }
.stack-4  > * + * { margin-block-start: var(--sp-4); }
.stack-5  > * + * { margin-block-start: var(--sp-5); }
.stack-6  > * + * { margin-block-start: var(--sp-6); }
.stack-7  > * + * { margin-block-start: var(--sp-7); }
.stack-8  > * + * { margin-block-start: var(--sp-8); }
.stack-9  > * + * { margin-block-start: var(--sp-9); }
.stack-10 > * + * { margin-block-start: var(--sp-10); }
.stack-11 > * + * { margin-block-start: var(--sp-11); }

/* Wrapping row of items with a consistent gap. */
.cluster {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--gap, var(--sp-3));
}

/* ---------- Utilities ---------- */
.text-center { text-align: center; }
.text-center p { margin-inline: auto; }
.muted { color: var(--ink-soft); }
.measure-none { max-width: none; }
.is-locked { overflow: hidden; }

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

.skip-link {
  position: fixed;
  top: var(--sp-3);
  left: var(--sp-3);
  z-index: 999;
  padding: var(--sp-3) var(--sp-4);
  background: var(--ink);
  color: var(--bg);
  border-radius: var(--r-sm);
  text-decoration: none;
  font-weight: 600;
  transform: translateY(-200%);
}
.skip-link:focus { transform: none; }

/* ---------- Focus ----------
   Ink ring on light, gold on dark/dark bands: always ≥3:1 against its surface
   (gold on ivory would be ~2.2:1 and fail). */
:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 3px;
}

/* ---------- Reduced motion ----------
   Blanket guard: transitions/animations collapse to ~0. GSAP is gated
   separately in JS (Phase 3) via gsap.matchMedia(). */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}
