/* Particle Charts — landing page.
   Dark, minimal, monochrome. The charts are the only thing that glows. */

:root {
  --bg: #050609;
  --bg-soft: #080a0f;
  --surface: #0b0d13;
  --surface-2: #0f1219;
  --line: rgba(255, 255, 255, 0.075);
  --line-strong: rgba(255, 255, 255, 0.14);
  --text: #eef1f6;
  --text-2: #a6adba;
  --text-3: #6f7889;
  --accent: #2ff0d6;
  --nav-bg: rgba(5, 6, 9, 0.94);
  --hover: rgba(255, 255, 255, 0.05);
  --hover-strong: rgba(255, 255, 255, 0.3);
  --stripe: rgba(255, 255, 255, 0.02);
  --glow: rgba(47, 240, 214, 0.07);
  --heart: #ff5d7a;
  /* The one place the page inverts: primary buttons and the pressed segment. */
  --invert-bg: #ffffff;
  --invert-fg: #06070a;
  --invert-bg-hover: #e6e9f0;
  --code-fg: #c9d1e0;
  --code-k: #9fb4ff;
  --code-s: #a5e6b8;
  --code-n: #ffd9a0;
  --code-c: #5b6373;
  --code-p: #e8edf6;
  --code-f: #ffffff;
  --radius: 14px;
  --max: 1140px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --sans: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
}

/* Light mode. Only the tokens move; every rule below reads through them.
   The chart chrome is themed separately, through the library's `theme` option. */
:root[data-theme="light"] {
  --bg: #fbfbfd;
  --bg-soft: #f3f5f8;
  --surface: #ffffff;
  --surface-2: #f5f7fa;
  --line: rgba(22, 26, 34, 0.1);
  --line-strong: rgba(22, 26, 34, 0.2);
  --text: #14181f;
  --text-2: #4d5666;
  --text-3: #79828f;
  --accent: #0e9c88;
  --nav-bg: rgba(251, 251, 253, 0.94);
  --hover: rgba(22, 26, 34, 0.05);
  --hover-strong: rgba(22, 26, 34, 0.28);
  --stripe: rgba(22, 26, 34, 0.025);
  --glow: rgba(14, 156, 136, 0.1);
  --heart: #e11d48;
  --invert-bg: #14181f;
  --invert-fg: #ffffff;
  --invert-bg-hover: #2b3240;
  --code-fg: #2b3240;
  --code-k: #4b56c4;
  --code-s: #157a4d;
  --code-n: #a35a00;
  --code-c: #8a93a1;
  --code-p: #2b3240;
  --code-f: #14181f;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  transition: background-color .25s ease, color .25s ease;
}

/* A single very soft light source behind the hero. */
body::before {
  content: "";
  position: fixed;
  inset: -20% 0 auto 0;
  height: 70vh;
  background: radial-gradient(60% 60% at 50% 0%, var(--glow), transparent 70%);
  pointer-events: none;
  z-index: 0;
}

.wrap { width: 100%; max-width: var(--max); margin: 0 auto; padding: 0 24px; position: relative; z-index: 1; }

a { color: inherit; }

h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.022em; line-height: 1.12; }
p { margin: 0; }

.eyebrow {
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-3);
  font-weight: 500;
}

/* ---------------------------------------------------------------- nav ---- */

