/* ── Clash Design System: Traffic Light ──────────────────────── */

/* ── Palette ────────────────────────────────────────────────── */
/*    light-dark(light, dark) — each color defined exactly once  */

:root {
  color-scheme: light dark;

  --bg:              light-dark(#f0f2ee, #0a0c0a);
  --bg-surface:      light-dark(#e5e8e2, #10120f);
  --bg-elevated:     light-dark(#d9ddd4, #181a17);
  --text:            light-dark(#141816, #c5ccc5);
  --text-secondary:  light-dark(#505850, #7a827a);
  --text-dim:        light-dark(#808880, #555b55);
  --accent:          light-dark(#28813f, #3daa5c);
  --accent-dim:      light-dark(rgba(40,129,63,0.08), rgba(61,170,92,0.10));
  --amber:           light-dark(#9a7a18, #d4a832);
  --alert:           light-dark(#b83020, #d04030);
  --border:          light-dark(rgba(0,0,0,0.08), rgba(255,255,255,0.06));
  --border-strong:   light-dark(rgba(0,0,0,0.14), rgba(255,255,255,0.14));
  --shadow:          light-dark(rgba(0,0,0,0.08), rgba(0,0,0,0.3));
  --selection-bg:    light-dark(#28813f, #3daa5c);
  --selection-text:  light-dark(#f0f2ee, #0a0c0a);
  --badge-allow-bg:  light-dark(#d4f0dc, #132a18);
  --badge-allow-text:light-dark(#1a6b2e, #4ecc6a);
  --badge-deny-bg:   light-dark(#fde0db, #2a1414);
  --badge-deny-text: light-dark(#8b2010, #e05545);
  --badge-ask-bg:    light-dark(#fdf3d0, #2a2514);
  --badge-ask-text:  light-dark(#7a6010, #d4a832);
  --code-bg:         light-dark(#1b2d1b, #0e170e);
  --code-text:       light-dark(#b8e0c0, #90b898);

  /* Shared (non-themed) */
  --font: "IBM Plex Mono", "SF Mono", "Cascadia Code", "Source Code Pro", Menlo, Consolas, monospace;
  --space-xs:  0.25rem;
  --space-sm:  0.5rem;
  --space-md:  1rem;
  --space-lg:  1.5rem;
  --space-xl:  2.5rem;
  --space-2xl: 4rem;
  --max-width: 52rem;
  --nav-height: 3rem;
}

:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"]  { color-scheme: dark; }

/* ── Reset ───────────────────────────────────────────────────── */

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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font);
  font-size: 15px;
  color: var(--text);
  background: var(--bg);
  line-height: 1.75;
}

::selection {
  background: var(--selection-bg);
  color: var(--selection-text);
}

img, svg { display: block; max-width: 100%; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Typography ──────────────────────────────────────────────── */

h1, h2, h3, h4 {
  font-family: var(--font);
  font-weight: 600;
  line-height: 1.3;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

h1 { font-size: 1.5rem; margin-bottom: var(--space-md); }
h2 { font-size: 1.15rem; margin-top: var(--space-2xl); margin-bottom: var(--space-md); }
h3 { font-size: 0.95rem; margin-top: var(--space-xl); margin-bottom: var(--space-sm); }
h4 { font-size: 0.85rem; margin-top: var(--space-lg); margin-bottom: var(--space-sm); }

p, li, td, blockquote { line-height: 1.85; }
p  { margin-bottom: var(--space-md); }
ul, ol { margin-bottom: var(--space-md); padding-left: var(--space-lg); }
li { margin-bottom: var(--space-xs); }
li > ul, li > ol { margin-top: var(--space-xs); margin-bottom: 0; }

strong { font-weight: 600; }
code {
  font-family: var(--font);
  font-size: 0.875em;
  background: var(--bg-surface);
  padding: 0.1em 0.35em;
  border-radius: 0;
}
pre code { background: none; padding: 0; }

blockquote {
  border-left: 3px solid var(--border-strong);
  padding: var(--space-sm) var(--space-md);
  margin-bottom: var(--space-md);
  color: var(--text-secondary);
  background: var(--bg-surface);
  border-radius: 0;
}

hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: var(--space-xl) 0;
}

/* ── Section dividers (homepage) ─────────────────────────────── */

.divider {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  margin: var(--space-2xl) 0;
  color: var(--text-dim);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.divider::before,
.divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ── Navigation ──────────────────────────────────────────────── */

.nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  height: var(--nav-height);
}

.nav-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--space-lg);
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-wordmark {
  font-family: var(--font);
  font-weight: 600;
  font-size: 1rem;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.nav-wordmark:hover { text-decoration: none; opacity: 0.85; }

.nav-links {
  display: flex;
  align-items: center;
  gap: var(--space-lg);
}

.nav-links a {
  font-family: var(--font);
  font-size: 0.6875rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  transition: color 0.15s;
}
.nav-links a:hover,
.nav-links a[aria-current="page"] {
  color: var(--accent);
  text-decoration: none;
}

/* ── Version selector ────────────────────────────────────────── */

.version-selector {
  position: relative;
}

.version-btn {
  display: flex;
  align-items: center;
  gap: 0.35em;
  font-family: var(--font);
  font-size: 0.6875rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 0;
  padding: 0.25em 0.6em;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.version-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.version-menu {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  min-width: 8rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: 0;
  box-shadow: 0 4px 12px var(--shadow);
  list-style: none;
  padding: var(--space-xs) 0;
  z-index: 200;
}
.version-selector.open .version-menu {
  display: block;
}

.version-menu li a {
  display: flex;
  align-items: center;
  gap: 0.5em;
  padding: 0.35em 0.75em;
  font-family: var(--font);
  font-size: 0.6875rem;
  color: var(--text);
  text-decoration: none;
}
.version-menu li a:hover {
  background: var(--accent-dim);
  text-decoration: none;
}
.version-menu li[aria-selected="true"] a {
  color: var(--accent);
  font-weight: 600;
}

.version-badge {
  font-family: var(--font);
  font-size: 0.6rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--badge-allow-text);
  background: var(--badge-allow-bg);
  padding: 0.1em 0.4em;
  border-radius: 0;
}

/* ── Version banner ─────────────────────────────────────────── */

.version-banner {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  text-align: center;
  padding: var(--space-sm) var(--space-lg);
  font-size: 0.8rem;
  color: var(--text-secondary);
}
.version-banner a {
  font-weight: 500;
}

/* ── Hamburger ───────────────────────────────────────────────── */

.nav-hamburger {
  display: none;
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: var(--space-xs);
}
.nav-hamburger:hover { color: var(--accent); }

.nav-overflow { display: contents; }

/* ── GitHub link ─────────────────────────────────────────────── */

.nav-github { display: flex; align-items: center; color: var(--text-secondary); }
.nav-github:hover { color: var(--accent); text-decoration: none; }

/* ── Theme toggle ────────────────────────────────────────────── */

.theme-toggle {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 0.8rem;
  padding: 2px;
  line-height: 1;
  display: flex;
  align-items: center;
}
.theme-toggle svg { width: 14px; height: 14px; }
.theme-toggle:hover { color: var(--accent); }

/* ── Main content ────────────────────────────────────────────── */

main {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: var(--space-xl) var(--space-lg) var(--space-2xl);
}

/* ── Hero ────────────────────────────────────────────────────── */

.hero {
  text-align: center;
  padding: 6rem 0 var(--space-2xl);
}

.hero-title {
  font-family: var(--font);
  font-size: 2rem;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: var(--space-sm);
}

.hero-tagline {
  font-family: var(--font);
  font-size: 1rem;
  font-weight: 500;
  color: var(--text);
  margin-bottom: var(--space-sm);
}

.hero-subtitle {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: var(--space-xl);
}

.hero-install {
  max-width: var(--max-width);
  margin: 0 auto;
  text-align: left;
}

/* ── Section headings ────────────────────────────────────────── */

.section { margin-top: var(--space-2xl); }
.section-title { text-align: center; }
.section-subtitle {
  text-align: center;
  color: var(--text-secondary);
  max-width: 36rem;
  margin: 0 auto var(--space-xl);
}

/* ── Concept cards ───────────────────────────────────────────── */

.cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-lg);
  margin-bottom: var(--space-xl);
}

.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-top: 3px solid var(--border);
  border-radius: 0;
  padding: var(--space-lg);
}
.card--green  { border-top-color: var(--accent); }
.card--amber  { border-top-color: var(--amber); }
.card--red    { border-top-color: var(--alert); }

.card h3 {
  margin-top: 0;
  font-size: 0.9rem;
}

.card p {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 0;
}

/* ── Tables ──────────────────────────────────────────────────── */

table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: var(--space-lg);
  font-size: 0.9rem;
}

thead {
  background: var(--bg-surface);
}

th, td {
  text-align: left;
  padding: var(--space-sm) var(--space-md);
  border: 1px solid var(--border);
}

th {
  font-family: var(--font);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
}

/* ── Comparison table ────────────────────────────────────────── */

.comparison { overflow-x: auto; }

.comparison table {
  min-width: 28rem;
}

.comparison th:first-child,
.comparison td:first-child {
  width: 40%;
}

/* ── Pipeline flow ───────────────────────────────────────────── */

.pipeline {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: var(--space-xl) 0;
}

.pipeline-row {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-surface);
  border-left: 3px solid var(--border);
  font-size: 0.85rem;
}

.pipeline-row--allow { border-left-color: var(--accent); }
.pipeline-row--deny  { border-left-color: var(--alert); }
.pipeline-row--ask   { border-left-color: var(--amber); }

.pipeline-cmd {
  min-width: 8rem;
  font-weight: 500;
  background: none;
  padding: 0;
}

.pipeline-arrow {
  color: var(--text-dim);
}

.pipeline-result {
  color: var(--text-secondary);
}

@media (max-width: 640px) {
  .pipeline-row {
    font-size: 0.75rem;
    gap: var(--space-sm);
  }
  .pipeline-cmd {
    min-width: 0;
  }
}

/* ── Code blocks (always dark) ───────────────────────────────── */

pre {
  background: var(--code-bg);
  color: var(--code-text);
  font-family: var(--font);
  font-size: 0.85rem;
  line-height: 1.65;
  padding: var(--space-md) var(--space-lg);
  border-radius: 0;
  overflow-x: auto;
  margin-bottom: var(--space-md);
  position: relative;
}

pre code {
  font-size: inherit;
  color: inherit;
  background: none;
}

/* Copy button */
.copy-btn {
  position: absolute;
  top: var(--space-sm);
  right: var(--space-sm);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--code-text);
  font-family: var(--font);
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.2em 0.55em;
  border-radius: 0;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s;
}
pre:hover .copy-btn { opacity: 1; }
.copy-btn:hover { background: rgba(255, 255, 255, 0.15); }
.copy-btn.copied { color: #4ecc6a; }

/* ── Prism token colors ──────────────────────────────────────── */
/*    light-dark(on #1b2d1b, on #0e170e)                         */
/*    grey-green (comments), cream (strings), amber (numbers),   */
/*    blue (keywords), gold (functions), purple (regex)          */

.token.comment,
.token.prolog,
.token.doctype,
.token.cdata        { color: light-dark(#5c6e5c, #4c5c4c); }

.token.punctuation   { color: light-dark(#80a880, #609060); }

.token.property,
.token.tag,
.token.boolean,
.token.number,
.token.constant,
.token.symbol,
.token.deleted       { color: light-dark(#ec9855, #d08040); }

.token.selector,
.token.attr-name,
.token.string,
.token.char,
.token.builtin,
.token.inserted      { color: light-dark(#d8c878, #c0b060); }

.token.operator,
.token.entity,
.token.url,
.language-css .token.string,
.style .token.string { color: light-dark(#b0b080, #949468); }

.token.atrule,
.token.attr-value,
.token.keyword       { color: light-dark(#60c8f0, #50b0d8); }

.token.function,
.token.class-name    { color: light-dark(#e8c060, #d0a840); }

.token.regex,
.token.important     { color: light-dark(#c898e8, #b078d8); }

.token.variable      { color: light-dark(#5cc8b0, #48b098); }

.token.important,
.token.bold          { font-weight: bold; }
.token.italic        { font-style: italic; }

/* ── Effect badges ───────────────────────────────────────────── */

.badge {
  display: inline-block;
  font-family: var(--font);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.1em 0.5em;
  border-radius: 0;
  vertical-align: middle;
}
.badge--allow { background: var(--badge-allow-bg); color: var(--badge-allow-text); }
.badge--deny  { background: var(--badge-deny-bg); color: var(--badge-deny-text); }
.badge--ask   { background: var(--badge-ask-bg); color: var(--badge-ask-text); }

/* ── Anchor links ────────────────────────────────────────────── */

h2 .header-anchor,
h3 .header-anchor,
h4 .header-anchor {
  color: var(--text-dim);
  font-weight: 400;
  margin-left: 0.3em;
  text-decoration: none;
}
h2:hover .header-anchor,
h3:hover .header-anchor,
h4:hover .header-anchor {
  color: var(--accent);
}

/* ── Page title (inner pages) ────────────────────────────────── */

.page-title {
  font-size: 1.5rem;
  margin-bottom: var(--space-sm);
}

.page-desc {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin-bottom: var(--space-xl);
}

/* ── Steps ───────────────────────────────────────────────────── */

.steps {
  counter-reset: step;
  list-style: none;
  padding-left: 0;
}

.steps li {
  counter-increment: step;
  position: relative;
  padding-left: 2.5rem;
  margin-bottom: var(--space-lg);
}

.steps li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 0.1em;
  width: 1.6rem;
  height: 1.6rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: var(--bg);
  font-family: var(--font);
  font-weight: 700;
  font-size: 0.85rem;
  border-radius: 0;
}

/* ── Architecture flow ───────────────────────────────────────── */

.flow {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-md);
  flex-wrap: wrap;
  margin: var(--space-lg) 0;
  font-family: var(--font);
  font-size: 0.85rem;
}

.flow-node {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  padding: var(--space-sm) var(--space-md);
  border-radius: 0;
}

.flow-arrow { color: var(--text-dim); }

/* ── Footer ──────────────────────────────────────────────────── */

.footer {
  border-top: 1px solid var(--border);
  padding: var(--space-xl) var(--space-lg);
  margin-top: var(--space-2xl);
}

.footer-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  text-align: center;
}

.footer-links {
  display: flex;
  justify-content: center;
  gap: var(--space-lg);
  margin-bottom: var(--space-md);
}

.footer-links a {
  font-size: 0.625rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
}
.footer-links a:hover { color: var(--accent); }

.footer-copy {
  font-size: 0.625rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  margin-bottom: 0;
}

/* ── Responsive ──────────────────────────────────────────────── */

@media (max-width: 640px) {
  :root {
    --space-xl: 2rem;
    --space-2xl: 3rem;
  }

  .hero { padding: 4rem 0 var(--space-2xl); }
  .hero-title { font-size: 1.5rem; }
  .hero-tagline { font-size: 0.9rem; }

  h1, .page-title { font-size: 1.25rem; }
  h2 { font-size: 1rem; }

  .cards {
    grid-template-columns: 1fr;
  }

  .nav-hamburger { display: flex; align-items: center; }

  .nav-links { gap: var(--space-md); }
  .nav-links a { font-size: 0.625rem; }

  .nav-overflow {
    display: none;
    position: absolute;
    top: var(--nav-height);
    right: 0;
    flex-direction: column;
    background: var(--bg);
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0;
    padding: var(--space-sm) var(--space-lg);
    box-shadow: 0 4px 12px var(--shadow);
    gap: 0;
  }

  .nav.open .nav-overflow { display: flex; }

  .nav-overflow a { padding: var(--space-sm) 0; }
  .nav-overflow .version-selector { padding: var(--space-sm) 0; }

  pre {
    padding: var(--space-sm) var(--space-md);
    font-size: 0.8rem;
  }

  .flow { font-size: 0.75rem; gap: var(--space-sm); }
}
