/* Shared styles for the content pages. index.html keeps its own inline styles.
   Night bluestone hero, limestone daylight body: the homepage's night-to-dawn, continued. */
:root {
  --sans: "Instrument Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --night: #0A1014; --night-2: #121C21; --night-3: #1A262C; --night-line: #2E3E46;
  --on-night: #E5ECEF; --on-night-2: #A9B8BE; --on-night-3: #7F8F96;
  --stone: #E6E4DE; --stone-2: #F2F0EB; --stone-line: #CDC8BE;
  --ink: #1F272B; --ink-2: #48535A;
  --copper: #CE6F42; --copper-hi: #E3854F; --copper-ink: #9A4A24; --on-copper: #160C06;
  --payments: #9E83C0; --platform: #6D9CBE; --data: #DCA544; --mobile: #88B065;
  --bad: #E0735A; --bad-ink: #A63D26; --good-ink: #4F7B36;
  --gutter: clamp(16px, 5vw, 64px);
  --max: 1160px;
}
* { box-sizing: border-box; }
html { background: var(--night); }
body { margin: 0; color: var(--ink); background: var(--stone); font: 400 18px/1.6 var(--sans); -webkit-font-smoothing: antialiased; }
img { max-width: 100%; height: auto; }
a { color: var(--copper-ink); text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { color: var(--ink); }
:focus-visible { outline: 2px solid var(--copper); outline-offset: 3px; border-radius: 3px; }
h1, h2, h3 { margin: 0; font-weight: 600; text-wrap: balance; }
h1 { font-size: clamp(2.6rem, 5.6vw, 4.4rem); line-height: .98; letter-spacing: -0.045em; }
h2 { font-size: clamp(1.9rem, 3.4vw, 2.75rem); line-height: 1.04; letter-spacing: -0.035em; }
h3 { font-size: 1.25rem; line-height: 1.25; letter-spacing: -0.015em; }
p, ul, ol, dl, figure { margin: 0; }
p + p { margin-top: 14px; }
strong { font-weight: 600; }
code { font: 500 .86em var(--mono); }
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---- Chrome ---- */
.skip { position: absolute; left: -999px; }
.skip:focus { left: 16px; top: 16px; z-index: 20; background: var(--night-2); color: var(--on-night); padding: 8px 12px; }
.top { background: var(--night); color: var(--on-night); padding-top: env(safe-area-inset-top, 0px); }
.top .in { max-width: var(--max); margin: 0 auto; display: flex; flex-wrap: wrap; align-items: center; gap: 10px 28px; min-height: 72px; padding: 10px var(--gutter); box-sizing: content-box; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 600; font-size: 17px; text-decoration: none; color: inherit; }
.logo { width: 22px; height: 24px; flex: none; }
.top nav ul { display: flex; flex-wrap: wrap; gap: 4px 22px; list-style: none; margin: 0; padding: 0; }
.top nav a { color: var(--on-night-2); text-decoration: none; font-size: 15px; }
.top nav a:hover, .top nav a[aria-current="page"] { color: var(--on-night); }
.top nav a[aria-current="page"] { box-shadow: 0 2px 0 var(--copper); }
.top .btn { margin-left: auto; padding: 12px 22px; font-size: 14px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; text-decoration: none; cursor: pointer;
  background: var(--copper); color: var(--on-copper); font: 600 16px/1 var(--sans);
  padding: 17px 32px; border: 0; border-radius: 7px; clip-path: polygon(0 0, 100% 0, 96% 100%, 4% 100%);
}
.btn:hover { background: var(--copper-hi); color: var(--on-copper); }
.btn:focus-visible { outline: 2px solid var(--on-copper); outline-offset: -6px; }
.quiet { color: inherit; font-weight: 500; }

/* ---- Hero: night ---- */
.hero { background: var(--night); color: var(--on-night); padding: clamp(28px, 6vh, 72px) var(--gutter) clamp(56px, 10vh, 112px); }
.hero .in { max-width: var(--max); margin: 0 auto; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.08fr); gap: clamp(32px, 5vw, 72px); align-items: center; }
.hero .in.solo { grid-template-columns: minmax(0, 1fr); max-width: 860px; margin-left: max(0px, calc((100% - var(--max)) / 2)); }
.hero .lede { margin-top: 22px; font-size: clamp(18px, 1.7vw, 21px); line-height: 1.5; color: var(--on-night-2); max-width: 42ch; }
.hero .row { margin-top: 30px; display: flex; flex-wrap: wrap; align-items: center; gap: 14px 24px; }
.hero .row .quiet { color: var(--on-night-2); }
.hero .row .quiet:hover { color: var(--on-night); }
.crumbs { margin-bottom: 28px; font-size: 14px; color: var(--on-night-3); }
.crumbs ol { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; padding: 0; margin: 0; }
.crumbs li + li::before { content: "/"; margin-right: 6px; opacity: .6; }
.crumbs a { color: var(--on-night-3); }
.crumbs a:hover { color: var(--on-night); }

