/* OpenCalc marketing site — implements the "OpenCalc Site" design.
   Light aesthetic, self-contained (system fonts, inline SVG, no CDN). */
:root {
  --bg: #ffffff;
  --fg: #0b0d12;
  --muted: #5b6472;
  --faint: #9aa1ad;
  --icon: #454b57;
  --border: #e2e5ea;
  --border-2: #dfe2e8;
  --hair: #eceef2;
  --line: #f1f2f5;
  --surface: #f8f9fb;
  /* A raised surface — cards, the editor window, the footer. Its own token
     because in dark a panel is *lighter* than the page, which is the exact
     inversion a hardcoded `#fff` cannot express. */
  --panel: #ffffff;
  /* Text on `--ink`, which is dark in both themes: the CTA band does not flip,
     so its ink must not either. */
  --on-ink: #ffffff;
  --on-ink-dim: rgba(255, 255, 255, .62);
  /* Inline code, and the two callout tints. Here rather than in each page's own
     `<style>` because that is where they were, which is why the first dark pass
     reached the landing page and left `deploy` and `docs` painting white boxes
     on a dark ground. A shared token cannot drift from a second copy of itself. */
  --code-bg: #f2f4f7;
  --code-fg: #0b0d12;
  --note-bg: #f6f9ff;
  --note-warn-bg: #fffaf0;
  --accent: #2f6df6;
  --accent-hover: #1f56cf;
  --ink: #0b0d12;
  --ink-hover: #22262f;
  --ok: #16a34a;
  --done: #0a7c42;
  --maxw: 1200px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, sans-serif;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0; background: var(--bg); color: var(--fg); font-family: var(--sans);
  font-size: 17px; line-height: 1.55; -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 28px; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }
h1, h2, h3, h4 { margin: 0; line-height: 1.06; letter-spacing: -0.032em; font-weight: 600; }
p { margin: 0; }
code { font-family: var(--mono); font-size: .88em; }
::selection { background: rgba(47, 109, 246, .16); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 9px; cursor: pointer; white-space: nowrap;
  height: 46px; padding: 0 22px; border-radius: 10px; font-size: 15px; font-weight: 600;
  border: 1px solid transparent; transition: background .12s, border-color .12s, color .12s, transform .12s;
}
.btn-sm { height: 32px; padding: 0 15px; border-radius: 8px; font-size: 13.5px; }
.btn-lg { height: 46px; }
.btn-ink { background: var(--ink); color: #fff; }
.btn-ink:hover { background: var(--ink-hover); color: #fff; }
.btn-outline { background: var(--panel); color: var(--fg); border-color: var(--border-2); }
.btn-outline:hover { border-color: #b6bcc7; color: var(--fg); }
.btn-light { background: var(--panel); color: var(--ink); }
.btn-light:hover { background: #e8eaee; color: var(--ink); }
.btn-ondark { background: transparent; color: #fff; border-color: rgba(255, 255, 255, .22); }
.btn-ondark:hover { border-color: rgba(255, 255, 255, .5); color: #fff; }

/* Nav */
.nav {
  position: sticky; top: 0; z-index: 50;
  background: rgba(255, 255, 255, .78); backdrop-filter: saturate(1.6) blur(18px);
  border-bottom: 1px solid var(--hair);
}
.nav-inner { height: 60px; display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--fg); font-size: 16.5px; font-weight: 600; letter-spacing: -0.02em; }
.logo { display: inline-flex; width: 22px; height: 22px; color: var(--accent); }
.logo svg { width: 100%; height: 100%; }
.nav-links { display: flex; align-items: center; gap: 26px; }
.nav-links a { color: var(--muted); font-size: 14px; font-weight: 500; }
.nav-links a:hover { color: var(--fg); }
.nav-links a.btn { color: #fff; }

/* Hero */
.hero { padding: 96px 0 0; }
.hero-copy { max-width: 860px; }
.pill {
  display: inline-flex; align-items: center; gap: 9px; padding: 5px 12px 5px 9px; margin-bottom: 30px;
  border-radius: 999px; border: 1px solid var(--border); background: var(--surface);
  font-size: 12.5px; font-weight: 600; color: var(--icon);
}
.pill .dot, .stat .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--ok); }
.hero h1 { font-size: clamp(42px, 6.2vw, 76px); line-height: 1.02; letter-spacing: -0.04em; }
.lede { font-size: clamp(18px, 2.2vw, 21px); line-height: 1.5; color: var(--muted); margin-top: 26px; max-width: 60ch; }
.cta { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 34px; }
.hero-note { margin-top: 20px; color: var(--faint); font-size: 13.5px; }

/* Live editor window */
.window {
  margin-top: 64px; border-radius: 16px; border: 1px solid var(--border); background: var(--panel); overflow: hidden;
  box-shadow: 0 1px 2px rgba(11, 13, 18, .04), 0 30px 80px rgba(11, 13, 18, .13);
}
.window-bar { display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 14px; border-bottom: 1px solid var(--hair); background: var(--surface); }
.wdot { width: 10px; height: 10px; border-radius: 50%; background: var(--border); }
.window-title { margin-left: 10px; color: var(--faint); font-size: 12px; font-weight: 600; }
.window iframe { display: block; width: 100%; height: 660px; border: 0; background: var(--panel); }

/* Stat strip */
.stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 1px; margin-top: 64px; border-top: 1px solid var(--hair); border-bottom: 1px solid var(--hair); background: var(--hair); }
.stat { background: var(--panel); padding: 26px 4px 26px 22px; }
.stat:first-child { padding-left: 0; }
.stat b { display: block; font-size: 28px; font-weight: 600; letter-spacing: -0.035em; font-variant-numeric: tabular-nums; }
.stat span { display: block; font-size: 13px; color: var(--muted); margin-top: 4px; }

/* Sections */
.section { padding: 110px 0; }
.section.alt { background: var(--surface); border-top: 1px solid var(--hair); border-bottom: 1px solid var(--hair); }
.eyebrow { font-family: var(--mono); font-size: 12px; letter-spacing: .14em; text-transform: uppercase; color: var(--accent); font-weight: 600; }
.section h2 { font-size: clamp(30px, 4vw, 44px); margin-top: 16px; }
.section-lede { font-size: 18px; color: var(--muted); margin-top: 18px; max-width: 64ch; }

/* Feature grid */
/* Six panes in three equal columns is two tidy rows of three: every cell the
   same size says every claim carries the same weight, so none of them lead.
   A six-track grid instead, each row opening with a wider pane — 3+3 is a
   table, 4+2 has a subject and a footnote. */
.feature-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 1px; margin-top: 56px; background: var(--hair); border: 1px solid var(--hair); border-radius: 18px; overflow: hidden; }
.feature-grid > :nth-child(3n+1) { grid-column: span 2; }
.feature-grid > :nth-child(3n+2) { grid-column: span 2; }
.feature-grid > :nth-child(3n+3) { grid-column: span 2; }
@media (min-width: 981px) {
  .feature-grid > :nth-child(1) { grid-column: span 3; }
  .feature-grid > :nth-child(2) { grid-column: span 3; }
  .feature-grid > :nth-child(3) { grid-column: span 2; }
  .feature-grid > :nth-child(4) { grid-column: span 2; }
  .feature-grid > :nth-child(5) { grid-column: span 2; }
  .feature-grid > :nth-child(6) { grid-column: span 6; }
}
.feature { background: var(--panel); padding: 34px 30px 36px; }
.ficon { display: inline-flex; width: 34px; height: 34px; align-items: center; justify-content: center; color: var(--fg); margin-bottom: 22px; }
.ficon svg { width: 24px; height: 24px; }
.feature h3 { font-size: 19px; letter-spacing: -0.02em; }
.feature p { color: var(--muted); font-size: 15px; margin-top: 10px; }

/* What works checklists */
.today-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 40px; flex-wrap: wrap; }
.today-sub { color: var(--muted); font-size: 16px; max-width: 46ch; }
/* Auto-fit rather than a fixed three: the list grew a fourth column when
   pivots and charts shipped, and a hard-coded count silently reflowed the last
   one onto a row of its own. */
.checks {
  display: grid; gap: 20px; margin-top: 48px;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}
.check-col { border: 1px solid var(--border); border-radius: 14px; background: var(--panel); padding: 28px 26px; }
.check-col h4 { font-size: 13px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--faint); }
.check-col ul { list-style: none; margin: 0; padding: 0; }
.check-col li { position: relative; padding: 11px 0 11px 26px; border-top: 1px solid var(--line); font-size: 15px; color: var(--fg); }
.check-col li::before {
  content: ""; position: absolute; left: 0; top: 15px; width: 13px; height: 9px;
  border-left: 2.4px solid var(--accent); border-bottom: 2.4px solid var(--accent);
  transform: rotate(-45deg);
}
.io-note { margin-top: 26px; font-size: 14.5px; color: var(--muted); }
.io-note b { color: var(--fg); font-weight: 600; }

