/* Text first: one moment per card, cream paper on dark marina blue; JSON examples on a marina panel. */
:root {
  --stage: #13212c;
  --stage-ink: #dcd5c6;
  --stage-soft: #8394a0;
  --paper: #f6eedf;
  --ink: #15242f;
  --ink-soft: #4f5a5f;
  --clay: #c9876a;
  --ochre: #d6ae6a;
  --chip: #1b2e3c;
  --line: #2c4252;
  --display: "Instrument Sans", "Helvetica Neue", Arial, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
  color-scheme: dark;
}
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--stage);
  color: var(--stage-ink);
  font: 16px/1.5 var(--display);
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.stage { max-width: 1400px; margin: 0 auto; padding-block: 28px 36px; display: grid; grid-template-columns: 190px minmax(0, 1fr); gap: 28px; align-items: start; }
.stage > .main { display: grid; gap: 18px; min-width: 0; }
.card {
  background: var(--paper);
  color: var(--ink);
  border-radius: 6px;
  min-height: min(62vh, 520px);
  padding: clamp(24px, 4vw, 56px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 18px;
  cursor: pointer;
}
.num { font: 500 13px/1 var(--mono); letter-spacing: .04em; color: var(--ink-soft); }
.title { margin: 0; font: 500 clamp(28px, 4.6vw, 48px)/1.1 var(--display); text-wrap: balance; max-width: 18ch; }
.text { margin: 0; font-size: clamp(17px, 2vw, 21px); line-height: 1.55; color: var(--ink-soft); max-width: 40ch; text-wrap: pretty; }
.text b { font-weight: 500; color: var(--ink); border-bottom: 2px solid var(--clay); }
.list { margin: 0; padding: 0; list-style: none; display: grid; gap: 10px; font-size: clamp(18px, 2.2vw, 24px); }
.list li { padding-left: 22px; position: relative; }
.list li::before { content: ""; position: absolute; left: 0; top: .55em; width: 9px; height: 9px; border-radius: 50%; background: var(--ochre); }

@media (prefers-reduced-motion: no-preference) {
  .card.enter .title { animation: fade .5s ease-out both; }
  .card.enter .text, .card.enter .list { animation: fade .5s .12s ease-out both; }
}
@keyframes fade { from { opacity: 0; transform: translateY(6px); } }

.terms { display: flex; flex-wrap: wrap; gap: 8px; min-height: 32px; }
.terms span { font: 500 13px var(--mono); padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); color: var(--stage-soft); }
.terms span.new { border-color: var(--ochre); color: var(--ochre); }

