/* Design tokens.
   Every page and component reads values from here and nowhere else.
   Contrast for every text pair is listed in qa/contrast.md (generated from this file). */

:root {
  color-scheme: light dark;

  /* Color: light. Warm white instead of blue-white, because aging lenses yellow and
     lose blue first; status is never carried by hue alone (icon + word + color). */
  --color-bg: #FBFAF7;
  --color-surface: #FFFFFF;
  --color-surface-sunken: #F1EEE7;
  --color-text: #1B1F23;
  --color-text-muted: #434A51;
  --color-border: #DCD7CD;
  --color-border-strong: #6E757C;
  --color-action: #173F6B;
  --color-action-hover: #0F2E52;
  --color-on-action: #FFFFFF;
  --color-link: #173F6B;
  --color-focus: #173F6B;
  --color-focus-halo: #FFFFFF;
  --color-scam: #8E2116;
  --color-scam-tint: #FCEDEA;
  --color-real: #19573A;
  --color-real-tint: #E8F3EC;
  --color-marker: #FFE27A;
  --color-marker-safe: #BDE5CB;
  --color-on-marker: #1B1F23;
  --color-on-scam: #FFFFFF;
  --color-on-real: #FFFFFF;
  --color-badge: #1B1F23;
  --color-on-badge: #FFE27A;
  --color-phone-bezel: #1B1F23;
  --color-phone-screen: #FFFFFF;
  --color-bubble-in: #E9E9EB;
  --color-on-bubble: #1B1F23;
  --color-phone-meta: #434A51;
  --color-ad-band: #F1EEE7;
  --color-ad-label: #434A51;
  --color-bar-surface: rgb(251 250 247 / 0.82);
  --color-sheet-surface: rgb(251 250 247 / 0.94);

  /* Type. System UI font: zero download (LCP on slow 4G in the Facebook browser),
     optical sizing built in, and it is what people already read on their phone. */
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --text-caption: 1.125rem;  /* 18px, the smallest text on the site */
  --text-body: 1.25rem;      /* 20px */
  --text-lead: 1.375rem;     /* 22px */
  --text-h3: 1.5rem;         /* 24px */
  --text-h2: clamp(1.75rem, 1.35rem + 1.8vw, 2.5rem);
  --text-h1: clamp(2rem, 1.45rem + 2.6vw, 3.5rem);
  --text-display: clamp(2.5rem, 1.6rem + 4vw, 4.5rem);

  --leading-tight: 1.1;
  --leading-snug: 1.25;
  --leading-body: 1.5;

  /* Tracking is size specific: tighter as type grows, never one value for all. */
  --tracking-display: -0.025em;
  --tracking-h1: -0.022em;
  --tracking-h2: -0.015em;
  --tracking-body: 0;
  --tracking-caption: 0.005em;

  --weight-regular: 400;
  --weight-medium: 500;
  --weight-semibold: 600;
  --weight-bold: 700;

  /* Space. rem based so 200% text scales the layout with it. */
  --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: 4rem;
  --space-9: 6rem;
  --gutter: 16px;

  /* Size */
  --target-min: 3rem;        /* 48px, above WCAG 2.2 AAA 44px */
  --target-answer: 4rem;     /* 64px for the two answer buttons */
  --measure: 36rem;          /* about 60 characters at 20px */
  --page-max: 72rem;
  --phone-width: 22rem;

  /* Radius. Nested radius = outer radius - gap. */
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 22px;
  --radius-xl: 32px;
  --radius-phone: 44px;
  --radius-pill: 999px;

  /* Elevation */
  --shadow-1: 0 1px 2px rgb(27 31 35 / 0.06), 0 1px 1px rgb(27 31 35 / 0.04);
  --shadow-2: 0 2px 6px rgb(27 31 35 / 0.06), 0 10px 28px rgb(27 31 35 / 0.08);
  --shadow-phone: 0 2px 4px rgb(27 31 35 / 0.08), 0 24px 60px rgb(27 31 35 / 0.18);
  --shadow-lift: 0 6px 14px rgb(27 31 35 / 0.12), 0 30px 70px rgb(27 31 35 / 0.22);
  --shadow-bar: 0 1px 2px rgb(27 31 35 / 0.06), 0 8px 24px rgb(27 31 35 / 0.08);
  --shadow-panel: 0 2px 6px rgb(27 31 35 / 0.06), 0 24px 64px rgb(27 31 35 / 0.16);

  /* Motion. Critically damped spring (damping 1.0, no overshoot), sampled for CSS.
     The curve shape is the same for every response; only the duration changes. */
  --ease-spring: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-standard: cubic-bezier(0.2, 0, 0, 1);
  --dur-press: 100ms;
  --dur-color: 300ms;
  --dur-spring: 590ms;       /* response 0.4 s */
  --dur-spring-slow: 880ms;  /* response 0.6 s, the cinematic answer reveal */
  --stagger: 320ms;          /* gap between red flags lighting up */
  --stagger-menu: 60ms;      /* menu items arrive one after another, capped at 400ms */
  --rise-menu: 24px;
  --rise-section: 32px;
  --dur-section: 700ms;
  --press-scale: 0.97;

  /* Ads. Mediavine reserves the box; we reserve the space so nothing jumps. */
  --ad-min-height: 250px;
  --ad-adhesion-reserve: 0px;

  /* Layers */
  --z-sheet: 9;
  --z-masthead: 10;
  --z-skip: 20;
  --bar-height: 3.5rem;
  --bar-offset: 8px;

  /* Reader text size, set by the "Text size" control (on top of browser zoom). */
  --text-scale: 1;

  /* Home page decoder dial: drawn in the same palette. Ink, paper, scam and real follow the color tokens
     (and so switch in dark mode); the window is always the marker yellow, so its text uses fixed dark colors. */
  --hx-paper: var(--color-bg);
  --hx-ink: var(--color-action);
  --hx-marker: var(--color-marker);
  --hx-scam: var(--color-scam);
  --hx-real: var(--color-real);
  --hx-on-marker: var(--color-on-marker);
  --hx-scam-on-marker: #8E2116;
  --hx-real-on-marker: #19573A;
  --hx-serif: Georgia, "Times New Roman", serif;
}

