/* Tokens come from the design handoff (Night first, Day under
   [data-theme="day"]). Everything below uses the names. */

@font-face { font-family: "Martian Mono"; font-weight: 700; font-display: swap; src: url("/fonts/martian-mono-700.woff2") format("woff2"); }
@font-face { font-family: "Martian Mono"; font-weight: 800; font-display: swap; src: url("/fonts/martian-mono-800.woff2") format("woff2"); }
@font-face { font-family: "Instrument Sans"; font-weight: 400; font-display: swap; src: url("/fonts/instrument-sans-400.woff2") format("woff2"); }
@font-face { font-family: "Instrument Sans"; font-weight: 600; font-display: swap; src: url("/fonts/instrument-sans-600.woff2") format("woff2"); }
/* The full JetBrains Mono, not a latin subset: the app's frames draw with
   box-drawing, block and braille characters that the subsets leave out. */
@font-face { font-family: "JetBrains Mono"; font-weight: 400; font-display: swap; src: url("/fonts/jetbrains-mono-400.woff2") format("woff2"); }
@font-face { font-family: "JetBrains Mono"; font-weight: 700; font-display: swap; src: url("/fonts/jetbrains-mono-700.woff2") format("woff2"); }

:root {
  --bg: #08111d;
  --card: #0f1b2b;
  --raised: #15253a;
  --line: #1d2d42;
  --text: #c9d6e3;
  --strong: #eef5fb;
  --muted: #9aabbd;
  --foam: #e8f1f8;
  --teal: #3dd6c6;
  --needs: #f5c542;
  --done: #7fd99a;
  --dim: #6f8399;
  --water: #0d1d2f;
  --crest: #1f6f8b;
  --ink: #08111d;
  --hard: #0a5a63;
  --t-bg: #08111d;
  --t-bar: #0f1b2b;
  --t-line: #1d2d42;
  --t-dot: #2a3d55;
  --shadow: 0 40px 120px -40px rgba(0, 0, 0, .85);
  --ship-filter: brightness(.9) saturate(.94) drop-shadow(0 0 1px rgba(232, 241, 248, .3)) drop-shadow(0 18px 28px rgba(0, 0, 0, .4));
  --display: "Martian Mono", ui-monospace, monospace;
  --mono: "JetBrains Mono", ui-monospace, Consolas, monospace;
  --sans: "Instrument Sans", system-ui, sans-serif;
  --gutter: clamp(16px, 4vw, 32px);
  --section-pad: clamp(72px, 10vw, 128px);
  color-scheme: dark;
}