.nav { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.nav button {
  font: 500 15px var(--display);
  color: var(--paper);
  background: var(--chip);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 10px 20px;
  cursor: pointer;
}
#next { background: var(--paper); color: var(--ink); border-color: var(--paper); }
.nav button:disabled { opacity: .3; cursor: default; }
.nav button:focus-visible, .track button:focus-visible { outline: 2px solid var(--ochre); outline-offset: 2px; }

.track { position: relative; display: flex; justify-content: space-between; align-items: center; padding: 6px 2px; }
.track::before { content: ""; position: absolute; left: 0; right: 0; top: 50%; height: 1.5px; background: var(--line); }
.track .fill { position: absolute; left: 0; top: 50%; height: 1.5px; background: var(--stage-ink); transition: width .5s ease; }
.track button { position: relative; width: 11px; height: 11px; padding: 0; border-radius: 50%; border: 1.5px solid #3b5466; background: var(--stage); cursor: pointer; }
.track button.past { background: var(--stage-ink); border-color: var(--stage-ink); }
.track button.now { background: var(--ochre); border-color: var(--ochre); transform: scale(1.35); }

.stories { position: sticky; top: 24px; display: grid; gap: 2px; }
.navhead { display: block; font: 500 13px var(--mono); letter-spacing: .08em; color: var(--stage-soft); margin: 4px 10px 10px; text-decoration: none; }
.stories button { display: grid; grid-template-columns: 24px 1fr auto; align-items: baseline; gap: 6px; text-align: left;
  font: 500 14px var(--display); color: var(--stage-soft); background: none; border: 0; border-radius: 6px; padding: 7px 10px; cursor: pointer; }
.stories button:hover { color: var(--stage-ink); background: var(--chip); }
.stories .nn, .stories .nc { font: 500 11px var(--mono); color: #5d7383; }
.stories button.on { color: var(--ink); background: var(--paper); }
.stories button.on .nn, .stories button.on .nc { color: var(--ink-soft); }
.stories .navdec { display: block; margin-top: 12px; border: 1px solid var(--line); }
@media (max-width: 900px) {
  .stage { grid-template-columns: minmax(0, 1fr); }
  .stories { position: static; display: flex; overflow-x: auto; gap: 6px; padding-bottom: 4px; }
  .navhead { display: none; }
  .stories button { flex: none; grid-template-columns: auto auto; }
  .stories .nc { display: none; }
  .stories .navdec { margin-top: 0; }
}

.card .body { flex: 1; display: grid; grid-template-columns: minmax(0, 1fr); align-content: center; row-gap: 18px; }
.card.has-code .body { grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr); column-gap: 36px; }
.card .body > * { grid-column: 1; }
.card .side { grid-column: 2; grid-row: 1 / span 4; align-self: center; display: grid; gap: 16px; min-width: 0; }
.flow { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.flow span { font: 500 13px var(--mono); padding: 8px 12px; border-radius: 6px; background: var(--ochre); color: var(--ink); }
.flow i { font-style: normal; color: var(--ink-soft); }
.side:has(> :not([hidden])) { display: grid; }
.card.has-code .title { font-size: clamp(26px, 3.4vw, 38px); }
.card.has-code .text { font-size: clamp(16px, 1.6vw, 18px); }
.code {
  margin: 0; padding: 20px 22px; border-radius: 6px; background: var(--stage); color: var(--stage-ink);
  font: 400 clamp(12px, 1vw, 13px)/1.6 var(--mono); white-space: pre; overflow-x: auto; cursor: text;
}
.code i { font-style: normal; color: #9fb4c2; }
.code u { text-decoration: none; color: var(--ochre); }
.code s { text-decoration: none; color: #c9876a; }
@media (max-width: 820px) {
  .card.has-code .body { grid-template-columns: minmax(0, 1fr); }
  .card .side { grid-column: 1; grid-row: auto; }
}

.table { width: 100%; border-collapse: collapse; font: 400 clamp(12px, 1.2vw, 14px)/1.4 var(--mono); }
.table th { text-align: left; font-weight: 500; color: var(--ink-soft); padding: 0 8px 10px 0; border-bottom: 1.5px solid var(--ink); }
.table td { padding: 9px 8px 9px 0; border-bottom: 1px solid #e2d6c0; vertical-align: top; }
.table td:first-child { font-family: var(--display); font-size: clamp(13px, 1.3vw, 15px); }
.table td:not(:first-child) { color: var(--ink-soft); }

/* theDECISIONS */
.intents { display: none; gap: 14px; }
.show-intents .intents { display: grid; }
.show-intents .cardwrap, .show-intents .card, .show-intents .terms, .show-intents .nav, .show-intents .track { display: none; }
.dhead h1 { margin: 6px 0 4px; font: 500 clamp(26px, 4vw, 40px)/1.1 var(--display); color: var(--stage-ink); }
.dhead p { margin: 0 0 12px; color: var(--stage-soft); }
.dcard { background: var(--paper); color: var(--ink); border-radius: 6px; padding: clamp(18px, 3vw, 28px); display: grid; gap: 8px; scroll-margin-top: 16px; }
.dtop { display: flex; align-items: center; gap: 10px; font: 500 12px var(--mono); }
.did { background: var(--ink); color: var(--paper); border-radius: 4px; padding: 3px 8px; }
.dcard:has(.superseded) { opacity: .75; }
.ddate { color: var(--ink-soft); margin-left: auto; }
.dcard h2 { margin: 2px 0 0; font: 500 clamp(19px, 2.2vw, 24px)/1.2 var(--display); }
.ddec { margin: 0; font-size: 16px; line-height: 1.55; }
.dwhy { margin: 0; font-size: 14px; line-height: 1.55; color: var(--ink-soft); }
.dwhy b { font-weight: 500; color: var(--ink); margin-right: 4px; }
.dsrc { margin: 0; padding-left: 18px; font-size: 13px; color: var(--ink-soft); }
.dsrc a { color: var(--ink); }


/* "Under the hood": the technical deep dive, pinned to the bottom of every slide. */
.deep { margin: 0; padding-top: 14px; border-top: 1px solid #e2d6c0; font-size: 13px; line-height: 1.55; color: var(--ink-soft); max-width: 110ch; }
.deep b { display: block; font: 500 11px var(--mono); letter-spacing: .06em; text-transform: uppercase; color: var(--ink); margin-bottom: 4px; }

/* One screen, no page scroll: the card takes the free height, one bottom bar. */
@media (min-width: 901px) {
  html, body { overflow: hidden; }
  .stage { height: 100vh; box-sizing: border-box; padding-block: 20px; grid-template-rows: minmax(0, 1fr); }
  .stage > .main { height: 100%; grid-template-rows: minmax(0, 1fr) auto; gap: 14px; }
  .stories { max-height: 100%; overflow-y: auto; }
  .card { min-height: 0; overflow-y: auto; }
  .show-intents .stage > .main { grid-template-rows: minmax(0, 1fr); }
  .intents { min-height: 0; overflow-y: auto; align-content: start; padding-right: 4px; }
}
.card { position: relative; }
.card .terms { position: absolute; top: 18px; right: 22px; max-width: 55%; justify-content: flex-end; min-height: 0; z-index: 1; }
.card .terms span { padding: 3px 9px; font-size: 11px; border-color: #e2d6c0; color: var(--ink-soft); background: var(--paper); }
.card .terms span.new { border-color: var(--clay); color: var(--ink); }
.nav { display: flex; align-items: center; gap: 18px; }
.nav .track { flex: 1; min-width: 0; }
.nav button { flex: none; white-space: nowrap; }
#next { max-width: 42%; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 900px) { .card .terms { position: static; max-width: none; justify-content: flex-start; } }

/* Compact bottom bar: small buttons, each step's new terms right below its dot. */
.nav { align-items: flex-start; gap: 12px; }
.nav button#prev, .nav button#next { font-size: 13px; padding: 7px 14px; margin-top: -6px; }
.card .terms { display: none; }
.nav .track { display: flex; justify-content: stretch; align-items: flex-start; padding: 0; }
.nav .track::before, .nav .track .fill { top: 5px; left: calc(100% / var(--n) / 2); }
.nav .track::before { right: calc(100% / var(--n) / 2); }
.nav .track button { flex: 1 1 0; min-width: 0; width: auto; height: auto; border: 0; border-radius: 0; background: none; transform: none;
  display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 0 2px; }
.nav .track button i { width: 11px; height: 11px; border-radius: 50%; border: 1.5px solid #3b5466; background: var(--stage); box-sizing: border-box; }
.nav .track button span { white-space: normal; font: 500 10px/1.25 var(--mono); color: #5d7383; text-align: center; overflow-wrap: anywhere; max-width: 100%; }
/* Phones: a chapter's dots fit beside Back and Next without padding; with it, a long chapter pushed the bar, and the
   page, sideways (found by theOS's check, AIP-1). */
@media (max-width: 900px) { .nav .track button { padding: 0; } }
.nav .track button.past i { background: var(--stage-ink); border-color: var(--stage-ink); }
.nav .track button.now i { background: var(--ochre); border-color: var(--ochre); transform: scale(1.3); }
.nav .track button.now span { color: var(--ochre); }
.nav .track button.past span { color: var(--stage-soft); }

/* Long JSON lines wrap instead of running off the panel, at any window width. */
.code { white-space: pre-wrap; overflow-wrap: anywhere; overflow-x: hidden; }

.achap { color: var(--ink); font: 500 15px var(--display); text-decoration: none; }
.sev, .verdict { display: inline-block; font: 500 10.5px var(--mono); letter-spacing: .04em; border-radius: 999px; padding: 1px 8px; margin: 6px 6px 0 0; }
.sev.critical, .verdict.breaks { background: #9e3f2b; color: var(--paper); }
.sev.high { background: var(--clay); color: var(--ink); }
.sev.medium, .verdict.partly { background: var(--ochre); color: var(--ink); }
.sev.low, .verdict.holds { background: #a9b79a; color: var(--ink); }
.arefs { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.arefs a { font: 500 11px var(--mono); color: var(--ink); background: #ece2cf; border-radius: 4px; padding: 2px 6px; text-decoration: none; }
.arefs a.prop { background: var(--ochre); }

/* Short windows: type and spacing follow the window's height as well as its width, so every slide fits above the
   bottom bar without scrolling. */
@media (min-width: 901px) {
  .card { padding: clamp(20px, min(4vw, 5vh), 56px); gap: clamp(10px, 2vh, 18px); }
  .card .body { row-gap: clamp(10px, 2vh, 18px); }
  .title { font-size: clamp(24px, min(4.6vw, 5.6vh), 48px); }
  .card.has-code .title { font-size: clamp(22px, min(3.4vw, 4.4vh), 38px); }
  .text { font-size: clamp(15px, min(2vw, 2.6vh), 21px); }
  .card.has-code .text { font-size: clamp(14px, min(1.6vw, 2.3vh), 18px); }
  .list { font-size: clamp(15px, min(2.2vw, 2.8vh), 24px); gap: clamp(5px, 1.2vh, 10px); }
  .code { font-size: clamp(11px, min(1vw, 1.55vh), 13px); line-height: 1.5; padding: clamp(12px, 2.2vh, 20px) clamp(14px, 2vw, 22px); }
  .deep { font-size: clamp(11.5px, 1.6vh, 13px); padding-top: clamp(8px, 1.6vh, 14px); }
  .table { font-size: clamp(11px, min(1.2vw, 1.6vh), 14px); }
  .table td { padding: clamp(4px, 1vh, 9px) 8px clamp(4px, 1vh, 9px) 0; }
}

/* Architecture: a panel over the card's right half with the slide's exact records, rules and decisions. */
.cardwrap { position: relative; display: grid; min-height: 0; }
.cardwrap > .card { min-height: 0; }
.spectab { position: absolute; top: 12px; right: 14px; z-index: 2; font: 500 10.5px var(--mono); letter-spacing: .06em; text-transform: uppercase;
  color: var(--ink-soft); background: var(--paper); border: 1px solid #d9ccb4; border-radius: 999px; padding: 4px 10px; cursor: pointer; }
.spectab.has { color: var(--ink); border-color: var(--clay); }
.spec { position: absolute; top: 0; right: 0; bottom: 0; width: min(580px, 52%); z-index: 3; overflow-y: auto; box-sizing: border-box;
  background: #fbf7ee; color: var(--ink); border-left: 1px solid #d9ccb4; border-radius: 0 6px 6px 0; box-shadow: -14px 0 32px rgba(10, 20, 28, .22);
  padding: 18px 22px 24px; font-size: 13px; line-height: 1.5; }
.spec header { display: flex; align-items: center; justify-content: space-between; font: 500 11px var(--mono); letter-spacing: .06em; text-transform: uppercase; color: var(--ink-soft); }
.sclose { font: 400 20px/1 var(--display); color: var(--ink); background: none; border: 0; cursor: pointer; padding: 2px 6px; }
.spec h2 { margin: 6px 0 8px; font: 500 20px/1.2 var(--display); }
.spec h3 { margin: 16px 0 6px; font: 500 12px var(--mono); color: var(--ink); }
.spec p { margin: 0 0 6px; color: var(--ink-soft); }
.sfields { width: 100%; border-collapse: collapse; font-size: 12px; table-layout: fixed; }
.sfields td:first-child { width: 30%; }
.sfields td:nth-child(2) { width: 22%; }
.sfields td { vertical-align: top; padding: 4px 6px 4px 0; border-top: 1px solid #e6dbc7; }
.sfields td:first-child { overflow-wrap: anywhere; }
.sfields td:nth-child(2) { color: var(--ink-soft); font: 400 11px var(--mono); }
.spec code { font: 500 11.5px var(--mono); }
.srules { margin: 0; padding-left: 20px; display: grid; gap: 7px; }
.srules code { display: block; color: #8a4a33; }
.snone { font-style: italic; }
@media (max-width: 900px) { .spec { position: fixed; inset: 0; width: auto; border-radius: 0; z-index: 20; } }

.agrid b, .arefs b { font: 500 11px var(--mono); letter-spacing: .06em; text-transform: uppercase; color: var(--ink-soft); margin-right: 6px; }
.agrid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; font-size: 13.5px; line-height: 1.45; color: var(--ink-soft); }
.agrid ul { margin: 4px 0 0; padding-left: 16px; } .agrid li + li { margin-top: 4px; }
.arefs { align-items: center; }
@media (max-width: 760px) { .agrid { grid-template-columns: 1fr; } }

/* Intents: a board of stage columns; each intent opens in full with its stages as tabs. */
.board { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; align-items: start; }
.col { background: var(--chip); border-radius: 8px; padding: 10px; display: grid; gap: 8px; }
.col h2 { margin: 2px 4px 4px; font: 500 12px var(--mono); letter-spacing: .06em; text-transform: uppercase; color: var(--stage-ink); display: flex; justify-content: space-between; }
.col h2 span { color: var(--stage-soft); }
.mini { display: grid; gap: 4px; background: var(--paper); color: var(--ink); border-radius: 6px; padding: 10px 12px; text-decoration: none; }
.mini:hover { outline: 2px solid var(--ochre); }
.mini.superseded, .mini.rejected { opacity: .62; }
.mtop { display: flex; align-items: center; gap: 6px; font: 500 11px var(--mono); }
.mtop .chipx { margin: 0; }
.mt { font: 500 14px/1.3 var(--display); }
.mc { font: 500 11px var(--mono); color: var(--ink-soft); }
.mnone { margin: 4px; color: var(--stage-soft); font-size: 13px; }
.chipx { display: inline-block; margin: 0; font: 500 10.5px var(--mono); border-radius: 999px; padding: 1px 8px; background: #ece2cf; color: var(--ink); }
.chipx.accepted { background: #a9b79a; } .chipx.superseded, .chipx.rejected { background: #ddd2bf; color: var(--ink-soft); }
.chipx.phase { background: var(--ink); color: var(--paper); }
.chipx.sev.critical { background: #9e3f2b; color: var(--paper); } .chipx.sev.high { background: var(--clay); } .chipx.sev.medium { background: var(--ochre); } .chipx.sev.low { background: #a9b79a; }
.iback { color: var(--stage-ink); font: 500 13px var(--display); text-decoration: none; }
.intent .dtop { flex-wrap: wrap; }
.itabs { display: flex; gap: 6px; border-bottom: 1px solid #d9ccb4; margin: 4px 0 6px; }
.itabs button { font: 500 13px var(--display); color: var(--ink-soft); background: none; border: 0; border-bottom: 2px solid transparent; padding: 6px 10px; cursor: pointer; }
.itabs button.on { color: var(--ink); border-bottom-color: var(--clay); }
.ih3 { margin: 10px 0 2px; font: 500 12px var(--mono); }
.islides { margin: 0; padding-left: 18px; font-size: 14px; display: grid; gap: 4px; }
.islides a { color: var(--ink); }
.islides .specl { font: 500 11px var(--mono); background: #ece2cf; border-radius: 4px; padding: 1px 6px; text-decoration: none; margin-left: 6px; }
.dwhy a, .ddec a { color: var(--ink); }
.arefs a.accepted { background: #c9d3bd; } .arefs a.propose, .arefs a.learn { background: var(--ochre); } .arefs a.superseded { text-decoration: line-through; }
@media (max-width: 900px) { .board { grid-template-columns: minmax(0, 1fr); } }
.ilabel { display: block; font: 500 11px var(--mono); letter-spacing: .06em; text-transform: uppercase; color: var(--ink-soft); margin: 0 0 4px; }
.scens { display: grid; gap: 12px; margin-top: 6px; }
.scens > .ilabel { margin: 0; }
.scen { border-top: 1px solid #e6dbc7; padding-top: 12px; }
.shead { display: flex; gap: 10px; align-items: baseline; margin: 0; font-size: 15px; font-weight: 500; line-height: 1.4; }
.shead .verdict { margin: 0; flex: none; }
.sgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-top: 8px; font-size: 13.5px; line-height: 1.5; color: var(--ink-soft); }
.sgrid p { margin: 0; } .sgrid a { color: var(--ink); }
@media (max-width: 760px) { .sgrid { grid-template-columns: 1fr; gap: 8px; } }
/* Intents and Sources are light: the same tokens on a paper ground; the chapter nav stays dark. */
.show-intents .stage > .main { --stage: #ece3d2; --stage-ink: #15242f; --stage-soft: #5b666b; --chip: #e1d6c1; --line: #cbbda3; color-scheme: light;
  background: var(--stage); color: var(--stage-ink); border-radius: 10px; padding: clamp(14px, 2vw, 24px); box-sizing: border-box; }
.show-intents .dcard, .show-intents .mini { background: #fbf7ee; }
.show-intents .mini { box-shadow: 0 1px 0 rgba(21, 36, 47, .08); }
@media (min-width: 901px) { .stories .navdec + .navdec { margin-top: 6px; } }
.srclist { columns: 2 280px; column-gap: 32px; font-size: 14px; }
.srclist li { break-inside: avoid; margin-bottom: 5px; }
/* The board fills the panel; each column scrolls on its own, its heading stays. */
@media (min-width: 901px) {
  .intents.isboard { overflow: hidden; grid-template-rows: minmax(0, 1fr); padding-right: 0; }
  .isboard .board { min-height: 0; height: 100%; align-items: stretch; }
  .isboard .col { min-height: 0; overflow-y: auto; align-content: start; padding-top: 0; }
  .isboard .col h2 { position: sticky; top: 0; z-index: 1; margin: 0 -10px; padding: 12px 14px 8px; background: var(--chip); }
}
