/* Tokens, reset, typography, and everything outside the playground.
   Loaded first: later sheets rely on the custom properties declared here. */

:root {
  --paper: #F3F4F1;
  --panel: #E8EAE3;
  --panel-2: #DFE2DA;
  --card-bg: #FFFFFF;
  --ink: #111618;
  --ink-soft: #2D3739;
  --slate: #5A6669;
  --slate-2: #7E8C8F;
  --rule: #CCD1C7;
  --rule-strong: #A6AEA0;
  --kept: #1D6B57;
  --kept-bg: #E3EFEA;
  --dropped: #9E3E26;
  --dropped-bg: #F7E5DF;
  --amber: #876211;
  --amber-bg: #F8EED9;
  --f-ui: "Archivo", "Helvetica Neue", Arial, sans-serif;
  --f-body: "Source Serif 4", Georgia, serif;
  --f-mono: "JetBrains Mono", ui-monospace, Consolas, monospace;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.08), 0 2px 4px -1px rgba(0,0,0,0.04);
  --radius: 6px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0E1214; --panel: #151B1D; --panel-2: #1D2427;
    --card-bg: #14191C;
    --ink: #E2E5DF; --ink-soft: #BFC6BE; --slate: #8F9998; --slate-2: #757E7C;
    --rule: #252D30; --rule-strong: #384245;
    --kept: #56AE92; --kept-bg: #112D27;
    --dropped: #D1785E; --dropped-bg: #321D17;
    --amber: #D1A447; --amber-bg: #2E230E;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.4);
  }
}
:root[data-theme="dark"] {
  --paper: #0E1214; --panel: #151B1D; --panel-2: #1D2427;
  --card-bg: #14191C;
  --ink: #E2E5DF; --ink-soft: #BFC6BE; --slate: #8F9998; --slate-2: #757E7C;
  --rule: #252D30; --rule-strong: #384245;
  --kept: #56AE92; --kept-bg: #112D27;
  --dropped: #D1785E; --dropped-bg: #321D17;
  --amber: #D1A447; --amber-bg: #2E230E;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.4);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 72px; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font-family: var(--f-body); font-size: 17px; line-height: 1.68;
  -webkit-font-smoothing: antialiased;
}
button, input, textarea, select { font-family: var(--f-ui); font-size: 14px; color: inherit; }
h1, h2, h3, h4 { font-family: var(--f-ui); margin: 0; text-wrap: balance; color: var(--ink); }
p { margin: 0; }
a { color: var(--kept); text-underline-offset: 3px; }
:focus-visible { outline: 2px solid var(--kept); outline-offset: 2px; }

/* The one content width on the page. Everything inside it lines up
   with everything else, and nothing sets a narrower cap of its own. */
/* Headings and prose wrap on their own sense rather than against a width
   cap: `balance` evens the lines of a short heading, `pretty` keeps a single
   word off the last line of a paragraph. Neither constrains the column, so
   both survive the container getting wider. */
h1, h2, h3, .shead h2, .hero h1 { text-wrap: balance; }
p, .deck, .hint, .lead, li { text-wrap: pretty; }

.wrap { width: min(1460px, 95vw); margin: 0 auto; padding: 0 clamp(1.25rem, 4vw, 3rem); }
.col { margin: 0 auto; }
.col > p + p { margin-top: 1.15em; }

.label {
  display: inline-block;
  font-family: var(--f-ui); font-size: 11px; font-weight: 700;
  letter-spacing: .12em; text-transform: uppercase; color: var(--slate);
}
.mono { font-family: var(--f-mono); font-variant-numeric: tabular-nums; }

/* ---------------- Navigation ---------------- */
.nav { position: sticky; top: 0; z-index: 60; background: var(--paper); border-bottom: 1px solid var(--rule); backdrop-filter: blur(8px); }
.nav .wrap { display: flex; align-items: center; justify-content: space-between; gap: 1.5rem; height: 60px; }
.nav .brand { font-family: var(--f-ui); font-weight: 800; font-size: 15px; letter-spacing: -.02em; white-space: nowrap; color: var(--ink); }
.nav .links { display: flex; align-items: center; gap: 1.5rem; }
.nav .links a { font-family: var(--f-ui); font-size: 13px; font-weight: 600; color: var(--slate); text-decoration: none; white-space: nowrap; transition: color .15s ease; }
.nav .links a:hover { color: var(--ink); }
.nav .links a.cta { color: var(--kept); font-weight: 700; }
.tbtn { border: 1px solid var(--rule-strong); background: var(--panel); color: var(--ink); padding: .35rem .75rem; font-size: 12px; font-weight: 600; cursor: pointer; border-radius: var(--radius); transition: all .15s ease; }
.tbtn:hover { background: var(--panel-2); }
@media (max-width: 860px) { .nav .links a:not(.cta) { display: none; } }

