/* themes — the ONE token vocabulary. Every surface reads from here.
 *
 * · the `--legacy` block at the end of each theme aliases the pre-redesign names onto the
 *   new ones. It exists so a stylesheet that has not been ported yet still resolves to a
 *   real value instead of falling back to an invented default, which is what the audit
 *   found workspace.css doing. Delete an alias only once nothing references it.
 */

:root,
html[data-theme="dark"] {
  --bg-window:  #0b0a16;
  --bg-chrome:  #141227;
  --bg-rail:    #100e20;
  --bg-panel:   #15132a;
  --bg-canvas:  #0e0c1d;
  --bg-raised:  #1c1936;
  --bg-input:   #0a0918;
  --bg-hover:   rgba(255, 255, 255, 0.045);
  --bg-active:  rgba(180, 77, 232, 0.13);

  --text:     #f0eaff;
  --text-2:   #b9a9dd;
  /* · ≥4.5:1 on --bg-canvas — used at 10–12px, keep it WCAG AA */
  --text-3:   #8878b8;
  --text-inv: #ffffff;

  --line:   rgba(255, 255, 255, 0.075);
  --line-2: rgba(255, 255, 255, 0.14);

  --accent:      #b44de8;
  --accent-2:    #d47fff;
  --accent-ink:  #ffffff;
  --accent-dim:  rgba(180, 77, 232, 0.14);
  --accent-glow: rgba(180, 77, 232, 0.35);

  --st-pending:     #8a9fc8;
  --st-in_progress: #60b0ff;
  --st-in_review:   #a882ff;
  --st-done:        #38d98a;
  --st-blocked:     #ff6060;
  --st-on_hold:     #ffb830;

  --warn:   #ffb830;
  --danger: #ff6060;
  --ok:     #38d98a;
  --danger-strong: #e03040;

  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-2: 0 8px 28px rgba(0, 0, 0, 0.55);
  --shadow-3: 0 24px 70px rgba(0, 0, 0, 0.7);
  --scrim:    rgba(4, 3, 12, 0.66);

  --font-family:
    "Inter", "Segoe UI Variable", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-mono:
    "Cascadia Code", "Cascadia Mono", "Consolas", "Courier New", monospace;
  --font-size-xs: 11px;
  --font-size-sm: 12.5px;
  --font-size-base: 13px;
  --font-size-md: 14px;
  --font-size-lg: 17px;

  --r-sm: 5px;
  --r-md: 8px;
  --r-lg: 12px;
  --r-xl: 16px;
  --r-pill: 999px;

  --t-fast: 120ms cubic-bezier(0.4, 0, 0.2, 1);
  --t-base: 190ms cubic-bezier(0.4, 0, 0.2, 1);
  --t-slow: 300ms cubic-bezier(0.4, 0, 0.2, 1);
  --t-spring: 350ms cubic-bezier(0.34, 1.56, 0.64, 1);

  --row-h: 38px;
  --rail-w: 62px;
  --preview-w: 392px;
}

html[data-theme="light"] {
  --bg-window:  #f4f2fb;
  --bg-chrome:  #e9e5f6;
  --bg-rail:    #eeebf9;
  --bg-panel:   #ffffff;
  --bg-canvas:  #f7f5fd;
  --bg-raised:  #ffffff;
  --bg-input:   #ffffff;
  --bg-hover:   rgba(80, 40, 160, 0.05);
  --bg-active:  rgba(144, 18, 176, 0.09);

  --text:     #1a1040;
  --text-2:   #4b3a83;
  --text-3:   #6f61a0;
  --text-inv: #ffffff;

  --line:   rgba(90, 60, 160, 0.14);
  --line-2: rgba(90, 60, 160, 0.24);

  --accent:      #9012b0;
  --accent-2:    #7a0f96;
  --accent-ink:  #ffffff;
  --accent-dim:  rgba(144, 18, 176, 0.09);
  --accent-glow: rgba(144, 18, 176, 0.2);

  --st-pending:     #5a7090;
  --st-in_progress: #1d5ccc;
  --st-in_review:   #6c28d8;
  --st-done:        #09824a;
  --st-blocked:     #c01a1a;
  --st-on_hold:     #b85c00;

  --warn:   #b85c00;
  --danger: #c01a1a;
  --ok:     #09824a;
  --danger-strong: #dc2626;

  --shadow-1: 0 1px 2px rgba(80, 40, 160, 0.1);
  --shadow-2: 0 6px 22px rgba(80, 40, 160, 0.14);
  --shadow-3: 0 20px 60px rgba(40, 20, 100, 0.2);
  --scrim:    rgba(30, 18, 70, 0.4);
}

