/* Core deck chrome: stage, toolbar, progress, overview, shortcut sheet, print rules.
   Each deck's own stylesheet sets the palette, the type and the motion on top of this. */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--backdrop, #111);
  color: var(--type, #fff);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  display: grid;
  place-items: center;
  overflow: hidden;
}
body.modal { overflow: hidden; }

/* ---------- stage ---------- */
.wrap { width: 100%; height: 100%; display: grid; place-items: center; padding: 16px; }
#stage {
  position: relative;
  width: min(100%, calc((100vh - 96px) * 16 / 9));
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: var(--bg);
  border-radius: var(--stage-radius, 4px);
  box-shadow: 0 24px 80px rgba(0, 0, 0, .45);
  container-type: inline-size;
  cursor: default;
}
.slide {
  position: absolute;
  inset: 0;
  padding: var(--pad, 6.2cqw);
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 0;
}
.slide.live { display: flex; }
.slide:focus, .slide:focus-visible { outline: none; }  /* focus is moved by script, not by the user */
.slide.leaving { display: flex; }

/* The stagger: every [data-anim] child waits its turn. Decks override the transform. */
.slide [data-anim] {
  opacity: 0;
  transition: opacity .42s ease, transform .52s cubic-bezier(.2, .8, .2, 1), clip-path .52s cubic-bezier(.2, .8, .2, 1);
  transition-delay: calc(var(--i, 0) * 70ms);
}
/* The resting state has to beat every per-deck direction rule, and those are written against #stage[data-dir],
   which carries an id. !important keeps the arrival state simple: decks only ever describe where things come from. */
#stage .slide.in [data-anim] { opacity: 1 !important; transform: none !important; clip-path: inset(0) !important; }
[data-draw] { transition: stroke-dashoffset .62s ease-out; }
[data-bar] { width: 0; transition: width .4s cubic-bezier(.2, .8, .2, 1); transition-delay: calc(var(--i, 0) * 70ms + 240ms); }
#stage .slide.in [data-bar] { width: var(--to); }