/* ---------------- Sections & Typography ---------------- */
section { padding: clamp(3.5rem, 7vw, 6rem) 0; border-top: 1px solid var(--rule); }
#top { border-top: 0; }
.shead { text-align: center; margin: 0 auto clamp(2rem, 4vw, 3rem); }
.shead .label { color: var(--kept); background: var(--kept-bg); padding: .25rem .65rem; border-radius: 20px; }
.shead h2 { font-size: clamp(1.8rem, 4vw, 2.6rem); font-weight: 800; letter-spacing: -.03em; line-height: 1.15; margin-top: .85rem; }
.shead p { margin: 1rem auto 0; color: var(--slate); font-size: clamp(1rem, 1.8vw, 1.15rem); }
.section-title-left { text-align: left; margin: 2.75rem auto 1rem; }
h3 { font-size: 1.25rem; font-weight: 700; margin: 2.75rem 0 .9rem; text-align: left; }
.centered-heading { text-align: center; margin-left: auto; margin-right: auto; }

/* ---------------- Hero Section ---------------- */
.hero { text-align: center; padding: clamp(3.5rem, 8vw, 6.5rem) 0 clamp(2.5rem, 5vw, 3.5rem); }
.hero .label { color: var(--kept); background: var(--kept-bg); padding: .3rem .8rem; border-radius: 20px; font-size: 11.5px; }
.hero h1 { font-size: clamp(2.5rem, 7.5vw, 5rem); font-weight: 800; letter-spacing: -.04em; line-height: 1.02; margin: 1.25rem auto 0; }
.deck { font-size: clamp(1.2rem, 2.4vw, 1.6rem); line-height: 1.45; margin: 1.6rem auto 0; color: var(--ink-soft); }
.deck b { color: var(--kept); font-weight: 700; }
.hero-note { margin: 1.35rem auto 0; color: var(--slate); font-size: 1.05rem; }
.hero .nextup { margin: 2.25rem auto 0; justify-content: center; text-align: left; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin: 2.5rem auto 0; }
.stat { background: var(--card-bg); border: 1px solid var(--rule); border-radius: var(--radius); padding: 1.35rem 1.25rem; text-align: center; box-shadow: var(--shadow-sm); }
.stat b { display: block; font-family: var(--f-ui); font-size: clamp(1.8rem, 3.5vw, 2.5rem); font-weight: 800; letter-spacing: -.03em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat span { display: block; margin-top: .45rem; font-size: 11px; }
.stat.good b { color: var(--kept); }
@media (max-width: 800px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 480px) {
  .stats { grid-template-columns: 1fr; }
}

/* ---------------- Plain Words & Open Engineering Cards ---------------- */
.plain, .deepbox {
  background: var(--card-bg);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: clamp(1.25rem, 3vw, 1.85rem);
  margin: 2rem auto;
  box-shadow: var(--shadow-sm);
}
.plain {
  border-left: 4px solid var(--kept);
  background: var(--kept-bg);
}
.plain > .label {
  display: inline-block; margin-bottom: .6rem; color: var(--kept);
  font-weight: 800; font-size: 11px;
}
.plain p { font-size: 1.02rem; color: var(--ink-soft); }
.plain p + p { margin-top: .85rem; }
.plain ul { margin: .85rem 0 0; padding-left: 1.25rem; }
.plain li { font-size: 1rem; color: var(--ink-soft); margin-bottom: .5rem; line-height: 1.55; }

.deepbox {
  border-left: 4px solid var(--slate);
  background: var(--panel);
}
.deepbox-header {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding-bottom: .85rem; margin-bottom: 1.15rem; border-bottom: 1px solid var(--rule);
}
.deepbox-title {
  font-family: var(--f-ui); font-size: 13.5px; font-weight: 800;
  letter-spacing: .04em; color: var(--ink); text-transform: uppercase;
}
.deepbox-sub {
  font-family: var(--f-mono); font-size: 11.5px; color: var(--slate); font-weight: 500;
}
.deepbox .dbody { font-size: .98rem; }
.deepbox p { font-size: .98rem; color: var(--ink-soft); }
.deepbox p + p { margin-top: .85rem; }
.deepbox ul { margin: .85rem 0 0; padding-left: 1.25rem; }
.deepbox li { font-size: .96rem; color: var(--ink-soft); margin-bottom: .5rem; line-height: 1.55; }
.deepbox h4 { font-family: var(--f-ui); font-size: 1.05rem; font-weight: 700; margin: 1.35rem 0 .45rem; color: var(--ink); }
.deepbox h4:first-child { margin-top: 0; }
.deepbox .code { margin-top: .85rem; }

/* ---------------- Component Grid / Fields ---------------- */
.fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr));
  gap: 1.25rem;
  margin: 2rem auto;
  }
