/* Maestree landing — dark theme matching the studio. */
:root {
  --bg: #0f1115;
  --bg-2: #161a21;
  --bg-3: #1c222b;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.14);
  --text: #e6e9ef;
  --text-dim: #9aa4b2;
  --text-faint: #6b7280;
  --blue: #7aa2ff;
  --green: #60d68e;
  --amber: #f0b657;
  --purple: #b48cff;
  --red: #ef6e6e;
  /* Studio node palette (kept identical to the Maestree app so the hero tree
     matches the real thing). Category colors + runtime status colors. */
  --cat-control: #f0b657;
  --cat-decorator: #b48cff;
  --cat-action: #62b7ff;
  --cat-condition: #4dd0e1;
  --st-running: #4a9eff;
  --st-success: #4caf50;
  --st-failure: #e05252;
  --radius: 12px;
  --wrap: 100%;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, monospace;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

code {
  font-family: var(--mono);
  font-size: 0.88em;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--line);
  padding: 1px 5px;
  border-radius: 4px;
}

.wrap { width: 100%; max-width: var(--wrap); margin: 0 auto; padding: 0 clamp(24px, 4vw, 64px); }

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 9px;
  font-weight: 600;
  font-size: 14px;
  border: 1px solid transparent;
  transition: transform 0.06s ease, background 0.15s ease, border-color 0.15s ease;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn--primary {
  background: linear-gradient(135deg, var(--blue), var(--green));
  color: #0b0e13;
}
.btn--primary:hover { filter: brightness(1.07); }
.btn--ghost {
  background: rgba(255, 255, 255, 0.04);
  border-color: var(--line-strong);
  color: var(--text);
}
.btn--ghost:hover { background: rgba(255, 255, 255, 0.08); }
.btn--lg { padding: 14px 26px; font-size: 16px; }

/* ── Nav ─────────────────────────────────────────────────────────────────── */
.nav {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(15, 17, 21, 0.8);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.nav__inner { display: flex; align-items: center; justify-content: space-between; height: 62px; }
.brand { display: flex; align-items: baseline; gap: 10px; }
.brand__mark {
  width: 22px; height: 22px; border-radius: 5px;
  object-fit: contain;
  align-self: center;
}
.brand__name { font-weight: 800; font-size: 18px; letter-spacing: -0.01em; }
.brand__tag { color: var(--text-faint); font-size: 12px; }
.nav__links { display: flex; align-items: center; gap: 20px; }
.nav__links > a { color: var(--text-dim); font-size: 14px; font-weight: 500; }
.nav__links > a:hover { color: var(--text); }
.nav__gh { display: inline-flex; color: var(--text-dim); }
.nav__gh:hover { color: var(--text); }

/* ── Hero ────────────────────────────────────────────────────────────────── */
.hero {
  position: relative;
  overflow: hidden;
  padding: 96px 0 40px;
  background:
    radial-gradient(60% 60% at 50% 0%, rgba(122, 162, 255, 0.14), transparent 70%),
    radial-gradient(40% 50% at 85% 10%, rgba(96, 214, 142, 0.10), transparent 70%);
}
.hero__inner { text-align: center; }
.eyebrow {
  display: inline-block;
  color: var(--blue);
  font-size: 13px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase;
  margin: 0 0 14px;
}
.hero__title {
  margin: 0;
  font-size: clamp(38px, 7vw, 68px);
  line-height: 1.05;
  letter-spacing: -0.03em;
  font-weight: 820;
}
.grad {
  background: linear-gradient(120deg, var(--blue), var(--green) 70%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero__lead {
  max-width: 660px;
  margin: 22px auto 0;
  color: var(--text-dim);
  font-size: 18px;
}
.hero__lead strong { color: var(--text); font-weight: 600; }
.hero__cta { display: flex; gap: 12px; justify-content: center; margin-top: 30px; flex-wrap: wrap; }

/* ── Live-ticking behavior tree (hero graphic) ───────────────────────────── */
.bt {
  position: relative;
  margin: 56px auto 0;
  max-width: 820px;
  padding: 34px 20px 28px;
  overflow-x: auto;
  background: linear-gradient(180deg, var(--bg-2), rgba(22, 26, 33, 0.4));
  border: 1px solid var(--line);
  border-radius: 16px;
}
.bt__badge {
  position: absolute;
  top: 12px; left: 14px;
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 11px; font-family: var(--mono); color: var(--text-dim);
  padding: 3px 9px; border-radius: 999px;
  background: rgba(255, 255, 255, 0.04); border: 1px solid var(--line);
}
.bt__badge-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); animation: bt-pulse 1.6s ease-in-out infinite; }
@keyframes bt-pulse { 0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(96,214,142,.5); } 50% { opacity: .5; box-shadow: 0 0 0 5px rgba(96,214,142,0); } }

