/*
 * Institute of AI — design tokens
 * The single source of colour, type, spacing and measure for the site
 * (and for the Phase 5 education app). Components in site.css reference these
 * custom properties only; no colour or size is hard-coded elsewhere.
 *
 * Theme
 *   Light mode only (client, D-041). The site does not switch on
 *   prefers-color-scheme or [data-theme]. The Phase 1 dark values are kept,
 *   commented out, at the end of this file so dark mode can return later.
 *   plate  fixed-dark tokens, now used only for text over hero media
 *          (D-032) and kept for the Phase 5 education app.
 *
 * Fonts (D-045, supersedes the serif-headings part of D-041 and D-042):
 *   Inter for everything: headings, display, numbers, pull quotes, body, UI
 *   and labels. One self-hosted woff2 (Latin subset, SIL OFL 1.1, licence in
 *   ../fonts/), the only font file any page downloads. The wordmark alone is
 *   serif: an inline SVG outlined from Source Serif 4 by tools/wordmark.py
 *   (app/views/partials/wordmark.php). The Source Serif 4 woff2 files live
 *   in tools/fonts/ (repo root, never deployed) as the outline source only,
 *   with OFL-SourceSerif4.txt. Sources, versions and sizes: docs/handoffs/frontend.md.
 *
 * Contrast ratios (WCAG 2.x) are recorded in docs/handoffs/frontend.md.
 */

/* ---------------------------------------------------------------------
   Font faces
   Latin unicode-range as served by Google Fonts. Characters outside it
   (e.g. the → arrow) fall back per glyph to the next family in the stack.
   --------------------------------------------------------------------- */

