/* ==========================================
   SparkBox — Theme Variants (Pro)
   All themes stay in dark-mode family.
   Overrides CSS custom properties defined in style.css.
   ========================================== */

/* -------- Light mode (free, toggled from topbar) --------
 * Warm white base, slate cards, deep text. Accent purple kept at
 * violet-600 — still reads punchy on a white surface. Shadows go
 * from deep-black rings to soft gray drops. */
:root[data-theme="light"] {
  --bg-0: #f6f6f8;
  --bg-1: #ffffff;
  --bg-2: #f0f0f3;
  --bg-3: #e6e6ea;

  --bg: var(--bg-0);
  --bg-elevated: var(--bg-1);
  --bg-card: var(--bg-1);
  --bg-card-hover: var(--bg-2);
  --bg-input: #ffffff;
  --border: #e4e4e7;
  --border-strong: #cfcfd4;
  --border-hair: rgba(0, 0, 0, 0.06);
  --border-soft: rgba(0, 0, 0, 0.03);

  --text: #18191c;
  --text-secondary: #48494e;
  --text-muted: #6a6b72;

  --accent: #7c3aed;
  --accent-2: #6d28d9;
  --accent-hover: #8b5cf6;
  --accent-soft: rgba(124, 58, 237, 0.12);
  --accent-glow: rgba(124, 58, 237, 0.28);

  --live: #16a34a;
  --live-glow: rgba(22, 163, 74, 0.22);
  --warn: #d97706;
  --danger: #dc2626;

  --warm-glow: rgba(124, 58, 237, 0.04);

  /* Light-mode shadow ladder — soft gray drops, no black inset rings. */
  --elev-1: 0 1px 2px rgba(0, 0, 0, 0.05), 0 0 0 1px var(--border);
  --elev-2: 0 4px 12px rgba(0, 0, 0, 0.08), 0 0 0 1px var(--border);
  --elev-3: 0 16px 40px rgba(0, 0, 0, 0.12), 0 0 0 1px var(--border-strong);

  /* Launcher key-cap for light mode — soft gray gradient. */
  --keycap-bg: linear-gradient(180deg, #ffffff, #eeeef2);
  --shadow-keycap:
    rgba(0, 0, 0, 0.08) 0 1.5px 0.5px 2px,
    rgba(255, 255, 255, 0.6) 0 1px 0 0 inset,
    rgba(0, 0, 0, 0.04) 0 -1px 0 0 inset,
    var(--border) 0 0 0 1px;
}

/* Base background for light mode — override the dark body::before/::after
 * so the cold-void mesh doesn't bleed through a white page.
 * v1.6.52: prefix selector covers `light` AND `light-{forest,sunset,
 * arctic,rose}`. Was previously hard-coded to exact-match `light` only,
 * leaving the variant themes with the dark mode's body backgrounds
 * (and dark-tinted topbar) on a light page. Tom caught this on a
 * fresh-tester run-through right before the launch announcement. */
:root[data-theme^="light"] body::before {
  background: radial-gradient(1200px 800px at 50% 0%, var(--warm-glow), transparent 60%);
}
:root[data-theme^="light"] body::after {
  background: radial-gradient(1600px 1000px at 50% 50%, transparent 60%, rgba(0, 0, 0, 0.04) 100%);
}

/* Kill gradient-text in light mode — white→grey gradients are invisible
 * on a white background. Use plain dark text instead. */
:root[data-theme^="light"] .section-title,
:root[data-theme^="light"] .page-intro h1,
:root[data-theme^="light"] .launcher-greeting h1,
:root[data-theme^="light"] #greeting,
:root[data-theme^="light"] .brand-text,
:root[data-theme^="light"] .guide-title {
  background: none;
  -webkit-background-clip: unset;
  background-clip: unset;
  -webkit-text-fill-color: unset;
  color: var(--text);
}

/* Topbar glass goes white-tinted in light mode. */
:root[data-theme^="light"] .topbar {
  background: rgba(255, 255, 255, 0.8);
  border-bottom: 1px solid var(--border);
}

/* ============================================================
   LIGHT MODE THEME VARIANTS
   Same white base, different accent colors + subtle background tints.
   Each light theme tints the warm-glow, accent, and borders so the
   dashboard feels distinctly different without sacrificing readability.
   ============================================================ */

/* -------- Light Forest -------- */
:root[data-theme="light-forest"] {
  --bg-0: #f4f8f5;
  --bg-1: #ffffff;
  --bg-2: #edf3ef;
  --bg-3: #e0ebe3;

  --bg: var(--bg-0);
  --bg-elevated: var(--bg-1);
  --bg-card: var(--bg-1);
  --bg-card-hover: var(--bg-2);
  --bg-input: #ffffff;
  --border: #d4e4d8;
  --border-strong: #b8d4bf;

  --text: #18191c;
  --text-secondary: #3d4a40;
  --text-muted: #657a6a;

  --accent: #059669;
  --accent-2: #047857;
  --accent-hover: #10b981;
  --accent-soft: rgba(5,150,105,0.12);
  --accent-glow: rgba(5,150,105,0.20);

  --live: #16a34a;
  --warm-glow: rgba(5,150,105,0.04);

  --elev-1: 0 1px 2px rgba(0, 0, 0, 0.05), 0 0 0 1px var(--border);
  --elev-2: 0 4px 12px rgba(0, 0, 0, 0.08), 0 0 0 1px var(--border);
  --elev-3: 0 16px 40px rgba(0, 0, 0, 0.12), 0 0 0 1px var(--border-strong);
  --keycap-bg: linear-gradient(180deg, #ffffff, #edf3ef);
}

/* -------- Light Sunset -------- */
:root[data-theme="light-sunset"] {
  --bg-0: #faf7f4;
  --bg-1: #ffffff;
  --bg-2: #f5f0ea;
  --bg-3: #ede4d9;

  --bg: var(--bg-0);
  --bg-elevated: var(--bg-1);
  --bg-card: var(--bg-1);
  --bg-card-hover: var(--bg-2);
  --bg-input: #ffffff;
  --border: #e8ddd0;
  --border-strong: #d9c9b5;

  --text: #1c1916;
  --text-secondary: #4a4036;
  --text-muted: #7a6e60;

  --accent: #d97706;
  --accent-2: #b45309;
  --accent-hover: #f59e0b;
  --accent-soft: rgba(217,119,6,0.12);
  --accent-glow: rgba(217,119,6,0.20);

  --live: #16a34a;
  --warm-glow: rgba(217,119,6,0.04);

  --elev-1: 0 1px 2px rgba(0, 0, 0, 0.05), 0 0 0 1px var(--border);
  --elev-2: 0 4px 12px rgba(0, 0, 0, 0.08), 0 0 0 1px var(--border);
  --elev-3: 0 16px 40px rgba(0, 0, 0, 0.12), 0 0 0 1px var(--border-strong);
  --keycap-bg: linear-gradient(180deg, #ffffff, #f5f0ea);
}

/* -------- Light Arctic -------- */
:root[data-theme="light-arctic"] {
  --bg-0: #f4f7fa;
  --bg-1: #ffffff;
  --bg-2: #edf2f7;
  --bg-3: #e0e8f0;

  --bg: var(--bg-0);
  --bg-elevated: var(--bg-1);
  --bg-card: var(--bg-1);
  --bg-card-hover: var(--bg-2);
  --bg-input: #ffffff;
  --border: #d4dfe8;
  --border-strong: #b8cad8;

  --text: #18191c;
  --text-secondary: #3a4450;
  --text-muted: #607080;

  --accent: #0891b2;
  --accent-2: #0e7490;
  --accent-hover: #06b6d4;
  --accent-soft: rgba(8,145,178,0.12);
  --accent-glow: rgba(8,145,178,0.20);

  --live: #16a34a;
  --warm-glow: rgba(8,145,178,0.04);

  --elev-1: 0 1px 2px rgba(0, 0, 0, 0.05), 0 0 0 1px var(--border);
  --elev-2: 0 4px 12px rgba(0, 0, 0, 0.08), 0 0 0 1px var(--border);
  --elev-3: 0 16px 40px rgba(0, 0, 0, 0.12), 0 0 0 1px var(--border-strong);
  --keycap-bg: linear-gradient(180deg, #ffffff, #edf2f7);
}

/* -------- Light Rose -------- */
:root[data-theme="light-rose"] {
  --bg-0: #faf5f7;
  --bg-1: #ffffff;
  --bg-2: #f5edf0;
  --bg-3: #ede0e6;

  --bg: var(--bg-0);
  --bg-elevated: var(--bg-1);
  --bg-card: var(--bg-1);
  --bg-card-hover: var(--bg-2);
  --bg-input: #ffffff;
  --border: #e8d4dc;
  --border-strong: #d9b8c4;

  --text: #1c1618;
  --text-secondary: #4a3640;
  --text-muted: #7a6070;

  --accent: #db2777;
  --accent-2: #be185d;
  --accent-hover: #ec4899;
  --accent-soft: rgba(219,39,119,0.12);
  --accent-glow: rgba(219,39,119,0.20);

  --live: #16a34a;
  --warm-glow: rgba(219,39,119,0.04);

  --elev-1: 0 1px 2px rgba(0, 0, 0, 0.05), 0 0 0 1px var(--border);
  --elev-2: 0 4px 12px rgba(0, 0, 0, 0.08), 0 0 0 1px var(--border);
  --elev-3: 0 16px 40px rgba(0, 0, 0, 0.12), 0 0 0 1px var(--border-strong);
  --keycap-bg: linear-gradient(180deg, #ffffff, #f5edf0);
}

/* Apply the same gradient-text kill to all light theme variants */
:root[data-theme="light-forest"] .section-title,
:root[data-theme="light-forest"] .page-intro h1,
:root[data-theme="light-forest"] .launcher-greeting h1,
:root[data-theme="light-forest"] #greeting,
:root[data-theme="light-forest"] .brand-text,
:root[data-theme="light-sunset"] .section-title,
:root[data-theme="light-sunset"] .page-intro h1,
:root[data-theme="light-sunset"] .launcher-greeting h1,
:root[data-theme="light-sunset"] #greeting,
:root[data-theme="light-sunset"] .brand-text,
:root[data-theme="light-arctic"] .section-title,
:root[data-theme="light-arctic"] .page-intro h1,
:root[data-theme="light-arctic"] .launcher-greeting h1,
:root[data-theme="light-arctic"] #greeting,
:root[data-theme="light-arctic"] .brand-text,
:root[data-theme="light-rose"] .section-title,
:root[data-theme="light-rose"] .page-intro h1,
:root[data-theme="light-rose"] .launcher-greeting h1,
:root[data-theme="light-rose"] #greeting,
:root[data-theme="light-rose"] .brand-text {
  background: none;
  -webkit-background-clip: unset;
  background-clip: unset;
  -webkit-text-fill-color: unset;
  color: var(--text);
}

/* ============================================================
   DARK MODE THEME VARIANTS
   ============================================================ */

/* -------- Midnight Purple (default, matches :root) --------
 * Warm dark palette tuned to match the light mode's clean, readable
 * feel. Real drop shadows, not ring tricks. */
:root[data-theme="midnight-purple"] {
  --bg-0: #0F1117;
  --bg-1: #1A1D26;
  --bg-2: #262B37;
  --bg-3: #323847;

  --bg: var(--bg-0);
  --bg-elevated: var(--bg-1);
  --bg-card: var(--bg-1);
  --bg-card-hover: var(--bg-2);
  --bg-input: #262B37;
  --border: #2A2E3A;
  --border-strong: #3E4352;
  --border-hair: rgba(255, 255, 255, 0.08);
  --border-soft: rgba(255, 255, 255, 0.04);

  --text: #F8F9FB;
  --text-secondary: #C7CCD6;
  --text-muted: #9196A5;

  --accent: #8b5cf6;
  --accent-2: #7c3aed;
  --accent-hover: #a78bfa;
  --accent-soft: rgba(139,92,246,0.20);
  --accent-glow: rgba(139,92,246,0.45);

  --live: #30d158;
  --live-glow: rgba(48,209,88,0.25);

  --mesh-1: rgba(124, 58, 237, 0.22);
  --mesh-2: rgba(100, 210, 255, 0.10);
  --mesh-3: rgba(255, 55, 95, 0.08);
}

/* -------- Forest -------- */
:root[data-theme="forest"] {
  --bg-0: #0A110D;
  --bg-1: #18221C;
  --bg-2: #243329;
  --bg-3: #2F4236;

  --bg: var(--bg-0);
  --bg-elevated: var(--bg-1);
  --bg-card: var(--bg-1);
  --bg-card-hover: var(--bg-2);
  --bg-input: #243329;
  --border: #2E3C33;
  --border-strong: #3F5044;
  --border-hair: rgba(255, 255, 255, 0.08);
  --border-soft: rgba(255, 255, 255, 0.04);

  --text: #F1F5F2;
  --text-secondary: #B8C5BC;
  --text-muted: #8B9A90;

  --accent: #10b981;
  --accent-2: #059669;
  --accent-hover: #34d399;
  --accent-soft: rgba(16,185,129,0.16);
  --accent-glow: rgba(16,185,129,0.38);

  --live: #84cc16;
  --live-glow: rgba(132,204,22,0.28);

  --mesh-1: rgba(5, 150, 105, 0.25);
  --mesh-2: rgba(132, 204, 22, 0.10);
  --mesh-3: rgba(20, 184, 166, 0.10);
}

/* -------- Sunset -------- */
:root[data-theme="sunset"] {
  --bg-0: #120B0E;
  --bg-1: #221A1D;
  --bg-2: #30252A;
  --bg-3: #402F36;

  --bg: var(--bg-0);
  --bg-elevated: var(--bg-1);
  --bg-card: var(--bg-1);
  --bg-card-hover: var(--bg-2);
  --bg-input: #30252A;
  --border: #3C2E34;
  --border-strong: #503F46;
  --border-hair: rgba(255, 255, 255, 0.08);
  --border-soft: rgba(255, 255, 255, 0.04);

  --text: #F5F1F2;
  --text-secondary: #C5BAC0;
  --text-muted: #9A8E94;

  --accent: #f97316;
  --accent-2: #ea580c;
  --accent-hover: #fb923c;
  --accent-soft: rgba(249,115,22,0.16);
  --accent-glow: rgba(249,115,22,0.40);

  --live: #facc15;
  --live-glow: rgba(250,204,21,0.28);

  --mesh-1: rgba(234, 88, 12, 0.28);
  --mesh-2: rgba(244, 63, 94, 0.14);
  --mesh-3: rgba(250, 204, 21, 0.08);
}

/* -------- Arctic -------- */
:root[data-theme="arctic"] {
  --bg-0: #0A1017;
  --bg-1: #181F2B;
  --bg-2: #242E3E;
  --bg-3: #303D52;

  --bg: var(--bg-0);
  --bg-elevated: var(--bg-1);
  --bg-card: var(--bg-1);
  --bg-card-hover: var(--bg-2);
  --bg-input: #242E3E;
  --border: #2E3848;
  --border-strong: #3F4C62;
  --border-hair: rgba(255, 255, 255, 0.08);
  --border-soft: rgba(255, 255, 255, 0.04);

  --text: #F1F4F6;
  --text-secondary: #B8C3CD;
  --text-muted: #8B95A5;

  --accent: #0ea5e9;
  --accent-2: #0284c7;
  --accent-hover: #38bdf8;
  --accent-soft: rgba(14,165,233,0.16);
  --accent-glow: rgba(14,165,233,0.38);

  --live: #5eead4;
  --live-glow: rgba(94,234,212,0.28);

  --mesh-1: rgba(14, 116, 176, 0.25);
  --mesh-2: rgba(99, 102, 241, 0.12);
  --mesh-3: rgba(20, 184, 166, 0.10);
}

/* -------- Rose -------- */
:root[data-theme="rose"] {
  --bg-0: #110A10;
  --bg-1: #201820;
  --bg-2: #2C222C;
  --bg-3: #3A2D3A;

  --bg: var(--bg-0);
  --bg-elevated: var(--bg-1);
  --bg-card: var(--bg-1);
  --bg-card-hover: var(--bg-2);
  --bg-input: #2C222C;
  --border: #352A35;
  --border-strong: #483A48;
  --border-hair: rgba(255, 255, 255, 0.08);
  --border-soft: rgba(255, 255, 255, 0.04);

  --text: #F4F1F3;
  --text-secondary: #C5B8C1;
  --text-muted: #9A8C95;

  --accent: #ec4899;
  --accent-2: #be185d;
  --accent-hover: #f472b6;
  --accent-soft: rgba(236,72,153,0.16);
  --accent-glow: rgba(236,72,153,0.38);

  --live: #34d399;
  --live-glow: rgba(52,211,153,0.25);

  --mesh-1: rgba(190, 24, 93, 0.28);
  --mesh-2: rgba(168, 85, 247, 0.12);
  --mesh-3: rgba(251, 113, 133, 0.12);
}

/* ==========================================
   Theme Picker UI (Settings page)
   ========================================== */
.theme-picker {
  padding: 1.25rem 1.5rem 1.5rem;
}
.theme-picker-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.25rem;
}
.theme-picker-title {
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: -0.005em;
}
.theme-picker-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}
.theme-swatches {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(108px, 1fr));
  gap: 0.75rem;
}
.theme-swatch {
  position: relative;
  background: var(--bg-elevated, var(--bg-1));
  border: none;
  border-radius: 12px;
  padding: 0.75rem 0.75rem 0.65rem;
  cursor: pointer;
  font-family: inherit;
  color: var(--text);
  /* Unselected state: clean drop shadow so each swatch reads as a
   * card against the settings-group fill. */
  box-shadow: var(--elev-1);
  transition: opacity 0.15s ease, box-shadow 0.15s ease;
  text-align: left;
  overflow: hidden;
}
.theme-swatch::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 30% 20%, var(--sw-c1) 0%, transparent 55%),
              radial-gradient(circle at 80% 80%, var(--sw-c2) 0%, transparent 60%);
  opacity: 0.45;
  pointer-events: none;
}
.theme-swatch:hover {
  opacity: 0.85;
}
.theme-swatch.selected {
  box-shadow:
    0 0 0 2px var(--sw-c1),
    rgb(7, 8, 10) 0 0 0 3px inset;
}
.theme-swatch-preview {
  position: relative;
  height: 44px;
  border-radius: 10px;
  margin-bottom: 0.6rem;
  background: linear-gradient(135deg, var(--sw-c1), var(--sw-c2));
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.25), inset 0 -12px 20px rgba(0,0,0,0.3);
}
.theme-swatch-preview::after {
  content: '';
  position: absolute;
  right: 8px;
  bottom: 8px;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: #fff;
  opacity: 0.85;
  box-shadow: 0 0 6px rgba(255,255,255,0.6);
}
.theme-swatch-name {
  position: relative;
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: -0.005em;
}
.theme-swatch-check {
  position: absolute;
  top: 8px; right: 8px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--sw-c1);
  color: #fff;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 800;
  box-shadow: 0 2px 6px rgba(0,0,0,0.4);
}
.theme-swatch.selected .theme-swatch-check { display: flex; }

