/* ══════════════════════════════════════════════════════════════
   FlexRank Design Token Overrides
   Extends fyf_theme tokens with FlexRank brand + missing tokens.
   ══════════════════════════════════════════════════════════════ */

:root {
  /* ══ RGB channel mirrors (light) ══════════════════════════════
     Parallel "<r> <g> <b>" triplets for every solid color the
     Tailwind config exposes, consumed as rgb(var(--x-rgb) / <alpha-value>).
     These exist ONLY so Tailwind opacity modifiers (bg-accent/15,
     ring-accent/50, text-text-dim/50, …) generate real CSS — bare
     var(--x) colors can't be alpha-composited by Tailwind.
     The original hex/rgba vars below are left untouched so hand-written
     CSS and the fyf_theme gem (which we don't edit) keep working.
     Keep values in sync with the hex source of truth in this file and
     fyf_theme/tokens.css. Translucent "-bg"/"-tint" vars are intentionally
     NOT mirrored — they're pre-blended fills used without opacity. ──── */
  --accent-rgb: 200 36 120;
  --accent-hover-rgb: 217 58 142;
  --accent-btn-hover-rgb: 168 28 99;
  --bg-rgb: 250 220 194;
  --surface-rgb: 253 238 226;
  --surface-2-rgb: 246 208 176;
  --surface-3-rgb: 240 195 158;
  --border-rgb: 224 196 175;
  --border-hover-rgb: 193 167 152;
  --border-subtle-rgb: 234 205 182;
  --border-muted-rgb: 210 182 164;
  --text-rgb: 48 32 45;
  --text-muted-rgb: 90 72 85;
  --text-dim-rgb: 132 115 127;
  --green-rgb: 42 125 62;
  --blue-rgb: 97 153 200;
  --orange-rgb: 232 114 74;
  --red-rgb: 212 64 48;
  --purple-rgb: 156 96 224;
  --yellow-rgb: 226 180 30;
  --pink-rgb: 200 36 120;
  --pos-qb-rgb: 232 114 74;
  --pos-rb-rgb: 42 125 62;
  --pos-wr-rgb: 97 153 200;
  --pos-te-rgb: 226 180 30;
  --pos-k-rgb: 156 96 224;

  /* ── FlexRank accent (FYF pink) ────────────────────────────── */
  --accent: #c82478;
  --accent-hover: #d93a8e;
  --accent-btn-hover: #a81c63;
  --accent-bg: rgba(240, 70, 160, 0.10);

  /* ── Light-mode surface warmth (overrides gem near-white) ──── */
  --bg: #fadcc2;
  --surface: #fdeee2;
  --surface-2: #f6d0b0;

  /* ── FYF brand surfaces (charcoal ink on cream paper). Values follow the
     Claude Design "App Shell + Editor" artboard's light theme
     (docs/design/app-redesign/); the gem defaults for text and border are
     restated here so the hex and the -rgb mirrors cannot drift.

     --accent is pink-deep in light, not brand pink: it is used as TEXT on
     cream far more often than as a fill, and brand pink is 3.0:1 there.
     --on-accent is the ink for anything sitting ON a pink fill -- cream or
     white on pink fails AA in both themes, charcoal passes in dark and white
     passes on pink-deep in light. ── */
  --on-accent: #ffffff;
  --on-accent-rgb: 255 255 255;
  --border: #e0c4af;
  --text: #30202d;
  --text-muted: #5a4855;
  --pink: #c82478;

  /* ── Additional text ───────────────────────────────────────── */
  --text-dim: #84737f;

  /* ── Additional surfaces ───────────────────────────────────── */
  --surface-3: #f0c39e;
  --border-hover: #c1a798;

  /* ── Panel border variants (opaque, for drawer/panel UIs) ── */
  --border-subtle: #eacdb6;
  --border-muted: #d2b6a4;

  /* ── Missing brand-color backgrounds ───────────────────────── */
  --purple-bg: rgba(156, 96, 224, 0.1);
  --pink-bg: rgba(240, 70, 160, 0.10);

  /* ── Position badge colors (optimized for legibility) ──────── */
  --pos-qb:     var(--orange);
  --pos-qb-bg:  var(--orange-bg);
  --pos-rb:     var(--green);
  --pos-rb-bg:  var(--green-bg);
  --pos-wr:     var(--blue);
  --pos-wr-bg:  var(--blue-bg);
  --pos-te:     var(--yellow);
  --pos-te-bg:  var(--yellow-bg);
  --pos-k:      var(--purple);
  --pos-k-bg:   var(--purple-bg);

  /* ── Position row tints (subtle version of badge colors) ──── */
  --pos-qb-tint: rgba(249, 115, 22, 0.06);
  --pos-rb-tint: rgba(42, 125, 62, 0.06);
  --pos-wr-tint: rgba(97, 153, 200, 0.06);
  --pos-te-tint: rgba(250, 204, 21, 0.06);
  --pos-k-tint: rgba(156, 96, 224, 0.06);
  --pos-def-tint: rgba(136, 122, 114, 0.04);

  /* ── Dashboard typefaces ───────────────────────────────────────
     --font-dash: geometric sans for data-table chrome / headers
     --font-data: monospace with uniform tabular figures for the
     numbers themselves. Loaded via Google Fonts in the app layout. ── */
  --font-dash: var(--font), system-ui, sans-serif; /* was Space Grotesk; the brand face now */
  --font-data: "JetBrains Mono", var(--mono), ui-monospace, monospace;

  /* ── Comparison medal TEXT (theme-aware; darker than the gold/bronze ring
     colors so text stays legible on the light surface) ─────────────────── */
  --cmp-gold-text: #8a6d15;
  --cmp-bronze-text: #7a4a20;

  /* ── Comparison week strip — weekly positional-tier fills ──────────────
     A traffic-light palette, NOT the single-hue ramp the dot-plot uses.
     Lightness is staggered deliberately: green and red at equal lightness is
     the textbook CVD collision (the reference status palette measures dE 4.1
     deutan), and the stagger lifts deutan separation to 12.7. Same tier
     vocabulary as Editor::StatRankable::RANK_TIER_COLORS, collapsed from five
     bands to three because these are unlabelled 11px fills.
     Light values are INTERIM — see the design spec; app-wide light mode is
     getting its own pass. ─────────────────────────────────────────────────── */
  --wk-t1: #14562c;
  --wk-t2: #b8892c;
  --wk-t3: #e2a89f;
}

