/* ============================================================================
   DOC BERN HEALTH COACHING — design tokens
   The shared system for every Doc Bern product surface: the LTO lander, the
   Rescue Card, The GLP-1 Side-Effect Protocol, the Doc Bern newsletter page,
   and Beyond the Label when it ships.

   Rewritten 2026-08-24. The reference implementation is the LTO lander
   (products/low-ticket-offer/landing/landing-current.html). Token NAMES are
   inherited from it verbatim so it migrates with zero edits to its body.

   HOW TO USE — the whole interface:
     <link rel="stylesheet" href="brain/brand/tokens.css">
     ...then use var(--ground), var(--accent), var(--step-h1), etc.
   For print/PDF, link tokens-print.css AFTER this file.

   THE LANE — a drug package insert and a field manual, not a wellness brand.
   Condensed poster caps for the one headline and for numerals. A newspaper
   serif for everything a man actually reads. Monospace for labels, data, and
   buttons — the instrument voice. Mono is literal here, not costume: this is a
   pharmacist's document, and the reference object is a dosing chart.

   FONTS are declared here but not loaded. See the OPEN QUESTION below — the
   current stacks resolve to different faces on different platforms.

   OKLCH is authored. A hex fallback for the LIGHT theme only sits at the bottom
   under @supports; the legacy consumers that need it (PDF renderers, DOCX
   pipelines) have no dark mode, so a dark fallback would be dead weight.
   ============================================================================ */

/* ===========================================================================
   LIGHT — the default
   =========================================================================== */