.theme-swatch:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

/* Locked state for Free tier */
.theme-picker.locked .theme-swatch {
  cursor: not-allowed;
  filter: grayscale(0.6) brightness(0.7);
}
.theme-picker.locked .theme-swatch:hover {
  transform: none;
  box-shadow: none;
}
.theme-picker.locked .theme-swatch[data-theme-value="midnight-purple"] {
  filter: none;
  cursor: default;
}

.theme-picker-upsell {
  margin-top: 1rem;
  padding: 0.9rem 1rem;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(251,191,36,0.08), rgba(167,139,250,0.10));
  border: 1px solid rgba(251,191,36,0.25);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.85rem;
}
.theme-picker-upsell-icon {
  width: 28px; height: 28px;
  border-radius: 8px;
  background: linear-gradient(135deg, #fcd34d, #a78bfa);
  display: flex; align-items: center; justify-content: center;
  color: #0d0d0f;
  font-weight: 800;
  font-size: 0.75rem;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(251,191,36,0.35);
}
.theme-picker-upsell-text { flex: 1; color: var(--text-secondary); }
.theme-picker-upsell-text strong { color: var(--text); }

.theme-picker-coming {
  margin-top: 0.85rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
}
.theme-coming-card {
  background: var(--bg-input);
  border: 1px dashed var(--border);
  border-radius: 10px;
  padding: 0.7rem 0.85rem;
  font-size: 0.78rem;
  color: var(--text-muted);
}
.theme-coming-card strong {
  display: block;
  font-size: 0.82rem;
  color: var(--text-secondary);
  margin-bottom: 0.15rem;
}

@media (max-width: 480px) {
  .theme-picker-coming { grid-template-columns: 1fr; }
}

/* Swatch accent variables (used inside markup) */
.sw-midnight-purple { --sw-c1: #a78bfa; --sw-c2: #7c3aed; }
.sw-forest         { --sw-c1: #34d399; --sw-c2: #059669; }
.sw-sunset         { --sw-c1: #fb923c; --sw-c2: #ea580c; }
.sw-arctic         { --sw-c1: #38bdf8; --sw-c2: #0284c7; }
.sw-rose           { --sw-c1: #f472b6; --sw-c2: #be185d; }

/* Theme-change transition (briefly animates body bg) */
.theme-transitioning,
.theme-transitioning * {
  transition: background-color 400ms ease,
              color 400ms ease,
              border-color 400ms ease,
              box-shadow 400ms ease !important;
}

@media (prefers-reduced-motion: reduce) {
  .theme-swatch, .theme-transitioning, .theme-transitioning * { transition: none !important; }
}