html[data-theme="dark"] {
  /* ══ RGB channel mirrors (dark) — see :root note above ════════ */
  --accent-rgb: 240 70 160;
  --accent-hover-rgb: 244 114 182;
  --accent-btn-hover-rgb: 217 58 142;
  --bg-rgb: 37 25 37;
  --surface-rgb: 44 30 42;
  --surface-2-rgb: 49 33 46;
  --surface-3-rgb: 61 42 57;
  --border-rgb: 66 50 62;
  --border-hover-rgb: 92 74 86;
  --border-subtle-rgb: 56 42 53;
  --border-muted-rgb: 74 57 69;
  --text-rgb: 250 220 194;
  --text-muted-rgb: 178 154 141;
  --text-dim-rgb: 138 118 114;
  --green-rgb: 43 163 69;
  --blue-rgb: 106 173 222;
  --orange-rgb: 255 133 96;
  --red-rgb: 239 83 80;
  --purple-rgb: 192 132 252;
  --yellow-rgb: 253 216 53;
  --pink-rgb: 240 70 160;
  --pos-qb-rgb: 251 146 60;
  --pos-rb-rgb: 74 222 128;
  --pos-wr-rgb: 106 173 222;
  --pos-te-rgb: 250 204 21;
  --pos-k-rgb: 192 132 252;

  --accent: #f046a0;
  --accent-hover: #f472b6;
  --accent-btn-hover: #d93a8e;
  --accent-bg: rgba(240, 70, 160, 0.16);

  /* ── FYF plum dark ─────────────────────────────────────────────
     Charcoal-plum page with cream ink — the dark theme of the Claude Design
     "Admin Portal" and "App Shell" artboards. Overrides the gem's dark hex so
     hand-written CSS (var(--surface)) stays in sync with the -rgb mirrors
     above (Tailwind opacity utils). ── */
  --bg: #251925;
  --surface: #2c1e2a;
  --surface-2: #31212e;
  --surface-3: #3d2a39;

  --text: #fadcc2;
  --text-muted: #b29a8d;
  --text-dim: #8a7672;

  --border: #42323e;
  --border-hover: #5c4a56;

  /* ── Panel border variants (opaque, for drawer/panel UIs) ── */
  --border-subtle: #382a35;
  --border-muted: #4a3945;

  /* ── Gem-owned solids restated for the plum dark theme ── */
  --on-accent: #1f141d;
  --on-accent-rgb: 31 20 29;
  --pink: #f046a0;

  --purple-bg: rgba(192, 132, 252, 0.15);
  --pink-bg: rgba(240, 70, 160, 0.14);

  /* ── Position badge colors — brighter for dark surface contrast ─
     Brand --green (#2ba345) and --red (#ef5350) fall below WCAG AA
     at 10px on dark surfaces. These overrides hit ≥4.5:1 contrast. */
  --pos-qb:     #fb923c;
  --pos-qb-bg:  rgba(251, 146, 60, 0.15);
  --pos-rb:     #4ade80;
  --pos-rb-bg:  rgba(74, 222, 128, 0.15);
  --pos-wr:     #6aadde;
  --pos-wr-bg:  rgba(106, 173, 222, 0.15);
  --pos-te:     #facc15;
  --pos-te-bg:  rgba(250, 204, 21, 0.15);
  --pos-k:      #c084fc;
  --pos-k-bg:   rgba(192, 132, 252, 0.15);

  /* ── Position row tints (subtle version of badge colors) ────── */
  --pos-qb-tint: rgba(251, 146, 60, 0.07);
  --pos-rb-tint: rgba(74, 222, 128, 0.07);
  --pos-wr-tint: rgba(106, 173, 222, 0.07);
  --pos-te-tint: rgba(250, 204, 21, 0.07);
  --pos-k-tint: rgba(192, 132, 252, 0.07);
  --pos-def-tint: rgba(160, 144, 136, 0.04);

  /* ── Comparison medal TEXT (theme-aware) — dark surface reads the original
     light gold/bronze fine, so these match the mark's ring colors ──────── */
  --cmp-gold-text: #f0d98a;
  --cmp-bronze-text: #e0a877;

  /* Dark: CVD 12.7 deutan, normal-vision 19.6, all three >=3:1 on --surface-2.
     Validated with the dataviz skill's validate_palette.js --pairs all. */
  --wk-t1: #6ee89b;
  --wk-t2: #c9a03c;
  --wk-t3: #b44a52;
}

