/* ---- tokens ---- */
:root {
  --paper: #FAFAF9;
  --ink: #14151A;
  --line: #DEDFE3;
  --muted: #6B6E76;
  --surface: #FFFFFF;
  --surface-rgb: 255 255 255;
  --line-rgb: 222 223 227;

  --branch-green: #2E7D5B;
  --branch-rust: #C1443C;
  --branch-blue: #3457D5;
  --branch-amber: #B08628;

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

  --container: 1120px;
  --gutter: 24px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #101114;
    --ink: #F2F1ED;
    --line: #2A2C33;
    --muted: #94969F;
    --surface: #17181C;
    --surface-rgb: 23 24 28;
    --line-rgb: 42 44 51;

    --branch-green: #3FAE81;
    --branch-rust: #E2685F;
    --branch-blue: #6C86EE;
    --branch-amber: #D9A83F;
  }
}
:root[data-theme="dark"] {
  --paper: #101114;
  --ink: #F2F1ED;
  --line: #2A2C33;
  --muted: #94969F;
  --surface: #17181C;
  --surface-rgb: 23 24 28;
  --line-rgb: 42 44 51;

  --branch-green: #3FAE81;
  --branch-rust: #E2685F;
  --branch-blue: #6C86EE;
  --branch-amber: #D9A83F;
}

body, .site-header, .tree-stage, .glass-panel, input, .btn-primary,
.branch-path, .story-branch, .waitlist-note {
  transition: background-color .25s ease, border-color .25s ease, color .25s ease;
}

/* ---- reset ---- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { max-width: 100%; overflow-x: hidden; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
img, svg { display: block; max-width: 100%; }
a { color: inherit; }
h1, h2, h3, p, figure { margin: 0; }
button { font: inherit; }

/* ---- focus ---- */
a:focus-visible,
button:focus-visible,
input:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
}

/* ---- layout ---- */
.wrap {
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 var(--gutter);
}
section {
  padding: 96px 0;
  border-top: 1px solid var(--line);
}
section:first-of-type { border-top: none; }

.eyebrow {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  display: block;
  margin-bottom: 16px;
}

/* ---- nav ---- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgb(var(--surface-rgb) / 0.88);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.site-header .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}
.wordmark {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.04em;
  text-decoration: none;
}
.nav-links {
  display: flex;
  gap: 32px;
  list-style: none;
  margin: 0;
  padding: 0;
}
.nav-links a {
  font-family: var(--mono);
  font-size: 13px;
  text-decoration: none;
  color: var(--ink);
  padding: 4px 2px;
  border-bottom: 1px solid transparent;
  transition: border-color 0.15s ease;
}
.nav-links a:hover { border-color: var(--ink); }
.nav-links .cta {
  border: 1px solid var(--ink);
  padding: 8px 14px;
  border-radius: 3px;
}
.nav-links .cta:hover { background: var(--ink); color: var(--paper); }

.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
}
.theme-toggle:hover { border-color: var(--ink); }
.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

/* ---- hero ---- */
.hero { padding-top: 72px; }
.hero h1 {
  font-family: var(--mono);
  font-weight: 600;
  font-size: clamp(28px, 7.5vw, 72px);
  line-height: 1.08;
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
}
.hero .sub {
  color: var(--muted);
  font-size: 18px;
  max-width: 46ch;
  margin-top: 24px;
}
.hero-cta {
  margin-top: 32px;
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}
.btn-primary {
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: 0.02em;
  background: var(--ink);
  color: var(--paper);
  border: 1px solid var(--ink);
  border-radius: 3px;
  padding: 13px 22px;
  text-decoration: none;
  cursor: pointer;
  transition: opacity 0.15s ease;
  display: inline-block;
}
.btn-primary:hover { opacity: 0.82; }

.tree-stage {
  margin-top: 64px;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 32px 16px 24px;
  overflow: hidden;
  background:
    linear-gradient(var(--line) 1px, transparent 1px) 0 0 / 100% 32px;
  background-color: var(--surface);
}
.tree-stage svg { width: 100%; height: auto; overflow: visible; }