[data-theme="day"] {
  --bg: #f6f8fa;
  --card: #ffffff;
  --raised: #edf2f6;
  --line: #d3dce5;
  --text: #1f2f3f;
  --strong: #0b1724;
  --muted: #46576a;
  --foam: #0b1724;
  --teal: #0b7a71;
  --needs: #b06a00;
  --done: #277a4c;
  --dim: #61748a;
  --water: #d9e8ef;
  --crest: #9cc6d6;
  --ink: #ffffff;
  --hard: #0b1724;
  --t-bg: #ffffff;
  --t-bar: #edf2f6;
  --t-line: #d3dce5;
  --t-dot: #c3ced9;
  --shadow: 0 40px 100px -40px rgba(11, 23, 36, .22);
  --ship-filter: drop-shadow(0 18px 24px rgba(11, 23, 36, .12));
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; background: var(--bg); }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 17px/1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
[hidden] { display: none !important; }
img { max-width: 100%; }
a { color: var(--teal); text-underline-offset: 3px; }
a:hover { color: var(--strong); }
button { font: inherit; }
:focus-visible { outline: 2px solid var(--teal); outline-offset: 3px; }
::selection { background: #3dd6c6; color: #08111d; }

.wrap { max-width: 1280px; margin: 0 auto; padding: 0 var(--gutter); }
.teal { color: var(--teal); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip {
  position: absolute; left: -9999px; top: 8px; z-index: 30;
  background: var(--teal); color: var(--ink);
  padding: 10px 14px; border-radius: 3px; font: 700 14px var(--mono);
}
.skip:focus { left: 8px; }

.chip {
  font: 600 .82em var(--mono);
  color: var(--strong);
  background: var(--raised);
  border: 1px solid var(--line);
  padding: 1px 6px;
  border-radius: 3px;
}

/* ---------- header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.header-row { height: 64px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { display: flex; align-items: center; gap: 10px; min-height: 44px; text-decoration: none; color: var(--foam); }
.brand img { display: block; width: 40px; height: auto; }
.wordmark { font: 800 15px var(--display); letter-spacing: .04em; color: var(--foam); }
.wordmark .ai { color: var(--teal); }
.nav { display: flex; align-items: center; gap: clamp(2px, 1.4vw, 14px); font: 500 13px var(--mono); }
.nav > a { color: var(--text); text-decoration: none; padding: 0 6px; min-height: 44px; display: inline-flex; align-items: center; }
.nav > a:hover { color: var(--teal); }
.theme-toggle { display: flex; border: 1px solid var(--line); border-radius: 3px; overflow: hidden; background: var(--card); margin-left: 4px; }
.theme-toggle button {
  width: 44px; height: 44px; display: grid; place-items: center; padding: 0;
  border: 0; cursor: pointer; background: transparent; color: var(--muted);
}
.theme-toggle button[aria-pressed="true"] { background: var(--teal); color: var(--ink); }
.moon { width: 13px; height: 13px; border-radius: 50%; box-shadow: inset 4px -3px 0 0 currentColor; transform: rotate(-15deg); }
.sun { width: 7px; height: 7px; border-radius: 50%; background: currentColor; outline: 2px dotted currentColor; outline-offset: 2px; }
@media (max-width: 480px) {
  .brand .wordmark { display: none; }
  .nav { font-size: 12px; }
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 10px;
  min-height: 44px; padding: 0 18px;
  border-radius: 3px; border: 2px solid;
  font: 700 14px var(--mono); text-decoration: none; cursor: pointer;
  transition: transform .12s, box-shadow .12s, border-color .2s, background-color .2s;
}
.btn-primary { border-color: var(--teal); background: var(--teal); color: var(--ink); box-shadow: 4px 4px 0 var(--hard); }
.btn-primary:hover { color: var(--ink); transform: translate(-1px, -1px); box-shadow: 5px 5px 0 var(--hard); }
.btn-primary:active { transform: translate(3px, 3px); box-shadow: 1px 1px 0 var(--hard); }
.btn-primary[data-copied] { background: var(--done); border-color: var(--done); }
.btn-secondary { border-color: var(--line); background: var(--card); color: var(--strong); box-shadow: 4px 4px 0 var(--line); }
.btn-secondary:hover { color: var(--strong); border-color: var(--teal); transform: translate(-1px, -1px); box-shadow: 5px 5px 0 var(--teal); }
.btn-secondary:active { transform: translate(3px, 3px); box-shadow: 1px 1px 0 var(--teal); }

/* ---------- install block ---------- */
.install {
  width: 100%; text-align: left;
  background: var(--card); border: 1px solid var(--line); border-radius: 6px; overflow: hidden;
}
.install-bar { display: flex; align-items: stretch; background: var(--raised); border-bottom: 1px solid var(--line); }
.install-bar [role="tablist"] { display: flex; }
.install-bar [role="tab"] {
  min-height: 44px; padding: 0 18px; border: 0; border-right: 1px solid var(--line);
  background: transparent; color: var(--muted); font: 700 13px var(--mono); cursor: pointer;
}
.install-bar [role="tab"][aria-selected="true"] { background: var(--card); color: var(--strong); }
.shell { margin-left: auto; display: flex; align-items: center; padding: 0 14px; font: 500 12px var(--mono); color: var(--muted); }
.install-cmd { padding: 18px 18px 8px; }
.install-cmd code { display: block; font: 400 14px/1.65 var(--mono); color: var(--strong); white-space: pre-wrap; word-break: break-all; }
.prompt { color: var(--teal); font-weight: 700; user-select: none; }
.install-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 18px 18px; font-size: 14px; color: var(--muted); }
@media (max-width: 420px) {
  .install-bar [role="tab"] { padding: 0 12px; }
  .shell { display: none; }
}

/* ---------- hero ---------- */
/* Product-led: the hero frame's top has to show above the fold at 1280×800,
   so the copy is tight and the frame rides up over the wave. */
.hero { padding-top: clamp(28px, 4vw, 48px); }
.hero-copy {
  max-width: calc(1040px + 2 * var(--gutter));
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: 18px;
  padding-bottom: 24px;
}
h1 {
  margin: 0;
  font: 800 clamp(34px, 5.4vw, 68px)/1.02 var(--display);
  letter-spacing: -.04em; color: var(--strong);
}
@media (max-width: 999px) { h1 span { display: block; } }
.lede { margin: 0; font-size: clamp(18px, 1.8vw, 22px); line-height: 1.5; max-width: 32ch; text-wrap: pretty; }
.meta { margin: 0; font: 500 13px var(--mono); color: var(--muted); }
.hero .install { max-width: 820px; margin-top: 4px; }

/* The one moving thing on the page: the swell under the hero, as in the
   app's splash. Same mask for crest and water so they move together. */
.wave {
  height: 64px; position: relative;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 600 64' preserveAspectRatio='none'%3E%3Cpath d='M0 32 Q75 14 150 32 T300 32 T450 32 T600 32 V64 H0 Z'/%3E%3C/svg%3E") 0 0 / 600px 64px repeat-x;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 600 64' preserveAspectRatio='none'%3E%3Cpath d='M0 32 Q75 14 150 32 T300 32 T450 32 T600 32 V64 H0 Z'/%3E%3C/svg%3E") 0 0 / 600px 64px repeat-x;
  animation: swell 16s linear infinite;
}
.wave.still { animation: none; }
.wave-crest { background: var(--crest); margin-bottom: -61px; z-index: 1; }
.wave-water { background: var(--water); z-index: 2; }
@keyframes swell { to { -webkit-mask-position: 600px 0; mask-position: 600px 0; } }
.water { background: var(--water); position: relative; z-index: 2; }
.hero .water { padding-bottom: var(--section-pad); }
.hero .term { position: relative; margin-top: -40px; }

/* ---------- terminal frames ---------- */
.term {
  margin: 0; min-width: 0;
  background: var(--t-bg); border: 1px solid var(--t-line); border-radius: 10px;
  overflow: hidden; box-shadow: var(--shadow);
}
.term-bar {
  display: flex; align-items: center; gap: 6px; height: 28px; padding: 0 12px;
  background: var(--t-bar); border-bottom: 1px solid var(--t-line);
  font: 500 12px var(--mono); color: var(--muted);
}
.term-bar i { width: 9px; height: 9px; border-radius: 50%; background: var(--t-dot); }
.term-bar span { margin: 0 auto; padding-right: 39px; }
/* The frame scales its cell grid to the box width (0.6em is JetBrains Mono's
   advance, with a little slack for rounding), down to a floor; below it the frame scrolls inside the box
   rather than widening the page. */
.term-body { container-type: inline-size; overflow-x: auto; }
.term-body .frame {
  margin: 0;
  font-family: var(--mono);
  font-size: clamp(3px, calc(100cqi / (var(--cols, 120) * .605)), 14px);
  /* JetBrains Mono's box-drawing glyphs span 1.32em; any less leaves gaps
     in the app's vertical borders. */
  line-height: 1.32;
  white-space: pre;
  width: max-content;
}
/* Glyphs JetBrains Mono lacks fall back to another font with a different
   advance; the exporter wraps them so each still takes exactly its cells. */
.frame .g, .frame .g2 { display: inline-block; overflow: hidden; text-align: center; vertical-align: top; }
.frame .g { width: 1ch; }
.frame .g2 { width: 2ch; }
.fv-day { display: none; }
[data-theme="day"] .fv-night { display: none; }
[data-theme="day"] .fv-day { display: block; }
.frame-slot {
  margin: 0; display: grid; place-items: center; min-height: 260px;
  border: 1px dashed var(--t-line); border-radius: 6px;
  font: 500 13px var(--mono); color: var(--muted);
}
.term figcaption { padding: 10px 14px; border-top: 1px solid var(--t-line); background: var(--t-bar); font-size: 15px; color: var(--muted); }
.term figcaption b { color: var(--strong); }

/* ---------- sections ---------- */
.section { padding: var(--section-pad) 0; border-top: 1px solid var(--line); }
.section.alt { background: var(--card); }
h2 {
  margin: 0 0 16px;
  font: 700 clamp(26px, 3.6vw, 44px)/1.12 var(--display);
  letter-spacing: -.035em; color: var(--strong); text-wrap: balance;
}
h3 { margin: 0 0 6px; font: 700 16px var(--display); letter-spacing: -.02em; color: var(--strong); }
.section p { color: var(--muted); max-width: 56ch; margin: 0 0 16px; }
.section p.intro { margin-bottom: 36px; }
.split {
  display: grid; align-items: center;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr));
  gap: clamp(32px, 5vw, 64px);
}
/* A frame beside text gets the wider share. */
@media (min-width: 1000px) { .split { grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); } }
.split-even { align-items: end; }
@media (min-width: 1000px) { .split-even { grid-template-columns: 1fr 1fr; } }
.status-frame { margin-top: 40px; }

