/* ============================================================================
   AfterShow - Canonical theme tokens (light + dark)
   ----------------------------------------------------------------------------
   Single source of truth for every color/elevation token used across the site.
   Linked by every page as <link rel="stylesheet" href="/theme.css"> in <head>,
   BEFORE each page's own inline <style> so a page can still override a token
   locally if it ever needs to.

   HOW THEMING WORKS
   -----------------
   - :root          = light theme (the default).
   - html[data-theme="dark"] = dark overrides. Set on <html> by /theme.js before
                      first paint. Because every page rule references var(--token),
                      flipping the attribute reskins the whole site automatically.
   - Brand colors (--green / --accent / platform colors) intentionally stay vivid
     in dark; only surfaces, text, borders, neutrals, grids and shadows change.

   STUDIO RESKIN (Phase 1, 2026-06) - both themes retuned to the "Studio"
   direction: warmer near-black darks, a vivid lime --accent doing real work in
   dark, warm amber on money/opportunity callouts, saturated gradient panels for
   insights. Light is the prior cream/forest palette retuned (amber comes forward,
   the loud lime stays dark-only); dark is the Studio rewrite. New tokens added:
   --surface-2, --border-accent, --grad-panel, --glow, --font-mono.

   EDITING
   -------
   Change a value here once and it propagates to every page. Per-page non-color
   tokens (e.g. --sidebar-w) stay in that page's own :root, not here.
   ============================================================================ */

