/* ── Theme tokens ────────────────────────────────────────── */

:root {
  --font-size-base: 13px;
  --font-mono: "SF Mono", SFMono-Regular, ui-monospace, Menlo, Consolas, monospace;
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
}

[data-theme="dark"] {
  --bg: #0a0c10;
  --surface: #111318;
  --surface-raised: #161a23;
  --surface-2: #181c23;
  --surface-3: #1e2330;
  --border: #2a3142;
  --border-strong: #3a4460;
  --border-subtle: #1c2232;
  --text: #dde3ef;
  --text-muted: #6b7694;
  --text-label: #9fadc5;
  --text-dim: #3d4866;
  --accent: #3b82f6;
  --accent-dim: #1d3a6e;
  --green: #22c55e;
  --green-dim: #0f2d1a;
  --orange: #fb923c;
  --orange-dim: #431407;
  --puter-bg: #0e1018;
  /* ── Glossy accent palette ── */
  --gold: #d4a017;
  --gold-dim: rgba(212, 160, 23, 0.12);
  --gold-border: rgba(212, 160, 23, 0.45);
  --gold-glow: rgba(212, 160, 23, 0.07);
  --silver: #8892a4;
  --silver-border: rgba(136, 146, 164, 0.38);
  --silver-glow: rgba(136, 146, 164, 0.05);
  --green-border: rgba(34, 197, 94, 0.38);
  --green-glow: rgba(34, 197, 94, 0.07);
}

[data-theme="light"] {
  --bg: #f2f4f8;
  --surface: #ffffff;
  --surface-raised: #f8f9fb;
  --surface-2: #eef0f4;
  --surface-3: #e2e6ed;
  --border: #d0d5e0;
  --border-strong: #b8bfcc;
  --border-subtle: #e4e7ed;
  --text: #1a1f2e;
  --text-muted: #5a6380;
  --text-label: #3d4a66;
  --text-dim: #a0a8bc;
  --accent: #2563eb;
  --accent-dim: #dbeafe;
  --green: #16a34a;
  --green-dim: #dcfce7;
  --orange: #ea580c;
  --orange-dim: #ffedd5;
  --puter-bg: #f0f2f6;
  /* ── Glossy accent palette ── */
  --gold: #826200;
  --gold-dim: rgba(130, 98, 0, 0.1);
  --gold-border: rgba(130, 98, 0, 0.42);
  --gold-glow: rgba(130, 98, 0, 0.05);
  --silver: #546275;
  --silver-border: rgba(84, 98, 117, 0.38);
  --silver-glow: rgba(84, 98, 117, 0.04);
  --green-border: rgba(22, 163, 74, 0.4);
  --green-glow: rgba(22, 163, 74, 0.06);
}

/* ── Rich theme — One Dark / Python rich terminal aesthetic ─ */
[data-theme="rich"] {
  /* One Dark backgrounds */
  --bg: #21252b;
  --surface: #282c34;
  --surface-raised: #2c313c;
  --surface-2: #313640;
  --surface-3: #393e49;
  --border: #3e4451;
  --border-strong: #4f5668;
  --border-subtle: #23272e;

  /* Text — boosted for readability (terminal emulators use near-white body text) */
  --text: #e0e4ec;
  --text-muted: #8b95a8;
  --text-label: #98c379;   /* One Dark green — labels look terminal-authentic */
  --text-dim: #4a5165;

  /* One Dark blue accent */
  --accent: #61afef;
  --accent-dim: rgba(97, 175, 239, 0.12);

  /* One Dark green */
  --green: #98c379;
  --green-dim: rgba(152, 195, 121, 0.1);
  --green-border: rgba(152, 195, 121, 0.42);
  --green-glow: rgba(152, 195, 121, 0.05);

  /* One Dark yellow/orange */
  --orange: #e5c07b;
  --orange-dim: rgba(229, 192, 123, 0.1);

  --puter-bg: #21252b;

  /* Primary accent → One Dark blue (replaces gold) */
  --gold: #61afef;
  --gold-dim: rgba(97, 175, 239, 0.1);
  --gold-border: rgba(97, 175, 239, 0.48);
  --gold-glow: rgba(97, 175, 239, 0.05);

  /* Secondary → One Dark purple (replaces silver) */
  --silver: #c678dd;
  --silver-border: rgba(198, 120, 221, 0.4);
  --silver-glow: rgba(198, 120, 221, 0.04);

  /* Shark — cool steel highlight for top-edge accents */
  --shark: rgba(160, 188, 215, 0.55);
  --shark-soft: rgba(145, 172, 200, 0.22);
  --shark-card-border: rgba(130, 158, 185, 0.32);
}

