/* ==========================================================================
   Parallel Machines / tokens.css
   Design tokens. Section 5 of docs/SITE_SPEC.md verbatim, plus the scales
   (space, type, radii, z-index, easing, durations) and the semantic surface
   variables that every component reads (--fg, --line, --focus, ...).
   System rule: solid = the machine / now / reality; dots = the twin / the record.
   ========================================================================== */

:root {
  /* ---- colour: spec section 5, verbatim ---- */
  --ink:#070E3A; --ultramarine:#0B1A8C; --deep:#0B3A9C; --blue-700:#1048B2; --sky-500:#1F67D0;
  --sky-400:#4A8EDF; --sky-300:#6BA9E8; --haze:#BFD9F2; --mist:#DCEBFA; --paper:#F5F7FF; --white:#FFFFFF;
  --electric:#0A2CFF;   /* sparingly: focus ring, link hover, live dot on paper */
  --print-0:#050A2A; --print-1:#0F2466; --print-2:#2C56A8; --print-3:#8FB0DE; --print-4:#DCE8F8;  /* machine tone ramp */
  --sky: linear-gradient(180deg,#0B3A9C 0%,#1F67D0 52%,#6BA9E8 90%,#BFD9F2 100%);   /* PHOTO.sky */
  --line-on-paper: rgba(7,14,58,.12); --line-on-blue: rgba(255,255,255,.22);

  /* ---- colour: derived (contrast-checked) ----
     ink-2 9.0:1 on paper, ink-3 5.5:1 on paper / 4.9:1 on mist / 5.9:1 on white */
  --ink-2: #3A4170;
  --ink-3: #5A6190;
  --ink-4: #8A90B4;                       /* decorative only (ticks, disabled), never body text */
  --line-on-paper-strong: rgba(7,14,58,.28);
  --line-on-blue-strong: rgba(255,255,255,.5);
  --paper-2: #EBEFFC;                     /* paper, one step down (table stripes, wells) */
  --card: #FFFFFF;

  /* --sky-text: the same PHOTO colours retimed for pages with text on them (the surfaces use it).
     The light-blue band starts at 60% instead of 52% and the haze is pressed into the last 16%, so
     white body text holds to ~68% of the height (~80% on the vignetted left) and large text to ~87%.
     --sky stays the exact PHOTO preset for art (banners, plates). */
  --sky-text: linear-gradient(180deg, #0B3A9C 0%, #1F67D0 60%, #4E8FDF 84%, #6BA9E8 93%, #BFD9F2 100%);
  /* sky surface extras (PHOTO preset): the low backlight glow and a left vignette that
     keeps white text legible on the left half (see layout.css .surface-sky) */
  --sky-glow: radial-gradient(58% 62% at 66% 104%, rgba(220,235,250,.46) 0%, rgba(220,235,250,.16) 45%, rgba(220,235,250,0) 72%);
  --sky-vignette: linear-gradient(90deg, rgba(7,14,58,.34) 0%, rgba(7,14,58,.17) 36%, rgba(7,14,58,0) 64%);
  /* a soft local burn behind a text block on the sky (.scrim) */
  --sky-scrim: radial-gradient(closest-side, rgba(7,14,58,.34) 0%, rgba(7,14,58,.22) 52%, rgba(7,14,58,0) 100%);
  --deep-surface: linear-gradient(180deg, #070E3A 0%, #0A1566 100%);
  --ultra-surface: linear-gradient(180deg, #0B1A8C 0%, #0B3A9C 100%);

  /* ---- type ---- */
  --font-serif: "Instrument Serif", "Instrument Serif Fallback", "Times New Roman", Times, serif;
  --font-sans: "Inter Tight", "Inter Tight Fallback", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  --font-mono: "JetBrains Mono", "JetBrains Mono Fallback", ui-monospace, "SFMono-Regular", Consolas, "Courier New", monospace;
  --font-dots: "Doto", "JetBrains Mono", ui-monospace, monospace;

  /* scale (spec): display / h1 / h2 serif, h3 Inter Tight 600, body, small, label */
  --fs-display: clamp(3.5rem, 8.5vw, 8.5rem);
  --fs-h1: clamp(2.75rem, 5vw, 5rem);
  --fs-h2: clamp(2rem, 3.4vw, 3.25rem);
  --fs-h3: 1.375rem;
  --fs-h4: 1.125rem;
  --fs-lead: clamp(1.1875rem, 1.25vw + .6rem, 1.4375rem);
  --fs-body: 1.0625rem;
  --fs-small: .875rem;
  --fs-label: .75rem;
  --fs-micro: .6875rem;
  --fs-quote: clamp(1.75rem, 2.9vw, 2.75rem);
  --fs-num: clamp(2.25rem, 3.6vw, 3.5rem);        /* KPI digits (Doto) */
  --fs-counter: clamp(3.5rem, 12vw, 12rem);       /* the Pulse block counter (Doto) */

  --lh-display: .9;
  --lh-heading: 1.02;
  --lh-tight: 1.15;
  --lh-snug: 1.35;
  --lh-body: 1.6;

  --tr-display: -.01em;
  --tr-heading: -.005em;
  --tr-label: .08em;
  --tr-mono: .02em;

  --measure: 64ch;        /* body line length */
  --measure-narrow: 46ch;

  /* ---- space (4 px base) ---- */
  --space-0: 0;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --space-8: 64px;
  --space-9: 96px;
  --space-10: 128px;
  --space-section: clamp(72px, 10vw, 140px);      /* section padding (spec) */
  --space-section-tight: clamp(48px, 6vw, 88px);
  --space-stack: clamp(24px, 3vw, 40px);          /* between blocks inside a section */

  /* ---- layout ---- */
  --max: 1320px;
  --max-text: 720px;
  --gutter: 24px;
  --page-margin: clamp(16px, 4vw, 48px);
  --cols: 12;
  --header-h: 64px;

  /* scattered title grid, from the banner: 120 px columns and 70 px steps at a 66 px word */
  --scatter-col: 1.82em;
  --scatter-row: 1.06em;

  /* ---- shape ---- */
  --r-0: 0;
  --r-1: 2px;
  --r-2: 3px;
  --r-3: 4px;
  --hair: 1px;
  --shadow-float: 0 24px 48px -24px rgba(7,14,58,.45), 0 2px 8px -2px rgba(7,14,58,.12);   /* the one soft shadow: floating cards, drawers */

  /* ---- dots (the twin / the record) ---- */
  --dot: 2px;             /* square dot size in rules and legends */
  --dot-gap: 3px;         /* gap between dots */
  --dot-cell: 6px;        /* dot field cell */
  --grain-opacity: .9;    /* grain tile already carries +-7% alpha; this scales it */

  /* ---- z-index layers ---- */
  --z-below: -1;
  --z-base: 0;
  --z-grain: 1;
  --z-content: 2;
  --z-raised: 10;
  --z-sticky: 50;
  --z-header: 100;
  --z-drawer: 200;
  --z-sheet: 300;
  --z-tooltip: 400;
  --z-toast: 500;
  --z-skip: 1000;

  /* ---- motion (spec) ---- */
  --ease: cubic-bezier(.2,.7,.1,1);
  --ease-out: cubic-bezier(.2,.7,.1,1);
  --ease-in-out: cubic-bezier(.65,0,.35,1);
  --ease-in: cubic-bezier(.5,0,.75,0);
  --dur-1: 240ms;
  --dur-2: 480ms;
  --dur-3: 900ms;
  --dur-micro: 140ms;
  --stagger: 60ms;
  --reveal-rise: 12px;
  --scramble-max: 400ms;
  /* "the twin moves": every hover twin steps up and to the right by one step (image plates: the large step) */
  --twin-step: 6px;
  --twin-step-lg: 10px;
}

@media (max-width: 767.98px) {
  :root {
    --gutter: 16px;
    --header-h: 56px;
  }
}

/* ==========================================================================
   Semantic surface variables. Components only read these, so the same markup
   works on paper and on blue. Paper is the default.
   ========================================================================== */
:root,
.surface-paper,
.surface-mist,
.on-paper {
  --bg: var(--paper);
  --fg: var(--ink);
  --fg-2: var(--ink-2);
  --fg-3: var(--ink-3);
  --fg-4: var(--ink-4);
  --line: var(--line-on-paper);
  --line-strong: var(--line-on-paper-strong);
  --accent: var(--electric);
  --focus: var(--electric);
  --dot-color: var(--ink);
  --live-dot: var(--electric);
  --well: rgba(7,14,58,.035);
  --well-strong: rgba(7,14,58,.07);
  --card-bg: var(--card);
  --btn-bg: var(--ink);
  --btn-fg: var(--white);
  --btn-bg-hover: var(--electric);
  --btn-fg-hover: var(--white);
  --selection-bg: var(--electric);
  --selection-fg: var(--white);
  color-scheme: light;
}

.surface-mist { --bg: var(--mist); --well: rgba(7,14,58,.05); }

/* Blue surfaces: white text, white dot motifs.
   Contrast of white on the PHOTO sky (top -> bottom of the surface):
   >= 4.5:1 down to ~60% of the height, >= 3:1 down to ~80%, then it fails (1.5:1 at the haze).
   The left vignette pushes those lines lower on the left. Below them use .on-haze (ink). */
.surface-sky,
.surface-deep,
.surface-ultra,
.on-blue {
  --bg: var(--deep);
  --fg: var(--white);
  --fg-2: rgba(255,255,255,.95);
  --fg-3: rgba(255,255,255,.92);
  --fg-4: rgba(255,255,255,.5);
  --line: var(--line-on-blue);
  --line-strong: var(--line-on-blue-strong);
  --accent: var(--white);
  --focus: var(--white);
  --dot-color: var(--white);
  --live-dot: var(--white);
  --well: rgba(255,255,255,.06);
  --well-strong: rgba(255,255,255,.12);
  --card-bg: rgba(7,14,58,.18);
  --btn-bg: var(--white);
  --btn-fg: var(--ink);
  --btn-bg-hover: var(--mist);
  --btn-fg-hover: var(--ink);
  --selection-bg: var(--white);
  --selection-fg: var(--ink);
  color-scheme: dark;
}

/* deep surfaces are dark enough for softer secondary text */
.surface-deep,
.surface-ultra {
  --fg-2: rgba(255,255,255,.8);
  --fg-3: rgba(255,255,255,.66);
  --card-bg: rgba(255,255,255,.04);
}

/* text that sits on the light end of the sky (the haze) switches to ink */
.on-haze {
  --fg: var(--ink);
  --fg-2: var(--ink-2);
  --fg-3: var(--ink-2);
  --line: var(--line-on-paper);
  --line-strong: var(--line-on-paper-strong);
  --accent: var(--ink);
  --focus: var(--ink);
  --dot-color: var(--ink);
  --live-dot: var(--ink);
  --btn-bg: var(--ink);
  --btn-fg: var(--white);
  --btn-bg-hover: var(--ultramarine);
  --btn-fg-hover: var(--white);
  color: var(--fg);
}