.field {
  background: var(--card-bg);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 1.25rem 1.35rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: .5rem;
}
.field dt {
  font-family: var(--f-ui); font-weight: 700; font-size: 1rem; color: var(--ink);
  display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: .4rem;
}
.field dt small {
  font-family: var(--f-mono); font-size: 11px; font-weight: 500;
  color: var(--kept); background: var(--kept-bg); padding: .15rem .45rem; border-radius: 3px;
}
.field dd { margin: 0; color: var(--ink-soft); font-size: .96rem; line-height: 1.55; }

/* ---------------- Use Cases Grid ---------------- */
.cases {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr));
  gap: 1.5rem;
  margin: 2.25rem auto 0;
  }
.case {
  background: var(--card-bg);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 1.5rem 1.4rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  position: relative;
}
.case-num {
  font-family: var(--f-mono); font-size: 13px; font-weight: 800;
  color: var(--kept); background: var(--kept-bg);
  width: 32px; height: 32px; display: grid; place-items: center; border-radius: 4px;
  margin-bottom: 1rem;
}
.case h3 { margin: 0 0 .5rem; font-size: 1.15rem; font-weight: 700; }
.case p { color: var(--ink-soft); font-size: .96rem; line-height: 1.55; flex: 1; }
.case .who {
  display: block; margin-top: 1rem; padding-top: .75rem; border-top: 1px dashed var(--rule);
  font-family: var(--f-mono); font-size: 11px; color: var(--slate);
}

/* ---------------- Guided Path ---------------- */
.path {
  list-style: none; margin: 2rem auto 0; padding: 0; display: flex; flex-direction: column; gap: 1rem;
}
.path li {
  background: var(--card-bg);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 1.15rem 1.35rem;
  box-shadow: var(--shadow-sm);
  display: grid;
  grid-template-columns: 2.5rem 1fr auto;
  gap: 1.25rem;
  align-items: center;
}
.path .pn {
  font-family: var(--f-mono); font-size: 14px; font-weight: 800;
  color: var(--kept); background: var(--kept-bg);
  width: 32px; height: 32px; display: grid; place-items: center; border-radius: 4px;
}
.path a {
  font-family: var(--f-ui); font-weight: 700; font-size: 1.05rem;
  color: var(--ink); text-decoration: none; border-bottom: 1px solid transparent;
}
.path a:hover { color: var(--kept); border-bottom-color: var(--kept); }
.path .pd {
  display: block; font-family: var(--f-body); font-size: .95rem;
  color: var(--slate); margin-top: .25rem; line-height: 1.45;
}
.path .mins {
  font-family: var(--f-mono); font-size: 11.5px; font-weight: 600;
  color: var(--slate); background: var(--panel); padding: .25rem .55rem; border-radius: 4px; white-space: nowrap;
}
@media (max-width: 680px) {
  .path li { grid-template-columns: 2.2rem 1fr; gap: .75rem; }
  .path .mins { grid-column: 2; justify-self: start; }
}

/* ---------------- FAQ ----------------
   Fourteen answers laid out flat is a wall, and the part a reader scans is
   the questions. Closed, the section is exactly that list.

   Single file rather than two columns: opening an item in one column shoves
   the other one down, so the thing you were not reading moves. */