/* ---- Body: limestone ---- */
.band { padding: clamp(64px, 11vh, 120px) var(--gutter); }
.band + .band { padding-top: 0; }
.band > .in { max-width: var(--max); margin: 0 auto; }
.intro { max-width: 720px; }
.intro p { margin-top: 18px; color: var(--ink-2); font-size: 19px; max-width: 60ch; }

/* A claim beside its proof. Every second one flips. */
.claim { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: clamp(28px, 5vw, 72px); align-items: center; }
.claim + .claim { margin-top: clamp(72px, 12vh, 128px); }
.claim.flip > :first-child { order: 2; }
.claim.flip { grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); }
.claim .text > p, .claim .text > ul { margin-top: 16px; color: var(--ink-2); max-width: 52ch; }
.claim .text h2 + p { margin-top: 20px; }
.claim .text ul { padding-left: 1.1em; }
.claim .text li + li { margin-top: 8px; }
.claim .text li::marker { color: var(--copper); }

.shot { position: relative; }
.shot .frame { border-radius: 10px; overflow: hidden; background: var(--night-2); border: 1px solid #0003; box-shadow: 0 24px 60px -24px rgba(22, 34, 40, .55); }
.shot .bar { display: flex; gap: 6px; padding: 10px 12px; background: var(--night); }
.shot .bar i { width: 9px; height: 9px; border-radius: 50%; background: var(--night-line); }
.shot img { display: block; width: 100%; }
.shot figcaption { margin-top: 12px; font-size: 14px; color: var(--ink-2); }
.hero .shot figcaption { color: var(--on-night-3); }

/* Facts laid out as a definition list, two columns */
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); gap: 30px clamp(28px, 4vw, 56px); margin-top: 40px; }
.facts div { border-top: 2px solid var(--ink); padding-top: 14px; }
.facts dt { font-weight: 600; font-size: 18px; }
.facts dd { margin: 6px 0 0; color: var(--ink-2); font-size: 16px; }

/* Comparison tables */
.table-scroll { overflow-x: auto; margin-top: 36px; }
table { border-collapse: separate; border-spacing: 0; width: 100%; min-width: 620px; font-size: 16px; }
th, td { text-align: left; vertical-align: top; padding: 14px 16px; border-bottom: 1px solid var(--stone-line); }
thead th { font-weight: 600; font-size: 15px; color: var(--ink-2); border-bottom: 2px solid var(--ink); }
tbody th { font-weight: 500; }
/* The Keystone column is a raised slab */
th.us, td.us { background: var(--night); color: var(--on-night); border-bottom-color: var(--night-line); }
thead th.us { color: var(--on-night); border-bottom: 2px solid var(--copper); border-radius: 8px 8px 0 0; }
tbody tr:last-child td.us { border-radius: 0 0 8px 8px; border-bottom: 0; }
.yes { font-weight: 500; }
td.us.yes::before { content: ""; display: inline-block; width: 9px; height: 10px; margin-right: 8px; background: var(--copper); clip-path: polygon(0 0, 100% 0, 78% 100%, 22% 100%); }
td.no { color: var(--bad-ink); }
.source { margin-top: 16px; font-size: 14px; color: var(--ink-2); }