header.nav {
  position: sticky;
  top: 0;
  z-index: 50;
  /* Deliberately not `backdrop-filter`. A blurred backdrop on a full-width
     sticky bar has to be recomputed on every scroll frame, and on a page with
     live canvases that is the difference between smooth and sticky scrolling.
     On a near-black page an opaque fill is indistinguishable anyway. */
  background: var(--nav-bg);
  border-bottom: 1px solid var(--line);
}
.nav-inner { display: flex; align-items: center; gap: 10px; height: 60px; }
.nav-inner .brand + .pill { flex: 0 0 auto; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; letter-spacing: -0.02em; text-decoration: none; }
.brand-mark { width: 22px; height: 22px; flex: 0 0 auto; }
.nav-links { margin-left: auto; display: flex; align-items: center; gap: 4px; padding-left: 10px; }
.nav-links a {
  text-decoration: none;
  color: var(--text-2);
  font-size: 14px;
  padding: 7px 12px;
  border-radius: 8px;
  transition: color .18s ease, background .18s ease;
}
.nav-links a:hover { color: var(--text); background: var(--hover); }
/* Icon-only, so it costs no horizontal room on a phone. The sun shows in dark
   mode and the moon in light — each icon names the mode you would switch to. */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  margin-left: 4px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
  transition: color .18s ease, background .18s ease, border-color .18s ease;
}
.theme-toggle:hover { color: var(--text); background: var(--hover); border-color: var(--line-strong); }
.theme-toggle svg { width: 16px; height: 16px; display: block; }
.theme-toggle .ico-moon { display: none; }
:root[data-theme="light"] .theme-toggle .ico-sun { display: none; }
:root[data-theme="light"] .theme-toggle .ico-moon { display: block; }

.pill {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-3);
  border: 1px solid var(--line);
  padding: 3px 8px;
  border-radius: 999px;
}

/* --------------------------------------------------------------- hero ---- */

.hero { padding: 44px 0 24px; text-align: center; }
.hero-kicker {
  font-size: 12px;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--text-2);
  font-weight: 500;
  margin-bottom: 14px;
}
.hero h1 {
  font-size: clamp(40px, 7vw, 76px);
  letter-spacing: -0.038em;
  color: var(--accent);
  text-wrap: balance;
}
.hero p.lede {
  margin: 16px auto 0;
  max-width: 620px;
  color: var(--text-2);
  font-size: clamp(16px, 2vw, 19px);
}
.cta { display: flex; gap: 12px; justify-content: center; margin-top: 24px; flex-wrap: wrap; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 20px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform .15s ease, background .18s ease, border-color .18s ease;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--invert-bg); color: var(--invert-fg); }
.btn-primary:hover { background: var(--invert-bg-hover); }
.btn-ghost { border-color: var(--line-strong); color: var(--text); }
.btn-ghost:hover { background: var(--hover); }

.hero-chart {
  margin-top: 28px;
  height: clamp(260px, 42vh, 400px);
  position: relative;
}
.hero-caption {
  margin-top: 18px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-3);
  text-align: center;
}

/* ------------------------------------------------------------ sections --- */

section { padding: 80px 0; position: relative; z-index: 1; }
.section-head { max-width: 620px; margin-bottom: 40px; }
.section-head h2 { font-size: clamp(26px, 3.6vw, 38px); margin-top: 10px; }
.section-head p { color: var(--text-2); margin-top: 14px; }

.rule { height: 1px; background: var(--line); border: 0; margin: 0; }

/* ---------------------------------------------------------- chart grid --- */

.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
/* Grid and flex children default to `min-width: auto`, which is the *content's*
   minimum — a code block's longest line. Without this, a `pre` too wide for the
   phone drags its whole column past the viewport instead of scrolling inside
   its own box. Every track below is sized `minmax(0, 1fr)` for the same reason. */
.grid > * { min-width: 0; }

.card {
  background: linear-gradient(180deg, var(--surface) 0%, var(--bg-soft) 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  position: relative;
  overflow: hidden;
}
.card-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 4px; flex-wrap: wrap; }
.card h3 { font-size: 15px; letter-spacing: -0.01em; }
.card .card-note { font-size: 13px; color: var(--text-3); }
.card-chart { height: 240px; margin: 14px -6px -4px; }
.card code {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--text-3);
}

/* --------------------------------------------------------- playground --- */

.play { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 20px; align-items: start; }
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
}
.panel h4 {
  margin: 0 0 14px;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-3);
  font-weight: 600;
}
.panel + .panel { margin-top: 16px; }

.seg { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; }
.seg button {
  font: inherit;
  font-size: 13px;
  padding: 8px 6px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
  transition: background .16s ease, color .16s ease, border-color .16s ease;
}
.seg button:hover { color: var(--text); border-color: var(--line-strong); }
.seg button[aria-pressed="true"] { background: var(--invert-bg); color: var(--invert-fg); border-color: var(--invert-bg); }