:root[data-text="2"] { --text-scale: 1.15; }
:root[data-text="3"] { --text-scale: 1.3; }

@supports (transition-timing-function: linear(0, 1)) {
  :root {
    --ease-spring: linear(0, 0.057, 0.18, 0.321, 0.455, 0.573, 0.671, 0.75, 0.812, 0.86, 0.897,
      0.924, 0.944, 0.96, 0.971, 0.979, 0.985, 0.989, 0.992, 0.994, 0.996, 0.997, 0.998, 0.999, 1);
  }
}

/* Color: dark. Same roles; every text pair re-checked at 7:1. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --color-bg: #131518;
    --color-surface: #1C1F23;
    --color-surface-sunken: #0E1012;
    --color-text: #F2F0EB;
    --color-text-muted: #BAC0C6;
    --color-border: #343A40;
    --color-border-strong: #8C939A;
    --color-action: #A9CBF2;
    --color-action-hover: #C6DCF6;
    --color-on-action: #0B1A2B;
    --color-link: #A9CBF2;
    --color-focus: #A9CBF2;
    --color-focus-halo: #131518;
    --color-scam: #FFAFA3;
    --color-scam-tint: #3A1D19;
    --color-real: #93DDB0;
    --color-real-tint: #15301F;
    --color-marker: #FFE27A;
    --color-marker-safe: #BDE5CB;
    --color-on-marker: #1B1F23;
    --color-on-scam: #1B1F23;
    --color-on-real: #0B1A12;
    --color-badge: #FFE27A;
    --color-on-badge: #1B1F23;
    --color-phone-bezel: #050607;
    --color-phone-screen: #000000;
    --color-bubble-in: #26282C;
    --color-on-bubble: #F2F0EB;
    --color-phone-meta: #BAC0C6;
    --color-ad-band: #0E1012;
    --color-ad-label: #BAC0C6;
    --color-bar-surface: rgb(28 31 35 / 0.82);
    --color-sheet-surface: rgb(19 21 24 / 0.94);
    --shadow-1: none;
    --shadow-2: 0 0 0 1px #2A2F35;
    --shadow-phone: 0 0 0 1px #2A2F35, 0 24px 60px rgb(0 0 0 / 0.5);
    --shadow-lift: 0 0 0 1px #3A4047, 0 30px 70px rgb(0 0 0 / 0.6);
    --shadow-bar: 0 0 0 1px #2A2F35, 0 8px 24px rgb(0 0 0 / 0.4);
    --shadow-panel: 0 0 0 1px #2A2F35, 0 24px 64px rgb(0 0 0 / 0.55);
  }
}

/* Mediavine mobile adhesion (320x50 + padding) sits on top of the page bottom. */
@media (max-width: 767px) {
  :root[data-ads="on"] { --ad-adhesion-reserve: 66px; }
}

@media (prefers-reduced-motion: reduce) {
  :root {
    --dur-spring: 200ms;
    --dur-spring-slow: 200ms;
    --stagger: 0ms;
    --stagger-menu: 0ms;
    --rise-menu: 0px;
    --rise-section: 0px;
    --press-scale: 1;
  }
}
