/* ============================================================
   CrowdControl Docs — Oxide-inspired dark-first theme
   Design tokens from permit/DESIGN.md
   ============================================================ */

:root {
  /* Light theme defaults */
  --bg-primary: #FAFBFC;
  --bg-secondary: #F4F5F7;
  --bg-tertiary: #EBEEF0;
  --surface: #FFFFFF;
  --surface-hover: #F7F8F9;
  --border: #D1D9DE;
  --border-secondary: #B8C4CB;
  --text-primary: #1A1D1F;
  --text-secondary: #6B7280;
  --text-tertiary: #9CA3AF;

  --accent: #48D597;
  --accent-50: #E8FAF2;
  --accent-100: #D1F5E5;
  --accent-300: #76E1B1;
  --accent-500: #2BB87A;
  --accent-700: #1A6E48;
  --accent-hover: #2BB87A;

  --success: #48D597;
  --warning: #F5A623;
  --error:   #E5484D;
  --info:    #3B82F6;

  --shadow-oxide:    0 0 0 1px rgba(30, 49, 54, 0.08);
  --shadow-oxide-lg: 0 8px 24px rgba(15, 23, 42, 0.08);

  --font-sans: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', Menlo, Consolas, monospace;

  --sidebar-width: 280px;
  --toc-width: 240px;
  --header-height: 56px;
  --content-max: 780px;
}

html[data-theme="dark"] {
  --bg-primary: #080F11;
  --bg-secondary: #0C1416;
  --bg-tertiary: #101B1E;
  --surface: #141F22;
  --surface-hover: #1A282C;
  --border: #1E3136;
  --border-secondary: #2A4249;
  --text-primary: #F1F5F9;
  --text-secondary: #94A3B8;
  --text-tertiary: #64748B;

  --accent-hover: #76E1B1;

  --shadow-oxide:    0 0 0 1px rgba(30, 49, 54, 0.5);
  --shadow-oxide-lg: 0 4px 16px rgba(0, 0, 0, 0.4);
}

/* ---------- reset ------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-size: 15px;
  line-height: 1.6;
}
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--header-height) + 16px); }

a {
  color: var(--accent);
  text-decoration: none;
  transition: color 150ms ease;
}
a:hover { color: var(--accent-hover); }

::selection { background: rgba(72, 213, 151, 0.3); }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg-secondary); }
::-webkit-scrollbar-thumb { background: var(--border-secondary); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-tertiary); }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ---------- layout ------------------------------------------ */
body { display: flex; flex-direction: column; min-height: 100vh; }

header.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--header-height);
  display: flex;
  align-items: center;
  padding: 0 24px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  backdrop-filter: saturate(180%) blur(10px);
}
.site-header .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}
.site-header .brand .logo {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: rgba(72, 213, 151, 0.12);
  color: var(--accent);
  display: grid;
  place-items: center;
}
.site-header .brand .logo svg { width: 18px; height: 18px; }
.site-header nav.top-nav {
  margin-left: 32px;
  display: flex;
  gap: 20px;
  font-size: 13px;
}
.site-header nav.top-nav a { color: var(--text-secondary); }
.site-header nav.top-nav a:hover { color: var(--text-primary); }
.site-header nav.top-nav a.active { color: var(--accent); }

.site-header .spacer { flex: 1; }
.site-header .header-actions { display: flex; align-items: center; gap: 10px; }
.site-header .divider {
  width: 1px;
  height: 24px;
  background: var(--border);
  margin: 0 4px;
}
.header-btn {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  border-radius: 6px;
  cursor: pointer;
  transition: all 150ms ease;
}
.header-btn:hover {
  background: var(--surface-hover);
  border-color: var(--border-secondary);
  color: var(--text-primary);
}
.header-btn svg { width: 16px; height: 16px; }

.github-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
}
.github-link:hover { background: var(--surface-hover); color: var(--text-primary); }
.github-link svg { width: 14px; height: 14px; }

.shell { display: flex; flex: 1; min-height: 0; }