.faq {
  display: flex;
  flex-direction: column;
  gap: .7rem;
  margin: 2.25rem auto 0;
}
.faq-item {
  background: var(--card-bg);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.faq-item.open { border-color: var(--kept); }
.faq-q {
  display: flex; align-items: center; gap: .6rem; width: 100%;
  padding: 1.1rem 1.3rem; border: 0; background: none;
  font-family: var(--f-ui); font-weight: 700; font-size: 1.08rem;
  color: var(--ink); line-height: 1.35; text-align: left; cursor: pointer;
}
.faq-q:hover { color: var(--kept); }
.faq-q:focus-visible { outline: 2px solid var(--kept); outline-offset: -3px; }
.faq-item.open .faq-q { color: var(--kept); }
.faq-t { flex: 1; }
.faq-q::before {
  content: "Q";
  font-family: var(--f-mono); font-size: 11px; font-weight: 800;
  color: var(--kept); background: var(--kept-bg);
  padding: .15rem .45rem; border-radius: 3px; flex: none;
}
.faq .ans {
  padding: 0 1.3rem 1.35rem 2.85rem;
  color: var(--ink-soft); font-size: .96rem; line-height: 1.6;
}
.faq .ans[hidden] { display: none; }
.faq .ans p + p { margin-top: .75rem; }
.faq .ans ul { margin: .65rem 0 0; padding-left: 1.2rem; }
.faq .ans li { margin-bottom: .35rem; }

/* ---------------- Figures & Diagrams ---------------- */
figure { margin: 2.5rem auto; }
.figbox {
  border: 1px solid var(--rule); background: var(--card-bg);
  border-radius: var(--radius); padding: clamp(1rem, 3vw, 2rem);
  overflow-x: auto; box-shadow: var(--shadow-sm);
}
figcaption {
  font-size: .9rem; color: var(--slate); margin-top: .9rem;
  text-align: center; margin-left: auto; margin-right: auto;
}
svg { display: block; max-width: 100%; height: auto; margin: 0 auto; }
.svg-label { font-family: var(--f-ui); font-size: 11px; font-weight: 700; letter-spacing: .1em; }
.svg-text { font-family: var(--f-ui); font-size: 13px; font-weight: 600; }
.svg-mono { font-family: var(--f-mono); font-size: 11px; }

/* ---------------- Code & Callouts ---------------- */
.codeblock { margin: 1.5rem auto; }
.codecap {
  font-family: var(--f-mono); font-size: 11px; letter-spacing: .06em;
  text-transform: uppercase; color: var(--slate); padding: .55rem .85rem;
  background: var(--panel-2); border: 1px solid var(--rule); border-bottom: 0;
  border-radius: var(--radius) var(--radius) 0 0;
}
.code {
  background: var(--panel); border: 1px solid var(--rule);
  font-family: var(--f-mono); font-size: 13px; line-height: 1.75;
  padding: 1.15rem 1.25rem; overflow-x: auto; margin: 0; tab-size: 2;
  border-radius: 0 0 var(--radius) var(--radius);
}
.code .c { color: var(--slate-2); }
.code .k { color: var(--kept); font-weight: 600; }
.code .s { color: var(--dropped); }
.sidenote { margin: .9rem auto 0; font-size: .92rem; color: var(--slate); text-align: center; }

.callout {
  border: 1px solid var(--dropped); border-left: 4px solid var(--dropped);
  background: var(--dropped-bg); border-radius: var(--radius);
  padding: 1.25rem 1.5rem; margin: 2rem auto; box-shadow: var(--shadow-sm);
}
.callout.good { border-color: var(--kept); background: var(--kept-bg); }
.callout p { font-size: .98rem; color: var(--ink-soft); }
.callout .label { display: block; margin-bottom: .45rem; color: var(--dropped); font-weight: 800; }
.callout.good .label { color: var(--kept); }

/* ---------------- Tables & Glossary ---------------- */
.tablewrap { overflow-x: auto; margin: 2rem auto; }
table {
  border-collapse: separate; border-spacing: 0; width: 100%; font-size: .95rem;
  background: var(--card-bg); border: 1px solid var(--rule); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); overflow: hidden;
}
th, td { text-align: left; padding: .85rem 1.15rem; border-bottom: 1px solid var(--rule); }
tr:last-child td { border-bottom: 0; }
th {
  font-family: var(--f-ui); font-size: 11px; font-weight: 700; letter-spacing: .12em;
  text-transform: uppercase; color: var(--slate); background: var(--panel);
}
td.m { font-family: var(--f-mono); font-size: 12.5px; white-space: nowrap; }

.gloss { border-bottom: 1px dotted var(--kept); cursor: help; position: relative; color: var(--kept); }
.gloss::after {
  content: attr(data-def); position: absolute; left: 0; top: calc(100% + 6px); z-index: 70;
  width: max-content; max-width: min(24rem, calc(100vw - 2.5rem));
  background: var(--ink); color: var(--paper);
  font-family: var(--f-ui); font-size: 12px; line-height: 1.45; padding: .65rem .85rem;
  border-radius: 4px; box-shadow: var(--shadow-md); pointer-events: none; display: none;
}
.gloss:hover::after, .gloss:focus::after { display: block; }
.gloss.flip::after { left: auto; right: 0; }