/* Sharp corners — terminals don't round */
[data-theme="rich"] { --r-sm: 1px; --r-md: 2px; --r-lg: 3px; }

/* ── B&W theme — clean editorial black & white ────────── */
[data-theme="bw"] {
  /* Pure white surface hierarchy */
  --bg:             #ffffff;
  --surface:        #ffffff;
  --surface-raised: #fafafa;
  --surface-2:      #f4f4f4;
  --surface-3:      #ebebeb;

  /* Neutral gray borders */
  --border:        #d4d4d4;
  --border-strong: #a3a3a3;
  --border-subtle: #eeeeee;

  /* High-contrast text — all WCAG AA */
  --text:       #0a0a0a;   /* 19.6:1 on white */
  --text-muted: #525252;   /*  9.0:1 on white */
  --text-label: #171717;   /* 18.1:1 on white */
  --text-dim:   #a3a3a3;   /* decorative only  */

  /* Pure black accent */
  --accent:     #171717;
  --accent-dim: #f4f4f4;

  /* Status — accessible dark tones */
  --green:     #15803d;   /* 6.3:1 on white */
  --green-dim: #f0fdf4;
  --orange:    #92400e;   /* 6.9:1 on white */
  --orange-dim: #fffbeb;

  --puter-bg: #fafafa;

  /* Monochrome palette (replaces gold/silver) */
  --gold:          #404040;
  --gold-dim:      rgba(0, 0, 0, 0.04);
  --gold-border:   rgba(0, 0, 0, 0.22);
  --gold-glow:     rgba(0, 0, 0, 0.02);
  --silver:        #737373;
  --silver-border: rgba(0, 0, 0, 0.15);
  --silver-glow:   rgba(0, 0, 0, 0.02);
  --green-border:  rgba(21, 128, 61, 0.30);
  --green-glow:    rgba(21, 128, 61, 0.04);
}

/* Clean sans-serif for prose and key UI elements */
[data-theme="bw"] body,
[data-theme="bw"] .nav-bar,
[data-theme="bw"] .nav-rail,
[data-theme="bw"] .nav-rail-label,
[data-theme="bw"] .topbar,
[data-theme="bw"] .footer,
[data-theme="bw"] .meta-area,
[data-theme="bw"] .meta-value,
[data-theme="bw"] .prose-page,
[data-theme="bw"] .btn,
[data-theme="bw"] .icon-btn,
[data-theme="bw"] input:not([type="checkbox"]),
[data-theme="bw"] select,
[data-theme="bw"] textarea,
[data-theme="bw"] .settings-row-label,
[data-theme="bw"] .settings-row-desc,
[data-theme="bw"] .sidebar {
  font-family: system-ui, -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
  letter-spacing: 0;
}