aside.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  padding: 24px 20px 40px 24px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  position: sticky;
  top: var(--header-height);
  height: calc(100vh - var(--header-height));
}
.sidebar-section { margin-bottom: 24px; }
.sidebar-section-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-tertiary);
  padding: 0 10px;
  margin-bottom: 6px;
}
.sidebar-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  border-radius: 6px;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 450;
  transition: all 120ms ease;
}
.sidebar-item:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
}
.sidebar-item.active {
  background: rgba(72, 213, 151, 0.10);
  color: var(--accent);
}
.sidebar-item .tag {
  margin-left: auto;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--bg-tertiary);
  color: var(--text-tertiary);
  padding: 2px 6px;
  border-radius: 4px;
}

main.content-area {
  flex: 1;
  min-width: 0;
  display: flex;
  justify-content: center;
  padding: 40px 48px 80px;
  overflow-x: hidden;
}
article.doc {
  max-width: var(--content-max);
  width: 100%;
}

aside.toc {
  width: var(--toc-width);
  flex-shrink: 0;
  padding: 40px 24px;
  position: sticky;
  top: var(--header-height);
  height: calc(100vh - var(--header-height));
  overflow-y: auto;
  font-size: 13px;
}
.toc-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-tertiary);
  margin-bottom: 10px;
}
.toc ul { list-style: none; padding: 0; margin: 0; }
.toc li { margin: 4px 0; }
.toc a {
  display: block;
  color: var(--text-secondary);
  padding: 4px 10px;
  border-left: 2px solid transparent;
  transition: all 150ms ease;
  line-height: 1.4;
}
.toc a:hover { color: var(--text-primary); }
.toc a.active {
  color: var(--accent);
  border-left-color: var(--accent);
}
.toc .toc-h3 { padding-left: 22px; font-size: 12px; }

/* ---------- typography -------------------------------------- */
article.doc h1, article.doc h2, article.doc h3, article.doc h4 {
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.015em;
  line-height: 1.25;
}
article.doc h1 {
  font-size: 32px;
  margin: 0 0 8px;
  letter-spacing: -0.025em;
}
article.doc .lede {
  font-size: 17px;
  color: var(--text-secondary);
  margin: 0 0 32px;
  line-height: 1.55;
}
article.doc h2 {
  font-size: 22px;
  margin: 48px 0 14px;
  padding-top: 8px;
}
article.doc h2:first-of-type { margin-top: 16px; }
article.doc h3 {
  font-size: 17px;
  margin: 28px 0 10px;
}
article.doc h4 {
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  margin: 20px 0 8px;
}
article.doc p {
  margin: 0 0 16px;
  color: var(--text-primary);
}
article.doc p, article.doc li { font-size: 15px; line-height: 1.7; }
article.doc ul, article.doc ol { padding-left: 22px; margin: 0 0 16px; }
article.doc li { margin: 4px 0; }
article.doc strong { color: var(--text-primary); font-weight: 600; }
article.doc em { color: var(--text-primary); }

/* inline code */
article.doc :not(pre) > code {
  background: var(--bg-tertiary);
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 0.88em;
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--border);
}

/* code blocks */
article.doc pre {
  position: relative;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px 18px;
  margin: 16px 0 24px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.65;
  box-shadow: var(--shadow-oxide);
}
article.doc pre code {
  background: none;
  border: none;
  padding: 0;
  color: var(--text-primary);
  font-size: inherit;
}
.code-lang {
  position: absolute;
  top: 10px;
  right: 14px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-tertiary);
  font-family: var(--font-sans);
  font-weight: 500;
}
.copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  border-radius: 5px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-tertiary);
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  transition: all 120ms ease;
}
article.doc pre:hover .copy-btn { display: flex; }
.copy-btn:hover { color: var(--accent); border-color: var(--accent); }
.copy-btn.copied { color: var(--accent); }
.copy-btn svg { width: 14px; height: 14px; }

