/* spark-vector docs — Comet-style shell. Light theme default; dark via [data-theme=dark]. */

:root {
  --fg: #1f2328;
  --muted: #656d76;
  --line: #d0d7de;
  --line-soft: #e6eaef;
  --bg: #ffffff;
  --bg-alt: #f6f8fa;
  --card: #f6f8fa;
  --accent: #2563eb;
  --accent-soft: #dbe7ff;
  --header-h: 56px;
  --sidebar-w: 268px;
  --toc-w: 220px;
  --maxw: 1400px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

:root[data-theme="dark"] {
  --fg: #e6edf3;
  --muted: #9198a1;
  --line: #30363d;
  --line-soft: #262c33;
  --bg: #0d1117;
  --bg-alt: #161b22;
  --card: #161b22;
  --accent: #4f8dfd;
  --accent-soft: #1f2d47;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: calc(var(--header-h) + 16px); }

body {
  margin: 0;
  font: 16px/1.6 var(--sans);
  color: var(--fg);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.skip-link {
  position: absolute; left: -999px; top: 0; z-index: 200;
  background: var(--accent); color: #fff; padding: 8px 14px; border-radius: 0 0 6px 0;
}
.skip-link:focus { left: 0; }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 100;
  height: var(--header-h);
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  backdrop-filter: saturate(1.2) blur(4px);
}
.header-inner {
  max-width: var(--maxw); margin: 0 auto; height: 100%;
  display: flex; align-items: center; gap: 16px;
  padding: 0 20px;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--fg); font-weight: 650; }
.brand:hover { text-decoration: none; }
.brand-mark { display: inline-flex; }
.brand-name { font-size: 1.05rem; letter-spacing: -0.01em; }
.top-nav { display: flex; gap: 4px; margin-left: 18px; }
.top-nav a {
  color: var(--fg); padding: 6px 12px; border-radius: 6px; font-size: .95rem; font-weight: 500;
}
.top-nav a:hover { background: var(--bg-alt); text-decoration: none; }
.header-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.gh-link, .theme-toggle, .menu-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: 8px; color: var(--fg);
  background: transparent; border: 0; cursor: pointer;
}
.gh-link:hover, .theme-toggle:hover, .menu-toggle:hover { background: var(--bg-alt); text-decoration: none; }
.menu-toggle { display: none; }
.theme-toggle .i-moon { display: none; }
:root[data-theme="dark"] .theme-toggle .i-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .i-moon { display: inline; }

/* ---------- Layout grid ---------- */
.layout {
  max-width: var(--maxw); margin: 0 auto;
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr) var(--toc-w);
  align-items: start;
}

/* ---------- Sidebar ---------- */
.sidebar {
  position: sticky; top: var(--header-h);
  height: calc(100vh - var(--header-h));
  overflow-y: auto;
  border-right: 1px solid var(--line);
  padding: 18px 8px 40px 20px;
}
.nav-group { margin-bottom: 20px; }
.nav-section {
  font-size: .72rem; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); font-weight: 700; margin: 0 0 6px 8px;
}
.sidebar ul { list-style: none; margin: 0; padding: 0; }
.sidebar li a {
  display: block; padding: 5px 10px; border-radius: 6px;
  color: var(--fg); font-size: .92rem; line-height: 1.4;
  border-left: 2px solid transparent;
}
.sidebar li a:hover { background: var(--bg-alt); text-decoration: none; }
.sidebar li a.active {
  color: var(--accent); background: var(--accent-soft);
  border-left-color: var(--accent); font-weight: 600;
}
.ext { color: var(--muted); font-size: .8em; }
.sidebar-backdrop {
  position: fixed; inset: var(--header-h) 0 0 0; background: rgba(0,0,0,.4); z-index: 90;
}

/* ---------- Content ---------- */
.content { min-width: 0; padding: 8px 40px 64px; }
.doc { max-width: 820px; }
.doc h1 { font-size: 2rem; line-height: 1.25; margin: .4em 0 .5em; letter-spacing: -0.02em; }
.doc h2 {
  font-size: 1.4rem; margin: 2em 0 .6em; padding-bottom: .3em;
  border-bottom: 1px solid var(--line-soft); letter-spacing: -0.01em;
}
.doc h3 { font-size: 1.15rem; margin: 1.7em 0 .5em; }
.doc h4 { font-size: 1rem; margin: 1.4em 0 .4em; }
.doc p, .doc li { color: var(--fg); }
.doc ul, .doc ol { padding-left: 1.4em; }
.doc li { margin: .25em 0; }
.doc img { max-width: 100%; }

