/* ============================================================
   CogNEXUS — Theme layer (dark default · optional light mode)
   Dark is the brand-canonical mode; light is opt-in via the
   .theme-toggle button (theme.js persists 'cognexus_theme').
   Self-contained: also supplies defaults for tokens some pages
   do not define. Load AFTER each page's own styles.
   ============================================================ */

:root {
  /* ink helpers — pages route hardcoded near-white inks through these */
  --ink-hi: #f5f6f8;
  --ink-soft: rgba(245, 246, 248, 0.72);
  --ink-faint: rgba(245, 246, 248, 0.5);
  --ink-line: rgba(245, 246, 248, 0.12);
  --chip-bg: rgba(255, 255, 255, 0.02);
  --on-teal: #ffffff;
  --hairline-faint: rgba(255, 255, 255, 0.05);
  --zone-bg: rgba(13, 15, 20, 0.6);
  --scrim-bg: rgba(4, 6, 12, 0.6);
  --glass-bg: rgba(10, 10, 11, 0.72);
  --glass-solid: rgba(10, 10, 11, 0.97);
  --teal-grid: rgba(124, 58, 237, 0.03);
  /* defaults for tokens not declared on every page */
  --teal-bright: #A855F7;
  --teal-hover: #A855F7;
  --teal-line: rgba(124, 58, 237, 0.25);
  /* small accent text/links brighten on dark for AA (>=4.5:1);
     #7C3AED stays for large UI, buttons, and the brand lockup */
  --accent-text: #A855F7;
  color-scheme: dark;
}

html[data-theme="light"] {
  /* canvas / surfaces */
  --black: #f5f6f8;
  --near-black: #eceef2;
  --surface: #ffffff;
  --surface-2: #f1f2f6;
  --surface-3: #e7e9ef;
  /* hairlines */
  --border: rgba(12, 18, 28, 0.09);
  --border-bright: rgba(12, 18, 28, 0.16);
  /* violet accent — #7C3AED passes AA on white for small text */
  --teal: #7C3AED;
  --teal-hover: #6D28D9;
  --teal-bright: #A855F7;
  --accent-text: #7C3AED;
  --teal-dim: rgba(124, 58, 237, 0.10);
  --teal-dim2: rgba(124, 58, 237, 0.05);
  --teal-line: rgba(124, 58, 237, 0.30);
  --teal-grid: transparent;
  /* ink — deepen muted tones for AA on white/gray surfaces */
  --white: #0d1016;
  --text: #1a1f2a;
  --muted: #4a5160;
  --muted-2: #6b7385;
  /* semantic status */
  --red: #dc2626;
  --yellow: #b45309;
  --green: #15803d;
  --blue: #2563eb;
  --red-dim: rgba(220, 38, 38, 0.08);
  --yellow-dim: rgba(180, 83, 9, 0.08);
  --green-dim: rgba(21, 128, 61, 0.08);
  --blue-dim: rgba(37, 99, 235, 0.08);
  --pd-cyan: #0e7490;
  --pd-purple: #7c3aed;
  /* glass + shadows + glows */
  --glass-bg: rgba(245, 246, 248, 0.8);
  --glass-solid: rgba(245, 246, 248, 0.97);
  --glass-panel: rgba(255, 255, 255, 0.82);
  --shadow-sm: 0 4px 20px rgba(15, 23, 42, 0.08);
  --shadow-md: 0 8px 24px rgba(15, 23, 42, 0.10);
  --shadow-lg: 0 8px 32px rgba(15, 23, 42, 0.12);
  --shadow-pop: 0 12px 40px rgba(15, 23, 42, 0.14);
  --glow-teal: 0 0 28px rgba(124, 58, 237, 0.10);
  --glow-teal-hover: 0 0 30px rgba(124, 58, 237, 0.20);
  --glow-teal-strong: 0 10px 40px -12px rgba(124, 58, 237, 0.45);
  --glow-dot: 0 0 8px rgba(124, 58, 237, 0.55);
  --focus-ring: rgba(124, 58, 237, 0.35);
  /* ink helpers */
  --ink-hi: #0d1016;
  --ink-soft: rgba(13, 16, 22, 0.72);
  --ink-faint: rgba(13, 16, 22, 0.45);
  --ink-line: rgba(12, 18, 28, 0.15);
  --chip-bg: rgba(12, 18, 28, 0.03);
  --hairline-faint: rgba(12, 18, 28, 0.06);
  --zone-bg: rgba(255, 255, 255, 0.6);
  --scrim-bg: rgba(15, 23, 42, 0.35);
  color-scheme: light;
}

/* light-mode structural overrides for hardcoded-gradient spots */
html[data-theme="light"] .backdrop .glow {
  background: radial-gradient(ellipse 120% 60% at 50% -10%, rgba(124, 58, 237, 0.08), transparent 50%);
}
html[data-theme="light"] .backdrop .topline {
  background: linear-gradient(90deg, transparent, rgba(124, 58, 237, 0.35), transparent);
}
html[data-theme="light"] .zone.cnx {
  background: linear-gradient(180deg, rgba(124, 58, 237, 0.07), rgba(124, 58, 237, 0.02));
}
html[data-theme="light"] .arch-canvas {
  background: radial-gradient(900px 500px at 50% -5%, rgba(124, 58, 237, 0.05), transparent 60%), var(--near-black);
}

/* Drop the decorative background grid in light mode — it reads as noise on pale canvas */
html[data-theme="light"] body::before {
  background-image: none;
}

/* Sidebar group labels need clearer contrast on light gray rail */
html[data-theme="light"] .sidebar-group-header,
html[data-theme="light"] .sidebar-group-subhead {
  color: var(--muted);
}
html[data-theme="light"] .sidebar-item {
  color: var(--text);
}
html[data-theme="light"] .sidebar-item:hover {
  color: var(--ink-hi);
}
html[data-theme="light"] .panel-sub,
html[data-theme="light"] .ov-stat-change,
html[data-theme="light"] .ov-stat-label {
  color: var(--muted);
}
html[data-theme="light"] .panel-eyebrow {
  color: var(--muted);
}

/* theme toggle control */
.theme-toggle {
  width: 2.25rem;
  height: 2.25rem;
  display: grid;
  place-items: center;
  border: 1px solid var(--border-bright);
  border-radius: 9999px;
  background: var(--chip-bg);
  color: var(--ink-hi);
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s, background 0.2s;
  flex-shrink: 0;
}
.theme-toggle:hover { border-color: var(--teal-line); color: var(--teal); background: var(--teal-dim); }
.theme-toggle svg { width: 1.05rem; height: 1.05rem; display: block; }
.theme-toggle .ic-moon { display: none; }
html[data-theme="light"] .theme-toggle .ic-sun { display: none; }
html[data-theme="light"] .theme-toggle .ic-moon { display: block; }