/* tables */
article.doc .table-wrap {
  overflow-x: auto;
  margin: 16px 0 24px;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow-oxide);
}
article.doc table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
article.doc th, article.doc td {
  text-align: left;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
article.doc th {
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
article.doc tr:last-child td { border-bottom: none; }
article.doc tr:hover td { background: var(--surface-hover); }

/* callouts */
.callout {
  border-left: 3px solid var(--accent);
  background: rgba(72, 213, 151, 0.06);
  border-radius: 6px;
  padding: 14px 16px;
  margin: 20px 0;
  font-size: 14px;
}
.callout-title {
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}
.callout.warning { border-left-color: var(--warning); background: rgba(245, 166, 35, 0.07); }
.callout.warning .callout-title { color: var(--warning); }
.callout.error { border-left-color: var(--error); background: rgba(229, 72, 77, 0.07); }
.callout.error .callout-title { color: var(--error); }
.callout.info { border-left-color: var(--info); background: rgba(59, 130, 246, 0.07); }
.callout.info .callout-title { color: var(--info); }
.callout p:last-child { margin-bottom: 0; }

/* buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  transition: all 150ms ease;
  border: 1px solid transparent;
  cursor: pointer;
}
.btn-primary {
  background: var(--accent);
  color: #051a10;
  border-color: var(--accent);
}
.btn-primary:hover {
  background: var(--accent-hover);
  color: #051a10;
}
.btn-secondary {
  background: var(--surface);
  color: var(--text-primary);
  border-color: var(--border);
}
.btn-secondary:hover {
  background: var(--surface-hover);
  border-color: var(--border-secondary);
}

/* hero on landing page */
.hero {
  padding: 60px 0 40px;
  text-align: center;
  border-bottom: 1px solid var(--border);
  margin-bottom: 48px;
}
.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  background: rgba(72, 213, 151, 0.10);
  color: var(--accent);
  border: 1px solid rgba(72, 213, 151, 0.25);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  margin-bottom: 20px;
}
.hero h1 {
  font-size: 48px;
  letter-spacing: -0.035em;
  margin: 0 0 16px;
  background: linear-gradient(180deg, var(--text-primary) 0%, var(--text-secondary) 140%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero p.lede {
  font-size: 19px;
  max-width: 620px;
  margin: 0 auto 28px;
}
.hero-cta { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  margin: 32px 0 48px;
}
.feature-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px;
  transition: all 150ms ease;
  box-shadow: var(--shadow-oxide);
}
.feature-card:hover {
  border-color: var(--border-secondary);
  transform: translateY(-1px);
}
.feature-card .icon {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  background: rgba(72, 213, 151, 0.1);
  color: var(--accent);
  display: grid;
  place-items: center;
  margin-bottom: 12px;
}
.feature-card .icon svg { width: 18px; height: 18px; }
.feature-card h3 {
  font-size: 15px !important;
  margin: 0 0 6px !important;
}
.feature-card p {
  color: var(--text-secondary);
  font-size: 13px;
  margin: 0;
  line-height: 1.55;
}

/* prev/next page nav */
.page-nav {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 64px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}
.page-nav a {
  flex: 1;
  padding: 14px 18px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text-primary);
  transition: all 150ms ease;
}
.page-nav a:hover {
  border-color: var(--accent);
  background: var(--surface-hover);
}
.page-nav .label {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-tertiary);
  margin-bottom: 2px;
}
.page-nav .title { font-weight: 500; font-size: 14px; }
.page-nav .prev { text-align: left; }
.page-nav .next { text-align: right; }

/* footer */
footer.site-footer {
  border-top: 1px solid var(--border);
  padding: 28px 48px;
  font-size: 12px;
  color: var(--text-tertiary);
  text-align: center;
  background: var(--bg-secondary);
}
footer.site-footer a { color: var(--text-secondary); }
footer.site-footer a:hover { color: var(--accent); }