/* Org-chart connectors: nested <ul>/<li> with ::before/::after lines. */
.bt-tree, .bt-tree ul { list-style: none; margin: 0; padding: 0; display: flex; justify-content: center; position: relative; }
/* Center each node over its subtree so it lines up with the connectors. */
.bt-tree li { position: relative; display: flex; flex-direction: column; align-items: center; padding: 22px 12px 0; }
.bt-tree li::before, .bt-tree li::after {
  content: ""; position: absolute; top: 0; right: 50%;
  width: 50%; height: 22px; border-top: 1px solid var(--line-strong);
}
.bt-tree li::after { right: auto; left: 50%; border-left: 1px solid var(--line-strong); }
.bt-tree li::before { border-right: 1px solid var(--line-strong); }
.bt-tree > li::before, .bt-tree > li::after { display: none; }         /* no line above root */
.bt-tree li:first-child::before { border: 0; }                          /* straighten outer edges */
.bt-tree li:last-child::after { border: 0; }
.bt-tree li:last-child::before { border-right: 1px solid var(--line-strong); }
/* Vertical drop from a parent node into its children's connector bar. Nested
   uls only (not the root's ul), so there's no line above the root. */
.bt-tree li > ul { margin-top: 22px; }
.bt-tree li > ul::before {
  content: ""; position: absolute; left: 50%; top: -22px;
  height: 22px; border-left: 1px solid var(--line-strong);
}

/* A node card — visually identical to the Maestree studio node (scaled down):
   dark card, 1px border, a thick category-colored TOP border, header row with
   the CATEGORY label + #uid, bold type, italic name, status word at the bottom.
   The tick animation drives the status ring + which status word is showing. */
.bt-node {
  --node-color: var(--line-strong);   /* category color (top border) */
  position: relative;
  width: 148px;
  min-height: 78px;
  padding: 6px 10px 20px;             /* bottom room for the status word */
  display: flex; flex-direction: column; gap: 1px;
  text-align: left;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-top: 4px solid var(--node-color);
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  animation: bt-ring 6s ease-in-out infinite;
  animation-delay: calc(var(--o) * 0.42s);
}
.bt-control   { --node-color: var(--cat-control); }
.bt-action    { --node-color: var(--cat-action); }
.bt-condition { --node-color: var(--cat-condition); }
.bt-decorator { --node-color: var(--cat-decorator); }

.bt-node__header { display: flex; justify-content: space-between; align-items: center; }
.bt-node__cat { font-size: 8.5px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-faint); }
.bt-node__uid { font-size: 8.5px; color: var(--text-faint); opacity: 0.7; }
.bt-node__type { font-weight: 600; font-size: 13px; line-height: 1.2; color: var(--text); }
.bt-node__name { font-size: 10.5px; color: var(--text-dim); font-style: italic; line-height: 1.2; }

/* Two status words share the bottom row; the animation cross-fades them so the
   node reads "RUNNING" then its result (SUCCESS/FAILURE), like the live studio. */
.bt-node__st {
  position: absolute; bottom: 5px; left: 50%; transform: translateX(-50%);
  font-size: 9.5px; font-weight: 700; letter-spacing: 0.06em; line-height: 1;
  white-space: nowrap; opacity: 0;
}
.bt-node__st--run { color: var(--st-running); animation: bt-lbl-run 6s ease-in-out infinite; }
.bt-node__st--res { color: var(--res); animation: bt-lbl-res 6s ease-in-out infinite; }
.bt-node__st--run, .bt-node__st--res { animation-delay: calc(var(--o) * 0.42s); }