.states { margin: 0; display: grid; gap: 0; border-top: 1px solid var(--line); }
.states > div { display: grid; grid-template-columns: 11ch 1fr; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.states dt { font: 700 14px var(--mono); color: var(--strong); white-space: nowrap; }
.states dd { margin: 0; color: var(--muted); font-size: 15px; }
.glyph { display: inline-block; width: 1.2em; }
.glyph.working { color: var(--teal); }
.glyph.needs { color: var(--needs); }
.glyph.done { color: var(--done); }
.glyph.idle { color: var(--dim); }

.picker { display: flex; flex-direction: column; gap: 18px; }
.tabs { display: flex; flex-wrap: wrap; gap: 10px; }
.tabs [role="tab"] {
  min-height: 44px; padding: 0 16px; border: 2px solid var(--line); border-radius: 3px;
  background: var(--bg); color: var(--text); font: 700 13px var(--mono); cursor: pointer;
  box-shadow: 3px 3px 0 var(--line);
}
.section.alt .tabs [role="tab"]:not([aria-selected="true"]) { background: var(--card); }
.tabs [role="tab"][aria-selected="true"] { background: var(--teal); border-color: var(--teal); color: var(--ink); box-shadow: 3px 3px 0 var(--hard); }

.cols3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); gap: 32px; margin-top: 40px; }
.cols3 p { margin-bottom: 12px; }
.cols3 b { color: var(--strong); }
.code {
  margin: 0; padding: 16px 18px; overflow-x: auto;
  background: var(--t-bg); border: 1px solid var(--t-line); border-radius: 6px;
  font: 400 13px/1.7 var(--mono); color: var(--strong);
}
.code-lg { font-size: 14px; padding: 22px; border-radius: 10px; box-shadow: var(--shadow); }
.code .c { color: var(--muted); }
.code .k, .code .p { color: var(--teal); }
.code .s { color: var(--done); }