.pick { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); gap: clamp(24px, 4vw, 48px); margin-top: 36px; }
.pick section { padding-top: 16px; border-top: 2px solid var(--stone-line); }
.pick section.ours { border-top-color: var(--copper); }
.pick ul { margin-top: 12px; padding-left: 1.1em; color: var(--ink-2); }
.pick li + li { margin-top: 6px; }

details { border-top: 1px solid var(--stone-line); padding: 18px 0; }
details:last-of-type { border-bottom: 1px solid var(--stone-line); }
summary { cursor: pointer; font-weight: 600; font-size: 19px; }
details p { margin-top: 10px; color: var(--ink-2); max-width: 64ch; }
.faq { max-width: 780px; margin-top: 28px; }

/* Long-form reading (C4 guide) */
.prose { max-width: 700px; }
.prose h2 { margin-top: 72px; }
.prose h2:first-child { margin-top: 0; }
.prose h3 { margin-top: 36px; }
.prose p, .prose ul { margin-top: 16px; color: var(--ink-2); }
.prose ul { padding-left: 1.1em; }
.prose li + li { margin-top: 8px; }
.prose li::marker { color: var(--copper); }
.prose strong { color: var(--ink); }

/* ---- Closing call to action: back to night ---- */
.close { background: var(--night); color: var(--on-night); padding: clamp(72px, 13vh, 140px) var(--gutter); }
.close .in { max-width: var(--max); margin: 0 auto; display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 40px clamp(32px, 6vw, 96px); align-items: end; }
.close h2 { font-size: clamp(2.4rem, 5.4vw, 4.2rem); line-height: .98; letter-spacing: -0.045em; }
.close p { color: var(--on-night-2); font-size: 18px; max-width: 44ch; }
.close .row { margin-top: 26px; display: flex; flex-wrap: wrap; gap: 14px 24px; align-items: center; }
.close .addr { color: var(--on-night-2); font-size: 15px; }

.foot { background: var(--night); color: var(--on-night-3); border-top: 1px solid var(--night-line); padding: 36px var(--gutter) calc(36px + env(safe-area-inset-bottom, 0px)); font-size: 14px; }
.foot .in { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr)); gap: 28px; max-width: var(--max); margin: 0 auto; }
.foot .brand { color: var(--on-night); }
.foot p { margin-top: 8px; }
.foot h2 { font-size: 14px; letter-spacing: 0; margin: 0 0 10px; color: var(--on-night); }
.foot ul { list-style: none; padding: 0; margin: 0; }
.foot li + li { margin-top: 6px; }
.foot a { color: var(--on-night-3); text-decoration: none; }
.foot a:hover { color: var(--on-night); }