:root {
  /* ---- Surfaces ---- */
  --bg: #faf9f6;            /* page background */
  --bg2: #f2f0ea;           /* secondary fill: tracks, segmented controls, th */
  --bg3: #e8e4da88;         /* tertiary fill (alpha; sits on varied surfaces) */
  --surface: #ffffff;       /* cards, sidebar, modals, inputs */
  --surface-2: #f6f4ec;     /* secondary surface (nested panels, sub-cards) */

  /* ---- Brand greens ---- */
  --green: #3B6D11;         /* primary brand fill: bars, buttons, dots, focus */
  --green-mid: #4e8a18;     /* hover / mid stop */
  --green-light: #eaf3de;   /* tint bg: active nav, badges, panels */
  --green-pale: #f4f9ed;    /* faintest brand wash */
  --accent: #3B6D11;        /* the lime. Light = forest (no loud lime in light);
                               dark brightens to a vivid lime for CTAs/active. */
  --accent-hover: #4e8a18;  /* primary-button hover fill (tracks --accent per theme) */
  --teal: #0F6E56;
  --brand: var(--green);    /* alias some pages use */
  /* --green-text: brand green when used as TEXT or a small accent (nav-active,
     tabs, links, badges, titles, table-sort, up-trends). Equal to --green in
     light; brightens in dark so it stays legible on dark surfaces while --green
     itself stays saturated for fills. ALWAYS use this for green text. */
  --green-text: #3B6D11;

  /* ---- Status / accent ---- */
  --blue: #185FA5;   --blue-bg: #e6f1fb;
  --amber: #b06f10;  --amber-bg: #faeeda;   /* money / opportunity accent */
  --red: #a8432a;    --red-bg: #faece7;     /* warm-alert family */

  /* ---- Text ---- */
  --text: #1a1a18;          /* primary */
  --text-2: #4a4a44;        /* secondary */
  --text-3: #6b6b64;        /* muted / labels */

  /* ---- Borders / dividers ---- */
  --border: rgba(0,0,0,0.09);
  --border-mid: rgba(0,0,0,0.16);
  --border-accent: rgba(59,109,17,0.45);  /* lime focus/active border (forest in light) */
  --input-border: var(--border);
  /* Brand-tint borders on green/amber panels (kept legible per theme). */
  --green-border: rgba(59,109,17,0.2);
  --green-border-soft: rgba(59,109,17,0.1);
  --green-border-strong: rgba(59,109,17,0.3);
  --amber-border: rgba(176,111,16,0.2);

  /* ---- On-color text ---- */
  --on-accent: #ffffff;     /* text/icons on a saturated brand (--green) fill.
                               For --accent (lime) fills, label with var(--surface)
                               so it reads white in light / near-black in dark. */
  --surface-blur: rgba(250,249,246,0.92);  /* frosted sticky nav/header bg */

  /* ---- Data-viz neutrals (charts, maps) ---- */
  --chart-neutral: #e2dfd6;   /* "empty"/one-time/zero swatch, gradient start */
  --chart-grid: rgba(0,0,0,0.05);
  --chart-tick: #888880;      /* axis tick labels (mirrors --text-3) */
  --map-label-strong: #1a1a18;
  --map-label-zero: #aaaaaa;
  --map-stroke: #ffffff;      /* stroke between cartogram tiles (= page bg) */
  /* Cartogram intensity ramp endpoints (plain hex - JS interpolates between
     them per state, so "more intense = stronger market" reads in both themes). */
  --map-ramp-weak: #ffffff;
  --map-ramp-strong: #3B6D11;

  /* ---- Callout (e.g. fee-rate alert) - warm-alert family ---- */
  --callout-text: #a8432a;
  --callout-bg: #faece7;
  --callout-border: rgba(168,67,42,0.2);

  /* ---- Insight / coach gradient panels ("AfterShow noticed", "Reading the
     room", "Why this matters"). Saturated, white text on top. ---- */
  --grad-panel: linear-gradient(135deg, #1a3500, #2d5a0d);
  --glow: none;                /* soft lime glow - dark only */

  /* ---- Elevation (softened, not hue-flipped, in dark) ---- */
  --shadow-sm: rgba(0,0,0,0.1);
  --shadow-md: rgba(0,0,0,0.18);
  --shadow-lg: rgba(0,0,0,0.25);
  --overlay: rgba(26,26,24,0.45);   /* modal scrim */

  /* ---- Bespoke aliases (legacy variable names on a few internal/admin pages
     and the winback page). Mapped here so those pages inherit the canonical
     palette - and dark mode - without rewriting their rules. New code should
     NOT use these names; they exist only for back-compat. ---- */
  --cream: var(--bg);
  --ink: var(--text);
  --mute: var(--text-3);
  --muted: var(--text-3);
  --line: var(--border);
  --green-soft: var(--green-light);
  --amber-soft: var(--amber-bg);
  --red-soft: var(--red-bg);

  /* ---- Type (theme-independent; no dark variant needed) ----
     Figtree is the headline face (push 800/900 for big stats), DM Sans the body/
     UI face, DM Mono for link chips and numeric counts. */
  --font-display: 'Figtree', system-ui, -apple-system, sans-serif;
  --font-body:    'DM Sans', system-ui, -apple-system, sans-serif;
  --font-mono:    'DM Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;

  /* ---- Optional radius primitives (match what's already on screen) ---- */
  --radius-sm: 8px;
  --radius:    12px;
  --radius-lg: 18px;

  /* ---- Semantic data roles (distinct from brand green) ----
     Green stays brand/positive chrome; these give the data layer its own roles
     so meaning stops blurring. Light values here; dark overrides below. */
  --data-positive: #1f9d57;   /* emerald: up / good / goal met */
  --data-negative: #c63d20;   /* brick: down / bad / goal missed */
  --data-warning:  #b8740a;   /* amber: cost / attention */

  /* ---- Categorical ramp: 6 mutually-distinct hues, harmonized to cream/forest.
     Use in order; each varies in hue AND lightness for separability. ---- */
  --cat-1: #3B6D11;   /* forest */
  --cat-2: #0F6E56;   /* teal   */
  --cat-3: #C77D1A;   /* ochre  */
  --cat-4: #A8432A;   /* clay   */
  --cat-5: #3E6CA8;   /* slate  */
  --cat-6: #7A3F63;   /* plum   */

  /* ---- Convenience aliases for the recurring 2-series charts ---- */
  --series-returning: var(--cat-1);
  --series-new:       var(--cat-3);
  --series-line:      var(--cat-5);
}

/* ============================================================================
   DARK THEME - Studio
   Overrides only the tokens that must change. Warm near-black surfaces; the
   --accent goes vivid lime (CTAs, active nav, "Go live", chart highlight bars),
   amber stays the money accent, gradient panels saturate with a soft glow.
   ============================================================================ */
html[data-theme="dark"] {
  color-scheme: dark;       /* native controls, scrollbars, form widgets */

  /* Surfaces */
  --bg: #0e0f0b;
  --bg2: #16170f;
  --bg3: #20221688;
  --surface: #15160f;
  --surface-2: #1c1e13;

  /* Greens: --green/--green-mid fills stay vivid (inherited); the lime --accent,
     tints + green-text adapt for the Studio look on near-black. */
  --accent: #79c427;        /* vivid lime: CTAs, active nav, highlight bars */
  --accent-hover: #8fd636;  /* brighter lime for primary-button hover */
  --green-light: rgba(121,196,39,0.14);
  --green-pale: rgba(121,196,39,0.07);
  --green-text: #a4d962;    /* bright lime-text, legible on dark */

  /* Status */
  --blue: #7fb5e8;   --blue-bg: rgba(127,181,232,0.12);
  --amber: #e8a33d;  --amber-bg: rgba(232,163,61,0.13);
  --red: #d96f47;    --red-bg: rgba(217,111,71,0.13);

  /* Text */
  --text: #f2f0e6;
  --text-2: #b9b7a8;
  --text-3: #79786b;

  /* Borders */
  --border: rgba(244,240,228,0.09);
  --border-mid: rgba(244,240,228,0.18);
  --border-accent: rgba(164,217,98,0.4);
  --green-border: rgba(121,196,39,0.22);
  --green-border-soft: rgba(121,196,39,0.12);
  --green-border-strong: rgba(121,196,39,0.32);
  --amber-border: rgba(232,163,61,0.22);

  /* Data-viz neutrals */
  --chart-neutral: #3a4031;
  --chart-grid: rgba(255,255,255,0.07);
  --chart-tick: #79786b;
  --map-label-strong: #f2f0e6;
  --map-label-zero: #5d6354;
  --map-stroke: #0e0f0b;
  --map-ramp-weak: #3a4031;   /* matches --chart-neutral: near-zero blends into "empty" */
  --map-ramp-strong: #79c427; /* lime: stronger market = brighter on dark */

  /* Callout - warm-alert family */
  --callout-text: #e8a33d;
  --callout-bg: rgba(232,163,61,0.13);
  --callout-border: rgba(232,163,61,0.25);

  /* Insight / coach gradient panels + soft lime glow (dark only) */
  --grad-panel: linear-gradient(135deg, #16290295, #2d5a0d66);
  --glow: 0 0 80px rgba(121,196,39,0.13);

  --surface-blur: rgba(14,15,11,0.92);  /* frosted nav on dark */

  /* Elevation: deeper, since shadows on dark need more presence */
  --shadow-sm: rgba(0,0,0,0.4);
  --shadow-md: rgba(0,0,0,0.5);
  --shadow-lg: rgba(0,0,0,0.6);
  --overlay: rgba(0,0,0,0.6);

  /* Bespoke aliases re-point automatically via the var() chain above. */
  --green-soft: var(--green-light);

  /* ---- Data-viz: brighter, slightly desaturated to hold contrast on dark.
     (Type + radius tokens above are theme-independent, so not repeated here.)
     The --series-* aliases re-point automatically via the var() chain. ---- */
  --data-positive: #4cc585;
  --data-negative: #e8765a;
  --data-warning:  #e8a33d;

  --cat-1: #7cb53f;   /* forest (brightened) */
  --cat-2: #2faE93;   /* teal   */
  --cat-3: #df9b3e;   /* ochre  */
  --cat-4: #d2734f;   /* clay   */
  --cat-5: #6ea0db;   /* slate  */
  --cat-6: #b878a0;   /* plum   */
}

/* Respect users who ask the OS to reduce contrast/animation is out of scope
   here; theme.js handles prefers-color-scheme. */