/* The status ring on the node: idle → RUNNING (blue) → result (green/red) → idle. */
@keyframes bt-ring {
  0%, 6%    { box-shadow: 0 4px 12px rgba(0,0,0,.3); }
  12%       { box-shadow: 0 0 0 2px rgba(74,158,255,.55), 0 4px 12px rgba(0,0,0,.3); }
  24%, 72%  { box-shadow: 0 0 0 2px var(--res-glow), 0 4px 12px rgba(0,0,0,.3); }
  84%, 100% { box-shadow: 0 4px 12px rgba(0,0,0,.3); }
}
@keyframes bt-lbl-run { 0%, 6% { opacity: 0; } 12%, 21% { opacity: 1; } 26%, 100% { opacity: 0; } }
@keyframes bt-lbl-res { 0%, 22% { opacity: 0; } 26%, 72% { opacity: 1; } 82%, 100% { opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  .bt-node, .bt__badge-dot { animation: none; }
  .bt-node { box-shadow: 0 0 0 2px var(--res-glow), 0 4px 12px rgba(0,0,0,.3); }
  .bt-node__st--res { opacity: 1; }   /* show a settled, colored result */
}

/* ── Sections ────────────────────────────────────────────────────────────── */
.section { padding: 84px 0; border-top: 1px solid var(--line); }
.section--alt { background: var(--bg-2); }
.section__title {
  margin: 0;
  text-align: center;
  font-size: clamp(26px, 4vw, 36px);
  letter-spacing: -0.02em;
  font-weight: 760;
}
.section__sub {
  text-align: center;
  color: var(--text-dim);
  max-width: 600px;
  margin: 12px auto 0;
}
.section__sub em { color: var(--text-faint); font-style: normal; }

/* ── Feature grid ────────────────────────────────────────────────────────── */
.grid {
  margin-top: 44px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
}
.card {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.section--alt .card { background: var(--bg-3); }
.card:hover { border-color: var(--line-strong); transform: translateY(-2px); }
.card__icon { font-size: 26px; margin-bottom: 12px; }
.card h3 { margin: 0 0 8px; font-size: 18px; }
.card p { margin: 0; color: var(--text-dim); font-size: 14.5px; }

/* ── Demos media grid ────────────────────────────────────────────────────── */
.media-grid {
  margin-top: 44px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 22px;
}
.media { margin: 0; }
.media__frame {
  position: relative;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background:
    repeating-linear-gradient(45deg, rgba(255,255,255,0.02) 0 12px, transparent 12px 24px),
    var(--bg-3);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
/* Empty (placeholder) frames keep a 16:9 box; frames with real media size to it. */
.media__frame:not(:has(video)):not(:has(img)) { aspect-ratio: 16 / 9; }
/* Show the WHOLE video at its natural aspect (no cropping); it fills the card
   width and the frame height follows the video. Click to view fullscreen. */
.media__frame video, .media__frame img {
  width: 100%;
  height: auto;
  display: block;
  cursor: zoom-in;
}
.media__ph { color: var(--text-faint); font-family: var(--mono); font-size: 14px; }
.media__frame:has(video, img) .media__ph { display: none; }
/* "⛶ Fullscreen" hint on hover. */
.media__frame:has(video)::after {
  content: "⛶ Fullscreen";
  position: absolute;
  top: 8px;
  right: 8px;
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  opacity: 0;
  transition: opacity 0.15s ease;
  pointer-events: none;
}
.media__frame:hover::after { opacity: 1; }
.media figcaption { margin-top: 12px; color: var(--text-dim); font-size: 14px; text-align: center; }
.media figcaption strong { color: var(--text); font-weight: 650; }

/* ── Engines ─────────────────────────────────────────────────────────────── */
.engines { display: grid; grid-template-columns: 1.2fr 0.8fr; gap: 48px; align-items: center; }
.engines .section__title, .engines .section__sub { text-align: left; margin-left: 0; }
.ticks { list-style: none; padding: 0; margin: 22px 0 0; display: grid; gap: 12px; }
.ticks li { position: relative; padding-left: 28px; color: var(--text-dim); }
.ticks li::before {
  content: "✓";
  position: absolute; left: 0; top: 0;
  color: var(--green); font-weight: 700;
}
.ticks strong { color: var(--text); }
.engines__badges { display: grid; gap: 14px; }
.badge {
  display: flex; align-items: center; gap: 14px;
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
}
.badge b { display: block; font-size: 15px; }
.badge small { color: var(--text-faint); font-family: var(--mono); font-size: 12px; }
.badge__dot { width: 12px; height: 12px; border-radius: 50%; flex: 0 0 auto; }
.badge__dot--cpp { background: var(--blue); box-shadow: 0 0 12px rgba(122,162,255,0.6); }
.badge__dot--py  { background: var(--green); box-shadow: 0 0 12px rgba(96,214,142,0.6); }

/* ── Flow diagram ────────────────────────────────────────────────────────── */
.flow {
  margin-top: 44px;
  display: flex;
  align-items: stretch;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
}
.flow__box {
  flex: 1 1 220px;
  max-width: 300px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
}
.section--alt .flow__box { background: var(--bg-3); }
.flow__box b { display: block; font-size: 16px; margin-bottom: 6px; }
.flow__box small { color: var(--text-dim); font-size: 13px; }
.flow__box--accent { border-color: rgba(122, 162, 255, 0.4); box-shadow: 0 0 0 1px rgba(122,162,255,0.15); }
.flow__arrow { display: flex; align-items: center; color: var(--text-faint); font-size: 22px; }
.flow__note { text-align: center; color: var(--text-faint); font-size: 14px; max-width: 640px; margin: 26px auto 0; }

/* ── Download ────────────────────────────────────────────────────────────── */
.download {
  max-width: 940px;
  margin: 44px auto 0;              /* don't stretch full-width — keep cards tidy */
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 22px;
  align-items: stretch;            /* both cards equal height */
}
.download__latest {
  background: linear-gradient(180deg, rgba(122,162,255,0.08), var(--bg-2));
  border: 1px solid rgba(122, 162, 255, 0.28);
  border-radius: 16px;
  padding: 28px;
}
.tag {
  display: inline-block;
  font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--green);
  background: rgba(96, 214, 142, 0.12);
  border: 1px solid rgba(96, 214, 142, 0.35);
  padding: 3px 9px; border-radius: 999px;
}
.download__ver { font-size: 34px; font-weight: 800; margin-top: 14px; letter-spacing: -0.02em; }
.download__meta { color: var(--text-faint); margin-top: 2px; font-size: 14px; }
.download__btns { display: flex; gap: 10px; margin-top: 20px; flex-wrap: wrap; }
.os-ico { width: 15px; height: 15px; flex: 0 0 auto; }
.os-emoji { font-size: 15px; line-height: 1; flex: 0 0 auto; }
/* Not-yet-supported platforms: grayed out, non-clickable, with a "soon" badge. */
.btn.is-soon { opacity: 0.45; cursor: not-allowed; pointer-events: none; }
.btn.is-soon em {
  font-style: normal;
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 1px 5px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
}
.download__all {
  display: flex;
  flex-direction: column;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 28px;
}
.download__all .link-arrow { margin-top: auto; }   /* pin "All releases" to the bottom */
.download__all h3 { margin: 0 0 14px; font-size: 16px; }
.ver-list { list-style: none; padding: 0; margin: 0 0 16px; display: grid; gap: 10px; }
.ver-list li {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 12px;
  align-items: center;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}
.ver-list__num { font-family: var(--mono); font-weight: 600; }
.ver-list__date { color: var(--text-faint); font-size: 13px; }
.ver-list__link { color: var(--blue); font-size: 13px; }
.ver-list__link:hover { text-decoration: underline; }
.link-arrow { color: var(--blue); font-weight: 600; font-size: 14px; }
.link-arrow:hover { text-decoration: underline; }

/* ── CTA ─────────────────────────────────────────────────────────────────── */
.cta {
  padding: 90px 0;
  text-align: center;
  background: radial-gradient(60% 100% at 50% 0%, rgba(96, 214, 142, 0.10), transparent 70%);
  border-top: 1px solid var(--line);
}
.cta h2 { margin: 0 0 26px; font-size: clamp(26px, 4vw, 38px); letter-spacing: -0.02em; }

/* ── Footer ──────────────────────────────────────────────────────────────── */
.footer { border-top: 1px solid var(--line); padding: 28px 0; }
.footer__inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; color: var(--text-faint); font-size: 14px; }
.footer__links { display: flex; gap: 18px; }
.footer__links a { color: var(--text-dim); }
.footer__links a:hover { color: var(--text); }
.footer__made { font-family: var(--mono); font-size: 12px; }

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 860px) {
  .grid { grid-template-columns: 1fr 1fr; }
  .engines { grid-template-columns: 1fr; gap: 28px; }
  .download { grid-template-columns: 1fr; }
  .nav__links > a:not(.nav__gh):not(.btn) { display: none; } /* keep GitHub + CTA on mobile */
}
@media (max-width: 560px) {
  .grid, .media-grid { grid-template-columns: 1fr; }
  .hero { padding-top: 64px; }
  .flow__arrow { transform: rotate(90deg); }
}