/* Severity labels — weight-based monochrome hierarchy */
[data-theme="bw"] .sev-critical { color: #0a0a0a; font-weight: 700; }
[data-theme="bw"] .sev-high     { color: #262626; font-weight: 600; }
[data-theme="bw"] .sev-medium   { color: #525252; font-weight: 500; }
[data-theme="bw"] .sev-low      { color: #737373; font-weight: 400; }

/* Analyze result badges — monochrome borders/fills */
[data-theme="bw"] .result-badge.sev-critical { color: #0a0a0a; border-color: rgba(0,0,0,0.40); background: rgba(0,0,0,0.06); }
[data-theme="bw"] .result-badge.sev-high     { color: #262626; border-color: rgba(0,0,0,0.28); background: rgba(0,0,0,0.04); }
[data-theme="bw"] .result-badge.sev-medium   { color: #404040; border-color: rgba(0,0,0,0.20); background: rgba(0,0,0,0.03); }
[data-theme="bw"] .result-badge.sev-low      { color: #737373; border-color: rgba(0,0,0,0.14); background: rgba(0,0,0,0.02); }

/* Error states — dark instead of red */
[data-theme="bw"] .status-bar.error #status-text { color: #0a0a0a; }

/* ── Rich theme: shark — steel edge highlights ───────────────── */

/* Cards & prose panels: steel top-edge catch-light */
[data-theme="rich"] .card,
[data-theme="rich"] #snippet-card,
[data-theme="rich"] .prose-page {
  border-color: var(--shark-card-border);
  box-shadow:
    inset 0 1px 0 var(--shark),
    inset 0 -1px 0 rgba(0, 0, 0, 0.25);
}

/* Meta area separator: steel instead of gold */
[data-theme="rich"] .meta-area {
  border-bottom-color: var(--shark-card-border);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.2);
}

/* Code block wrap: steel top edge */
[data-theme="rich"] .code-block-wrap {
  border-color: var(--shark-card-border) !important;
  box-shadow: inset 0 1px 0 var(--shark-soft);
}

/* Code header: steel separator */
[data-theme="rich"] .code-header {
  border-bottom: 1px solid var(--shark-card-border);
}

/* Topbar: steel bottom edge */
[data-theme="rich"] .topbar {
  border-bottom-color: var(--shark-card-border);
  box-shadow: 0 1px 0 var(--shark-soft);
}

/* Sidebar: left steel spine */
[data-theme="rich"] .sidebar {
  border-left: 2px solid var(--shark-card-border);
}

/* Buttons: steel top-edge sheen */
[data-theme="rich"] .btn,
[data-theme="rich"] .icon-btn {
  box-shadow: inset 0 1px 0 var(--shark-soft);
}
[data-theme="rich"] .btn:hover,
[data-theme="rich"] .icon-btn:hover {
  box-shadow: inset 0 1px 0 var(--shark);
}

/* Input / select controls: steel top highlight */
[data-theme="rich"] input:not([type="checkbox"]),
[data-theme="rich"] select,
[data-theme="rich"] textarea,
[data-theme="rich"] .settings-select,
[data-theme="rich"] .analyze-textarea,
[data-theme="rich"] .analyze-lang-select {
  box-shadow: inset 0 1px 0 var(--shark-soft);
}

/* Challenge bar buttons: use border-strong so they're legible on dark bg */
[data-theme="rich"] .challenge-btn {
  border-color: var(--border-strong);
}
[data-theme="rich"] .challenge-btn:not(:disabled):hover {
  border-color: var(--gold-border);
  background: var(--gold-dim);
}

/* ── Rich theme: powerline ribbon nav-bar ───────────────────── */

/* Restore nav-rail in rich mode; powerline bar sits alongside it */

[data-theme="rich"] .nav-bar {
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 0;
  gap: 0;
  height: 36px;
  align-items: stretch;
  overflow: visible;
}

[data-theme="rich"] .nav-links {
  gap: 0;
  padding: 0;
  align-items: stretch;
  overflow: visible;
}

[data-theme="rich"] .nav-sep { display: none; }

/* Base segment shape — NO gap between segments; arrow overlaps the next */
[data-theme="rich"] .nav-link {
  position: relative;
  display: inline-flex;
  align-items: center;
  /* extra right padding so text clears the 12px arrow zone */
  padding: 0 calc(1rem + 12px) 0 1.6rem;
  margin-right: 0;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  transition: filter 0.12s;
  background: #313640;
  color: #abb2bf;
}

/* Arrow extends 12px beyond the segment right edge, overlapping the next segment.
   Descending z-index on each segment ensures earlier arrows sit on top. */
[data-theme="rich"] .nav-link::after {
  content: '';
  position: absolute;
  right: -12px;
  top: 0;
  bottom: 0;
  width: 0;
  border-top: 18px solid transparent;
  border-bottom: 18px solid transparent;
  border-left: 12px solid #313640;
}

/* Per-segment One Dark colors + descending z-index (arrow of prev overlaps next)
   DOM children: [a:1=Home] [span:2=sep] [a:3=Browse] [span:4] [a:5=Analyze] [span:6] [a:7=About] [span:8] [a:9=Settings] */
[data-theme="rich"] .nav-links > .nav-link:nth-child(1) { z-index: 9; background: #313640; color: #abb2bf; }
[data-theme="rich"] .nav-links > .nav-link:nth-child(1)::after { border-left-color: #313640; }

[data-theme="rich"] .nav-links > .nav-link:nth-child(3) { z-index: 8; background: #1d3d6b; color: #61afef; }
[data-theme="rich"] .nav-links > .nav-link:nth-child(3)::after { border-left-color: #1d3d6b; }

[data-theme="rich"] .nav-links > .nav-link:nth-child(5) { z-index: 7; background: #1c3823; color: #98c379; }
[data-theme="rich"] .nav-links > .nav-link:nth-child(5)::after { border-left-color: #1c3823; }

[data-theme="rich"] .nav-links > .nav-link:nth-child(7) { z-index: 6; background: #3c1e52; color: #c678dd; }
[data-theme="rich"] .nav-links > .nav-link:nth-child(7)::after { border-left-color: #3c1e52; }

[data-theme="rich"] .nav-links > .nav-link:nth-child(9) { z-index: 5; background: #3d2e12; color: #e5c07b; }
[data-theme="rich"] .nav-links > .nav-link:nth-child(9)::after { border-left-color: #3d2e12; }

/* Hover: brighten whole segment including its arrow */
[data-theme="rich"] .nav-link:hover { filter: brightness(1.28); }

/* Active: stronger brightness + white text */
[data-theme="rich"] .nav-link-active { filter: brightness(1.45); color: #fff !important; }

/* Flat — no ambient glows */
[data-theme="rich"] .card,
[data-theme="rich"] .prose-page,
[data-theme="rich"] #snippet-card { box-shadow: none; }

/* Code panel: flat terminal look */
[data-theme="rich"] .code-block-wrap {
  border-left: none;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
}
[data-theme="rich"] .code-header { background: var(--surface-3); }

/* Full monospace UI — body text, labels, buttons, nav all go mono in rich mode */
[data-theme="rich"],
[data-theme="rich"] body {
  --font-mono: 'Cascadia Code', 'Cascadia Mono', 'JetBrains Mono', 'Fira Code', 'Source Code Pro', 'Hack', ui-monospace, Menlo, Consolas, monospace;
  font-family: var(--font-mono);
  font-variant-ligatures: none;
  letter-spacing: 0.01em;
}

/* Section titles: ── title ── rule style */
[data-theme="rich"] .settings-section-title,
[data-theme="rich"] .meta-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
[data-theme="rich"] .settings-section-title::before,
[data-theme="rich"] .settings-section-title::after,
[data-theme="rich"] .meta-title::before {
  content: "──";
  color: var(--gold-border);
  font-family: var(--font-mono), ui-monospace, monospace;
  font-size: 0.85em;
  letter-spacing: -0.12em;
  flex-shrink: 0;
}
[data-theme="rich"] .meta-title::after {
  content: "──";
  flex: 1;
  overflow: hidden;
  color: var(--gold-border);
  font-family: var(--font-mono), ui-monospace, monospace;
  font-size: 0.85em;
  letter-spacing: -0.12em;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-mono), ui-monospace, monospace;
  font-size: var(--font-size-base);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  transition: background 0.2s, color 0.2s;
}

.page-wrap { min-height: 100vh; display: flex; flex-direction: column; }