.gtable td:first-child { font-family: var(--f-ui); font-weight: 700; font-size: .95rem; }
.gtable td:first-child small { display: block; font-family: var(--f-mono); font-size: 10.5px; font-weight: 500; color: var(--slate-2); margin-top: .2rem; }
.gtable td:nth-child(2) { color: var(--ink-soft); }
.gtable td:last-child { font-size: .92rem; color: var(--slate); }
@media (max-width: 760px) {
  .gtable, .gtable tbody, .gtable tr, .gtable td { display: block; width: auto; min-width: 0; }
  .gtable thead { display: none; }
  .gtable tr { border-bottom: 1px solid var(--rule-strong); padding: .85rem 1rem; }
  .gtable td { border: 0; padding: .25rem 0; }
  .gtable td:nth-child(2)::before { content: "Plain words \2014 "; color: var(--slate-2); font-family: var(--f-mono); font-size: 10px; font-weight: 700; }
  .gtable td:last-child::before { content: "Precisely \2014 "; color: var(--slate-2); font-family: var(--f-mono); font-size: 10px; font-weight: 700; }
}

/* ---------------- Next-Step Strips ---------------- */
.nextup {
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
  margin: 2.5rem auto 0; padding: 1rem 1.35rem; border: 1px solid var(--rule); border-left: 4px solid var(--kept);
  background: var(--card-bg); border-radius: var(--radius);
  font-family: var(--f-ui); box-shadow: var(--shadow-sm);
}
.nextup > .label { flex: none; color: var(--kept); font-weight: 800; }
.nextup a { font-size: 1rem; font-weight: 700; color: var(--ink); text-decoration: none; border-bottom: 2px solid var(--kept); }
.nextup a:hover { color: var(--kept); }
.nextup .why { font-size: 13px; color: var(--slate); flex: 1 1 16rem; }

/* ---------------- Design Decisions Grid ---------------- */
.dd-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr));
  gap: 1.25rem; margin: 2rem auto; }
.dd-grid > div {
  background: var(--card-bg); border: 1px solid var(--rule); border-radius: var(--radius);
  padding: 1.25rem 1.35rem; box-shadow: var(--shadow-sm);
}
.dd-grid h4 { font-family: var(--f-ui); font-size: 1.05rem; font-weight: 700; margin: 0 0 .45rem; }
.dd-grid p { font-size: .95rem; color: var(--ink-soft); }
.dd-grid .mono {
  display: inline-block; margin-top: .65rem; font-size: 11.5px;
  color: var(--slate); background: var(--panel); padding: .2rem .5rem; border-radius: 3px;
}

/* A caret, so a closed thing reads as openable rather than as something that
   was cut off. Shared: the worker cards and the questions both use it. */
.chev {
  width: 7px; height: 7px; flex: none; margin-left: .1rem;
  border-right: 2px solid var(--slate); border-bottom: 2px solid var(--slate);
  transform: rotate(45deg); transition: transform .15s ease;
}
.faq-item.open .chev { transform: rotate(-135deg); border-color: var(--kept); }

/* ---------------- Visit count ----------------
   Bottom left, out of the way of everything the page asks you to do, and out
   of the way of the run view on the right. It is a fact about the page, not
   a control, so it does not behave like one: no hover state, no cursor. */
.visits {
  position: fixed; left: 1rem; bottom: 1rem; z-index: 40;
  display: flex; align-items: center; gap: .45rem;
  padding: .42rem .7rem .42rem .6rem;
  background: var(--card-bg); border: 1px solid var(--rule);
  border-radius: 999px; box-shadow: var(--shadow-sm);
  font-family: var(--f-mono); font-size: 11.5px; line-height: 1;
  color: var(--slate); user-select: none;
  backdrop-filter: blur(6px);
}
.visits svg {
  width: 13px; height: 13px; flex: none;
  fill: none; stroke: var(--slate); stroke-width: 1.7;
  stroke-linecap: round; stroke-linejoin: round;
}
.visits-n { font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; }
.visits-l { letter-spacing: .04em; text-transform: uppercase; font-size: 10px; }

@media (max-width: 560px) {
  /* On a phone the label is the first thing to go, and the badge sits above
     the browser's own bottom bar. */
  .visits { left: .65rem; bottom: .8rem; padding: .38rem .6rem; }
  .visits-l { display: none; }
}
