/* Hotwire, explorable — the paste-up.
   The server is a print shop. The browser is a board you pin a sheet to.
   HTML rides the wire on a clip. What the browser uses gets cut out;
   what it throws away gets torn off. */
@import url('https://fonts.googleapis.com/css2?family=Fraunces:ital,opsz,wght,SOFT@0,9..144,400..900,100;1,9..144,400..900,100&family=Atkinson+Hyperlegible:ital,wght@0,400;0,700;1,400&family=JetBrains+Mono:wght@400;600&display=swap');

:root {
  --paper: #f4efe4;
  --paper-2: #ebe4d3;
  --board: #e3d9c3;          /* the board behind the sheet */
  --sheet: #fffdf8;          /* a printed sheet */
  --note: #fff8c9;           /* a sticky note */
  --tape: rgba(255, 222, 120, 0.55);
  --ink: #1c1a16;
  --ink-2: #5b564c;
  --ink-3: #8a8375;
  --rule: #d7cfbd;
  --hot: #e4572e;            /* the wire, the clip, the pins */
  --hot-ink: #b83d1a;
  --hot-soft: #fbe3da;
  --stamp: #b83d1a;          /* rubber stamps */
  --cool: #2b6f8a;           /* blue pencil */
  --cool-ink: #1f5568;
  --cool-soft: #dcebf1;
  --pencil: var(--cool);
  --ok: #2e8b57;
  --bad: #b3261e;
  --display: 'Fraunces', Georgia, serif;
  --body: 'Atkinson Hyperlegible', system-ui, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
  --nav-h: 60px;
  --shadow: 3px 4px 0 var(--ink);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background-color: var(--paper);
  /* paper fibre: 5.5% alpha noise, never more */
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='300' height='300'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.2  0 0 0 0 0.17  0 0 0 0 0.12  0 0 0 0.055 0'/></filter><rect width='300' height='300' filter='url(%23n)'/></svg>");
  background-size: 300px 300px;
  color: var(--ink);
  font-family: var(--body);
  font-size: 18px;
  line-height: 1.5;
  overflow: hidden;
}
::selection { background: var(--hot-soft); }
a { color: var(--hot-ink); text-decoration-thickness: 2px; text-underline-offset: 3px; }
code, kbd, pre { font-family: var(--mono); font-variant-ligatures: none; font-feature-settings: 'liga' 0, 'calt' 0; }
code {
  font-size: 0.82em;
  background: var(--paper-2);
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 0.05em 0.35em;
  white-space: nowrap;
}
pre {
  font-size: 13.5px;
  line-height: 1.5;
  background: var(--sheet);
  border: 2px solid var(--ink);
  box-shadow: var(--shadow);
  padding: 14px 16px;
  margin: 0;
  overflow: auto;
  white-space: pre;
}
pre code { background: none; border: 0; padding: 0; font-size: inherit; white-space: pre; }
pre mark, .hl { background: #fff2b3; color: var(--ink); box-shadow: 0 0 0 1px #f2d66a; padding: 0 2px; border-radius: 2px; }
pre .cm { color: var(--ink-3); font-style: italic; }
pre .cool { background: var(--cool-soft); color: var(--cool-ink); padding: 0 2px; border-radius: 2px; }

h1, h2, h3 { font-family: var(--display); font-weight: 600; line-height: 1.12; margin: 0 0 0.5em; letter-spacing: -0.015em; }
h1 { font-size: 46px; font-weight: 700; font-variation-settings: 'opsz' 120, 'SOFT' 100; }
h2 { font-size: 32px; font-variation-settings: 'opsz' 120, 'SOFT' 100; }
h3 { font-size: 22px; }
p { margin: 0 0 1em; }
p:last-child { margin-bottom: 0; }
em { font-style: italic; }
strong { font-weight: 700; }
.muted { color: var(--ink-2); }
.small { font-size: 15px; }

/* the eyebrow is a rubber stamp */
.eyebrow {
  display: inline-block;
  font-family: var(--mono); font-size: 12.5px; letter-spacing: 0.12em; text-transform: uppercase; font-weight: 600;
  color: var(--stamp); border: 1.5px solid var(--stamp); border-radius: 3px;
  padding: 2px 8px 1px; margin-bottom: 14px;
  transform: rotate(-1.6deg); transform-origin: left center;
  -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='120' height='40'><filter id='g'><feTurbulence baseFrequency='0.6' numOctaves='3'/><feColorMatrix values='0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 -1.4 2.1'/></filter><rect width='120' height='40' fill='white' filter='url(%23g)'/></svg>");
  mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='120' height='40'><filter id='g'><feTurbulence baseFrequency='0.6' numOctaves='3'/><feColorMatrix values='0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 -1.4 2.1'/></filter><rect width='120' height='40' fill='white' filter='url(%23g)'/></svg>");
  -webkit-mask-size: 120px 40px; mask-size: 120px 40px;
}
/* a word crossed out in red pencil */
.struck { position: relative; white-space: nowrap; }
.struck::after { content: ''; position: absolute; left: -2%; right: -2%; top: 52%; height: 0.14em; background: var(--stamp); transform: rotate(-2.5deg); border-radius: 2px; opacity: 0.85; }

/* ---------- deck ---------- */
.deck { position: relative; height: calc(100vh - var(--nav-h)); overflow: hidden; }
.slide {
  display: none;
  position: absolute; inset: 0;
  padding: 3vh 3vw 2vh;
  align-items: center;
  gap: clamp(24px, 3vw, 44px);
  grid-template-columns: minmax(28ch, 37ch) minmax(0, 1fr);
  overflow: auto;
}
.slide.active { display: grid; animation: slide-in 320ms ease-out; }
@keyframes slide-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.slide.center { grid-template-columns: 1fr; justify-items: center; text-align: center; }
.slide.center .prose { max-width: 62ch; }
.slide.wide { grid-template-columns: minmax(0, 1fr); }
.slide.text-right { grid-template-columns: minmax(0, 1fr) minmax(28ch, 37ch); }
.slide.text-right .prose { order: 2; }
.prose { max-width: 40ch; }
.prose > * + * { margin-top: 0.9em; }
.prose pre { font-size: 12.5px; white-space: pre-wrap; word-break: break-word; }
.prose pre code { white-space: inherit; }
.prose p { margin: 0; }
.prose ul { padding-left: 1.2em; margin: 0; }
.prose li + li { margin-top: 0.4em; }

.stage { width: 100%; min-width: 0; }

/* ---------- buttons & doors ---------- */
.btn, .door {
  display: inline-flex; align-items: center; gap: 0.5em;
  font-family: var(--display); font-weight: 600; font-size: 19px;
  color: var(--ink); background: var(--sheet);
  border: 2px solid var(--ink); border-radius: 12px; box-shadow: var(--shadow);
  padding: 9px 18px; text-decoration: none; cursor: pointer;
  transition: transform 90ms ease, box-shadow 90ms ease;
  line-height: 1.2;
}
.btn:hover, .door:hover { transform: translate(-1px, -1px); box-shadow: 4px 5px 0 var(--ink); }
.btn:active, .door:active { transform: translate(2px, 2px); box-shadow: 1px 2px 0 var(--ink); }
.btn.small, .door.small { font-size: 16px; padding: 6px 12px; border-radius: 9px; }
.btn.hot { background: var(--hot); color: #fff; border-color: var(--hot-ink); box-shadow: 3px 4px 0 var(--hot-ink); }
.btn.hot:hover { box-shadow: 4px 5px 0 var(--hot-ink); }
.btn.ghost { background: transparent; box-shadow: none; border-color: var(--ink-3); color: var(--ink-2); }
.btn.ghost:hover { box-shadow: none; transform: none; border-color: var(--ink); color: var(--ink); }
.btn[disabled], .btn.locked { opacity: 0.4; cursor: not-allowed; transform: none; box-shadow: var(--shadow); }
/* doors are luggage tags: a hole at the left end, a string you can imagine */
.door { position: relative; border-radius: 22px 10px 10px 22px; padding-left: 30px; background: var(--hot-soft); }
.door::before { content: ''; position: absolute; left: 12px; top: calc(50% - 4px); width: 8px; height: 8px; border-radius: 50%; background: var(--paper); border: 1.5px solid var(--ink); }
.door:hover { transform: translate(-1px, -1px) rotate(-0.6deg); }
.door.small { padding-left: 26px; border-radius: 18px 9px 9px 18px; }
.door.small::before { left: 10px; }
.door.return { background: var(--cool-soft); }
.door .arrow { font-family: var(--body); }
.doors { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 1.2em; }
.doors.stack { flex-direction: column; align-items: flex-start; }
.door-note { display: block; font-family: var(--body); font-weight: 400; font-size: 14px; color: var(--ink-2); }

/* toggles the reader flips on the sim */
.switch {
  display: inline-flex; align-items: center; gap: 10px;
  font-family: var(--mono); font-size: 13.5px;
  border: 2px solid var(--ink); border-radius: 999px; background: var(--sheet);
  padding: 5px 12px 5px 6px; cursor: pointer; user-select: none;
  box-shadow: 2px 3px 0 var(--ink);
}
.switch input { appearance: none; width: 34px; height: 20px; border-radius: 999px; background: var(--rule); position: relative; margin: 0; cursor: pointer; transition: background 150ms; }
.switch input::after { content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; border: 2px solid var(--ink); box-sizing: border-box; transition: transform 150ms; }
.switch input:checked { background: var(--hot); }
.switch input:checked::after { transform: translateX(14px); }
.switches { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 0.9em; }

/* a callout is a sticky note */
.callout { background: var(--note); padding: 10px 14px; font-size: 16px; box-shadow: 1px 2px 3px rgba(28,26,22,0.2); transform: rotate(-0.4deg); }
.callout.cool { background: #e4eef4; }

/* place your bets */
.bets { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 0.8em; }
.bets .btn { font-size: 16px; }
.bets .btn.picked { background: var(--ink); color: var(--paper); }
.bet-result { margin-top: 0.8em; min-height: 1.5em; }

/* witness table used in prose */
.wtable { border-collapse: collapse; font-size: 15px; width: 100%; }
.wtable th, .wtable td { text-align: left; padding: 6px 10px; border-bottom: 1px solid var(--rule); vertical-align: top; }
.wtable th { font-family: var(--mono); font-weight: 600; font-size: 12.5px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-2); }
.wtable td.ok { color: var(--cool-ink); font-weight: 700; }
.wtable td.bad { color: var(--stamp); font-weight: 700; text-decoration: line-through; text-decoration-thickness: 2px; }

/* ---------- bottom nav ---------- */
.hxnav {
  position: fixed; left: 0; right: 0; bottom: 0; height: var(--nav-h);
  background: var(--ink); color: var(--paper);
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  padding: 0 18px; font-size: 14px; z-index: 50;
}
.hxnav .left, .hxnav .right { display: flex; align-items: center; gap: 12px; min-width: 0; overflow: hidden; }
.hxnav .right { justify-content: flex-end; }
.hxnav .title { font-family: var(--display); font-size: 16px; color: var(--paper); text-decoration: none; opacity: 0.9; font-variation-settings: 'SOFT' 100; white-space: nowrap; }
.hxnav .crumb { color: var(--rule); font-family: var(--mono); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 30ch; flex: 0 1 auto; }
/* how much this rung throws away */
.hxnav .radius { display: inline-flex; align-items: center; gap: 8px; margin-left: 6px; color: var(--rule); font-family: var(--mono); font-size: 11.5px; white-space: nowrap; flex: none; }
.hxnav .radius svg { width: 18px; height: 22px; display: block; }
.radius-glyph .r-page { fill: none; stroke: currentColor; stroke-width: 1.5; }
.radius-glyph .r-hot { fill: var(--hot); stroke: none; }
.hxnav .radius .radius-glyph { color: var(--paper); }
/* pin heads */
.hxnav .dots { display: flex; gap: 10px; align-items: center; }
.hxnav .dot {
  width: 12px; height: 12px; border-radius: 2px; border: 2px solid var(--paper);
  background: transparent; padding: 0; cursor: pointer; transition: transform 120ms; transform: rotate(45deg);
}
.hxnav .dot.seen { background: rgba(246,241,231,0.35); }
.hxnav .dot.current { background: var(--paper); }
.hxnav .dot.gated { border-style: dashed; opacity: 0.55; cursor: not-allowed; }
.hxnav .dot:not(.gated):hover { transform: rotate(45deg) scale(1.2); }
.hxnav .navbtn {
  background: transparent; border: 2px solid var(--paper); color: var(--paper); border-radius: 999px;
  font-family: var(--body); font-size: 14px; padding: 4px 12px; cursor: pointer; white-space: nowrap;
}
.hxnav .navbtn:hover { background: var(--paper); color: var(--ink); }
.hxnav .navbtn[disabled] { opacity: 0.3; cursor: not-allowed; }
.hxnav .navbtn[disabled]:hover { background: transparent; color: var(--paper); }
.hxnav .navbtn.hot { border-color: var(--hot); color: var(--hot); }
.hxnav .navbtn.hot:hover { background: var(--hot); color: #fff; }
.hxnav kbd { font-size: 11px; border: 1px solid var(--ink-3); border-radius: 4px; padding: 0 5px; color: var(--ink-3); }

/* ---------- map ---------- */
.hxmap { position: fixed; inset: 0; background: rgba(28,26,22,0.55); z-index: 100; display: none; align-items: center; justify-content: center; }
.hxmap.open { display: flex; }
.hxmap .panel {
  background: var(--paper); border: 2px solid var(--ink); box-shadow: 6px 8px 0 var(--ink);
  width: min(920px, 92vw); max-height: 86vh; overflow: auto; padding: 28px 32px;
}
.hxmap h2 { margin-bottom: 4px; }
.hxmap .legend { font-size: 13px; color: var(--ink-2); margin-bottom: 16px; font-family: var(--mono); }
.hxmap ul { list-style: none; margin: 0; padding-left: 0; }
.hxmap ul ul { padding-left: 26px; border-left: 2px solid var(--rule); margin-left: 9px; }
.hxmap li { margin: 4px 0; }
.hxmap a {
  display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink);
  padding: 5px 10px; border-radius: 8px; border: 2px solid transparent; position: relative;
}
.hxmap a:hover { border-color: var(--ink); background: var(--sheet); }
.hxmap a .pip { width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--ink); flex: none; }
.hxmap a.seen .pip { background: var(--rule); }
.hxmap a.done .pip { background: var(--ink); }
.hxmap a .radius-glyph { width: 14px; height: 17px; color: var(--ink-3); flex: none; }
/* you are here: pinned */
.hxmap a.here { background: var(--note); border-color: transparent; box-shadow: 1px 2px 3px rgba(28,26,22,0.25); transform: rotate(-0.6deg); }
.hxmap a.here::before { content: ''; position: absolute; top: -5px; left: 50%; width: 10px; height: 10px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #ff9b7a, var(--hot) 55%, var(--hot-ink)); box-shadow: 1px 2px 2px rgba(0,0,0,0.3); }
.hxmap a .n { font-family: var(--mono); font-size: 12px; color: var(--ink-3); }
.hxmap a .t { font-family: var(--display); font-weight: 600; font-size: 17px; }
.hxmap a .sub { font-size: 13px; color: var(--ink-2); }
.hxmap .close { float: right; }

/* ================= SIM ================= */
.sim {
  --sim-h: 500px;
  display: grid; grid-template-columns: minmax(0, 1.25fr) 118px minmax(0, 1fr);
  height: var(--sim-h); width: 100%;
  font-size: 13px;
}
.sim .browser, .sim .server {
  border: 2px solid var(--ink); background: var(--sheet); box-shadow: var(--shadow);
  display: flex; flex-direction: column; min-width: 0; height: var(--sim-h);
  position: relative;
}
/* --- the browser is a board --- */
.sim .browser {
  background-color: var(--board);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='1.2' numOctaves='2'/><feColorMatrix values='0 0 0 0 0.25  0 0 0 0 0.18  0 0 0 0 0.1  0 0 0 0.055 0'/></filter><rect width='200' height='200' filter='url(%23n)'/></svg>");
}
.sim .server.off { opacity: 0.35; filter: grayscale(1); }

/* browser chrome */
.sim .tab { display: flex; align-items: center; gap: 6px; padding: 6px 10px 0; font-size: 11px; color: var(--ink-2); }
.sim .tab .favicon { width: 10px; height: 10px; border-radius: 2px; background: var(--hot); }
.sim .tab .tabtitle { background: var(--sheet); border: 1.5px solid var(--ink); border-bottom: 0; border-radius: 3px 3px 0 0; padding: 2px 10px; }
.sim .chrome { display: flex; align-items: center; gap: 6px; padding: 6px 8px 4px; flex: none; }
.sim .chrome .b {
  font-family: var(--mono); font-size: 12px; border: 1.5px solid var(--ink); background: #fff; box-shadow: 1px 1px 0 var(--ink);
  border-radius: 3px; width: 24px; height: 22px; display: grid; place-items: center; cursor: pointer; padding: 0;
}
.sim .chrome .b[disabled] { opacity: 0.35; cursor: default; }
.sim .chrome .url {
  flex: 1; font-family: var(--mono); font-size: 12px; border: 1.5px solid var(--ink); background: #fff; box-shadow: 1px 1px 0 var(--ink);
  border-radius: 3px; padding: 3px 8px; min-width: 0; white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; cursor: text;
}
.sim .chrome .url:focus { outline: 2px solid var(--hot); }
.sim .chrome .turbo-pill {
  font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.04em; border-radius: 999px;
  padding: 2px 8px; border: 1.5px solid var(--ink-3); color: var(--ink-3); white-space: nowrap;
}
.sim .chrome .turbo-pill.on { border-color: var(--hot); color: var(--hot-ink); background: var(--hot-soft); }
.sim .progress { position: absolute; top: 0; left: 0; height: 3px; background: var(--hot); width: 0; transition: width 300ms; z-index: 3; }

/* --- witnesses: four notes pinned above the sheet --- */
.sim .witnesses { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; padding: 4px 10px 8px; flex: none; }
.sim .w {
  position: relative; background: var(--note); border-radius: 1px; min-width: 0;
  padding: 8px 8px 12px; box-shadow: 1px 2px 3px rgba(28,26,22,0.22);
  transition: transform 300ms ease, opacity 300ms ease;
}
.sim .w:nth-child(1) { transform: rotate(-1.4deg); }
.sim .w:nth-child(2) { transform: rotate(0.8deg); background: #ffe9c9; }
.sim .w:nth-child(3) { transform: rotate(-0.5deg); background: #e6f0e8; }
.sim .w:nth-child(4) { transform: rotate(1.2deg); background: #e4eef4; }
.sim .w::before { /* the pin */
  content: ''; position: absolute; top: -5px; left: calc(50% - 5px); width: 10px; height: 10px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #ff9b7a, var(--hot) 55%, var(--hot-ink));
  box-shadow: 1px 2px 2px rgba(0,0,0,0.3);
}
.sim .w .k { font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-2); display: flex; justify-content: space-between; gap: 6px; white-space: nowrap; overflow: visible; }
.sim .w .v { font-family: var(--mono); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-height: 18px; color: var(--ink); }
/* the verdict is a tiny stamp in the corner */
.sim .w .badge { font-size: 10px; font-family: var(--mono); font-weight: 600; }
.sim .w .badge:not(:empty) {
  position: absolute; top: -7px; right: -6px; transform: rotate(7deg); color: var(--ink-2);
  border: 1.2px solid currentColor; border-radius: 2px; padding: 0 4px; background: var(--sheet);
  font-size: 9px; letter-spacing: 0.08em; text-transform: uppercase; line-height: 13px;
}
/* torn off */
.sim .w.lost {
  transform: rotate(-5deg) translate(1px, 5px); opacity: 0.8; background: #f3ebd6;
  clip-path: polygon(-12px -12px, calc(100% + 12px) -12px, calc(100% + 12px) 80%, 88% 90%, 74% 82%, 58% 94%, 40% 84%, 24% 96%, 10% 86%, -12px 96%);
}
.sim .w.lost .v, .sim .w.lost .badge { color: var(--stamp); }
/* kept: ticked in blue pencil */
.sim .w.kept { box-shadow: 0 0 0 2px var(--pencil), 1px 2px 3px rgba(28,26,22,0.22); }
.sim .w.kept .v, .sim .w.kept .badge { color: var(--pencil); }

/* --- the viewport is the pinned sheet --- */
.sim .viewport {
  flex: 1; overflow: auto; position: relative; scroll-behavior: auto;
  margin: 0 10px 8px; background: var(--sheet);
  box-shadow: 2px 3px 6px rgba(28,26,22,0.25);
  border: 1px solid rgba(28,26,22,0.18);
}
/* the sheet being torn off (a copy of the old page, appended by sim.js) */
.sim .viewport > .tear {
  position: absolute; left: 0; right: 0; height: 100%; overflow: hidden; z-index: 9; pointer-events: none;
  background: var(--sheet); box-shadow: 0 6px 10px rgba(28,26,22,0.35);
  clip-path: polygon(0 0, 100% 0, 100% 92%, 94% 100%, 86% 91%, 78% 99%, 70% 90%, 62% 100%, 54% 92%, 46% 99%, 38% 91%, 30% 100%, 22% 92%, 14% 99%, 6% 91%, 0 100%);
  animation: tearoff 720ms cubic-bezier(.5, 0, .9, .4) forwards;
}
@keyframes tearoff {
  0%   { transform: translateY(0) rotate(0); opacity: 1; }
  25%  { transform: translateY(6px) rotate(0.6deg); }
  85%  { opacity: 0.9; }
  100% { transform: translateY(-115%) rotate(-3deg); opacity: 0; visibility: hidden; }
}
/* the new sheet being pinned */
.sim .viewport.flash-all > .page { animation: pin-in 360ms cubic-bezier(.2,.7,.3,1); }
@keyframes pin-in { from { transform: translateY(-4px); opacity: 0; } to { transform: none; opacity: 1; } }
/* a bare board while the print shop works */
.sim .viewport.dead { background: repeating-linear-gradient(-45deg, transparent 0 10px, rgba(28,26,22,0.04) 10px 12px) var(--board); border: 1px dashed var(--ink-3); box-shadow: none; }
.sim .viewport.dead::after { content: 'printing…'; position: absolute; inset: 0; display: grid; place-items: center; font-family: var(--display); font-style: italic; font-size: 15px; color: var(--ink-2); }
/* a cached copy shown as a preview: a photocopy */
.sim .viewport.preview > .page { filter: grayscale(0.6) contrast(0.92); }
.sim .viewport.preview::before { content: 'preview · from cache'; position: absolute; top: 8px; right: 8px; z-index: 6; font-family: var(--mono); font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--pencil); border: 1.2px solid var(--pencil); padding: 1px 6px; transform: rotate(3deg); background: var(--sheet); }

/* --- partial flashes: a slip pasted on --- */
.sim .viewport .flash { animation: slip 900ms ease-out; position: relative; }
@keyframes slip {
  0%   { transform: translateY(-6px) rotate(-1.2deg) scale(1.02); box-shadow: 0 8px 12px rgba(28,26,22,0.3); background-color: var(--note); }
  35%  { transform: none; box-shadow: 0 2px 3px rgba(28,26,22,0.2); background-color: var(--note); }
  100% { transform: none; box-shadow: none; background-color: transparent; }
}
/* tape only on block elements; an inline counter would be hidden by it */
.sim .viewport .msg.flash::after, .sim .viewport form.flash::after, .sim .viewport turbo-frame.flash::after, .sim .viewport details.flash::after, .sim .viewport #messages.flash::after, .sim .viewport .flash-msg.flash::after {
  content: ''; position: absolute; top: -6px; left: 50%; width: 44px; height: 12px; margin-left: -22px; z-index: 3;
  background: var(--tape); transform: rotate(-4deg); box-shadow: 0 0 0 0.5px rgba(0,0,0,0.08);
  animation: tape-fade 900ms ease-out forwards; pointer-events: none;
}
@keyframes tape-fade { 0%, 60% { opacity: 1; } 100% { opacity: 0; } }
/* a permanent element carried across: pinned to the board, ticked in pencil */
.sim .viewport .flash-move { animation: none; box-shadow: 0 0 0 2px var(--pencil); }

/* the Board app inside the viewport */
.page { font-family: var(--body); color: var(--ink); font-size: 13px; }
.page nav.top {
  display: flex; align-items: center; gap: 14px; padding: 8px 12px; background: var(--ink); color: var(--paper);
  position: sticky; top: 0; z-index: 2;
}
.page nav.top .logo { font-family: var(--display); font-weight: 700; font-size: 15px; margin-right: auto; }
.page nav.top a { color: var(--paper); text-decoration: none; font-size: 12.5px; }
.page nav.top a:hover { text-decoration: underline; }
.page nav.top .count { background: var(--hot); color: #fff; border-radius: 999px; padding: 0 7px; font-family: var(--mono); font-size: 11px; margin-left: 4px; }
.page .layout { display: grid; grid-template-columns: 1fr 120px; gap: 12px; padding: 12px; }
.page .layout.one { grid-template-columns: 1fr; }
.page h1 { font-size: 20px; margin: 0 0 8px; }
.page h2 { font-size: 15px; margin: 0 0 6px; }
.page .msg { border: 1.5px solid var(--rule); border-radius: 8px; padding: 8px 10px; margin-bottom: 8px; background: #fff; }
.page .msg .who { font-weight: 700; font-size: 12px; display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.page .msg .who a { font-weight: 400; font-size: 11.5px; color: var(--cool-ink); }
.page .msg .who .tools { display: flex; gap: 8px; align-items: center; }
.page .msg .who button { font: inherit; font-size: 11px; border: 1px solid var(--ink); background: #fff; border-radius: 5px; padding: 1px 6px; cursor: pointer; white-space: nowrap; }
.page .msg p { margin: 4px 0 0; }
.page .msg .permalink { font-family: var(--mono); font-size: 10px; color: var(--ink-3); margin-top: 4px; }
.page form.compose { position: sticky; bottom: 0; border-top: 2px solid var(--ink); padding: 8px 12px; background: var(--sheet); display: grid; grid-template-columns: 1fr auto; gap: 6px 10px; align-items: end; }
.page form.compose label { grid-column: 1 / -1; margin: 0; font-size: 11.5px; font-weight: 700; display: block; margin-bottom: 4px; }
.page form.compose .errors { grid-column: 1 / -1; margin: 0; }
.page form.compose button.primary { margin: 0 0 1px; }
.page form.compose textarea { height: 38px; }
.page form.compose .perm-tag { grid-column: 1 / -1; }
.page textarea, .page input[type=text] { width: 100%; font: inherit; font-size: 12.5px; border: 1.5px solid var(--ink); border-radius: 6px; padding: 5px 7px; resize: none; background: #fff; }
.page textarea { height: 44px; }
.page button.primary { font: inherit; font-weight: 700; font-size: 12px; background: var(--hot); color: #fff; border: 1.5px solid var(--hot-ink); border-radius: 6px; padding: 4px 10px; margin-top: 6px; cursor: pointer; }
.page button.primary[disabled] { opacity: 0.5; cursor: wait; }
.page .flash-msg { background: var(--ok); color: #fff; padding: 5px 10px; border-radius: 6px; font-size: 12px; margin-bottom: 8px; position: relative; }
.page .errors { color: var(--bad); font-size: 11.5px; margin: 4px 0; }
.page aside details { border: 1.5px solid var(--rule); border-radius: 8px; padding: 6px 8px; background: #fff; }
.page aside summary { font-weight: 700; font-size: 12px; cursor: pointer; }
.page aside ul { padding-left: 14px; margin: 6px 0 0; font-size: 11.5px; }
.page aside li { margin: 2px 0; }
.page .about p { max-width: 40ch; }
/* a frame is a window cut in the sheet */
.page turbo-frame { display: block; outline: 1.5px dashed var(--cool); outline-offset: 3px; padding: 12px 6px 6px; margin: 14px 2px 12px; position: relative; background: rgba(43,111,138,0.04); }
.page turbo-frame::before {
  content: '✂ <turbo-frame id="' attr(id) '">'; position: absolute; top: -8px; left: 6px; background: var(--sheet); color: var(--cool-ink);
  font-family: var(--mono); font-size: 10px; padding: 0 5px; line-height: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: calc(100% - 12px);
}
.page turbo-frame[busy] { opacity: 0.6; }
.page turbo-frame .msg { margin-bottom: 0; }
.page turbo-frame .missing { color: var(--stamp); font-family: var(--mono); font-size: 12px; padding: 6px; border: 1.2px dashed var(--stamp); text-align: center; }
.page .edit-form input { margin-bottom: 6px; }
.page .edit-form .row { display: flex; gap: 8px; align-items: center; }
.page .edit-form a { font-size: 12px; }
.page .login { max-width: 32ch; }
.page .login input { margin-bottom: 8px; }
.page .spinner { font-family: var(--mono); font-size: 11px; color: var(--ink-3); padding: 6px; }
.page turbo-frame#archive { margin-top: 260px; }
.page turbo-frame#archive h2 { margin-top: 4px; }
.page .pager { display: flex; gap: 10px; font-size: 12px; margin-top: 6px; }
/* a permanent element has its own pin: it is on the board, not on the sheet */
.page [data-turbo-permanent] { box-shadow: 0 0 0 2px var(--pencil); position: relative; }
.page [data-turbo-permanent]::after { content: ''; position: absolute; top: -5px; right: 10px; width: 10px; height: 10px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #ff9b7a, var(--hot) 55%, var(--hot-ink)); box-shadow: 1px 2px 2px rgba(0,0,0,0.3); z-index: 3; }
.page .perm-tag { font-family: var(--mono); font-size: 9.5px; color: var(--pencil); }
/* an asset marked data-turbo-track is an inspection tag */
.page .track-tag { display: inline-block; font-family: var(--mono); font-size: 9.5px; color: var(--stamp); border: 1.2px solid var(--stamp); border-radius: 2px; padding: 0 4px; transform: rotate(-2deg); }

/* console line */
.sim .console {
  flex: none; margin: 0 10px 10px; background: var(--ink); color: var(--paper); border-radius: 2px;
  font-family: var(--mono); font-size: 11px; padding: 4px 8px; min-height: 24px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sim .console .warn { color: #f4c542; }
.sim .console .err { color: #ff7b6b; }
.sim .console .ok { color: #8fd19e; }

/* --- the wire --- */
.sim .wire { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.sim .wire .line { position: absolute; left: -3px; right: -3px; top: 50%; height: 0; border-top: 2px solid var(--ink); }
.sim .wire .line::before, .sim .wire .line::after { content: ''; position: absolute; top: -6px; width: 6px; height: 10px; background: var(--ink); border-radius: 0 0 3px 3px; }
.sim .wire .line::before { left: -2px; } .sim .wire .line::after { right: -2px; }
/* the WebSocket is a second, thinner line: string, not wire */
.sim .wire .line.ws { top: calc(50% + 22px); border-top: 1.5px dashed var(--cool); }
.sim .wire .line.ws::before, .sim .wire .line.ws::after { display: none; }
/* a packet is a slip hung from a bulldog clip */
.sim .wire .packet {
  position: absolute; top: calc(50% + 6px); left: 0; padding: 10px 6px 3px; border-radius: 1px; line-height: 1;
  font-family: var(--mono); font-size: 10px; font-weight: 600; letter-spacing: 0.04em; white-space: nowrap;
  background: var(--sheet); border: 1px solid var(--ink); color: var(--ink); opacity: 0;
  box-shadow: 1px 2px 3px rgba(28,26,22,0.3);
  transition: transform 520ms cubic-bezier(.4,0,.2,1), opacity 150ms;
}
.sim .wire .packet::before { content: ''; position: absolute; top: -8px; left: calc(50% - 6px); width: 12px; height: 10px; background: var(--ink); border-radius: 2px 2px 1px 1px; }
.sim .wire .packet.req { background: var(--sheet); color: var(--ink); }
/* a response comes back stamped */
.sim .wire .packet.res { color: var(--stamp); rotate: -3deg; box-shadow: inset 0 0 0 1.5px var(--stamp), 1px 2px 3px rgba(28,26,22,0.3); }
.sim .wire .packet.res[data-status^="4"], .sim .wire .packet.res[data-status^="5"] { color: var(--bad); box-shadow: inset 0 0 0 1.5px var(--bad), 1px 2px 3px rgba(28,26,22,0.3); }
.sim .wire .packet.res[data-status^="3"]::after { content: ' →'; }
.sim .wire .packet.ws { background: #fff; border-color: var(--cool); color: var(--cool-ink); top: calc(50% + 28px); box-shadow: inset 0 0 0 1.5px var(--cool), 1px 2px 3px rgba(28,26,22,0.3); }
.sim .wire .packet.ws::before { background: var(--cool); }
.sim .wire .label { position: absolute; top: calc(50% - 30px); font-family: var(--mono); font-size: 10.5px; color: var(--ink-2); white-space: nowrap; text-align: center; width: 140px; left: 50%; transform: translateX(-50%); }
.sim .wire .label.below { top: calc(50% + 34px); }
.sim .wire .label.below.ws { top: calc(50% + 50px); color: var(--cool-ink); }

/* --- the server is the print shop --- */
.sim .server { background: var(--paper-2); }
.sim .server .shead {
  display: flex; align-items: center; gap: 8px; padding: 6px 10px; flex: none;
  background: var(--ink); color: var(--paper); font-family: var(--mono); font-size: 11.5px; font-weight: 600;
}
.sim .server .shead .name { margin-right: auto; }
.sim .server .shead .name::before { content: '⚙ '; }
.sim .server .shead .ver { opacity: 0.7; font-weight: 400; }
.sim .server .log { flex: none; font-family: var(--mono); font-size: 10.5px; padding: 5px 10px; border-bottom: 1px dashed var(--ink-3); color: var(--ink-2); height: 68px; overflow: hidden; line-height: 1.45; }
.sim .server .log .l { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sim .server .log .l.now { color: var(--ink); font-weight: 600; }
.sim .server .rlabel { flex: none; font-family: var(--mono); font-size: 10px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-3); padding: 6px 10px 0; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
/* the "used" label is a stamp; it truncates rather than wraps */
.sim .server .rlabel .used { color: var(--stamp); font-weight: 600; letter-spacing: 0.08em; border: 1.5px solid var(--stamp); border-radius: 2px; padding: 0 5px; transform: rotate(-2deg); max-width: 62%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sim .server .rlabel .used:empty { display: none; }
/* the response is a continuous tractor-feed printout */
.sim .server pre.response {
  position: relative; flex: 1; margin: 6px 8px 10px; padding: 8px 10px 8px 22px; min-height: 0; overflow: auto;
  border: 1px solid var(--ink-3); border-radius: 0; box-shadow: 2px 2px 0 var(--ink-3);
  font-size: 11.5px; line-height: 1.4; white-space: pre-wrap; word-break: break-all; color: var(--ink-2);
  background-color: #fff;
  background-image: radial-gradient(circle at 8px 10px, var(--paper-2) 2.6px, transparent 3px), repeating-linear-gradient(0deg, #fff 0 20px, #f6f8f3 20px 40px);
  background-size: 100% 20px, 100% 40px; background-repeat: repeat-y, repeat;
}
.sim .server pre.response::before { content: ''; position: absolute; left: 15px; top: 0; bottom: 0; border-left: 1px dashed var(--ink-3); opacity: 0.6; }
.sim .server pre.response .dim { color: var(--ink-3); }
.sim .server pre.response .cut { color: var(--ink-3); font-style: italic; }
/* the part the browser used is cut out */
.sim .server pre.response mark {
  display: inline-block; max-width: 100%; vertical-align: top; white-space: pre-wrap; word-break: break-all; margin: 3px 0;
  background: var(--sheet); color: var(--ink); outline: 1.5px dashed var(--stamp); outline-offset: 2px; position: relative;
}
.sim .server pre.response mark::before { content: '✂'; position: absolute; left: -17px; top: -9px; color: var(--stamp); font-size: 12px; transform: rotate(-90deg); }
/* a response that arrived and was thrown in the bin */
.sim .server pre.response.discarded { color: var(--ink-3); background-image: repeating-linear-gradient(0deg, #f7f5f0 0 20px, #f1efe9 20px 40px); }
.sim .server pre.response.discarded::after { content: 'discarded'; position: sticky; bottom: 0; float: right; font-family: var(--mono); font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--stamp); border: 1.5px solid var(--stamp); border-radius: 2px; padding: 0 5px; transform: rotate(-4deg); background: var(--sheet); }

/* stimulus: a controller is pencil marginalia on the sheet */
.page [data-controller] { position: relative; box-shadow: -3px 0 0 0 var(--pencil); }
.page [data-controller]::after { content: attr(data-controller) ' · not connected'; position: absolute; right: 6px; top: -8px; padding: 0 4px; background: var(--sheet); font-family: var(--display); font-style: italic; font-size: 10.5px; line-height: 14px; color: var(--ink-3); z-index: 1; }
.page [data-controller][data-connected] { box-shadow: -3px 0 0 0 var(--pencil); }
.page [data-controller][data-connected]::after { content: '✓ ' attr(data-controller) ' · connected'; color: var(--pencil); }
.page .msg.lit, .page .permalink.lit, .page button.lit { outline: 3px solid var(--hot) !important; outline-offset: 2px; }
.sim .inspector { position: absolute; right: 8px; bottom: 32px; background: var(--ink); color: var(--paper); font-family: var(--mono); font-size: 10.5px; padding: 6px 8px; border-radius: 6px; max-width: 80%; z-index: 4; }
.sim .inspector b { color: #f4c542; }

/* small helper layouts for slides */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
.code-note { font-size: 13px; color: var(--ink-2); margin-top: 6px; font-family: var(--mono); }
.hint { font-size: 14px; color: var(--ink-3); font-style: italic; }
.gate-hint { font-size: 14px; color: var(--hot-ink); font-family: var(--mono); margin-top: 0.8em; }
.gate-hint.done { color: var(--pencil); font-style: italic; font-family: var(--display); font-size: 16px; }
.attr-map { display: grid; grid-template-columns: 1fr; gap: 8px; }
.attr-map .row { display: grid; grid-template-columns: 1fr; gap: 4px; padding: 8px 12px; border: 1.5px solid var(--rule); border-radius: 8px; background: var(--sheet); cursor: default; font-size: 14px; }
.attr-map .row > span:first-child { font-family: var(--mono); font-size: 13px; color: var(--hot-ink); }
.attr-map .row:hover, .attr-map .row.lit { border-color: var(--hot); background: var(--hot-soft); }
.attr-map .row .js { color: var(--cool-ink); }

/* the blast radius, drawn once (00 · S3) */
.rings { width: 100%; max-width: 540px; margin: 8px auto 0; display: grid; grid-template-columns: 300px 1fr; gap: 20px; align-items: center; }
.rings svg { width: 100%; height: auto; display: block; }
.rings .ring { fill: none; stroke: var(--ink); stroke-width: 1.1; stroke-dasharray: 3 3; }
.rings .ring.hot { stroke: var(--hot); stroke-width: 2.4; stroke-dasharray: none; }
.rings .ring.hot-fill { fill: var(--hot-soft); stroke: none; }
.rings .plan rect { fill: rgba(255,253,248,0.7); stroke: var(--ink-3); stroke-width: 1; }
.rings .pin { fill: var(--hot); }
.rings .ringlabel { font-family: var(--mono); font-size: 8.5px; fill: var(--ink); paint-order: stroke; stroke: var(--paper); stroke-width: 3px; }
.rings .legend { list-style: none; padding: 0; margin: 0; text-align: left; }
.rings .legend li { display: grid; grid-template-columns: 22px 1fr; gap: 10px; align-items: baseline; font-family: var(--display); font-weight: 600; font-size: 17px; padding: 3px 0; }
.rings .legend li small { font-family: var(--mono); font-weight: 400; font-size: 11.5px; color: var(--ink-3); display: block; }
.rings .legend li .n { font-family: var(--mono); font-size: 11px; color: var(--hot-ink); }
.rings .legend li.dim { color: var(--ink-3); }
/* the crumpled draft (00 · S2) */
.crumple { display: inline-block; width: 150px; margin: 6px 0 -6px 0; }
.crumple svg { width: 100%; height: auto; display: block; overflow: visible; }

/* the witness verdicts as four notes (10 · S2) */
.wnotes { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 6px 2px 10px; }
.wnotes .wn { position: relative; background: var(--note); padding: 10px 8px 8px; box-shadow: 1px 2px 3px rgba(28,26,22,0.22); font-size: 13px; }
.wnotes .wn:nth-child(1) { transform: rotate(-1.2deg); } .wnotes .wn:nth-child(2) { transform: rotate(0.9deg); background: #ffe9c9; }
.wnotes .wn:nth-child(3) { transform: rotate(-0.6deg); background: #e6f0e8; } .wnotes .wn:nth-child(4) { transform: rotate(1.1deg); background: #e4eef4; }
.wnotes .wn::before { content: ''; position: absolute; top: -5px; left: calc(50% - 5px); width: 10px; height: 10px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #ff9b7a, var(--hot) 55%, var(--hot-ink)); box-shadow: 1px 2px 2px rgba(0,0,0,0.3); }
.wnotes .k { font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-2); margin-bottom: 4px; }
.wnotes .r { display: flex; justify-content: space-between; gap: 6px; font-family: var(--mono); font-size: 11px; white-space: nowrap; padding: 2px 0; border-top: 1px dashed rgba(28,26,22,0.15); }
.wnotes .r .lbl { color: var(--ink-3); }
.wnotes .r .bad { color: var(--stamp); text-decoration: line-through; text-decoration-thickness: 1.5px; }
.wnotes .r .ok { color: var(--pencil); font-weight: 600; }
.wnotes .r .ok::before { content: '✓ '; }

/* a stamp you can press (31 · actions, 60 · desk) */
.stampbtn { font-family: var(--mono); font-size: 12px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--stamp); border: 1.5px solid var(--stamp); border-radius: 3px; background: var(--sheet); padding: 3px 8px; cursor: pointer; transform: rotate(-1.5deg); }
.stampbtn:hover { background: var(--hot-soft); }
.stampbtn.picked, .stampbtn:active { transform: rotate(-1.5deg) scale(0.96); background: var(--stamp); color: #fff; }

.landing { height: 100vh; display: grid; place-items: center; text-align: center; }
.landing .inner { max-width: 60ch; }
.landing h1 { font-size: 64px; }
.landing .sub { font-size: 20px; color: var(--ink-2); margin-bottom: 28px; }

@media (max-width: 1400px) { .hxnav .radius span { display: none; } }
@media (max-width: 1100px) {
  .slide { grid-template-columns: 1fr; align-content: start; }
  .slide.text-right .prose { order: 0; }
  .hxnav .radius span { display: none; }
}
@media (max-width: 1200px) {
  .sim .server pre.response { padding-left: 10px; background-image: repeating-linear-gradient(0deg, #fff 0 20px, #f6f8f3 20px 40px); background-size: 100% 40px; }
  .sim .server pre.response::before { display: none; }
  .sim .server pre.response mark::before { display: none; }
}
