/* Light "lab" theme: paper, ink, red accent (#d70000) */
:root {
  --paper: #f6f4ee;
  --paper-2: #ece9df;
  --grid: rgba(215, 0, 0, .05);
  --ink: #16212b;
  --ink-2: #4b5966;
  --ink-3: #8794a0;
  --rule: #d6d2c5;
  --accent: #d70000;
  --accent-ink: #ffffff;
  --logo-ink: #58595b;
  --mono: ui-monospace, "JetBrains Mono", "SF Mono", Menlo, Consolas, monospace;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
/* Dark theme (accent lightened to #ff4545 for contrast on the dark background): from the system (unless light is chosen explicitly) or set by the toggle */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0f1416;
    --paper-2: #161d20;
    --grid: rgba(255, 69, 69, .05);
    --ink: #e6ece9;
    --ink-2: #a3b0ac;
    --ink-3: #66756f;
    --rule: #26302f;
    --accent: #ff4545;
    --accent-ink: #120a0a;
    --logo-ink: #c9cdd0;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #0f1416;
  --paper-2: #161d20;
  --grid: rgba(255, 69, 69, .05);
  --ink: #e6ece9;
  --ink-2: #a3b0ac;
  --ink-3: #66756f;
  --rule: #26302f;
  --accent: #ff4545;
  --accent-ink: #120a0a;
  --logo-ink: #c9cdd0;
  color-scheme: dark;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  background-color: var(--paper);
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 24px 24px;
  color: var(--ink);
  font: 16px/1.55 var(--sans);
  padding: 0 clamp(16px, 4vw, 40px);
}
a { color: inherit; text-decoration: none; }

/* Brand logo (inline SVG): gray lettering follows the theme, the hexagon keeps the brand red */
.logo { display: inline-flex; align-items: center; }
.logo__svg { display: block; height: 26px; width: auto; }
.logo--small .logo__svg { height: 18px; }
.logo__ink { fill: var(--logo-ink); }
.logo__mark { fill: #d62526; }

/* Top bar */
.topbar {
  max-width: 1160px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 0;
  border-bottom: 1px solid var(--rule);
}
.topbar__right { display: flex; align-items: center; gap: 22px; }
.topbar nav { display: flex; gap: 22px; font: 13px var(--mono); }
.topbar nav a { color: var(--ink-2); }
.topbar nav a:hover { color: var(--accent); }
/* Language switch: a segmented control, same height as the theme toggle (32px) */
.langs {
  gap: 0 !important;
  height: 32px;
  border: 1px solid var(--rule);
  border-radius: 4px;
  overflow: hidden;
}
.langs a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  font-size: 12px;
  transition: color .12s;
}
.langs a + a { border-left: 1px solid var(--rule); }
.langs a:hover { color: var(--accent); }
.langs a[aria-current] { background: var(--ink); color: var(--paper); }
.theme {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: transparent;
  color: var(--ink-2);
  cursor: pointer;
}
.theme:hover { color: var(--accent); border-color: var(--accent); }
.theme svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.theme .i-moon { fill: currentColor; stroke: none; }
/* Light theme shows the moon (switch to dark), dark theme shows the sun */
.theme .i-sun { display: none; }
:root[data-theme="dark"] .theme .i-sun { display: block; }
:root[data-theme="dark"] .theme .i-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme .i-sun { display: block; }
  :root:not([data-theme="light"]) .theme .i-moon { display: none; }
}

/* Hero: text + chart */
.hero {
  max-width: 1160px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr 1.05fr;
  gap: 48px;
  align-items: center;
  padding: 72px 0 64px;
}
.kicker {
  font: 12px var(--mono);
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--accent);
  margin-bottom: 18px;
}
.hero h1 {
  font-size: clamp(30px, 4vw, 48px);
  text-wrap: balance;
  line-height: 1.06;
  letter-spacing: -.03em;
  font-weight: 800;
  margin-bottom: 22px;
}
.lead { color: var(--ink-2); font-size: 18px; max-width: 34em; margin-bottom: 30px; }
.btn {
  display: inline-block;
  background: var(--accent);
  color: var(--accent-ink);
  font: 600 14px var(--mono);
  padding: 14px 22px;
  border-radius: 4px;
  transition: transform .15s, box-shadow .15s;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 6px 18px -8px var(--accent); }

.plot {
  background: var(--paper-2);
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 18px;
}
.plot svg { display: block; width: 100%; height: auto; overflow: visible; }
.axis line { stroke: var(--ink-3); stroke-width: 1; }
.ticks text { font: 11px var(--mono); fill: var(--ink-3); text-anchor: middle; }
.ticks .unit { text-anchor: end; }
.ticks text.unit:last-child { text-anchor: start; }
.trace {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  animation: draw 2.6s ease-out .3s forwards;
}
.labels text {
  font: 600 11px var(--mono);
  fill: var(--ink);
  text-anchor: middle;
  opacity: 0;
  animation: show .4s ease-out 2.6s forwards;
}
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes show { to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .trace { animation: none; stroke-dashoffset: 0; }
  .labels text { animation: none; opacity: 1; }
}