.doc code {
  font-family: var(--mono); font-size: .88em;
  background: var(--bg-alt); border: 1px solid var(--line-soft);
  border-radius: 5px; padding: .12em .38em;
}
.doc pre {
  background: var(--bg-alt); border: 1px solid var(--line);
  border-radius: 8px; padding: 14px 16px; overflow-x: auto; margin: 1em 0;
}
.doc pre code { background: none; border: 0; padding: 0; font-size: .85rem; line-height: 1.5; }

.doc table {
  border-collapse: collapse; width: 100%; margin: 1em 0 1.6em; font-size: .92rem;
  display: block; overflow-x: auto;
}
.doc th, .doc td {
  border: 1px solid var(--line); padding: 7px 11px; text-align: left; vertical-align: top;
}
.doc th { background: var(--bg-alt); font-weight: 650; }
.doc tr:nth-child(even) td { background: color-mix(in srgb, var(--bg-alt) 45%, transparent); }

.doc blockquote {
  margin: 1em 0; padding: .4em 1em; color: var(--muted);
  border-left: 4px solid var(--accent); background: var(--bg-alt); border-radius: 0 6px 6px 0;
}

/* heading anchor on hover */
.doc h2, .doc h3 { position: relative; }
.head-anchor {
  position: absolute; left: -0.9em; opacity: 0; color: var(--muted);
  text-decoration: none; font-weight: 400;
}
.doc h2:hover .head-anchor, .doc h3:hover .head-anchor { opacity: 1; }

/* ---------- Right TOC ---------- */
.toc {
  position: sticky; top: var(--header-h);
  height: calc(100vh - var(--header-h)); overflow-y: auto;
  padding: 24px 16px 40px 8px;
}
.toc-title {
  font-size: .72rem; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); font-weight: 700; margin: 0 0 8px;
}
#toc-nav a {
  display: block; color: var(--muted); font-size: .85rem; line-height: 1.4;
  padding: 3px 0 3px 10px; border-left: 2px solid var(--line-soft);
}
#toc-nav a:hover { color: var(--fg); text-decoration: none; }
#toc-nav a.toc-h3 { padding-left: 22px; }
#toc-nav a.active { color: var(--accent); border-left-color: var(--accent); font-weight: 600; }
.toc:empty, #toc-nav:empty { display: none; }

/* ---------- Footer ---------- */
.site-footer { max-width: 820px; margin-top: 56px; padding-top: 24px; border-top: 1px solid var(--line); }
.footer-cols { display: flex; gap: 56px; flex-wrap: wrap; }
.footer-h { font-weight: 650; margin: 0 0 8px; font-size: .9rem; }
.footer-cols a { display: block; color: var(--muted); font-size: .9rem; padding: 2px 0; }
.footer-cols a:hover { color: var(--accent); }
.footer-legal { color: var(--muted); font-size: .82rem; margin-top: 22px; line-height: 1.5; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .layout { grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }
  .toc { display: none; }
}
@media (max-width: 800px) {
  :root { --sidebar-w: 82vw; }
  .layout { grid-template-columns: minmax(0, 1fr); }
  .menu-toggle { display: inline-flex; }
  .top-nav { display: none; }
  .content { padding: 8px 20px 56px; }
  .sidebar {
    position: fixed; top: var(--header-h); left: 0; z-index: 95;
    width: var(--sidebar-w); max-width: 340px;
    background: var(--bg); transform: translateX(-102%);
    transition: transform .2s ease; box-shadow: 2px 0 16px rgba(0,0,0,.15);
  }
  .sidebar.open { transform: translateX(0); }
}

/* ================= Home hero (Comet-style) ================= */
/* The home page opts out of the doc column width and drops the right TOC. */
.home .doc { max-width: none; }
.home .toc { display: none; }
.layout.home { grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }
@media (max-width: 800px) { .layout.home { grid-template-columns: minmax(0, 1fr); } }

/* The intro text on top and the terminal full width below it: side by side, the terminal's long
   spark-submit lines wrapped badly on wide screens. */