.branch-path {
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  pathLength: 1;
  animation: draw 900ms ease forwards;
}
@keyframes draw {
  to { stroke-dashoffset: 0; }
}
.trunk { stroke: var(--ink); animation-delay: 0ms; }
.b1 { stroke: var(--branch-green); animation-delay: 400ms; }
.b2 { stroke: var(--branch-rust); animation-delay: 620ms; }
.b3 { stroke: var(--branch-blue); animation-delay: 840ms; }
.b4 { stroke: var(--branch-amber); animation-delay: 1060ms; }

.branch-node {
  fill: var(--surface);
  stroke-width: 2;
  opacity: 0;
  animation: pop 300ms ease forwards;
}
.n1 { stroke: var(--branch-green); animation-delay: 1250ms; }
.n2 { stroke: var(--branch-rust); animation-delay: 1350ms; }
.n3 { stroke: var(--branch-blue); animation-delay: 1450ms; }
.n4 { stroke: var(--branch-amber); animation-delay: 1550ms; }
@keyframes pop {
  from { opacity: 0; transform: scale(0.4); transform-origin: center; }
  to { opacity: 1; transform: scale(1); }
}

.branch-hit { fill: transparent; cursor: pointer; }
.branch-hit:focus-visible + .branch-path,
.branch-group:hover .branch-path,
.branch-group:focus-within .branch-path { stroke-width: 3.5; }

.branch-label {
  font-family: var(--mono);
  font-size: 11px;
  fill: var(--ink);
  opacity: 0;
  transition: opacity 0.15s ease;
  pointer-events: none;
}
.branch-group:hover .branch-label,
.branch-group:focus-within .branch-label { opacity: 1; }

.tree-caption {
  margin-top: 12px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--muted);
  text-transform: uppercase;
}

@media (prefers-reduced-motion: reduce) {
  .branch-path, .branch-node { animation: none !important; stroke-dashoffset: 0 !important; opacity: 1 !important; }
}

/* ---- problem / vision ---- */
.problem p, .vision p {
  max-width: 62ch;
}
.problem p {
  font-size: 19px;
  color: var(--ink);
}
.problem p + p { margin-top: 20px; color: var(--muted); }

.vision blockquote {
  margin: 0;
  font-size: clamp(20px, 2.6vw, 28px);
  line-height: 1.55;
  max-width: 68ch;
}
.vision cite {
  display: block;
  margin-top: 24px;
  font-family: var(--mono);
  font-style: normal;
  font-size: 13px;
  color: var(--muted);
}

/* ---- scroll reveal ---- */
.reveal {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity .6s ease, transform .6s ease;
}
.reveal.is-visible { opacity: 1; transform: none; }
.reveal-group > *:nth-child(1) { transition-delay: 0ms; }
.reveal-group > *:nth-child(2) { transition-delay: 70ms; }
.reveal-group > *:nth-child(3) { transition-delay: 140ms; }
.reveal-group > *:nth-child(4) { transition-delay: 210ms; }
.reveal-group > *:nth-child(5) { transition-delay: 280ms; }
@media (prefers-reduced-motion: reduce) {
  .reveal { transition: none; transform: none; }
}

/* ---- glass panel (used only in the how-it-works scroll story) ---- */
.glass-panel {
  background: rgb(var(--surface-rgb) / 0.6);
  backdrop-filter: blur(16px) saturate(160%);
  -webkit-backdrop-filter: blur(16px) saturate(160%);
  border: 1px solid rgb(var(--line-rgb) / 0.8);
  border-radius: 10px;
}

/* ---- how it works ---- */
.how-title {
  font-family: var(--mono);
  font-size: clamp(22px, 3vw, 32px);
  font-weight: 600;
  max-width: 20ch;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3em;
}
.arrow-glyph {
  width: 0.75em;
  height: 0.75em;
  flex: none;
  color: var(--muted);
}
.how-scroll {
  margin-top: 48px;
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 40px;
  align-items: start;
}
.story-tree-stage {
  position: sticky;
  top: 96px;
  height: 420px;
  padding: 20px;
}
.story-tree { width: 100%; height: 100%; overflow: visible; }
.story-trunk { fill: none; stroke: var(--ink); stroke-width: 2; stroke-linecap: round; }
.story-branch {
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  pathLength: 1;
  transition: stroke-dashoffset .7s ease, stroke .25s ease;
}
.story-branch.drawn { stroke-dashoffset: 0; }
.story-branch.sb1 { stroke: var(--branch-green); }
.story-branch.sb2 { stroke: var(--branch-rust); }
.story-branch.sb3 { stroke: var(--branch-blue); }
.story-branch.sb4 { stroke: var(--branch-amber); }
@media (prefers-reduced-motion: reduce) {
  .story-branch { transition: none; stroke-dashoffset: 0; }
}

.steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.steps li {
  padding: 26px 28px;
  border-left: 3px solid var(--line);
}
.steps li[data-step="1"] { border-left-color: var(--branch-green); }
.steps li[data-step="2"] { border-left-color: var(--branch-rust); }
.steps li[data-step="3"] { border-left-color: var(--branch-blue); }
.steps li[data-step="4"] { border-left-color: var(--branch-amber); }
.steps li.is-active { border-color: rgb(var(--line-rgb) / 0.8); background: rgb(var(--surface-rgb) / 0.8); }
.step-num {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.06em;
}
.steps h3 {
  font-family: var(--mono);
  font-size: 17px;
  margin-top: 12px;
  font-weight: 600;
}
.steps p {
  margin-top: 10px;
  color: var(--muted);
  font-size: 15px;
}
@media (max-width: 900px) {
  .how-scroll { grid-template-columns: 1fr; }
  .story-tree-stage { display: none; }
}

/* ---- whats new ---- */
.new-list {
  margin: 40px 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 0;
}
.new-list li {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 32px;
  padding: 24px 0;
  border-top: 1px solid var(--line);
}
.new-list li:last-child { border-bottom: 1px solid var(--line); }
.new-list h3 {
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 600;
}
.new-list p { color: var(--muted); font-size: 15px; max-width: 60ch; }
.tag {
  display: inline-block;
  margin-top: 10px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: 2px 6px;
}

/* ---- use cases ---- */
.cases {
  margin-top: 40px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
}
.cases > div { background: var(--paper); padding: 28px 24px; }
.cases h3 {
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 600;
}
.cases p { margin-top: 10px; color: var(--muted); font-size: 15px; }

/* ---- waitlist ---- */
.waitlist .wrap { max-width: 640px; }
.waitlist h2 {
  font-family: var(--mono);
  font-size: clamp(24px, 4vw, 36px);
  font-weight: 600;
}
.waitlist-form {
  margin-top: 28px;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}
.waitlist-form input[type="email"] {
  flex: 1 1 260px;
  min-width: 0;
  font-family: var(--sans);
  font-size: 15px;
  padding: 13px 16px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--surface);
  color: var(--ink);
}
.waitlist-form input[type="email"]::placeholder { color: var(--muted); }
.waitlist-note {
  margin-top: 14px;
  font-size: 13px;
  color: var(--muted);
}
.waitlist-note[hidden] { display: none; }
.waitlist-note.is-error { color: var(--branch-rust); }

/* ---- footer ---- */
footer {
  border-top: 1px solid var(--line);
  padding: 40px 0;
}
footer .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}
footer .wordmark { font-size: 13px; }
.footer-meta {
  color: var(--muted);
  font-size: 13px;
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
}
.footer-meta a { text-decoration: underline; text-underline-offset: 3px; }

/* ---- responsive ---- */
@media (max-width: 860px) {
  .cases { grid-template-columns: 1fr; }
  .new-list li { grid-template-columns: 1fr; gap: 8px; }
}
@media (max-width: 640px) {
  section { padding: 64px 0; }
  .site-header .wrap { height: auto; padding-top: 14px; padding-bottom: 14px; flex-wrap: wrap; gap: 10px; }
  .nav-links { gap: 12px; flex-wrap: wrap; }
  .nav-links a { font-size: 12px; }
  .nav-links .cta { padding: 6px 10px; }
  .tree-desktop { display: none; }
  .tree-mobile { display: block !important; }
  .theme-toggle { width: 36px; height: 36px; }
}
@media (max-width: 400px) {
  :root { --gutter: 16px; }
  .nav-links { gap: 10px; }
  .hero h1 { font-size: 24px; }
}
@media (max-width: 640px) {
  .glass-panel {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    background: rgb(var(--surface-rgb) / 0.94);
  }
}
.tree-mobile { display: none; }

@media (min-width: 641px) {
  .tree-mobile { display: none !important; }
}