:root {
  /* --- Ground and surfaces. A cool near-neutral with a faint green cast;
         not a warm cream. The green cast ties to the ink, not to "wellness". */
  --ground:      oklch(0.950 0.003 174.5);  /* #ECEFEE  page ground */
  --surface:     oklch(0.980 0.002 165.1);  /* #F7F9F8  raised panels, bands */
  --surface-2:   oklch(0.924 0.006 170.4);  /* #E2E7E5  wells, table headers, chips */

  /* --- Ink --------------------------------------------------------------- */
  --ink:         oklch(0.232 0.017 189.6);  /* #14201F  body        14.45:1 on ground */
  --muted:       oklch(0.503 0.020 187.4);  /* #586866  secondary    5.06:1 on ground */
  --line:        oklch(0.866 0.010 171.8);  /* #CDD5D2  hairlines */

  /* --- Accent (amber) — the single conversion color ----------------------- */
  --accent:      oklch(0.685 0.152 64.3);   /* #D9820A  FILL ONLY. 2.54:1 as text — never text on light. */
  --accent-ink:  oklch(0.485 0.111 62.5);   /* #8A4E00  amber AS TEXT   5.72:1 on ground */
  --on-accent:   oklch(0.189 0.028 79.8);   /* #1a1205  text on an accent fill  6.31:1
                                               (was hardcoded in the lander's .btn) */

  /* --- Verified / cleared ------------------------------------------------- */
  /* CORRECTED 2026-08-24. Was #0E8C86 at 3.55:1 on ground — it failed AA for
     the citation markers and value-stack checkmarks, which render at 18.5px
     regular (not "large text"). Darkened along the same hue. Now 4.92:1. */
  --verified:    oklch(0.501 0.087 189.5);  /* #00736e  checkmarks, citation marks, good-outcome bars */
  --teal:        var(--verified);           /* DEPRECATED alias — the lander still calls it --teal.
                                               New surfaces use --verified. */

  /* --- The Safety Check (CONTEXT.md, ratified 2026-07-27) -----------------
     Two tiers, and they must never be told apart by color alone — each panel
     states its instruction in words. RED = "get emergency care now (911/ER)".
     AMBER = "call your prescriber tonight".
     RULE: never place a CTA button inside a Safety Check panel. The amber tier
     and the accent share a hue family; the button SHAPE is what keeps "call
     your prescriber" from reading as "buy". */
  /* CORRECTED 2026-08-24. Was #C7402F: 4.32:1 on ground and 4.08:1 on its own
     panel — both under AA for the 18.5px red-flag markers. Now 4.85 / 4.58. */
  --danger:       oklch(0.536 0.173 30.4);  /* #bd3727  red-tier text and markers */
  --danger-bg:    oklch(0.933 0.022 31.8);  /* #F7E4E0  red-tier panel */
  --danger-line:  oklch(0.697 0.077 31.5);  /* #c98c80  red-tier border */
  --on-danger:    oklch(1 0 0);             /* #ffffff  text on a --danger fill  5.61:1 */

  --caution-bg:   oklch(0.948 0.035 81.3);  /* #FAECD4  amber-tier panel */
  --caution-line: oklch(0.758 0.105 73.1);  /* #D9A662  amber-tier border */
  /* Amber-tier text is --accent-ink (5.68:1 on --caution-bg) or --ink (14.34:1).
     There is deliberately no separate caution text color: at AA-passing
     lightness it lands within 0.05 L of --accent-ink and would just be a
     second, confusable amber. */

  /* --- The emphasis band --------------------------------------------------
     A dark drench for the surfaces that carry a decision: the offer section,
     the sticky buy bar, the draft banner, the "honest math" header.
     It is its OWN role, not a reuse of --ink as a background. Reusing --ink
     that way inverts in dark mode — the band turns near-white and any amber
     label on it collapses to 1.7:1. --band stays dark in both themes. */
  --band:        oklch(0.232 0.017 189.6);  /* #14201F  same value as light --ink */
  --on-band:     oklch(0.950 0.003 174.5);  /* #ECEFEE  14.46:1 */

  /* --- Elevation ---------------------------------------------------------- */
  --shadow:      0 1px 2px rgb(20 32 31 / 0.06), 0 8px 30px rgb(20 32 31 / 0.08);

  /* --- Type families ------------------------------------------------------ */
  /* Poster: the hero headline and numerals ONLY — never section headings.
     Serif: body copy AND h2/h3. Mono: labels, kickers, data, buttons. */
  --font-poster: "Haettenschweiler", "Arial Narrow", Impact, "Franklin Gothic Bold", sans-serif;
  --font-serif:  "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --font-mono:   ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;

  /* --- Type scale. Base body is 20px: above the 19px floor this audience
         needs, and measured off the shipping lander. ------------------------ */
  --step-fine:    14px;                          /* mono micro-labels, legends */
  --step-caption: 15px;                          /* mono labels, section kickers */
  --step-small:   17px;                          /* dense table and card copy */
  --step-body:    20px;                          /* BASE — body copy */
  --step-lead:    clamp(21px, 2.3vw, 24px);      /* section lead-ins */
  --step-h3:      23px;
  --step-h2:      clamp(28px, 4.2vw, 44px);      /* serif, not poster */
  --step-kicker:  clamp(26px, 4.6vw, 44px);      /* poster caps above the h1 */
  --step-h1:      clamp(38px, 6.6vw, 76px);      /* poster caps — one per page */
  --step-display: clamp(56px, 9vw, 86px);        /* the price. Poster. Rare. */

  --leading-body: 1.65;
  --leading-tight: 0.94;
  --measure:      66ch;   /* prose cap */
  --measure-lead: 62ch;
  --page-max:     1060px;

  /* --- Spacing (4px base) -------------------------------------------------- */
  --space-1: 0.25rem;  --space-2: 0.5rem;   --space-3: 0.75rem;
  --space-4: 1rem;     --space-6: 1.5rem;   --space-8: 2rem;
  --space-12: 3rem;    --space-16: 4rem;    --space-24: 6rem;
  --section-y: 58px;

  --radius-sm:   3px;   /* buttons, chips — the system is squarer than default */
  --radius:      6px;   /* cards, panels */
  --radius-lg:  10px;   /* the offer stack */

  /* --- Z-index (semantic) -------------------------------------------------- */
  --z-dropdown: 100; --z-sticky: 200; --z-backdrop: 300;
  --z-modal:    400; --z-toast:  500; --z-tooltip:  600;

  /* --- Motion — no bounce, no elastic --------------------------------------- */
  --dur-fast: 120ms;
  --dur-base: 200ms;
  --dur-slow: 420ms;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);

  color-scheme: light dark;
}