.hero {
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 28px 0 40px;
  border-bottom: 1px solid var(--line-soft);
  margin-bottom: 8px;
}
.hero .hero-copy { max-width: 880px; }
.hero .terminal { width: 100%; max-width: 1100px; }

.hero h1 {
  font-size: 2.6rem; line-height: 1.1; letter-spacing: -0.03em; margin: 0 0 .3em;
}
.hero .tagline { font-size: 1.2rem; color: var(--muted); margin: 0 0 1.1em; line-height: 1.45; }
.hero .cta { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 1.4em; }
.hero .btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 18px; border-radius: 8px; font-weight: 600; font-size: .98rem;
  border: 1px solid var(--line);
}
.hero .btn:hover { text-decoration: none; }
.hero .btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.hero .btn.primary:hover { filter: brightness(1.06); }
.hero .btn.ghost { background: var(--bg-alt); color: var(--fg); }
.hero .btn.ghost:hover { background: var(--card); }
/* ---------- Animated terminal ---------- */
.terminal {
  background: #0d1117;
  border: 1px solid #30363d;
  border-radius: 12px;
  box-shadow: 0 12px 40px rgba(0,0,0,.28);
  overflow: hidden;
  font-family: var(--mono);
  color: #e6edf3;
  min-height: 300px;
}
:root[data-theme="dark"] .terminal { box-shadow: 0 12px 40px rgba(0,0,0,.5); }
.terminal-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px; background: #161b22; border-bottom: 1px solid #30363d;
}
.terminal-bar .dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; }
.terminal-bar .dot.r { background: #ff5f56; } .terminal-bar .dot.y { background: #ffbd2e; } .terminal-bar .dot.g { background: #27c93f; }
.terminal-bar .ttl { margin-left: 8px; font-size: .8rem; color: #9198a1; }
.terminal-body {
  padding: 16px 18px; font-size: .84rem; line-height: 1.55;
  white-space: pre-wrap; word-break: break-word; min-height: 240px;
  max-height: 420px; overflow-y: auto;
}
.terminal-body .prompt { color: #7ee787; }
.terminal-body .flag { color: #79c0ff; }
.terminal-body .val { color: #ffa657; }
.terminal-body .comment { color: #8b949e; }
.terminal-body .ok { color: #7ee787; }
.terminal-body .dim { color: #9198a1; }
.terminal-cursor {
  display: inline-block; width: 8px; height: 1.05em; vertical-align: text-bottom;
  background: #e6edf3; animation: sv-blink 1s steps(1) infinite;
}
@keyframes sv-blink { 50% { opacity: 0; } }

/* Respect reduced-motion: no blink, and the JS renders the final frame at once. */
@media (prefers-reduced-motion: reduce) {
  .terminal-cursor { animation: none; }
}

.home-features {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; margin: 2em 0;
}
.home-features .feature {
  background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 16px 18px;
}
.home-features .feature h3 { margin: 0 0 .3em; font-size: 1.05rem; }
.home-features .feature p { margin: 0; color: var(--muted); font-size: .93rem; }

/* ================= Benchmark-page components (shared) =================
   Mirror of the inline block the generators emit, so a benchmark page
   styled by the site shell still renders if its inline <style> is stripped. */
.doc:has(.bench) { max-width: none; }
.bench .lede { color: var(--muted); }
.bench .tldr { background: var(--card); border-left: 4px solid var(--accent); padding: 14px 18px; border-radius: 6px; margin: 1.2em 0; }
.bench .cards { display:grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; margin: 1em 0; }
.bench .card { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 14px 16px; }
.bench .card .n { font-size: 1.7rem; font-weight: 700; } .bench .card .l { color: var(--muted); font-size: .9rem; }
.bench table td:nth-child(n+2):not(:last-child) { font-variant-numeric: tabular-nums; }
.bench table.kv td:first-child { font-weight: 600; white-space: nowrap; }
.bench .chart { position: relative; height: 340px; margin: 1em 0 2em; } .bench .chart.tall { height: 420px; }
.bench .two { display:grid; grid-template-columns: 1fr 1fr; gap: 24px; } @media (max-width: 860px) { .bench .two { grid-template-columns: 1fr; } }
.bench details summary { cursor: pointer; font-weight: 600; margin: 1em 0; }
.bench .foot { color: var(--muted); font-size: .85rem; margin-top: 3em; }