/* Inter: variable weight 100–900 (we use 400–600). No italic file: body
   italics are rare and synthesised. Preloaded, the only preload (D-045). */
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("../fonts/inter-latin-wght-v20.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* Metric-matched local fallbacks, shown until the web font arrives, so the
   swap causes almost no layout shift. Overrides computed from each font's
   hhea metrics and its frequency-weighted average advance width
   (Latin text, default instance) against the local font. */
@font-face {
  font-family: "Inter Fallback";
  src: local("Arial"), local("ArialMT"), local("Liberation Sans"), local("Arimo");
  size-adjust: 107.28%;
  ascent-override: 90.30%;
  descent-override: 22.48%;
  line-gap-override: 0%;
}

:root {
  color-scheme: light;

  /* Neutral scale (off-white ground, near-black ink) */
  --ground: #F6F6F3;      /* page background; odd sections in the band rhythm */
  --surface: #EDEDE9;     /* even sections in the band rhythm (D-044), hover rows, inputs, placeholders */
  --band: #E4E4DF;        /* deeper band (D-044): explicit section bands (`band` in block data,
                             e.g. Assessment independence) and the footer. Every text colour
                             below stays AA on it (ratios: docs/handoffs/frontend.md, R3). */
  --well: var(--surface); /* inset fills (inputs, notice, form status, image placeholders);
                             site.css switches it to --ground inside --surface/--band sections */
  --ink: #1C1D1F;         /* primary text */
  --ink-soft: #46494E;    /* secondary text, ledes, split right-column body */
  --ink-faint: #5F6267;   /* labels, meta, field borders (>= 4.5:1 on ground, surface and band; R3, was #64676C) */
  --ink-muted: #787B80;   /* large section numbers and secondary display headings ONLY
                             (>= 3:1 on every shade, large text: 24px+, or 18.66px+ bold).
                             Never body text. (R3, was #7F8287) */
  --rule: #CFCFCA;        /* section and row hairlines (decorative) */
  --rule-soft: #E2E2DD;   /* lighter dividers */

  /* The one accent: deep ink blue, used sparingly (links, focus, labels, hero emphasis) */
  --accent: #214A80;
  --accent-ink: #F6F6F3;  /* text on a solid accent fill */

  /* Status (forms only) */
  --success: #2B5E3B;
  --error: #9B2C2C;
  --diff-add: #DCEBDD;    /* admin revision diff: added text (never the only signal: also underlined and labelled) */
  --diff-del: #F3DCDC;    /* admin revision diff: removed text (struck through and labelled) */

  /* Plate: fixed dark. Text over hero media (on --media-scrim) and Phase 5 */
  --plate: #0F1319;
  --plate-ink: #EDEFF2;
  --plate-soft: #A3ABB7;
  --plate-faint: #8790A0;
  --plate-rule: #2A313C;
  --plate-accent: #A2C0E6;

  /* Flat tint over hero media so text passes contrast (no gradients).
     0.55 (P2-F6, tuned on img-home-hero): --plate-ink >= 5.1:1 against the
     brightest pixel behind every hero text line at 390/768/1280 (handoff). */
  --media-scrim: rgb(8 12 18 / 0.55);

  /* Type families (D-045: Inter only; the serif wordmark is an SVG, not a font) */
  --font-sans: "Inter", "Inter Fallback", -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  --font-display: var(--font-sans);   /* headings, display, numbers, pull quotes */
  --font-body: var(--font-sans);      /* body, UI, labels */

  /* Fluid type scale (390px to 1280px) */
  --step--2: 0.6875rem;                                  /* labels */
  --step--1: 0.8125rem;                                  /* small, meta */
  --step-0: 1.0625rem;                                   /* body */
  --step-1: clamp(1.1875rem, 1.12rem + 0.3vw, 1.375rem);  /* lede, h4, right-column intro */
  --step-2: clamp(1.375rem, 1.25rem + 0.55vw, 1.75rem);   /* h3, right-column intro (large) */
  --step-3: clamp(1.75rem, 1.5rem + 1vw, 2.375rem);       /* h2 (prose) */
  --step-4: clamp(2.125rem, 1.7rem + 1.8vw, 3.25rem);     /* inner h1 */
  --step-5: clamp(2.5rem, 1.8rem + 3vw, 4.5rem);          /* Phase 1 home hero h1 (until P2-F6) */
  --step-stat: clamp(2rem, 1.6rem + 1.6vw, 3rem);         /* stat figures */

  /* Display scale (Phase 2, plan §1.4) */
  --step-hero: clamp(2.75rem, 1.6rem + 5vw, 6rem);        /* home hero h1 */
  --step-split: clamp(2rem, 1.4rem + 2.6vw, 3.75rem);     /* split-section h2 */
  --step-number: var(--step-split);                       /* "01" section numbers, in --ink-muted */
  --step-wordmark: clamp(2.5rem, 1.5rem + 4vw, 5rem);     /* large footer wordmark */
  /* Logo (D-052): font-size = the em of the outlined full name (3 lines, 3.2em tall).
     The header never goes below 12px (0.75rem), so the name stays legible at 320px. */
  --step-logo: clamp(0.75rem, 1.172vw, 0.9375rem);                 /* header logo: 12px up to 1024, 15px at 1280 */
  --step-logo-footer: clamp(1.125rem, 0.375rem + 2.344vw, 2.25rem); /* large footer logo: 30px at 1024, 36px at 1280 */

  --leading-display: 1.04;  /* hero and split headings (Inter, R3) */
  --leading-tight: 1.1;
  --leading-snug: 1.3;
  --leading-body: 1.6;
  /* Inter at display sizes needs negative tracking to look lean (R3) */
  --tracking-heading: -0.012em;  /* h3/h4, card titles */
  --tracking-display: -0.022em;  /* h1/h2, prose display */
  --tracking-hero: -0.03em;      /* hero, split titles, section numbers, stats, pull quotes */
  --tracking-label: 0.12em;

  --weight-body: 400;
  --weight-display: 400;    /* Inter display: regular reads lean and editorial at size */
  --weight-heading: 500;    /* small headings (h4, card titles) where 400 would look weak */
  --weight-strong: 600;
  --weight-label: 500;      /* uppercase letter-spaced labels ("HOW WE WORK") */

  /* Spacing scale */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-7: 3rem;
  --space-8: clamp(4rem, 3rem + 4vw, 8rem);      /* section padding */
  --space-9: clamp(5rem, 3.5rem + 5vw, 10rem);   /* between 8 and 10: page headers */
  --space-10: clamp(6rem, 4rem + 8vw, 12rem);    /* hero, gap before the footer */

  /* Measure and layout */
  --measure: 66ch;          /* prose column */
  --measure-split: 60ch;    /* split-section right-column text */
  --measure-narrow: 48ch;   /* ledes, hero sub-copy */
  --wrap: 90rem;            /* max content width (was 75rem) */
  --wrap-prose: 75rem;      /* article-style pages that should stay narrower */
  --gutter: clamp(1rem, 0.6rem + 2vw, 2.5rem);
  --grid-columns: 12;       /* split: 6/6 from 1024px, 5/7 from 768px, stacked below */
  --grid-gap: var(--gutter);
  --label-col: 12rem;       /* section-shell label column */
  --rail-col: 12rem;        /* article metadata rail */
  --date-col: 9rem;         /* dated index date column */

  /* Lines */
  --rule-width: 1px;
  --accent-rule-width: 2px;
  --focus-width: 3px;
  --focus-offset: 3px;
  --radius: 0;              /* square corners everywhere, images included */
  --target-min: 2.75rem;    /* minimum interactive target, 44px (WCAG 2.5.8 AAA / platform guidance); used by admin.css */
  --admin-nav-col: 15rem;   /* admin sidebar width (admin.css only) */
  --media-card-min: 14rem;  /* admin media grid: narrowest card (admin.css only) */
  --media-thumb-ratio: 4 / 3; /* admin media thumbnails (cropped, never stretched) */
  --picker-width: 56rem;    /* admin media picker dialog width */
  --media-thumb-size: 4.5rem; /* admin picker and field thumbnails */

  /* Motion (disabled entirely under prefers-reduced-motion) */
  --duration: 160ms;
  --duration-reveal: 300ms;
  --ease: cubic-bezier(0.2, 0, 0, 1);
}

/* ---------------------------------------------------------------------
   Dark theme: retired (D-041), kept for a possible return. Phase 1 values,
   not yet re-tuned for the Phase 2 palette; --ink-muted and --media-scrim
   proposals from plan §1.2 added. To restore, uncomment and wrap in
   @media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {…} }
   plus :root[data-theme="dark"] {…}, and set color-scheme: dark.

   --ground: #111316;
   --surface: #181B1F;
   --ink: #E8E9EB;
   --ink-soft: #A8ADB5;
   --ink-faint: #8C929B;
   --ink-muted: #70747A;
   --rule: #2D3138;
   --rule-soft: #22262B;
   --accent: #93B5DD;
   --accent-ink: #111316;
   --success: #8CC7A0;
   --error: #E59A9A;
   --media-scrim: rgb(8 12 18 / 0.45);
   --------------------------------------------------------------------- */