/* ---- Demos (driven by site.js) ---- */
.demo { background: var(--night-2); border: 1px solid var(--night-line); border-radius: 14px; padding: clamp(16px, 2.4vw, 24px); color: var(--on-night); box-shadow: 0 30px 80px -30px #000; }
.band .demo { box-shadow: 0 30px 70px -30px rgba(10, 16, 20, .7); }
.demo-title { font-size: 15px; font-weight: 600; color: var(--on-night-2); margin-bottom: 14px; }
.demo-note { margin-top: 14px; font-size: 15px; color: var(--on-night-2); min-height: 1.6em; }
.demo-note b { color: var(--on-night); font-weight: 600; }
.demo input[type="text"] {
  font: 500 16px var(--mono); color: var(--on-night); background: var(--night); width: 100%;
  border: 1px solid var(--night-line); border-radius: 7px; padding: 11px 12px;
}
.demo input[type="text"]:focus-visible { outline: 2px solid var(--copper); outline-offset: 1px; }
.demo label { font-size: 14px; font-weight: 600; }

/* Segmented switch built from real radio buttons */
.seg { display: inline-flex; border: 1px solid var(--night-line); border-radius: 8px; padding: 3px; margin: 0; gap: 2px; background: var(--night); }
.seg legend { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.seg label { position: relative; font: 600 14px var(--sans); color: var(--on-night-2); padding: 8px 14px; border-radius: 6px; cursor: pointer; }
.seg input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.seg label:has(input:checked) { background: var(--night-3); color: var(--on-night); box-shadow: inset 0 -2px 0 var(--copper); }
.seg label:has(input:focus-visible) { outline: 2px solid var(--copper); outline-offset: 1px; }

/* Rename demo */
.rn-controls { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 14px; align-items: end; }
.rn-controls label[for] { grid-column: 1 / -1; }
.copies { list-style: none; padding: 0; margin: 18px 0 0; display: grid; gap: 10px; }
.copy { display: grid; grid-template-columns: 1fr auto; gap: 8px 12px; align-items: center; padding: 12px 14px; border-radius: 9px; background: var(--night-3); border-left: 3px solid var(--team); transition: background-color .5s; }
.copy .where { font-size: 13.5px; color: var(--on-night-2); display: flex; align-items: center; gap: 8px; }
.copy .mini { grid-column: 1 / -1; display: flex; align-items: center; gap: 0; font: 500 13.5px var(--mono); min-width: 0; }
.copy .box { padding: 6px 10px; border: 1px solid var(--night-line); border-radius: 5px; background: var(--night-2); white-space: nowrap; }
.copy .db { border-color: var(--team); overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.copy .line { flex: 0 0 34px; height: 1px; background: var(--on-night-3); position: relative; }
.copy .line::after { content: ""; position: absolute; right: -1px; top: -4px; border: 4.5px solid transparent; border-left: 6px solid var(--on-night-3); border-right: 0; }
.copy .state { grid-row: 1; grid-column: 2; font-size: 12.5px; font-weight: 600; padding: 3px 8px; border-radius: 20px; color: var(--mobile); background: #88B0651f; white-space: nowrap; }
.copy.stale .state { color: var(--bad); background: #E0735A22; }
.copy.stale .db { text-decoration: line-through; text-decoration-color: var(--bad); color: var(--on-night-2); }
.copy.flash { background: #CE6F4238; transition: none; }

/* Simulation toy */
.sim svg { display: block; width: 100%; height: auto; }
.sim .node rect { fill: var(--night-3); stroke: var(--night-line); stroke-width: 1.5; }
.sim .node text { fill: var(--on-night); font: 600 13px var(--sans); }
.sim .node .sub { fill: var(--on-night-3); font: 500 10px var(--mono); }
.sim .wire { stroke: var(--night-line); stroke-width: 2; fill: none; }
.sim .pg rect.body { transition: stroke .3s; }
.sim .pg.hot rect.body { stroke: var(--bad); }
.sim .replica { transition: opacity .3s; }
.sim-controls { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px 20px; align-items: center; margin-top: 10px; }
.sim-controls .rate { display: grid; gap: 6px; }
.sim-controls .rate span { font: 500 14px var(--mono); color: var(--on-night-2); }
.sim-controls input[type="range"] { width: 100%; accent-color: var(--copper); }
.check { display: inline-flex; gap: 8px; align-items: center; font-size: 14px; font-weight: 600; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--copper); margin: 0; }
.sim-out { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-top: 16px; }
.sim-out div { background: var(--night); border-radius: 8px; padding: 10px 12px; }
.sim-out dt { font-size: 12.5px; color: var(--on-night-3); }
.sim-out dd { margin: 2px 0 0; font: 600 20px var(--sans); letter-spacing: -0.02em; }
.sim-out .bad { color: var(--bad); }
.trace { margin-top: 12px; font: 500 12.5px/1.5 var(--mono); color: var(--on-night-2); background: var(--night); border-radius: 8px; padding: 10px 12px; min-height: 3.2em; }
.trace b { color: var(--bad); font-weight: 600; }
.trace .ok { color: var(--mobile); }

/* C4 zoom */
.c4-steps { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; padding: 0; margin: 0 0 14px; }
.c4-steps button {
  font: 600 14px var(--sans); color: var(--on-night-2); background: var(--night); cursor: pointer;
  border: 1px solid var(--night-line); border-radius: 7px; padding: 8px 12px; display: inline-flex; gap: 8px; align-items: center;
}
.c4-steps button span { font: 600 12px var(--mono); width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; border: 1px solid var(--night-line); }
.c4-steps button[aria-pressed="true"] { color: var(--on-night); border-color: var(--copper); }
.c4-steps button[aria-pressed="true"] span { background: var(--copper); border-color: var(--copper); color: var(--on-copper); }
.c4 svg { display: block; width: 100%; height: auto; background: var(--night); border-radius: 9px; }
.c4 .sys rect, .c4 .ctr rect, .c4 .cmp rect { fill: var(--night-3); stroke: var(--on-night-3); }
.c4 .ctr rect { fill: var(--night-2); }
/* Borders stay 1px at every zoom level */
.c4 rect { vector-effect: non-scaling-stroke; stroke-width: 1px; }
.c4 rect.frame { fill: none; stroke: var(--platform); stroke-dasharray: 6 4; stroke-width: 1.5px; }
.c4 text { fill: var(--on-night); font-family: var(--sans); font-weight: 600; }
.c4 .dim { fill: var(--on-night-3); font-weight: 500; }
.c4 .code { fill: var(--on-night-2); font-family: var(--mono); font-weight: 500; }
.c4 .edge { stroke: var(--on-night-3); fill: none; }
.c4 .lvl { transition: opacity .5s; }
.c4-caption { margin-top: 14px; min-height: 3.2em; font-size: 15.5px; color: var(--on-night-2); }
.c4-caption b { color: var(--on-night); }

/* Terminal (self-hosting hero) */
.term { background: #05090B; border: 1px solid var(--night-line); border-radius: 12px; overflow: hidden; box-shadow: 0 30px 80px -30px #000; }
.term .bar { display: flex; gap: 6px; padding: 11px 14px; border-bottom: 1px solid var(--night-line); }
.term .bar i { width: 9px; height: 9px; border-radius: 50%; background: var(--night-line); }
.term pre { margin: 0; padding: 18px 20px 22px; overflow-x: auto; font: 500 14px/1.75 var(--mono); color: var(--on-night-2); }
.term .p { color: var(--copper-hi); }
.term .c { color: var(--on-night); }
.term .ok { color: var(--mobile); }
.term .dim { color: var(--on-night-3); }

@media (max-width: 860px) {
  .hero .in, .claim, .close .in { grid-template-columns: minmax(0, 1fr); }
  .claim.flip { grid-template-columns: minmax(0, 1fr); }
  .claim.flip > :first-child { order: 0; }
  .top .btn { margin-left: 0; }
  .sim-out dd { font-size: 17px; }
}
@media (max-width: 480px) {
  .rn-controls { grid-template-columns: minmax(0, 1fr); }
  .sim-controls { grid-template-columns: minmax(0, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
  .copy, .c4 .lvl, .sim .pg rect.body, .sim .replica { transition: none; }
}

/* Impact demo */
.impact svg { display: block; width: 100%; height: auto; }
.imp-node { cursor: pointer; outline: none; }
.imp-node rect:first-child { fill: var(--night-3); stroke: var(--night-line); stroke-width: 1.5; transition: fill .3s, stroke .3s, opacity .3s; }
.imp-node text { fill: var(--on-night); font: 600 14.5px var(--sans); transition: opacity .3s; }
.imp-node .hop { fill: var(--on-night-3); font: 500 11px var(--sans); }
.imp-node:hover rect:first-child, .imp-node:focus-visible rect:first-child { stroke: var(--on-night-3); }
.imp-node:focus-visible rect:first-child { stroke: var(--copper); stroke-width: 2; }
.imp-node.failed rect:first-child { fill: #3A1D17; stroke: var(--bad); }
.imp-node.failed .hop { fill: var(--bad); }
.imp-node.hit rect:first-child { fill: #2E2415; stroke: var(--data); }
.imp-node.hit .hop { fill: var(--data); }
.imp-node.dim { opacity: .45; }
.imp-edge { stroke: var(--night-line); stroke-width: 1.5; fill: none; transition: stroke .3s; }
.imp-edge.hit { stroke: var(--data); stroke-width: 2; }
@media (prefers-reduced-motion: reduce) { .imp-node rect:first-child, .imp-node text, .imp-edge { transition: none; } }