/* ── Theme toggle override (gem defaults to cream-on-dark) ──── */
.theme-toggle {
  background: var(--surface-3);
  color: var(--text-muted);
}
.theme-toggle:hover {
  background: var(--border-hover);
  color: var(--text);
}
html[data-theme="dark"] .theme-toggle {
  background: rgba(250, 220, 194, 0.1);
  color: rgba(250, 220, 194, 0.7);
}
html[data-theme="dark"] .theme-toggle:hover {
  background: rgba(250, 220, 194, 0.2);
  color: #fadcc2;
}

/* ── Avatar override (fyf_brand gem defaults to --orange) ───── */
.profile-avatar { background: var(--accent); }

/* ── Auth hint text ──────────────────────────────────────────── */
.auth-field .hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 6px;
}

/* ── Toast extensions ─────────────────────────────────────────
   The gem styles `.toast` / `.toast-icon` / `.toast-success` /
   `.toast-error`. These add the parts lib/notify.js renders on top:
   a flexible message column, an optional inline action, and the close
   button persistent (error) toasts get. Long failure copy needs a width
   cap and wrapping — the gem's toast is sized for one-line flashes. ── */
.toast {
  max-width: min(420px, calc(100vw - 48px));
  align-items: flex-start;
}
.toast-icon { flex: none; margin-top: 1px; }
.toast-message {
  flex: 1 1 auto;
  min-width: 0;
  line-height: 1.45;
  overflow-wrap: anywhere;
}
.toast-action {
  flex: none;
  align-self: center;
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 140ms ease, border-color 140ms ease, color 140ms ease;
}
.toast-action:hover {
  background: var(--surface-3);
  border-color: var(--accent);
  color: var(--accent);
}
.toast-close {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  /* 28px keeps the dismiss target above the WCAG 2.5.8 24px floor even though
     the glyph inside is 14px. */
  width: 28px;
  height: 28px;
  margin: -4px -6px -4px 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  transition: background-color 140ms ease, color 140ms ease;
}
.toast-close:hover {
  background: var(--surface-2);
  color: var(--text);
}