/* Engine pipeline + hosts + code */
.pipeline { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 44px; }
.stage { padding: 10px 16px; border-radius: 9px; border: 1px solid var(--border); background: var(--panel); font-family: var(--mono); font-size: 13px; font-weight: 600; }
.stage.accent { border-color: var(--accent); background: rgba(47, 109, 246, .08); color: var(--accent); }
.arrow { color: #c9cfd9; }
.hosts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; margin-top: 44px; }
.host { border: 1px solid var(--border); border-radius: 14px; padding: 26px; background: var(--panel); }
.host h4 { font-size: 17px; }
.host p { color: var(--muted); font-size: 15px; margin-top: 9px; }
.code-card { margin-top: 44px; border: 1px solid var(--border); border-radius: 14px; overflow: hidden; background: var(--panel); }
.code-head { display: flex; align-items: center; justify-content: space-between; height: 42px; padding: 0 16px; border-bottom: 1px solid var(--hair); background: var(--surface); font-size: 12.5px; font-weight: 600; color: var(--muted); }
.code-crate { font-family: var(--mono); font-size: 11.5px; color: var(--faint); font-weight: 400; }
.code-card pre { margin: 0; padding: 26px; overflow-x: auto; font-family: var(--mono); font-size: 13.5px; line-height: 1.75; color: var(--fg); }
.code-card .k { color: var(--accent); } .code-card .s { color: #0a7c42; } .code-card .n { color: #8250df; } .code-card .c { color: var(--faint); }

/* Embed / SDK */
.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; margin-top: 48px; counter-reset: step; }
.step { position: relative; border: 1px solid var(--border); border-radius: 14px; padding: 26px 26px 28px; background: var(--panel); }
.step::before {
  counter-increment: step; content: counter(step);
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; border-radius: 8px; margin-bottom: 14px;
  background: var(--accent); color: #fff; font-family: var(--mono); font-size: 13px; font-weight: 600;
}
.step h4 { font-size: 16.5px; }
.step p { color: var(--muted); font-size: 14.5px; margin-top: 8px; }
.step pre {
  margin: 14px 0 0; padding: 12px 14px; border-radius: 10px; background: #0f1216;
  color: #d7dee9; font-family: var(--mono); font-size: 12.5px; line-height: 1.6; overflow-x: auto;
}
.step pre .c { color: #6b7686; } .step pre .s { color: #c3e88d; } .step pre .k { color: #c792ea; }
.embed-more { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 32px; }
.embed-note { margin-top: 22px; font-size: 15px; color: var(--muted); max-width: 74ch; }

/* Compare table */
.cmp { margin-top: 48px; border: 1px solid var(--border); border-radius: 14px; background: var(--panel); overflow: hidden; }
.cmp-row { display: grid; grid-template-columns: 1.5fr repeat(4, 1fr); border-top: 1px solid var(--line); }
.cmp-row:first-child { border-top: 0; }
.cmp-head { color: var(--faint); }
.cmp-head > div { padding: 18px 14px; font-size: 12.5px; font-weight: 600; color: var(--muted); text-align: center; }
.cmp-head .cmp-approach { text-align: left; padding: 18px 22px; font-size: 13px; color: var(--faint); letter-spacing: .06em; text-transform: uppercase; }
.cmp-row > div { padding: 20px 14px; text-align: center; font-size: 15px; font-weight: 600; }
.cmp-approach { text-align: left !important; padding: 20px 22px !important; }
.cmp-approach b { display: block; font-size: 15.5px; font-weight: 600; color: var(--fg); }
.cmp-approach span { display: block; font-size: 13px; color: var(--muted); margin-top: 3px; }
.cmp .yes { color: var(--fg); } .cmp .no { color: #c9cfd9; } .cmp .part { color: var(--muted); }
.cmp-hi { background: rgba(47, 109, 246, .05); }
.cmp-note { margin-top: 16px; font-size: 13px; color: var(--faint); max-width: 80ch; }

/* Roadmap */
.phases { margin-top: 52px; border-top: 1px solid var(--hair); }
.phase { display: grid; grid-template-columns: 150px 1fr 210px; gap: 28px; align-items: baseline; padding: 24px 0; border-bottom: 1px solid var(--hair); }
.phase-id { font-family: var(--mono); font-size: 13px; color: var(--faint); }
.phase-title { font-size: 19px; font-weight: 600; letter-spacing: -0.02em; color: var(--fg); }
.phase-detail { font-size: 15px; color: var(--muted); margin-top: 6px; }
.status { justify-self: start; display: inline-flex; align-items: center; gap: 8px; padding: 5px 12px; border-radius: 999px; border: 1px solid; font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.status .dot { width: 6px; height: 6px; border-radius: 50%; }
.status.done { color: var(--done); background: rgba(10, 124, 66, .08); border-color: rgba(10, 124, 66, .22); }
.status.done .dot { background: var(--done); }
.status.prog { color: #8a5a00; background: rgba(245, 158, 11, .10); border-color: rgba(245, 158, 11, .28); }
.status.prog .dot { background: #f59e0b; }
.status.next { color: var(--icon); background: var(--surface); border-color: var(--border); }
.status.next .dot { background: #c9cfd9; }

/* Dark CTA band */
.cta-band { padding: 110px 0; background: var(--ink); color: var(--on-ink); }
.cta-grid { display: grid; grid-template-columns: 1.15fr 1fr; gap: 60px; align-items: center; }
.cta-band h2 { font-size: clamp(32px, 4.4vw, 46px); color: var(--on-ink); }
.cta-band p { font-size: 18px; color: var(--on-ink-dim); margin-top: 20px; max-width: 46ch; }
.cta-band .cta { margin-top: 32px; }
.cta-band code { color: rgba(255, 255, 255, .9); }
.contrib { border: 1px solid rgba(255, 255, 255, .14); border-radius: 14px; padding: 26px; background: rgba(255, 255, 255, .04); }
.contrib h4 { font-size: 15px; color: #fff; }
.contrib p { font-size: 14.5px; color: rgba(255, 255, 255, .62); margin-top: 10px; }
.contrib-cmd { margin-top: 20px; padding: 14px 16px; border-radius: 10px; background: rgba(255, 255, 255, .06); font-family: var(--mono); font-size: 13px; color: rgba(255, 255, 255, .86); }

/* Footer */
.foot { padding: 56px 0 44px; border-top: 1px solid var(--hair); background: var(--panel); }
.foot-grid { display: grid; grid-template-columns: 1.4fr repeat(4, 1fr); gap: 36px; }
.foot .brand { font-size: 16px; }
.foot-tag { font-size: 14px; color: var(--muted); margin-top: 14px; max-width: 34ch; }
.foot-col { display: flex; flex-direction: column; gap: 10px; }
.foot-h { font-size: 12px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--faint); }
.foot-col a { font-size: 14.5px; color: var(--icon); }
.foot-col a:hover { color: var(--accent); }
.foot-bottom { display: flex; align-items: center; justify-content: space-between; gap: 20px; flex-wrap: wrap; margin-top: 44px; padding-top: 22px; border-top: 1px solid var(--hair); font-size: 13px; color: var(--faint); }

/* Responsive */
@media (max-width: 960px) {
  /* The comparison table is five columns of real content, so collapsing it to
     one would destroy the comparison — the whole point is reading across a row.
     It scrolls **inside its own frame** instead, which is what a wide table
     should do and what `overflow-x: clip` on the document would otherwise turn
     into silently cut-off cells.
     `.cmp` had `overflow: hidden` for its rounded corners; that has to become
     `auto` on this axis or the scroll it now needs cannot happen. */
  .cmp { overflow-x: auto; overflow-y: hidden; -webkit-overflow-scrolling: touch; }
  .cmp-row { min-width: 620px; }

  .feature-grid, .checks, .hosts, .steps, .cta-grid, .foot-grid { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .stat, .stat:first-child { padding: 22px; }
  .today-head { flex-direction: column; align-items: flex-start; gap: 12px; }
  .cmp { overflow-x: auto; } .cmp-row { min-width: 640px; }
  .phase { grid-template-columns: 1fr; gap: 8px; }
  .nav-links a:not(.btn) { display: none; }
  .hero { padding: 60px 0 0; }
  .window iframe { height: 420px; }
}

/* ── Nothing may widen the page ──────────────────────────────────────────────
   The landing page scrolled sideways on every phone: 763px of document in a
   390px viewport, because the `<pre>` blocks inside the step cards set their
   own width and the cards grew to fit.

   `overflow-x: auto` was already on those `<pre>`s and never engaged. A grid
   and flex item defaults to `min-width: auto`, which means "do not shrink below
   your content" — so the card widened, the row widened, and the scrollbar the
   `<pre>` was supposed to grow never had a reason to appear. Declaring the
   floor explicitly is what lets the overflow rule do its job.

   Applied to the items that actually contain code rather than globally: a blunt
   `* { min-width: 0 }` would also let genuinely fixed-width things collapse. */
/* Every grid and flex child, not a list of them.
   The first version of this rule named six selectors and missed `.doc`, so the
   two documentation pages went on being 706px and 756px wide inside a 390px
   phone — their sidebar layout *did* collapse to one column, and the column
   still refused to shrink below its content. Enumerating the subjects of a rule
   like this is how you ship the same bug twice. */
:where(.steps, .feature-grid, .cta-grid, .foot-grid, .hosts, .doc, .checks, .cmp-row) > * {
  min-width: 0;
}
.code-card, .host, .contrib, .step {
  min-width: 0;
}

/* Every `<pre>`, not the classed ones.
   The first attempt named `.step pre`, `.code-card pre` and `.contrib pre` —
   and the blocks actually forcing the page wide were bare `<pre>`s with no
   class at all, so none of the rules matched them. A rule that has to enumerate
   its subjects is one enumeration away from being wrong.
   `min-width: 0` above lets the container shrink; this is what it shrinks to. */
pre {
  overflow-x: auto;
  max-width: 100%;
}

/* A table will not shrink below its columns, and a documentation table has real
   columns — collapsing it to one would destroy the comparison it exists to
   make. So it scrolls inside itself. `display: block` is what makes a table a
   scroll container at all; `width: max-content` keeps the columns sizing to
   their content rather than collapsing to the new block width. */
.body table {
  display: block;
  overflow-x: auto;
  max-width: 100%;
}
.body table > * {
  width: max-content;
  min-width: 100%;
}

/* ── Dark ────────────────────────────────────────────────────────────────────
   The site was light-only while the editor has been theme-aware throughout —
   and the hero *embeds* that editor, so on a dark machine the page rendered
   white with a dark application sitting inside it.

   Only tokens are redefined; every rule above already reads them, which is what
   makes this a palette swap rather than a second stylesheet to keep in step.

   Not an inversion. `--panel` is lighter than `--bg` here and darker in light,
   because a raised surface catches more light than what it sits on — flipping
   the values literally would make every card a hole. `--ink` stays a dark band
   in both, because that section is deliberately dark, so it must not flip with
   everything else. */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1017;
    --fg: #e8eaef;
    --muted: #98a1b0;
    --faint: #6b7484;
    --icon: #aab2c0;
    --border: #232936;
    --border-2: #2b3240;
    --hair: #1e2430;
    --line: #171c25;
    --surface: #141922;
    --panel: #161b24;
    --accent: #5b8cff;
    --accent-hover: #7ba3ff;
    --ink: #1c2430;
    --ink-hover: #26303e;
    --ok: #34d17e;
    --done: #34d17e;
    --code-bg: #1c222d;
    --code-fg: #dfe3ea;
    /* Tinted toward the accent and the warning hue respectively, at the low
       saturation a dark ground needs — the light values are washes on white and
       become glare on black. */
    --note-bg: #131b2b;
    --note-warn-bg: #221a10;
  }
  /* Translucent white would frost the page back to light. */
  .nav { background: rgba(13, 16, 23, .78); }
  .btn-outline { background: var(--panel); }
  .btn-light { background: var(--fg); color: var(--bg); }
  .btn-light:hover { background: #fff; color: var(--bg); }
  /* A shadow is invisible on a dark ground; the window needs a rim. */
  .window { box-shadow: 0 1px 2px rgba(0, 0, 0, .5), 0 30px 80px rgba(0, 0, 0, .45); }
  ::selection { background: rgba(91, 140, 255, .28); }
}