/* ===========================================================================
   DARK — same roles, re-grounded. Not an inversion: the accent brightens and
   --accent-ink merges into --accent, because a dark ground carries a lighter
   amber as text safely (9.13:1) where a light ground cannot.
   =========================================================================== */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ground:       oklch(0.188 0.011 175.7);  /* #0E1513 */
    --surface:      oklch(0.230 0.014 179.9);  /* #161F1D */
    --surface-2:    oklch(0.273 0.017 183.7);  /* #1E2A28 */
    --ink:          oklch(0.939 0.005 165.0);  /* #E8ECEA  15.52:1 */
    --muted:        oklch(0.699 0.018 182.5);  /* #93A29F   6.97:1 */
    --line:         oklch(0.324 0.018 184.9);  /* #2A3735 */
    --accent:       oklch(0.784 0.159 73.0);   /* #F5A623 */
    --accent-ink:   oklch(0.784 0.159 73.0);   /* same — 9.13:1 on ground */
    --on-accent:    oklch(0.189 0.028 79.8);   /* #1a1205   9.15:1 */
    --verified:     oklch(0.696 0.111 189.6);  /* #2BB3AC   7.18:1 */
    --danger:       oklch(0.679 0.149 30.4);   /* #E5705E   6.00:1 */
    --danger-bg:    oklch(0.238 0.026 30.9);   /* #2A1A17 */
    --danger-line:  oklch(0.450 0.070 30);     /* #77463e */
    /* CORRECTED: was #fff, which drops to 3.08:1 on the dark --danger and
       failed the 15px bold disclaimer header. Dark ink instead — 6.01:1. */
    --on-danger:    oklch(0.189 0.028 79.8);   /* #1a1205 */
    --caution-bg:   oklch(0.243 0.030 70);     /* #291d10 */
    --caution-line: oklch(0.470 0.070 70);     /* #74542c */
    --band:         oklch(0.273 0.017 183.7);  /* raised panel, not an inversion */
    --on-band:      oklch(0.939 0.005 165.0);  /* 12.42:1 */
    --shadow:       0 1px 2px rgb(0 0 0 / 0.4), 0 12px 40px rgb(0 0 0 / 0.45);
  }
}

:root[data-theme="dark"] {
  --ground:       oklch(0.188 0.011 175.7);
  --surface:      oklch(0.230 0.014 179.9);
  --surface-2:    oklch(0.273 0.017 183.7);
  --ink:          oklch(0.939 0.005 165.0);
  --muted:        oklch(0.699 0.018 182.5);
  --line:         oklch(0.324 0.018 184.9);
  --accent:       oklch(0.784 0.159 73.0);
  --accent-ink:   oklch(0.784 0.159 73.0);
  --on-accent:    oklch(0.189 0.028 79.8);
  --verified:     oklch(0.696 0.111 189.6);
  --danger:       oklch(0.679 0.149 30.4);
  --danger-bg:    oklch(0.238 0.026 30.9);
  --danger-line:  oklch(0.450 0.070 30);
  --on-danger:    oklch(0.189 0.028 79.8);
  --caution-bg:   oklch(0.243 0.030 70);
  --caution-line: oklch(0.470 0.070 70);
  --band:         oklch(0.273 0.017 183.7);  /* raised panel, not an inversion */
  --on-band:      oklch(0.939 0.005 165.0);  /* 12.42:1 */
  --shadow:       0 1px 2px rgb(0 0 0 / 0.4), 0 12px 40px rgb(0 0 0 / 0.45);
}

/* ===========================================================================
   Mandatory behavior. Link this file and you have it; do not re-implement
   these per page.
   =========================================================================== */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Visible focus on everything interactive. Never `outline: none` without a
   replacement. The ring uses --accent-ink so it stays visible on both themes. */
:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 2px solid var(--accent-ink);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* ===========================================================================
   Hex fallback — LIGHT ONLY, for renderers without OKLCH support. Values sit
   next to the OKLCH they mirror so a second hand-typed palette never has to
   exist anywhere else in the project.
   =========================================================================== */
@supports not (color: oklch(0 0 0)) {
  :root {
    --ground: #ECEFEE;  --surface: #F7F9F8;  --surface-2: #E2E7E5;
    --ink: #14201F;     --muted: #586866;    --line: #CDD5D2;
    --accent: #D9820A;  --accent-ink: #8A4E00; --on-accent: #1a1205;
    --verified: #00736e;
    --danger: #bd3727;  --danger-bg: #F7E4E0; --danger-line: #c98c80;
    --on-danger: #ffffff;
    --caution-bg: #FAECD4; --caution-line: #D9A662;
    --band: #14201F;    --on-band: #ECEFEE;
  }
}
