/*
 * Maternity edition — design tokens. THE single source of truth.
 *
 * Every page (report, design-system, chart-lab) links this file, and every
 * component and chart reads these variables at paint time. Change a value
 * here and the report, the design-system page and the chart lab all follow.
 *
 * Values recreated from the live report build (2026-10-30).
 * Theme: :root = light, :root[data-theme="dark"] = dark. The pre-paint
 * script on each page sets data-theme from localStorage "plum-theme" or the
 * OS preference.
 */

:root {
  /* ---- type families ---------------------------------------------------- */
  --font-display: "GT Alpina Standard", Georgia, "Times New Roman", serif;
  --font-sans: "Passenger Sans", ui-sans-serif, system-ui, sans-serif;
  --font-mono: "Azeret Mono Variable", ui-monospace, "SFMono-Regular", Consolas, monospace;
  /* the charts keep the report's original type: inside a chart's drawing area (charts.css) the display and sans
     roles resolve to these; the page around the charts uses GT Alpina and Passenger Sans */
  --font-chart-display: "Newsreader Variable", Georgia, "Times New Roman", serif;
  --font-chart-sans: "Inter Variable", ui-sans-serif, system-ui, sans-serif;

  /* ---- type scale (px) --------------------------------------------------- */
  --fs-kicker: 11px;          /* mono caps kicker above chapter titles      */
  --fs-h1: clamp(32px, 5vw, 42px);   /* chapter title (display)            */
  --fs-standfirst: 19px;      /* sans line under the chapter title          */
  --fs-h3: clamp(26px, 2.8vw, 32px);  /* prose subhead: the insight (display) */
  --fs-h4: 19px;
  --fs-body: 17px;            /* prose paragraph                            */
  --lh-body: 1.62;
  --fs-data-para: clamp(22px, 2.8vw, 27px);  /* the large "claim" paragraph */
  --fs-fig-title: 21px;       /* figure name (display)                      */
  --fs-chart-label: 13px;     /* axis/tick/annotation labels (mono)         */
  --fs-chart-name: 14px;      /* direct labels on series (mono, bold)       */
  --fs-method: 11.5px;        /* methods / source footnote (mono)           */
  --fs-ui: 12px;              /* buttons, pills, legend (mono)              */

  /* ---- surfaces and ink -------------------------------------------------- */
  --bg: #f7f1f0;
  --ink: #2e0515;
  --ink-rgb: 46, 5, 21;
  --muted: #76625a;            /* small grey text: 5.1:1 on --bg (was #9a8578, 3.1:1) */
  --hairline: #e3d6d2;
  --accent: #640b2e;
  --accent-rgb: 100, 11, 46;
  --accent2: #ba0b31;          /* focus rings, alarms in UI chrome          */
  --accent2-rgb: 186, 11, 49;
  --surface-rgb: 255, 255, 255;
  --highlight-rgb: 233, 77, 95;
  --chip-bg: rgba(var(--ink-rgb), .1);
  --card-tint: rgba(var(--highlight-rgb), .1);
  --card-border: rgba(var(--ink-rgb), .4);
  --pill-rgb: 159, 0, 255;
  --pill-bg: rgba(var(--pill-rgb), .3);
  --insight-rgb: 158, 39, 207;          /* violet wash: viewers, insights   */
  --insight-wash: rgba(var(--insight-rgb), .05);
  --insight-bar: rgba(var(--insight-rgb), .1);
  --takeaway-rgb: 158, 39, 207;
  --takeaway-wash: rgba(var(--takeaway-rgb), .05);
  --tooltip-bg: #fff;
  --tooltip-ink: var(--ink);
  --tooltip-line: rgba(var(--ink-rgb), .18);
  /* film: a surface that stays dark in both themes (the cover film, which
     has a pure black ground). Set only here, like --paper.               */
  --film: #000;
  --film-ink: #f0e3e1;
  --film-glow: #fec0a2;        /* the film's own highlight, for the kicker */
  /* sun: the orange-yellow sky of the embryo explorer (app/explorer.js SUN),
     red-orange at the lower left to yellow at the upper right. Used by the
     Sun opening (<m-sun-cover>); the same in both themes.               */
  --sun-1: #fe3b4b;
  --sun-2: #ff844a;
  --sun-3: #ff9f4f;
  --sun-4: #ffc667;
  --sun-glow-rgb: 255, 211, 117;
  --sun-ink: #3b0c0d;
  --sun-ink-rgb: 59, 12, 13;
  /* paper: a surface that stays light in both themes (Care City card).
     Set only here — the dark theme deliberately does not override it. */
  --paper: #f6f1ea;
  --paper-ink: #1c1412;
  --paper-ink-rgb: 28, 20, 18;
  --paper-muted: #6e5f58;      /* was #8a7a72 (3.9:1 on --paper) */

  /* ---- chart surfaces ---------------------------------------------------- */
  --chart-bg: #ffffff99;
  --chart-border: rgba(var(--ink-rgb), .4);
  --chart-line: rgba(var(--ink-rgb), .2);
  --chart-wash: rgba(var(--ink-rgb), .05);
  --fig-line: rgba(var(--ink-rgb), .14);
  --fig-border: rgba(var(--ink-rgb), .18);   /* the chart card's boundary */
  --fig-bg: color-mix(in srgb, var(--bg) 55%, #fff);
  --axis-ink: rgba(var(--ink-rgb), .25);    /* baselines and ticks          */
  --label-ink: rgba(var(--ink-rgb), .62);   /* tick and annotation labels: 5.1:1 (was .45, 3.0:1) */
  --ref-ink: rgba(var(--ink-rgb), .65);     /* reference lines + their text (was .55) */

  /* ---- categorical palette (fixed order; validated in both themes) ------- */
  --cat-1: #7048c8;   /* violet */
  --cat-2: #db594b;   /* orange */
  --cat-3: #128a70;   /* teal   */
  --cat-4: #c07819;   /* ochre  */
  --cat-5: #c5477c;   /* rose   */
  --cat-6: #3f6fc4;   /* blue   */
  --slot-1: var(--cat-1);
  --slot-2: var(--cat-2);
  --slot-3: var(--cat-3);
  --slot-4: var(--cat-4);
  --slot-5: var(--cat-5);
  --slot-6: var(--cat-6);

  /* roles — charts use roles, never raw hexes */
  --cat-primary: var(--slot-1);          /* chapter accent (set per chapter) */
  --cat-emph: var(--cat-primary);        /* the emphasised series            */
  --cat-ghost: #968087;                  /* context / de-emphasised series   */
  --cat-alarm: #b3253e;                  /* status only, never a series      */
  --cat-baby: #3f6fc4;                   /* newborn side of mother/baby splits */
  /* metro = var(--cat-3), non-metro = var(--cat-2): reference them directly.
     Aliases would resolve at :root and miss chapter overrides of --cat-2. */
  --div-neg: #128a70;
  --div-pos: #db594b;
  --div-mid: #efe4e0;
  --ramp-from: color-mix(in srgb, var(--cat-1) 16%, var(--bg));
  --ramp-via: var(--cat-emph);
  --ramp-to: var(--cat-2);
  --ramp: linear-gradient(90deg, var(--ramp-from) 2.3%, var(--ramp-via) 48.7%, var(--ramp-to) 95.1%);

  /* ---- spacing and measure ----------------------------------------------- */
  --copy-gap: 16px;
  --group-gap: 24px;
  --block-gap: 36px;
  --viewer-gap: 40px;
  --spark-gap: 48px;
  --chart-gap: 64px;
  --chapter-top: 64px;
  --chapter-end: 72px;
  --content-max: 720px;   /* prose measure          */
  --media-max: 1000px;    /* figures                */
  --viewer-max: 1120px;   /* condition viewers      */
  --chart-max: 1264px;
  --fig-max: 1000px;
  --fig-gutter: 24px;
  --radius-s: 8px;
  --radius-m: 12px;
  --shadow-pop: 0 18px 50px rgba(0, 0, 0, .42);   /* pop-overs: cards, menus */

  /* ---- navigation chrome ------------------------------------------------- */
  --nav-h: 72px;
  --nav-strong-bg: #f5ede8e6;
  --nav-soft-bg: #f5ede8cc;
  --nav-footer-bg: #ffffffe6;
  --nav-sheet-bg: #f5ede8;
  --nav-scrim: #2e051559;
  --nav-pill-bg: var(--bg);

  /* ---- motion ------------------------------------------------------------ */
  --rv-dur: .42s;
  --rv-dur-draw: .65s;
  --rv-ease: cubic-bezier(.22, .61, .36, 1);
  --theme-dur: .24s;

  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #0d020e;
  --fig-bg: color-mix(in srgb, var(--bg) 95%, #fff);
  --fig-border: rgba(var(--ink-rgb), .2);
  --ink: #f0e3e1;
  --ink-rgb: 240, 227, 225;
  --muted: rgba(var(--ink-rgb), .55);
  --hairline: rgba(var(--ink-rgb), .15);
  --surface-rgb: 0, 0, 0;
  --highlight-rgb: 251, 16, 213;
  --chart-bg: #0000004d;
  --chart-border: rgba(var(--ink-rgb), .6);
  --insight-bar: rgba(var(--insight-rgb), .2);
  --takeaway-rgb: 0, 0, 0;
  --tooltip-bg: #0a0a0b;
  --tooltip-ink: #f3f3f3;
  --tooltip-line: #ffffff2e;
  --nav-strong-bg: #0009;
  --nav-soft-bg: #0006;
  --nav-footer-bg: #0009;
  --nav-sheet-bg: #0e0204e6;
  --nav-scrim: #00000080;
  --cat-1: #9a7ce8;
  --cat-2: #df6651;
  --cat-3: #2aa88a;
  --cat-4: #c97f1e;
  --cat-5: #d96a9b;
  --cat-6: #6f93dd;
  --cat-ghost: #7a6670;
  --cat-alarm: #e0506b;
  --cat-baby: #6f93dd;
  --div-neg: #2aa88a;
  --div-pos: #df6651;
  --div-mid: #342930;
  color-scheme: dark;
}

/* ---- chapter accents ------------------------------------------------------
 * A chapter (or any element) picks its accent with data-chapter or
 * data-cat-slot. --cat-emph follows, so every chart inside inherits it.   */
[data-chapter="age-of-mothers"], [data-cat-slot="1"] { --cat-primary: var(--slot-1); }
[data-chapter="hospital-choice"], [data-cat-slot="2"] { --cat-primary: var(--slot-2); --cat-2: var(--slot-1); }
[data-chapter="c-section"], [data-cat-slot="3"] { --cat-primary: var(--slot-3); }
[data-chapter="complications"], [data-cat-slot="4"] { --cat-primary: var(--slot-4); }
[data-chapter="pregnancy-loss"], [data-cat-slot="5"] { --cat-primary: var(--slot-5); }
[data-chapter="childbirth-costs"], [data-cat-slot="6"] { --cat-primary: var(--slot-6); }
[data-chapter], [data-cat-slot] { --cat-emph: var(--cat-primary); }

@media (width <= 600px) {
  :root { --fig-gutter: 16px; }
}