/* anchor link on headings */
article.doc h2, article.doc h3 { position: relative; }
article.doc h2 .anchor, article.doc h3 .anchor {
  position: absolute;
  left: -24px;
  opacity: 0;
  color: var(--text-tertiary);
  font-size: 0.8em;
  padding: 0 4px;
  transition: opacity 150ms ease;
}
article.doc h2:hover .anchor, article.doc h3:hover .anchor { opacity: 1; }
article.doc h2 .anchor:hover, article.doc h3 .anchor:hover { color: var(--accent); }

/* mobile */
@media (max-width: 1200px) {
  aside.toc { display: none; }
}
@media (max-width: 900px) {
  aside.sidebar {
    position: fixed;
    left: 0;
    top: var(--header-height);
    height: calc(100vh - var(--header-height));
    transform: translateX(-100%);
    transition: transform 200ms ease;
    z-index: 40;
    box-shadow: var(--shadow-oxide-lg);
  }
  body.sidebar-open aside.sidebar { transform: translateX(0); }
  main.content-area { padding: 24px 20px 60px; }
  .hero h1 { font-size: 36px; }
  .site-header nav.top-nav { display: none; }
}
.mobile-menu-btn { display: none; }
@media (max-width: 900px) {
  .mobile-menu-btn { display: inline-grid; }
}

/* ============================================================
   Prism.js tokens — two-hue palette
   mint family = keywords / rule kinds (brand)
   amber family = strings / numbers / booleans (warm contrast)
   gray family  = identifiers / operators / punctuation / comments
   ============================================================ */

/* string literal palette — warm amber reads clearly against dark */
:root {
  --code-string: #F5D07A;
  --code-number: #F5A623;
  --code-string-light: #B0821F;
  --code-number-light: #A8550A;
}
html[data-theme="light"] {
  --code-string: #A8550A;
  --code-number: #A8550A;
}

/* neutrals (identifiers, punctuation, operators) */
.token.punctuation { color: var(--text-tertiary); }
.token.operator    { color: var(--text-secondary); }
.token.property    { color: var(--text-primary); }
.token.variable    { color: var(--text-primary); }
.token.class-name  { color: var(--text-primary); }
.token.symbol      { color: var(--text-primary); }

/* comments — dim + italic */
.token.comment,
.token.prolog,
.token.doctype,
.token.cdata {
  color: var(--text-tertiary);
  font-style: italic;
}

/* warm family (strings / numbers / booleans / regex) */
.token.string,
.token.char,
.token.attr-value,
.token.regex,
.token.inserted {
  color: var(--code-string);
}
.token.number,
.token.boolean,
.token.constant {
  color: var(--code-number);
  font-weight: 500;
}

/* mint family (keywords / rule kinds / builtins / functions) */
.token.keyword,
.token.atrule,
.token.selector,
.token.tag {
  color: var(--accent);
  font-weight: 500;
}
.token.builtin,
.token.function {
  color: var(--accent-300);
  font-weight: 500;
}

/* CrowdControl-specific — the hero: rule kinds are bolder */
.token.rule-kind {
  color: var(--accent);
  font-weight: 700;
}
/* metadata words (description/owner/link/message) —
   muted so the rule body is the focus */
.token.metadata {
  color: var(--text-secondary);
  font-weight: 500;
}

/* deletions / diff markers (generic) */
.token.deleted { color: var(--error); }

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

/* light-mode overrides — the dark-mode amber is too pale on white */
html[data-theme="light"] .token.string,
html[data-theme="light"] .token.char,
html[data-theme="light"] .token.attr-value,
html[data-theme="light"] .token.regex,
html[data-theme="light"] .token.inserted {
  color: #B45309;
}
html[data-theme="light"] .token.number,
html[data-theme="light"] .token.boolean,
html[data-theme="light"] .token.constant {
  color: #B45309;
}
html[data-theme="light"] .token.builtin,
html[data-theme="light"] .token.function {
  color: var(--accent-500);
}
html[data-theme="light"] .token.keyword,
html[data-theme="light"] .token.rule-kind,
html[data-theme="light"] .token.atrule,
html[data-theme="light"] .token.selector,
html[data-theme="light"] .token.tag {
  color: var(--accent-500);
}