/* ---------- chrome ---------- */
.chrome {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 18px;
  font: 500 12px/1 var(--sans);
  color: var(--chrome-ink, rgba(255, 255, 255, .72));
  background: var(--chrome-bg, rgba(10, 10, 12, .72));
  backdrop-filter: blur(8px);
  z-index: 40;
}
.chrome .sp { flex: 1; }
.chrome button, .chrome a {
  min-height: 44px;
  min-width: 44px;
  padding: 0 14px;
  border: 1px solid currentColor;
  border-radius: 999px;
  background: none;
  color: inherit;
  font: inherit;
  letter-spacing: .08em;
  text-transform: uppercase;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.chrome button:hover, .chrome a:hover { background: rgba(255, 255, 255, .1); }
.chrome button:disabled { opacity: .55; cursor: progress; }
.chrome :focus-visible, .ov-cell:focus-visible { outline: 2px solid var(--focus, #7ad); outline-offset: 2px; }
#counter { font-variant-numeric: tabular-nums; letter-spacing: .06em; }
#bar-track { position: fixed; left: 0; right: 0; bottom: 64px; height: 2px; background: rgba(255, 255, 255, .14); z-index: 40; }
#bar { height: 100%; background: var(--accent, #fff); transform-origin: 0 50%; transform: scaleX(0); transition: transform .45s cubic-bezier(.2, .8, .2, 1); }

/* ---------- editing affordance ---------- */
[contenteditable]:hover { box-shadow: inset 0 -1px 0 var(--edit-hint, rgba(255, 255, 255, .34)); }
[contenteditable]:focus { outline: none; box-shadow: inset 0 -2px 0 var(--accent, #fff); }

/* ---------- overlays ---------- */
.sheet {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(6, 6, 8, .9);
  backdrop-filter: blur(6px);
  display: grid;
  place-items: center;
  padding: 40px 24px 90px;
  color: #fff;
}
.sheet[hidden] { display: none; }   /* display:grid above would otherwise beat the hidden attribute */
.sheet-in { width: min(1100px, 100%); max-height: 100%; overflow: auto; }
.sheet h2 { margin: 0 0 20px; font-size: 15px; letter-spacing: .22em; text-transform: uppercase; font-weight: 600; }
.ov-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.ov-cell {
  text-align: left;
  min-height: 92px;
  padding: 14px;
  background: rgba(255, 255, 255, .06);
  border: 1px solid rgba(255, 255, 255, .16);
  border-radius: 6px;
  color: inherit;
  font: inherit;
  cursor: pointer;
  display: grid;
  gap: 8px;
  align-content: start;
}
.ov-cell:hover { background: rgba(255, 255, 255, .13); }
.ov-cell[aria-current="true"] { border-color: var(--accent, #fff); }
.ov-n { font: 600 11px/1 var(--mono); letter-spacing: .2em; opacity: .7; }
.ov-t { font-size: 15px; line-height: 1.35; }
.keys { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 10px 28px; font-size: 14px; }
.keys div { display: flex; gap: 12px; align-items: baseline; }
.keys kbd {
  font: 600 11px/1.6 var(--mono);
  padding: 3px 7px;
  border: 1px solid rgba(255, 255, 255, .3);
  border-radius: 4px;
  white-space: nowrap;
}
.sheet-x { position: absolute; top: 18px; right: 18px; }

/* ---------- toast ---------- */
#toast {
  position: fixed;
  left: 50%;
  bottom: 86px;
  transform: translate(-50%, 12px);
  padding: 11px 18px;
  border-radius: 999px;
  background: #15161a;
  color: #fff;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 70;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .slide [data-anim], [data-draw], [data-bar], #bar, .mask, .plate img { transition: none !important; animation: none !important; }
  .slide [data-anim] { opacity: 1 !important; transform: none !important; clip-path: inset(0) !important; }
  .slide.in [data-bar], .slide [data-bar] { width: var(--to) !important; }
}

/* ---------- print: one 16:9 page per slide ---------- */
@media print {
  @page { size: 1280px 720px; margin: 0; }
  html, body { height: auto; overflow: visible; background: #fff; display: block; }
  .wrap { padding: 0; display: block; }
  .chrome, #bar-track, .sheet, #toast, .sr { display: none !important; }
  #stage {
    width: 1280px;
    height: auto;
    aspect-ratio: auto;
    box-shadow: none;
    border-radius: 0;
    overflow: visible;
    container-type: normal;
  }
  .slide {
    position: relative !important;
    inset: auto !important;
    display: flex !important;
    width: 1280px;
    height: 720px;
    break-after: page;
    page-break-after: always;
    overflow: hidden;   /* a decorative layer that bleeds outside the slide must not spill onto a page of its own */
    transform: none !important;
    opacity: 1 !important;
    padding: 72px;
  }
  .slide:last-child { break-after: auto; page-break-after: auto; }
  .slide [data-anim] { opacity: 1 !important; transform: none !important; clip-path: inset(0) !important; transition: none !important; }
  .slide [data-bar] { width: var(--to) !important; }
  [data-draw] { stroke-dashoffset: 0 !important; }
  .mask { display: none !important; }
  * { print-color-adjust: exact !important; -webkit-print-color-adjust: exact !important; }
}


:root {
  --bg: #F6F1E4; --backdrop: #2C2A26; --ink: #1F2320; --pencil: #6F6A60; --red: #C0472B;
  --tape: rgba(226, 206, 150, .6); --type: var(--ink); --muted: var(--pencil);
  --accent: var(--red); --focus: var(--red);
  --sans: "Figtree", -apple-system, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --serif: "Source Serif 4", Georgia, "Times New Roman", serif;
  --hand: "Caveat", "Bradley Hand", "Segoe Print", cursive;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --chrome-bg: rgba(31, 35, 32, .9); --chrome-ink: rgba(246, 241, 228, .82);
  --edit-hint: rgba(31, 35, 32, .26); --pad: 4.6cqw; --stage-radius: 2px;
}
#stage {
  color: var(--ink);
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)' opacity='.055'/%3E%3C/svg%3E");
}
.slide { padding-left: 9cqw; padding-right: 20cqw; justify-content: flex-start; padding-top: 5cqw; }
.bind { position: absolute; left: 5.4cqw; top: 0; bottom: 0; width: 1px; background: rgba(192, 71, 43, .3); z-index: 0; }
.bind::after { content: ""; position: absolute; left: 3px; top: 0; bottom: 0; width: 1px; background: rgba(31, 35, 32, .09); }
.slide > *:not(.bind):not(.margin):not(.leaders):not(.tape) { position: relative; z-index: 1; }
.fnum { font: 600 clamp(8px, .74cqw, 11px)/1 var(--mono); letter-spacing: .2em; text-transform: uppercase; color: var(--red); margin: 0 0 1.8cqw; }
h1 { font: 600 clamp(22px, 3.3cqw, 56px)/1.1 var(--serif); margin: 0; letter-spacing: -.015em; }
h2 { font: 600 clamp(17px, 2.4cqw, 42px)/1.16 var(--serif); margin: 0 0 1.8cqw; letter-spacing: -.012em; }
.body { font-size: clamp(10px, 1.14cqw, 18px); line-height: 1.7; max-width: 60ch; margin: 0 0 1.4cqw; }
.dim { color: var(--pencil); }
.margin { position: absolute; right: 3.4cqw; top: 7cqw; width: 15cqw; z-index: 1; }
.margin p { font: 400 clamp(10px, 1.1cqw, 17px)/1.35 var(--hand); color: var(--red); margin: 0 0 1.6cqw; }
.leaders { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 2; }
.leaders path { fill: none; stroke: var(--red); stroke-width: 1.6; stroke-linecap: round; }
.tape { position: absolute; width: 11cqw; height: 3.2cqw; background: var(--tape); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .5); z-index: 3; }
.card { position: relative; background: #FDFBF3; border: 1px solid rgba(31, 35, 32, .12); padding: 3cqw 3.4cqw; box-shadow: 0 1.2cqw 3cqw rgba(31, 35, 32, .1); }
.quote { font: italic 400 clamp(17px, 3.1cqw, 54px)/1.26 var(--serif); margin: 0; }
.who { font: 600 clamp(8px, .78cqw, 12px)/1 var(--mono); letter-spacing: .18em; text-transform: uppercase; color: var(--pencil); margin: 2.2cqw 0 0; }
.meta { display: flex; gap: 2.6cqw; font: 600 clamp(8px, .76cqw, 11px)/1 var(--mono); letter-spacing: .16em; text-transform: uppercase; color: var(--pencil); margin-top: 2.6cqw; }
ul.b { margin: 1cqw 0 0; padding-left: 1.6em; }
ul.b li { font-size: clamp(10px, 1.12cqw, 18px); line-height: 1.65; margin-bottom: 1cqw; }
table { width: 100%; border-collapse: collapse; font-size: clamp(9px, 1.02cqw, 16px); margin-top: 1.4cqw; }
th { text-align: left; font: 600 clamp(8px, .74cqw, 11px)/1.6 var(--mono); letter-spacing: .16em; text-transform: uppercase; color: var(--pencil); border-bottom: 1px solid rgba(31, 35, 32, .3); padding: 0 1.6cqw .8cqw 0; }
td { padding: .9cqw 1.6cqw .9cqw 0; border-bottom: 1px solid rgba(31, 35, 32, .12); }
th:not(:first-child), td:not(:first-child) { text-align: right; font-variant-numeric: tabular-nums; }
.plot { width: 100%; height: 22cqw; overflow: visible; margin-top: 1.4cqw; }
.plot text { font: 600 9px/1 var(--mono); fill: #6F6A60; letter-spacing: .1em; }
.venn { width: 100%; height: 30cqw; overflow: visible; margin-top: 1cqw; }
.venn text { font: 600 11px/1 var(--mono); fill: #1F2320; letter-spacing: .12em; text-transform: uppercase; }
.next { display: grid; gap: 1.4cqw; margin-top: 1.4cqw; }
.next > div { display: grid; grid-template-columns: 1fr 12cqw 10cqw; gap: 2cqw; align-items: baseline; border-top: 1px solid rgba(31, 35, 32, .16); padding-top: 1.2cqw; }
.next .t { font-size: clamp(10px, 1.18cqw, 19px); }
.next .o, .next .d { font: 600 clamp(8px, .78cqw, 12px)/1.3 var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--pencil); }

/* ---- motion: drawn by hand ---- */
.slide.in { animation: sheetF .18s ease-out both; }
#stage[data-dir="back"] .slide.in { animation: sheetB .18s ease-out both; }
@keyframes sheetF { from { transform: translateX(12px); } to { transform: none; } }
@keyframes sheetB { from { transform: translateX(-12px); } to { transform: none; } }
.slide [data-anim] { clip-path: inset(0 100% 0 0); transform: none; transition: opacity .3s ease, clip-path .46s cubic-bezier(.3, .9, .3, 1); transition-delay: calc(var(--i, 0) * 80ms + 120ms); }
#stage[data-dir="back"] .slide [data-anim] { clip-path: inset(0 0 0 100%); }
.margin p[data-anim] { clip-path: none; transform: translateX(14px); transition-delay: calc(var(--i, 0) * 80ms + 460ms); }
.quote span { display: inline-block; opacity: 0; transform: translateY(.5em); transition: opacity .3s, transform .42s cubic-bezier(.2, .9, .2, 1); }
.slide.in .quote span { opacity: 1; transform: none; }
[data-draw] { transition-duration: .52s; transition-delay: .36s; }
@media (prefers-reduced-motion: reduce) { .slide.in { animation: none; } .quote span { opacity: 1 !important; transform: none !important; } }