/* Facts strip */
.strip {
  max-width: 1160px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-block: 1px solid var(--ink);
  font: 13px var(--mono);
  color: var(--ink-2);
}
.strip div { padding: 16px 14px; }
.strip span { display: block; }
.strip div + div { border-left: 1px solid var(--rule); }
.strip b { color: var(--ink); font-size: 16px; }

/* Main page sections */
.dirs, .tools { max-width: 1160px; margin: 0 auto; padding-top: 72px; scroll-margin-top: 8px; }
.section__head { max-width: 46em; margin-bottom: 32px; }
.section__head h2 { font-size: clamp(26px, 3.4vw, 36px); letter-spacing: -.02em; line-height: 1.15; }
.section__head p { color: var(--ink-2); font-size: 17px; margin-top: 10px; }

/* Areas: the "data path" — five links joined by a line on top */
.dirs__list {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
}
.dir {
  position: relative;
  padding: 26px 20px 24px 0;
  border-top: 1px solid var(--ink);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.dir + .dir { padding-left: 20px; border-left: 1px solid var(--rule); }
/* Node on the line, like a point on a data-flow diagram */
.dir::before {
  content: "";
  position: absolute;
  top: -6px;
  left: 0;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--paper);
  border: 2px solid var(--accent);
}
.dir + .dir::before { left: -6px; }
.dir__code { font: 700 12px var(--mono); color: var(--accent); }
.dir h3 { font-size: 18px; line-height: 1.25; letter-spacing: -.01em; }
.dir p { color: var(--ink-2); font-size: 14px; }

/* Tool groups, laid out as a technical spec sheet */
main { max-width: 1160px; margin: 0 auto; }
.tools .group:first-of-type { padding-top: 8px; }
.group {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 32px;
  padding: 48px 0 8px;
  scroll-margin-top: 16px;
}
.group__head { display: flex; gap: 14px; align-items: flex-start; position: sticky; top: 16px; align-self: start; }
.group__no { font: 700 13px var(--mono); color: var(--accent); padding-top: 6px; }
.group__head h2 { font-size: 24px; letter-spacing: -.02em; line-height: 1.2; }
.group__head p { color: var(--ink-2); font-size: 14px; margin-top: 6px; }

.list { list-style: none; border-top: 1px solid var(--ink); }
.list a {
  display: grid;
  grid-template-columns: 56px 200px 1fr auto;
  gap: 16px;
  align-items: baseline;
  padding: 16px 8px;
  border-bottom: 1px solid var(--rule);
  transition: background .12s, padding .12s;
}
.list a:hover { background: var(--paper-2); padding-left: 14px; }
.list__code { font: 12px var(--mono); color: var(--ink-3); }
.list__name { font-weight: 700; }
.list__desc { color: var(--ink-2); font-size: 14px; }
.list__go { font: 12px var(--mono); color: var(--ink-3); white-space: nowrap; }
.list a:hover .list__go,
.list a:hover .list__name { color: var(--accent); }

/* How it works */
.how { max-width: 1160px; margin: 0 auto; padding: 64px 0; scroll-margin-top: 16px; }
.how h2 { font-size: 28px; letter-spacing: -.02em; margin-bottom: 28px; }
.how ol { list-style: none; counter-reset: step; display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; }
.how li {
  counter-increment: step;
  border-top: 3px solid var(--accent);
  padding-top: 16px;
  color: var(--ink-2);
  font-size: 15px;
}
.how li::before { content: "0" counter(step); display: block; font: 700 13px var(--mono); color: var(--accent); margin-bottom: 8px; }
.how li b { display: block; color: var(--ink); font-size: 17px; margin-bottom: 4px; }

footer {
  max-width: 1160px;
  margin: 0 auto;
  padding: 24px 0 40px;
  border-top: 1px solid var(--ink);
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  font: 12px var(--mono);
  color: var(--ink-3);
}

@media (max-width: 1080px) {
  .dirs__list { grid-template-columns: repeat(3, 1fr); }
  .dir:nth-child(4) { padding-left: 0; border-left: 0; }
  .dir:nth-child(4)::before { left: 0; }
}
@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; padding-top: 48px; gap: 36px; }
  .strip { grid-template-columns: repeat(2, 1fr); }
  .strip div:nth-child(3) { border-left: 0; }
  .strip div:nth-child(n+3) { border-top: 1px solid var(--rule); }
  .group { grid-template-columns: 1fr; gap: 20px; }
  .group__head { position: static; }
  .list a { grid-template-columns: 48px 1fr; row-gap: 4px; }
  .list__desc, .list__go { grid-column: 2; }
  .how ol { grid-template-columns: 1fr; }
  .dirs__list { grid-template-columns: 1fr; border-left: 1px solid var(--ink); margin-left: 6px; }
  .dir, .dir + .dir, .dir:nth-child(4) { padding: 0 0 28px 24px; border: 0; }
  .dir::before, .dir + .dir::before, .dir:nth-child(4)::before { top: 2px; left: -6px; }
}
@media (max-width: 480px) {
  .topbar .links { display: none; }
  .strip { grid-template-columns: 1fr; }
  .strip div + div { border-left: 0; border-top: 1px solid var(--rule); }
}
