/* Japlin themes (package A).
   Load AFTER style.css. Contract: spec §2.3 / §11.1. Colour tokens are plain hex or rgba so
   dev/theme-lab.html can check them. Adding a theme: spec §2.12 (themes.css, ACME_THEMES, boot snippet). */

/* 1. Fonts: self-hosted latin subsets (SIL OFL, see fonts/OFL.txt) plus size-adjusted fallbacks */
@font-face {
  font-family: "Geist";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("fonts/geist-latin-var.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;
}
@font-face {
  font-family: "Geist Mono";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("fonts/geist-mono-latin-var.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;
}
@font-face {
  font-family: "Fraunces";
  font-style: normal;
  font-weight: 400 650;
  font-display: swap;
  src: url("fonts/fraunces-latin-var.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;
}
@font-face {
  font-family: "Source Sans 3";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  /* the shipped metrics (1.02 + 0.40 em) sit caps low and make SVG label boxes overlap; this centres caps */
  ascent-override: 94%;
  descent-override: 28%;
  line-gap-override: 0%;
  src: url("fonts/source-sans-3-latin-var.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;
}
@font-face {
  font-family: "IBM Plex Mono";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/ibm-plex-mono-400-latin.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;
}
@font-face {
  font-family: "IBM Plex Mono";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("fonts/ibm-plex-mono-500-latin.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;
}
/* Tuned 2026-10-12 with the dev/theme-lab.html overlay: line breaks match the web fonts for the hero H1 at
   375px and 1280px, an H2, prose and body copy (11 of 11 frames); the line box and baseline match exactly. */
@font-face { font-family: "Fraunces Fallback"; src: local("Georgia"); size-adjust: 105%; ascent-override: 93.3%; descent-override: 24.8%; line-gap-override: 0%; }
@font-face { font-family: "Geist Fallback"; src: local("Arial"), local("ArialMT"); size-adjust: 104%; ascent-override: 92%; descent-override: 27%; line-gap-override: 0%; }
@font-face { font-family: "Source Sans Fallback"; src: local("Arial"), local("ArialMT"); size-adjust: 93%; ascent-override: 101.1%; descent-override: 30.1%; line-gap-override: 0%; }

/* 2. Shared non-colour tokens and legacy aliases (charts.js, sector.js and the sector pages read these) */
:root, [data-theme] {
  --page: var(--paper); --border: var(--rule); --band: var(--band-2);
  --good: var(--st-verified); --good-text: var(--st-verified); --warning: var(--st-likely);
  --font: var(--font-text);
  --font-grotesk: "Geist", "Geist Fallback", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-text: "Geist", "Geist Fallback", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --radius-pill: 999px;
  /* resting depth for cards and figure plates; a whisper in light themes, a rim in dark ones */
  --shadow-card: 0 1px 2px rgba(16,24,40,.05), 0 12px 32px -18px rgba(16,24,40,.18);
  --space-section: clamp(64px, 5vw + 32px, 120px);
  /* text and scrim on the dusk hero photograph: the same in both themes, because the photo is */
  --on-photo: #FBF6F1; --on-photo-2: rgba(251,246,241,.84); --on-photo-accent: #F2C79B; --on-photo-mark: #C8763C; --photo-scrim: rgba(24,18,34,.42);
}
[data-theme="dusk"] { --shadow-card: 0 0 0 1px rgba(255,255,255,.04), 0 16px 40px -20px rgba(0,0,0,.7); }

/* 3. Sage (light): the default, and the no-JS light fallback */
:root:not([data-theme]), [data-theme="sage"] {
  color-scheme: light;
  --paper: #EEF1EA; --surface: #F7F9F4; --surface-2: #E2E8DC; --raised: #FBFCFA;
  --ink: #1E2620; --ink-2: #44504A; --muted: #5C6860;
  --rule: #D5DBD2; --grid: #E3E8DF; --axis: #76827A; --rule-w: 1px;
  --accent: #6E3C5C; --accent-ink: #FFFFFF; --accent-wash: #EADFE5; --highlight: #E4E59A; --focus: #6E3C5C;
  --glow-1: rgba(228,229,154,.35); --glow-2: rgba(110,60,92,.07);
  --motif: radial-gradient(var(--rule) 1px, transparent 1.2px) 0 0/16px 16px;
  --grain: .04; --grain-invert: 0;
  --shadow-pop: 0 18px 40px -16px rgba(30,38,32,.24);
  --series-1: #2D5F9A; --series-2: #11846D; --pos: #2D5F9A; --neg: #B85A10; --critical: #A1352B;
  --band-1: rgba(45,95,154,.30); --band-2: rgba(45,95,154,.17); --band-3: rgba(45,95,154,.08); --ensemble: rgba(45,95,154,.16);
  --seq-lo: #E3EBF2; --seq-hi: #1E426B; --seq-ink-hi: #FFFFFF;
  --st-verified: #2F7A4C; --st-likely: #9C6A10; --st-hypothesis: #5C6860; --st-ruled: #5C6860; --st-needs: #5C6860;
  --tag-verified-bg: #D7EBDB; --tag-likely-bg: #F1E6C4; --tag-hyp-bg: #DDE3D8; --tag-ruled-bg: #DDE3D8; --tag-needs-bg: transparent;
  --radius-s: 6px; --radius-m: 10px; --radius-l: 16px;
  --font-display: "Fraunces", "Fraunces Fallback", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --display-wght: 460; --display-soft: 30;
}

/* 4. Dusk (dark) */
[data-theme="dusk"] {
  color-scheme: dark;
  --paper: #1B1512; --surface: #241C18; --surface-2: #2E2420; --raised: #362D29;
  --ink: #F3E9DF; --ink-2: #D0C2B5; --muted: #A69587;
  --rule: #453D38; --grid: #372E2A; --axis: #8A7A6E; --rule-w: 1px;
  --accent: #F0C2CF; --accent-ink: #2A1419; --accent-wash: #3D2B30; --highlight: #5C3A28; --focus: #F0C2CF;
  --glow-1: rgba(240,194,207,.12); --glow-2: rgba(213,106,16,.08);
  --motif: linear-gradient(var(--rule), var(--rule)) left bottom/100% 1px no-repeat, linear-gradient(to top, var(--glow-1), transparent 120px);
  --grain: .07; --grain-invert: 1;
  --shadow-pop: 0 18px 48px -12px rgba(0,0,0,.55);
  --series-1: #4F8FD9; --series-2: #27A28A; --pos: #4F8FD9; --neg: #D56A10; --critical: #FF8C94;
  --band-1: rgba(79,143,217,.36); --band-2: rgba(79,143,217,.21); --band-3: rgba(79,143,217,.10); --ensemble: rgba(79,143,217,.22);
  --seq-lo: #232D3A; --seq-hi: #A8CDEB; --seq-ink-hi: #1B1512;
  --st-verified: #7BC98F; --st-likely: #E9B65A; --st-hypothesis: #A69587; --st-ruled: #A69587; --st-needs: #A69587;
  --tag-verified-bg: #203424; --tag-likely-bg: #3F2F17; --tag-hyp-bg: #352A25; --tag-ruled-bg: #352A25; --tag-needs-bg: transparent;
  --radius-s: 6px; --radius-m: 12px; --radius-l: 18px;
  --font-display: "Fraunces", "Fraunces Fallback", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --display-wght: 480; --display-soft: 60;
}

/* 5. No-JS dark fallback. Must stay a byte-identical copy of the [data-theme="dusk"] block
      (tokens inside @media cannot share a selector list with those outside it). */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
  color-scheme: dark;
  --paper: #1B1512; --surface: #241C18; --surface-2: #2E2420; --raised: #362D29;
  --ink: #F3E9DF; --ink-2: #D0C2B5; --muted: #A69587;
  --rule: #453D38; --grid: #372E2A; --axis: #8A7A6E; --rule-w: 1px;
  --accent: #F0C2CF; --accent-ink: #2A1419; --accent-wash: #3D2B30; --highlight: #5C3A28; --focus: #F0C2CF;
  --glow-1: rgba(240,194,207,.12); --glow-2: rgba(213,106,16,.08);
  --motif: linear-gradient(var(--rule), var(--rule)) left bottom/100% 1px no-repeat, linear-gradient(to top, var(--glow-1), transparent 120px);
  --grain: .07; --grain-invert: 1;
  --shadow-pop: 0 18px 48px -12px rgba(0,0,0,.55);
  --series-1: #4F8FD9; --series-2: #27A28A; --pos: #4F8FD9; --neg: #D56A10; --critical: #FF8C94;
  --band-1: rgba(79,143,217,.36); --band-2: rgba(79,143,217,.21); --band-3: rgba(79,143,217,.10); --ensemble: rgba(79,143,217,.22);
  --seq-lo: #232D3A; --seq-hi: #A8CDEB; --seq-ink-hi: #1B1512;
  --st-verified: #7BC98F; --st-likely: #E9B65A; --st-hypothesis: #A69587; --st-ruled: #A69587; --st-needs: #A69587;
  --tag-verified-bg: #203424; --tag-likely-bg: #3F2F17; --tag-hyp-bg: #352A25; --tag-ruled-bg: #352A25; --tag-needs-bg: transparent;
  --radius-s: 6px; --radius-m: 12px; --radius-l: 18px;
  --font-display: "Fraunces", "Fraunces Fallback", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --display-wght: 480; --display-soft: 60;
  }
}

/* 6. Motif refinements */
@supports (color: color-mix(in oklab, red, blue)) {
  [data-theme="dusk"] {
    --motif: linear-gradient(var(--rule), var(--rule)) left bottom/100% 1px no-repeat, linear-gradient(to top, color-mix(in oklab, var(--accent) 14%, transparent), transparent 120px);
  }
}
/* 7. Forced colours: hatches, outlines, glyphs and words keep status and polarity readable */
@media (forced-colors: active) {
  :root, [data-theme] {
    --neg: CanvasText; --pos: LinkText; --series-1: LinkText; --series-2: GrayText;
    --band-1: transparent; --band-2: transparent; --band-3: transparent; --ensemble: GrayText;
    --rule: CanvasText; --grid: CanvasText; --axis: CanvasText;
    --st-verified: CanvasText; --st-likely: CanvasText; --st-hypothesis: CanvasText; --st-ruled: CanvasText; --st-needs: CanvasText;
    --focus: Highlight;
  }
  .tag { border: 1px solid CanvasText; }
  .tag::before { forced-color-adjust: none; background: CanvasText; }
  body::before { display: none; }
}

/* 8. View Transition for the theme reveal: the clip-path animation is driven from theme.js */
html.vt-theme::view-transition-old(root),
html.vt-theme::view-transition-new(root) { animation: none; mix-blend-mode: normal; }