.ctrl { margin-bottom: 15px; }
.ctrl:last-child { margin-bottom: 0; }
.ctrl label { display: flex; justify-content: space-between; font-size: 13px; color: var(--text-2); margin-bottom: 7px; }
.ctrl label b { font-family: var(--mono); font-weight: 500; color: var(--text); font-size: 12px; }

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 3px;
  border-radius: 3px;
  background: var(--line-strong);
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  box-shadow: 0 0 12px color-mix(in srgb, var(--accent) 50%, transparent);
}
input[type="range"]::-moz-range-thumb {
  width: 14px; height: 14px; border: 0; border-radius: 50%; background: var(--accent); cursor: pointer;
}
input[type="range"]:focus-visible { outline: 2px solid var(--text); outline-offset: 4px; }

.toggles { display: flex; flex-wrap: wrap; gap: 8px; }
.toggle {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 13px; color: var(--text-2);
  border: 1px solid var(--line); border-radius: 999px;
  padding: 6px 12px; cursor: pointer;
  transition: color .16s ease, border-color .16s ease, background .16s ease;
}
.toggle:hover { border-color: var(--line-strong); color: var(--text); }
.toggle input { accent-color: var(--text); margin: 0; width: 13px; height: 13px; }
.toggle:has(input:checked) { color: var(--text); border-color: var(--hover-strong); background: var(--hover); }

.play-stage { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.play-stage > * { min-width: 0; }
.play-chart {
  height: 400px;
  background: linear-gradient(180deg, var(--surface) 0%, var(--bg-soft) 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
}

/* --------------------------------------------------------------- code ---- */

pre.code {
  margin: 0;
  max-width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  overflow-x: auto;
  /* Swiping a code block sideways on a phone must not chain into the page's
     own scroll or a back-navigation gesture. */
  overscroll-behavior-x: contain;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.75;
  color: var(--code-fg);
  tab-size: 2;
}
pre.code .k { color: var(--code-k); }
pre.code .s { color: var(--code-s); }
pre.code .n { color: var(--code-n); }
pre.code .c { color: var(--code-c); font-style: italic; }
pre.code .p { color: var(--code-p); }
pre.code .f { color: var(--code-f); }

.code-head {
  display: flex; align-items: center; gap: 10px;
  font-family: var(--mono); font-size: 11px; color: var(--text-3);
  padding: 0 4px 10px;
}
.code-head .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--line-strong); }

/* ---------------------------------------------------------- showcase --- */

.shot {
  margin: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
}
.shot img {
  display: block;
  width: 100%;
  height: auto;
  /* An intrinsic width/height on the tag reserves the row before the bytes
     arrive, so a lazy-loaded shot does not shove the page down as it lands. */
  border-bottom: 1px solid var(--line);
}
/* The whole card is the link, so the anchor has to be the block that fills it
   rather than an inline box wrapping the image. */
.shot a {
  display: block;
  text-decoration: none;
  color: inherit;
}
.shot figcaption {
  padding: 14px 18px;
  font-size: 13.5px;
  color: var(--text);
}
.shot figcaption span { color: var(--text-3); }

.shot:hover { border-color: var(--line-strong); }
.shot a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.showcase-cta {
  margin-top: 24px;
  text-align: center;
  font-size: 14.5px;
  color: var(--text-2);
}
.showcase-cta a { color: var(--text); text-decoration: none; border-bottom: 1px solid var(--line-strong); }
.showcase-cta a:hover { border-bottom-color: currentColor; }

/* A lone entry spans the full width rather than sitting in one column with a
   hole beside it. Sorts itself out as soon as a second one lands. */
#showcase-grid .shot:only-child { grid-column: 1 / -1; }

.showcase-empty {
  grid-column: 1 / -1;
  padding: 40px 22px;
  text-align: center;
  color: var(--text-3);
  font-size: 14px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
}

/* ----------------------------------------------------------- features --- */

