/* ============================================================
   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: #07080a;
  --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(0, 212, 170, 0.03);
  /* defaults for tokens not declared on every page */
  --teal-bright: #5eead4;
  --teal-hover: #00b89a;
  --teal-line: rgba(0, 212, 170, 0.25);
  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);
  /* teal accent — darkened for contrast on light */
  --teal: #008a6e;
  --teal-hover: #007a60;
  --teal-bright: #009e80;
  --teal-dim: rgba(0, 138, 110, 0.10);
  --teal-dim2: rgba(0, 138, 110, 0.05);
  --teal-line: rgba(0, 138, 110, 0.30);
  --teal-grid: rgba(0, 138, 110, 0.05);
  /* ink */
  --white: #0d1016;
  --text: #272c36;
  --muted: #5c6372;
  --muted-2: #979eac;
  /* 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(0, 138, 110, 0.10);
  --glow-teal-hover: 0 0 30px rgba(0, 138, 110, 0.20);
  --glow-teal-strong: 0 10px 40px -12px rgba(0, 138, 110, 0.45);
  --glow-dot: 0 0 8px rgba(0, 138, 110, 0.55);
  --focus-ring: rgba(0, 138, 110, 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(0, 138, 110, 0.08), transparent 50%);
}
html[data-theme="light"] .backdrop .topline {
  background: linear-gradient(90deg, transparent, rgba(0, 138, 110, 0.35), transparent);
}
html[data-theme="light"] .zone.cnx {
  background: linear-gradient(180deg, rgba(0, 138, 110, 0.07), rgba(0, 138, 110, 0.02));
}
html[data-theme="light"] .arch-canvas {
  background: radial-gradient(900px 500px at 50% -5%, rgba(0, 138, 110, 0.05), transparent 60%), var(--near-black);
}

/* theme toggle control */
.theme-toggle {
  width: 2rem;
  height: 2rem;
  display: grid;
  place-items: center;
  border: 1px solid var(--ink-line);
  border-radius: 9999px;
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
  flex-shrink: 0;
}
.theme-toggle:hover { border-color: var(--teal-line); color: var(--teal); }
.theme-toggle svg { width: 0.95rem; height: 0.95rem; 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; }
