/* ============================================================
   THEME.CSS — Centralized light / dark token system
   Light = :root (default)
   Dark  = html[data-theme="dark"]
   ============================================================ */

:root {
  /* Backgrounds */
  --bg:            #f5f4f0;
  --surface:       #ffffff;
  --bg-card:       #ffffff;
  --bg-card-hover: #eeecea;

  /* Borders */
  --border:        rgba(0, 0, 0, 0.10);
  --border-hover:  rgba(0, 0, 0, 0.20);

  /* Text */
  --text:          #0f0f0f;
  --text-primary:  #0f0f0f;
  --text-secondary:rgba(15, 15, 15, 0.75);
  --text-muted:    rgba(15, 15, 15, 0.56);

  /* Semantic */
  --success: #16a34a;
  --error:   #dc2626;
  --warn:    #fa4902;
  --soon:    #6b7280;

  /* Surface tints (overlays for hover / active states) */
  --surface-tint-1: rgba(0, 0, 0, 0.02);
  --surface-tint-2: rgba(0, 0, 0, 0.04);
  --surface-tint-3: rgba(0, 0, 0, 0.06);
  --surface-tint-4: rgba(0, 0, 0, 0.08);

  /* Component-specific */
  --nav-bg-scrolled:   rgba(245, 244, 240, 0.92);
  --mobile-nav-bg:     rgba(245, 244, 240, 0.97);
  --demo-chrome:       #f0f0ef;
  --demo-dot:          #d4d3cf;

  /* Buttons */
  --btn-primary-bg:    #0f0f0f;
  --btn-primary-text:  #ffffff;
  --btn-primary-hover: #333333;

  /* Shadows */
  --shadow-card: 0 1px 4px rgba(0, 0, 0, 0.08);

  /* Badge accent text (darker for legibility on light bg) */
  --badge-purple:  #7c3aed;
  --badge-blue:    #2563eb;
  --badge-teal:    #0d9488;
  --badge-orange:  #c2410c;
  --badge-emerald: #059669;
  --badge-slate:   #475569;
  --badge-indigo:  #4f46e5;
  --badge-gray:    #4b5563;
}

html[data-theme="dark"] {
  --bg:            #000000;
  --surface:       #0d0d0d;
  --bg-card:       #111111;
  --bg-card-hover: #161616;

  --border:        rgba(255, 255, 255, 0.08);
  --border-hover:  rgba(255, 255, 255, 0.16);

  --text:          #ffffff;
  --text-primary:  #ffffff;
  --text-secondary:rgba(255, 255, 255, 0.55);
  /* 0.3 measured ~2.6:1 against #000 — fails WCAG AA (4.5:1) for muted text
     that still carries real content (citations, labels, status text). 0.5
     gets ~5.3:1 while staying visually distinct from --text-secondary. */
  --text-muted:    rgba(255, 255, 255, 0.5);

  --success: #22c55e;
  --error:   #ef4444;
  --warn:    #fa4902;
  --soon:    #6b7280;

  --surface-tint-1: rgba(255, 255, 255, 0.015);
  --surface-tint-2: rgba(255, 255, 255, 0.025);
  --surface-tint-3: rgba(255, 255, 255, 0.04);
  --surface-tint-4: rgba(255, 255, 255, 0.06);

  --nav-bg-scrolled:   rgba(0, 0, 0, 0.85);
  --mobile-nav-bg:     rgba(0, 0, 0, 0.96);
  --demo-chrome:       #080808;
  --demo-dot:          #252525;

  --btn-primary-bg:    #ffffff;
  --btn-primary-text:  #000000;
  --btn-primary-hover: #e8e8e8;

  /* Shadows */
  --shadow-card: 0 1px 4px rgba(0, 0, 0, 0.4);

  /* Badge accent text (pastels for dark bg) */
  --badge-purple:  #a78bfa;
  --badge-blue:    #60a5fa;
  --badge-teal:    #2dd4bf;
  --badge-orange:  #fa4902;
  --badge-emerald: #34d399;
  --badge-slate:   #94a3b8;
  --badge-indigo:  #818cf8;
  --badge-gray:    #9ca3af;
}

/* ── Logo: invert the white logo for light mode ── */
.logo-img {
  filter: invert(1);
}
html[data-theme="dark"] .logo-img {
  filter: none;
}

/* ── Theme toggle button ── */
.theme-toggle {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-secondary);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  transition: border-color 0.2s ease, color 0.2s ease;
  flex-shrink: 0;
}

.theme-toggle:hover {
  border-color: var(--border-hover);
  color: var(--text);
}

/* Moon shown in light mode; sun shown in dark mode */
.theme-toggle .icon-sun  { display: none;  }
.theme-toggle .icon-moon { display: block; }

html[data-theme="dark"] .theme-toggle .icon-sun  { display: block; }
html[data-theme="dark"] .theme-toggle .icon-moon { display: none;  }

/* ── Reduced motion ──
   Shared across every page that loads theme.css. Neutralizes hover
   transitions and keyframe animations (spinners, pulses, shimmers,
   toasts, drawers) for users who request reduced motion. Page-specific
   effects (e.g. marketing's scroll fade-ins) still need their own
   opacity/transform reset alongside this. */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