.feature { padding: 22px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.feature h3 { font-size: 15px; margin-bottom: 8px; }
.feature p { font-size: 14px; color: var(--text-2); }
.feature .ico {
  width: 26px; height: 26px; margin-bottom: 14px; display: block;
  color: var(--text);
}

/* -------------------------------------------------------------- table --- */

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }
table.api { width: 100%; border-collapse: collapse; font-size: 13.5px; min-width: 640px; }
table.api th, table.api td { text-align: left; padding: 11px 16px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.api thead th { font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--text-3); font-weight: 600; }
table.api tbody tr:last-child td { border-bottom: 0; }
table.api td:first-child { font-family: var(--mono); font-size: 12.5px; color: var(--text); white-space: nowrap; }
table.api td:nth-child(2) { font-family: var(--mono); font-size: 12px; color: var(--text-3); white-space: nowrap; }
table.api td:last-child { color: var(--text-2); }
table.api tbody tr.group td { background: var(--stripe); font-weight: 600; color: var(--text-3);
  font-size: 11px; letter-spacing: .1em; text-transform: uppercase; font-family: var(--sans); }

/* ------------------------------------------------------------- footer --- */

footer {
  border-top: 1px solid var(--line);
  padding: 40px 0 56px;
  color: var(--text-3);
  font-size: 13.5px;
}
.footer-inner { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.footer-inner a { color: var(--text-2); text-decoration: none; }
.footer-inner a:hover { color: var(--text); }
.footer-inner .spacer { margin-left: auto; }
/* Inline-flex would strand each link on its own line if the row wrapped, so
   the credit stays inline text with the heart nudged into the baseline. */
.footer-love { display: inline; }
.footer-love .heart { width: 14px; height: 14px; color: var(--heart); vertical-align: -2px; margin: 0 1px; }
.footer-love a { color: var(--text-2); text-decoration: none; border-bottom: 1px solid var(--line-strong); }
.footer-love a:hover { color: var(--text); border-bottom-color: currentColor; }
.footer-inner .kofi { display: inline-flex; align-items: center; }
.footer-inner .kofi img { display: block; }

/* ------------------------------------------------------------- motion --- */

.reveal { opacity: 0; transform: translateY(16px); transition: opacity .7s cubic-bezier(.2,.7,.3,1), transform .7s cubic-bezier(.2,.7,.3,1); }
.reveal.in { opacity: 1; transform: none; }

/* The hero is on screen at load, so its observers all fire on the same tick —
   the stagger has to come from the transition, not from the trigger. Short
   steps: this reads as one entrance settling, not five separate arrivals. */
.hero .hero-kicker { transition-delay: .04s; }
.hero h1 { transition-delay: .1s; }
.hero .lede { transition-delay: .18s; }
.hero .cta { transition-delay: .26s; }
.hero-stage { transition-delay: .34s; }
/* The chart runs its own particle entrance underneath; a smaller lift keeps the
   two from reading as two separate movements. */
.hero-stage.reveal { transform: translateY(10px); }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .reveal { opacity: 1; transform: none; transition: none; }
  .hero .hero-kicker, .hero h1, .hero .lede, .hero .cta, .hero-stage { transition-delay: 0s; }
}

/* ---------------------------------------------------------- responsive -- */

@media (max-width: 900px) {
  .play { grid-template-columns: minmax(0, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  section { padding: 60px 0; }
}
@media (max-width: 640px) {
  .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .hero { padding: 28px 0 16px; }
  .hero-chart { margin-top: 20px; }
  .nav-links a.hide-sm { display: none; }
  .play-chart { height: 320px; }
  .card-chart { height: 210px; }
}
@media (max-width: 420px) {
  /* The gutter is the only thing competing with the charts for width here. */
  .wrap { padding: 0 16px; }
  .nav-inner { gap: 8px; }
  .nav-links a { padding: 7px 8px; }
  /* Beside the brand the pill is the first thing to go on a phone; the nav
     links and the theme toggle are the ones people actually reach for. */
  .nav-inner .brand + .pill { display: none; }
  .card, .feature, .panel { padding: 16px; }
  pre.code { padding: 14px 16px; font-size: 12px; }
  /* The brand is the one item allowed to give up room; the version pill and
     the links are already at their floor. */
  .brand { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}