.agents {
  list-style: none; margin: 20px 0 28px; padding: 0;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr)); gap: 0 40px;
  border-top: 1px solid var(--line);
}
.agents li { display: flex; align-items: center; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--line); font: 700 15px var(--mono); color: var(--strong); }
.agents li span { color: var(--teal); width: 1.2em; }

/* ---------- install ---------- */
.install-section { border-top: 1px solid var(--line); overflow: hidden; }
.ship {
  display: flex; justify-content: center;
  padding: clamp(56px, 8vw, 96px) var(--gutter) 0;
  margin-bottom: -56px; position: relative; z-index: 0;
}
.ship img { display: block; width: min(100%, 560px); height: auto; filter: var(--ship-filter); }
.install-section .water { padding-bottom: clamp(80px, 11vw, 140px); }
.install-copy {
  max-width: calc(760px + 2 * var(--gutter)); text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 22px;
}
.install-copy h2 { margin: 0; font: 800 clamp(30px, 5vw, 60px)/1.05 var(--display); letter-spacing: -.04em; }
.install-copy > p { margin: 0; font-size: 19px; }
/* Teal falls under AA on the Day water, so these links carry the text colour. */
.links { display: flex; flex-wrap: wrap; justify-content: center; gap: 0 18px; }
.links a { color: var(--strong); text-decoration-color: var(--teal); font: 600 14px var(--mono); min-height: 44px; display: inline-flex; align-items: center; padding: 0 6px; }
.links a:hover { color: var(--teal); }
[data-theme="day"] .links a:hover { color: var(--strong); text-decoration-thickness: 2px; }

/* ---------- footer ---------- */
.site-footer { border-top: 1px solid var(--line); background: var(--bg); }
.footer-row {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 18px;
  padding-top: 28px; padding-bottom: 36px; font: 500 13px var(--mono);
}
.footer-brand { display: flex; align-items: center; gap: 12px; }
.footer-brand img { width: 34px; height: auto; }
.footer-brand .wordmark { font-size: 13px; }
.version { color: var(--muted); }
.version a { display: inline-flex; align-items: center; min-height: 44px; }
.footer-links { display: flex; flex-wrap: wrap; gap: 0 18px; }
.footer-links a { color: var(--text); min-height: 44px; display: inline-flex; align-items: center; }
.footer-links a:hover { color: var(--teal); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  html { scroll-behavior: auto; }
}