/* · cryptic keeps the same structure and swaps the palette + typeface, exactly as before */
html[data-theme="dark"][data-style="cryptic"] {
  --bg-window:  #03020c;
  --bg-chrome:  #07051a;
  --bg-rail:    #05040f;
  --bg-panel:   #08061a;
  --bg-canvas:  #040310;
  --bg-raised:  #0c0924;
  --bg-input:   #05040f;
  --bg-hover:   rgba(200, 60, 255, 0.05);
  --bg-active:  rgba(204, 68, 232, 0.16);

  --text:     #e0ccff;
  --text-2:   #aa78e8;
  --text-3:   #9a7ad0;

  --line:   rgba(200, 60, 255, 0.1);
  --line-2: rgba(200, 60, 255, 0.2);

  --accent:      #cc44e8;
  --accent-2:    #e066ff;
  --accent-dim:  rgba(204, 68, 232, 0.16);
  --accent-glow: rgba(204, 68, 232, 0.4);

  --st-pending:     #8a6fd0;
  --st-in_progress: #4488ff;
  --st-in_review:   #cc44ff;
  --st-done:        #22ddaa;
  --st-blocked:     #ff3366;
  --st-on_hold:     #ffcc00;

  --warn:   #ffcc00;
  --danger: #ff3366;
  --ok:     #22ddaa;
  --danger-strong: #e8193c;

  --font-family:
    "Cascadia Code", "Cascadia Mono", "Fira Code", "Consolas", "Courier New", monospace;
  --r-sm: 3px;
  --r-md: 5px;
  --r-lg: 7px;
  --r-xl: 9px;

  --t-fast: 90ms cubic-bezier(0.4, 0, 0.2, 1);
  --t-base: 150ms cubic-bezier(0.4, 0, 0.2, 1);
}

html[data-theme="light"][data-style="cryptic"] {
  --font-family:
    "Cascadia Code", "Cascadia Mono", "Fira Code", "Consolas", "Courier New", monospace;
  --r-sm: 3px;
  --r-md: 5px;
  --r-lg: 7px;
  --r-xl: 9px;
}

/* ── legacy aliases ─────────────────────────────────────────────────────────
 * Pre-redesign names, mapped onto the vocabulary above.
 */
:root,
html[data-theme] {
  --bg-app: var(--bg-canvas);
  --bg-sidebar: var(--bg-rail);
  --bg-card: var(--bg-panel);
  --bg-card-hover: var(--bg-raised);
  --bg-modal: var(--bg-panel);
  --bg-titlebar: var(--bg-chrome);
  --bg-section: var(--bg-canvas);
  --bg-footer: var(--bg-chrome);

  --glass-card: var(--bg-hover);
  --glass-sidebar: var(--bg-hover);
  --glass-modal: var(--bg-hover);
  --glass-border: var(--line);
  --glass-surface: var(--accent-dim);

  --text-primary: var(--text);
  --text-secondary: var(--text-2);
  --text-muted: var(--text-3);
  --text-inverse: var(--text-inv);

  --surface: var(--bg-panel);
  --surface-alt: var(--bg-raised);

  --accent-hover: var(--accent-2);
  --accent-bright: var(--accent-2);
  --accent-subtle: var(--accent-dim);

  --secondary: var(--st-in_progress);
  --secondary-hover: var(--st-in_progress);
  --secondary-dim: var(--bg-hover);

  --border: var(--line);
  --border-focus: var(--accent);
  --border-strong: var(--line-2);
  --border-glass: var(--line);
  --divider: var(--line);

  --btn-secondary-bg: var(--bg-hover);
  --btn-secondary-hover: var(--bg-active);
  --btn-danger-bg: var(--bg-hover);
  --btn-danger-hover: var(--bg-active);
  --btn-danger-text: var(--danger);
  --danger-solid: var(--danger-strong);
  --danger-solid-hover: var(--danger-strong);
  --danger-glow: var(--accent-glow);

  --scrollbar-thumb: var(--line-2);

  --shadow-card: var(--shadow-1);
  --shadow-card-hover: var(--shadow-2);
  --shadow-modal: var(--shadow-3);
  --shadow-glow: var(--shadow-2);
  --shadow-sm: var(--shadow-1);

  --radius-sm: var(--r-sm);
  --radius-md: var(--r-md);
  --radius-lg: var(--r-lg);
  --radius-xl: var(--r-xl);
  --radius-2xl: var(--r-xl);
  --radius-pill: var(--r-pill);

  --transition-fast: var(--t-fast);
  --transition-base: var(--t-base);
  --transition-slow: var(--t-slow);
  --transition-spring: var(--t-spring);

  --status-pending: var(--st-pending);
  --status-in_progress: var(--st-in_progress);
  --status-in_review: var(--st-in_review);
  --status-done: var(--st-done);
  --status-blocked: var(--st-blocked);
  --status-on_hold: var(--st-on_hold);

  --strip-pending: var(--st-pending);
  --strip-in_progress: var(--st-in_progress);
  --strip-in_review: var(--st-in_review);
  --strip-done: var(--st-done);
  --strip-blocked: var(--st-blocked);
  --strip-on_hold: var(--st-on_hold);
}
