/* My Red Thread. A dark room: a projector below the viewer throws a beam (with dust) onto a plaster
   wall. In front of it a red thread is strung across the room like a darkroom line; every chapter is
   a print pegged to it, with the facts handwritten on its back. One dark look, by choice. */

/* Cabinet Grotesk (Fontshare FFL; licence in fonts/): the title face of the real-look prints */
@font-face {
  font-family: "Cabinet Grotesk"; src: url("../fonts/CabinetGrotesk-Variable.woff2") format("woff2");
  font-weight: 100 900; font-style: normal; font-display: swap;
}

:root {
  --room: #0B0B0D;
  --wall: #202025;
  --paper: #EFEEEA;
  --paper-back: #E7E3DA;
  --ink: #17181A;
  --ink-mute: #4D5157;
  --pen: #23304A;
  --ph: #5F646B;
  --fg: #EDEEEA;
  --mute: #A7ACB1;
  --line: #3A3F44;
  --thread: #D92F25;   /* red: the thread, the knots, the chapter questions. Nothing else. */
  --q: #A8160F;        /* the question red, darkened to read on paper */
  --display: "Archivo", "Arial Black", Arial, sans-serif;
  --body: "IBM Plex Sans", "Helvetica Neue", Arial, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
  --hand: "Caveat", "Segoe Print", "Bradley Hand", cursive;
  --ease-line: cubic-bezier(.22, .8, .24, 1);
  --pad-x: max(16px, env(safe-area-inset-left, 0px));
  --pad-xr: max(16px, env(safe-area-inset-right, 0px));
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-snap-type: y mandatory; background: var(--room); }
html.film-open, html.view-open { overflow: hidden; }
body { margin: 0; background: var(--room); color: var(--fg); font: 16px/1.6 var(--body); }
h1, h2, p { margin: 0; }
h1, h2 { font-family: var(--display); text-wrap: balance; }
img { display: block; max-width: 100%; }
button { font: inherit; }
[hidden] { display: none !important; }

:focus-visible { outline: 2px solid var(--fg); outline-offset: 3px; }
.face :focus-visible { outline-color: var(--ink); outline-offset: 1px; }

.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0;
}

.step { height: 100vh; height: 100svh; scroll-snap-align: start; scroll-snap-stop: always; }
/* iOS Safari: with the toolbars away the window is taller than 100svh, so the last step could never be reached
   (the last snap point lies past the end of the page); this makes room for it */
#steps { padding-bottom: calc(100vh - 100svh); }
html.nav-moving { scroll-snap-type: none; }
#debugLog {
  position: fixed; left: 4px; right: 4px; top: calc(env(safe-area-inset-top, 0px) + 44px); z-index: 9999; margin: 0; padding: 4px 6px; pointer-events: none;
  font: 9px/1.25 ui-monospace, Menlo, monospace; color: #9f9; background: rgba(0, 0, 0, .78); white-space: pre-wrap; word-break: break-all;
}

/* placeholder text: a fact that is still missing, always visible */
.ph {
  color: var(--ph); font-style: italic; background: rgba(23, 24, 26, .06);
  text-decoration: underline dashed; text-decoration-thickness: 1px; text-underline-offset: 4px;
  overflow-wrap: anywhere;
}

/* ---------- stage ---------- */
.stage {
  position: fixed; inset: 0; z-index: 1; display: flex; flex-direction: column; overflow: hidden;
  touch-action: pan-y; background-color: var(--wall);
  padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px);
}
.stage::before { content: ""; position: absolute; inset: 0; pointer-events: none;
  background-image: var(--plaster); background-size: 256px 256px; mix-blend-mode: multiply; opacity: .9; }
.stage::after { content: ""; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(62% 52% at 50% 30%, rgba(0, 0, 0, 0) 12%, rgba(0, 0, 0, .5) 55%, rgba(0, 0, 0, .88) 100%); }
.top, .room, .controls { position: relative; z-index: 2; }
#beam { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 1; pointer-events: none; }

.top {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 16px;
  padding: 12px var(--pad-xr) 12px var(--pad-x);
}
.brand { font-family: var(--display); font-weight: 800; font-stretch: 112%; font-size: 17px; color: var(--fg); text-decoration: none; }
.brand-sub { font-weight: 500; color: var(--mute); display: none; }
@media (min-width: 480px) { .brand-sub { display: inline; } }
.where {
  font-family: var(--mono); font-size: 12px; letter-spacing: .08em; text-transform: uppercase;
  color: var(--mute); font-variant-numeric: tabular-nums;
}
.where b { color: var(--fg); font-weight: 500; }

.room { flex: 1; min-height: 0; display: flex; flex-direction: column; justify-content: center; }
.fail { padding: 24px var(--pad-x); font-family: var(--mono); font-size: 13px; color: var(--mute); }

/* ---------- projection ---------- */
.wallzone { position: relative; display: flex; justify-content: center; padding: 0 var(--pad-xr) 0 var(--pad-x); }
.proj {
  position: relative; width: 100%; max-width: 100%;
  height: min(calc((100vw - 32px) * 1.2), 42svh);
  transform: perspective(1500px) rotateX(2deg); transition: opacity .16s ease;
}
.room.t2 .proj { height: min(calc((100vw - 32px) * 1.2), 32svh); }
.room.t3 .proj { height: min(calc((100vw - 32px) * 1.2), 24svh); }
.proj.off { opacity: .12; }
.lightmask {
  position: absolute; inset: 0;
  -webkit-mask-image: linear-gradient(to right, transparent, #000 3%, #000 97%, transparent), linear-gradient(to bottom, transparent, #000 4%, #000 96%, transparent);
  -webkit-mask-composite: source-in;
  mask-image: linear-gradient(to right, transparent, #000 3%, #000 97%, transparent), linear-gradient(to bottom, transparent, #000 4%, #000 96%, transparent);
  mask-composite: intersect;
}
.slide {
  position: absolute; inset: 0; overflow: hidden; mix-blend-mode: screen; filter: saturate(.92) contrast(1.06);
  transition: transform .5s cubic-bezier(.2, .7, .2, 1), opacity .35s ease;
}
.slide img { width: 100%; height: 100%; object-fit: cover; transform: scale(var(--zoom, 1)); }
.slide video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; pointer-events: none; }
.slide video.live { opacity: 1; }
.slide.on { transform: none; opacity: 1; }
.slide.off-n { transform: translateX(6%); opacity: 0; }
.slide.off-p { transform: translateX(-6%); opacity: 0; }
.grain { position: absolute; inset: 0; background-image: var(--plaster); background-size: 256px 256px; mix-blend-mode: multiply; opacity: .7; }
.hot { position: absolute; inset: 0; mix-blend-mode: screen;
  background: radial-gradient(55% 50% at 50% 48%, rgba(255, 242, 224, .20), rgba(255, 242, 224, 0) 70%); }
.flicker { animation: flicker 7s infinite steps(1); }
@keyframes flicker { 0% { opacity: 1 } 31% { opacity: .955 } 32% { opacity: 1 } 64% { opacity: .975 } 65% { opacity: 1 } 88% { opacity: .96 } 89% { opacity: 1 } }
.tag {
  position: absolute; right: 5%; top: 6%; padding: 3px 8px;
  font-family: var(--mono); font-size: 11px; letter-spacing: .1em; text-transform: uppercase; line-height: 1.3;
  color: rgba(255, 255, 255, .92); background: rgba(0, 0, 0, .6);
}
.photo .tag { right: 6px; top: 6px; padding: 1px 5px; font-size: 9px; letter-spacing: .08em; }

/* Desktop: the prints hang in front of the wall, so the thread crosses the lower ~28 % of the
   projection. --pw is the wall width; fit steps (t2, t3) shorten it. */
@media (min-width: 900px) {
  .room { --pw: min(1040px, calc((100svh - 440px) * 2.22)); }
  .room.t2 { --pw: min(1040px, calc((100svh - 497px) * 2.22)); }
  .room.t3 { --pw: min(1040px, calc((100svh - 560px) * 2.22)); }
  .proj, .room.t2 .proj, .room.t3 .proj { width: var(--pw); height: auto; aspect-ratio: 16 / 10; transform: perspective(1500px) rotateX(2.5deg); }
  .room .linezone { margin-top: calc(var(--pw) / 1.6 * -.28 - 12px); }
}

/* ---------- the line and the prints ---------- */
.linezone { position: relative; margin-top: -46px; }
.strip {
  position: relative; display: flex; align-items: flex-start; gap: var(--gap); width: max-content; padding-top: 22px;
  transition: transform .8s var(--ease-line); will-change: transform;
}
.strip svg { position: absolute; left: 0; top: 0; height: 40px; overflow: visible; pointer-events: none; }
#lineSvg path { fill: none; stroke: var(--thread); stroke-width: 2.2; stroke-linecap: round; }

.sheet {
  --w: min(76vw, 380px);
  flex: 0 0 var(--w); width: var(--w); position: relative; cursor: pointer; perspective: 1400px;
  transform-origin: 50% -12px; transform: rotate(var(--tilt, 0deg)) scale(.9); opacity: .38; filter: brightness(.62);
  transition: opacity .5s, filter .5s, transform .8s var(--ease-line);
}
@media (min-width: 900px) { .sheet { --w: min(76vw, 440px); } }
.sheet.ch-start { margin-left: 44px; }
.sheet:first-of-type { margin-left: 0; }
.sheet.cur { opacity: 1; filter: none; transform: rotate(0deg) scale(1); cursor: default; }
.sheet.swing { animation: swing 1.1s ease-out; }
@keyframes swing { 0% { transform: rotate(4.5deg) } 30% { transform: rotate(-2.6deg) } 55% { transform: rotate(1.3deg) } 78% { transform: rotate(-.5deg) } 100% { transform: rotate(0) } }

.peg {
  position: absolute; left: 50%; top: -24px; width: 10px; height: 26px; transform: translateX(-50%); z-index: 3;
  background: #2A2A2E; border-radius: 2px; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .08);
}
.peg::after { content: ""; position: absolute; left: 1px; right: 1px; top: 9px; height: 3px; background: #77797D; }

.faces { display: grid; transform-style: preserve-3d; transition: transform .7s cubic-bezier(.3, .7, .2, 1); }
.sheet.flipped .faces { transform: rotateY(180deg); }
.face {
  grid-area: 1 / 1; -webkit-backface-visibility: hidden; backface-visibility: hidden;
  background: var(--paper); color: var(--ink); padding: 12px 12px 14px;
  display: flex; flex-direction: column; gap: 10px;
  box-shadow: 0 18px 38px rgba(0, 0, 0, .6), 0 2px 6px rgba(0, 0, 0, .4);
}
.face.back { transform: rotateY(180deg); background: var(--paper-back); }

.photo { position: relative; overflow: hidden; height: clamp(64px, 11svh, 120px); background: #2A2A2E; }
.photo img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 50%; transform: scale(var(--zoom, 1)); }
.inner { display: flex; flex-direction: column; gap: 6px; padding-inline: 4px; }

.face .q { font-family: var(--mono); font-size: 12px; letter-spacing: .04em; color: var(--q); line-height: 1.4; }
.roll {
  display: inline-block; overflow: hidden; height: 1.4em; vertical-align: bottom; color: var(--ink); font-weight: 500;
  box-shadow: inset 0 -2px 0 var(--thread); transition: width .45s cubic-bezier(.3, .7, .2, 1);
}
.roll .stack { display: block; transition: transform .55s cubic-bezier(.3, .7, .2, 1); }
.roll .w { display: block; width: max-content; height: 1.4em; white-space: nowrap; }

.face .hl { font-size: clamp(21px, 2.4vw, 27px); font-weight: 800; font-stretch: 112%; line-height: 1.08; }
.face .hl.big { font-size: clamp(30px, 4.4vw, 50px); font-weight: 850; font-stretch: 125%; line-height: .94; letter-spacing: -.02em; }
.face .copy { color: var(--ink-mute); font-size: 15px; line-height: 1.5; }
.face .note {
  margin-top: 4px; padding-top: 8px; border-top: 1px dashed rgba(23, 24, 26, .3);
  font-family: var(--mono); font-size: 11.5px; line-height: 1.45; color: var(--ink-mute);
}
.actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0 8px; margin-top: 2px; }
.turn, .filmbtn {
  min-height: 36px; padding: 0 4px; border: 0; background: transparent; cursor: pointer; white-space: nowrap;
  font-family: var(--mono); font-size: 12px; letter-spacing: .06em; color: var(--ink-mute);
}
.turn { margin-left: auto; text-decoration: underline; text-underline-offset: 3px; }
.back > .turn { align-self: flex-end; margin-top: 2px; }
.filmbtn { padding: 0 8px; border: 1px solid var(--ink-mute); color: var(--ink); font-size: 11px; letter-spacing: .02em; }
.filmbtn ~ .turn { font-size: 11px; letter-spacing: .02em; }
.sheet:not(.cur) .turn, .sheet:not(.cur) .filmbtn { visibility: hidden; }
.backhead { padding-inline: 4px; font-family: var(--mono); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-mute); }
.notes { list-style: none; margin: 0; padding: 0 4px; display: flex; flex-direction: column; gap: 2px; }
.notes li { font-family: var(--hand); font-size: 23px; line-height: 1.15; color: var(--pen); font-weight: 500; }
.notes .ph { font-style: normal; text-decoration-thickness: 1.5px; }

/* fit step 1 (phones): smaller type on the prints. On desktop only the projection gives way. */
@media (max-width: 899px) {
  .strip.t1 .face { padding: 9px 9px 10px; gap: 7px; }
  .strip.t1 .photo { height: 52px; }
  .strip.t1 .face .hl { font-size: 18px; }
  .strip.t1 .face .hl.big { font-size: 26px; }
  .strip.t1 .face .copy { font-size: 13.5px; line-height: 1.42; }
  .strip.t1 .face .note { font-size: 10.5px; }
  .strip.t1 .notes li { font-size: 20px; }
}

/* ---------- controls ---------- */
.controls { display: flex; align-items: center; justify-content: center; gap: 14px; padding: 6px var(--pad-xr) 12px var(--pad-x); }
.nav {
  width: 44px; height: 44px; border: 1px solid var(--line); background: rgba(11, 11, 13, .6); color: var(--fg);
  font-size: 18px; cursor: pointer;
}
.nav[aria-disabled="true"] { opacity: .35; cursor: default; }
.count { min-width: 64px; text-align: center; font-family: var(--mono); font-size: 12px; letter-spacing: .08em; color: var(--mute); font-variant-numeric: tabular-nums; }

/* ---------- real look (?look=real) ---------- */
@keyframes drift {
  0%, 100% { transform: scale(calc(var(--zoom, 1) * 1.03)); }
  50% { transform: scale(calc(var(--zoom, 1) * 1.08)); }
}
.slide.drift img { animation: drift 24s ease-in-out infinite; }
@media (prefers-reduced-motion: reduce) { .slide.drift img { animation: none; } }
html.gl-on .lightmask { visibility: hidden; }
html.gl-on #beam { display: none; }
html:not(.gl-on) #gl { display: none; }
#gl { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 1; pointer-events: none; }
/* the prints catch the beam: faint light from below, tinted by the slide */
html.look-real .face.front { position: relative; }
html.look-real .face.front::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(to top, rgba(var(--beam-rgb, 255, 214, 170), .20), rgba(var(--beam-rgb, 255, 214, 170), 0) 55%);
}

/* ---------- room plate (real look, fourth pass) ----------
   An AI still of a dark room is the stage: a lit rectangle on plaster, a slide projector at the bottom.
   JS (plate.js) measures where things are in it and sets --rl --rt --rw --rh --rb (the lit rectangle),
   --prev-x/y --next-x/y --cnt-x/y (the controls on the projector body). */
.plate, .plate-note { display: none; }
html.plate-on .plate { display: block; position: absolute; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; }
html.plate-on .plate img { position: absolute; max-width: none; user-select: none; -webkit-user-drag: none; }
html.plate-on .plate.bars img { -webkit-mask-image: linear-gradient(to right, transparent, #000 4%, #000 96%, transparent); mask-image: linear-gradient(to right, transparent, #000 4%, #000 96%, transparent); }
html.plate-on.gl-on .plate { visibility: hidden; }
html.plate-on .stage { background: #0b0908; }
html.plate-on .stage::before, html.plate-on .stage::after { display: none; }
html.plate-on #beam { display: none; }
html.plate-on .plate-note {
  display: block; position: absolute; z-index: 4; left: var(--pad-x); bottom: calc(8px + env(safe-area-inset-bottom, 0px));
  font-family: var(--mono); font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: rgba(237, 238, 234, .5);
}

/* the lit rectangle is where the picture goes; the thread hangs across its lower part */
html.plate-on .room { position: static; display: block; --ov: .28; }
html.plate-on .room.t2 { --ov: .36; }
html.plate-on .room.t3 { --ov: .37; }
html.plate-on .room .wallzone { position: absolute; z-index: 2; left: var(--rl); top: var(--rt); width: var(--rw); height: var(--rh); padding: 0; display: block; }
html.plate-on .room .proj, html.plate-on .room.t2 .proj, html.plate-on .room.t3 .proj {
  position: absolute; inset: 0; width: 100%; height: 100%; aspect-ratio: auto; transform: none;
}
html.plate-on .room .linezone { position: absolute; z-index: 2; left: 0; right: 0; margin: 0; top: calc(var(--rb) - var(--ov) * var(--rh) - 12px); }

/* without WebGL (or with reduced motion) the slides are laid into the plate by CSS: multiplied, with a
   little screen so blacks stay plaster-dark, and a few percent larger so no lit edge of the plate shows */
html.plate-on:not(.gl-on) .lightmask { inset: -1.2%; -webkit-mask-image: none; mask-image: none; }
html.plate-on:not(.gl-on) .slide { mix-blend-mode: multiply; filter: none; }
html.plate-on:not(.gl-on) .lightmask::after {
  content: ""; position: absolute; inset: 0; mix-blend-mode: screen; background: rgba(52, 40, 30, .5); pointer-events: none;
}

/* prints: type and height give way before anything else (fit levels 1 to 3), at every width */
html.plate-on .sheet { --w: min(76vw, 380px); }
html.plate-on.plate-wide .sheet { --w: min(40vw, 520px); }
html.plate-on .photo { height: clamp(56px, 9svh, 96px); }
html.plate-on .strip.t1 .face { padding: 9px 9px 10px; gap: 7px; }
html.plate-on .strip.t1 .photo { height: 52px; }
html.plate-on .strip.t1 .face .hl { font-size: 18px; }
html.plate-on .strip.t1 .face .hl.big { font-size: 26px; }
html.plate-on .strip.t1 .face .copy { font-size: 13.5px; line-height: 1.42; }
html.plate-on .strip.t1 .face .note { font-size: 10.5px; }
html.plate-on .strip.t1 .notes li { font-size: 20px; }
html.plate-on .room.t2 .strip .photo { height: 40px; }
html.plate-on .room.t2 .strip .face .copy { font-size: 13px; line-height: 1.38; }
html.plate-on .room.t2 .strip .notes li { font-size: 18px; line-height: 1.1; }
html.plate-on .room.t3 .strip .photo { height: 34px; }
html.plate-on .room.t3 .strip .face { padding: 8px 9px 8px; gap: 5px; }
html.plate-on .room.t3 .strip .face .hl { font-size: 17.5px; }
html.plate-on .room.t3 .strip .face .copy { font-size: 13px; line-height: 1.36; }
html.plate-on .room.t3 .strip .notes li { font-size: 16.5px; line-height: 1.08; }
html.plate-on .room.t3 .strip .actions .turn, html.plate-on .room.t3 .strip .actions .filmbtn { min-height: 30px; }

/* card height: the front sets it; the back keeps its own height (it may be shorter or taller) */
html.plate-on .faces { display: block; position: relative; }
html.plate-on .face.back { position: absolute; left: 0; right: 0; top: 0; }
/* slides are never stretched (cover crop into the quad); drift stays within 4 % */
@keyframes drift-plate { 0%, 100% { transform: scale(var(--zoom, 1)); } 50% { transform: scale(calc(var(--zoom, 1) * 1.04)); } }
html.plate-on .slide.drift img { animation-name: drift-plate; }

/* the projector is the controls: counter on the slide tray, two buttons on the body */
html.plate-on .controls { position: absolute; inset: 0; z-index: 4; display: block; padding: 0; gap: 0; pointer-events: none; }
html.plate-on .nav {
  pointer-events: auto; position: absolute; isolation: isolate; display: grid; place-items: center; width: 44px; height: 44px; margin: 0; padding: 0;
  border: 0; background: none; color: #2b2723; font-size: 13px; line-height: 1; -webkit-tap-highlight-color: transparent;
}
html.plate-on #prev { left: calc(var(--prev-x) - 22px); top: calc(var(--prev-y) - 22px); }
html.plate-on #next { left: calc(var(--next-x) - 22px); top: calc(var(--next-y) - 22px); }
html.plate-on .nav::before {
  content: ""; position: absolute; z-index: -1; left: 7px; right: 7px; top: 11px; bottom: 11px; border-radius: 3px;
  background: linear-gradient(#d3cdbf, #8e8878);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .45), 0 2px 3px rgba(0, 0, 0, .75), 0 0 0 1px #26231f;
  transition: transform .06s;
}
html.plate-on .nav:active::before { transform: translateY(1px); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .3), 0 0 2px rgba(0, 0, 0, .8), 0 0 0 1px #26231f; }
html.plate-on .nav:focus-visible { outline: none; }
html.plate-on .nav:focus-visible::after { content: ""; position: absolute; inset: 4px; border: 2px solid #fff; border-radius: 6px; box-shadow: 0 0 0 1px #000; }
html.plate-on .nav[aria-disabled="true"] { opacity: .4; }
html.plate-on .count {
  position: absolute; left: var(--cnt-x); top: var(--cnt-y); transform: translate(-50%, -50%); min-width: 0; white-space: nowrap; pointer-events: none;
  font-size: 10px; letter-spacing: .14em; color: rgba(236, 214, 170, .88); text-shadow: 0 1px 0 rgba(0, 0, 0, .85), 0 -1px 0 rgba(255, 240, 210, .14);
}
@media (prefers-reduced-motion: reduce) { html.plate-on .nav::before { transition: none; } }

/* ---------- real look: photo prints on steel clips (sixth pass) ----------
   Ported from lab/cards. Off-white photo paper, 14 px white border, two stainless darkroom clips at 12 % and 88 %,
   one twisted red cord (canvas), a real knot at chapter gaps. The front has no picture: question, title, a line
   or two, "Turn over". Nothing between .sheet and .rface may flatten 3D (no filter, opacity, overflow). */
html.look-real .strip { transition: none; z-index: 4; }
html.look-real #lineSvg { display: none; }
#threadCanvas { position: absolute; left: 0; top: -32px; width: 100%; height: 96px; pointer-events: none; z-index: 3; }

html.look-real .sheet.rc, html.look-real .sheet.rc:not(.cur) {
  opacity: 1; filter: none; transition: none; -webkit-perspective: 1150px; perspective: 1150px; transform-origin: 50% -10px;
  will-change: transform; -webkit-tap-highlight-color: transparent;
  --hl-k: .165; --hl-min: 22; --pad: 14px;
}
html.look-real .sheet.rc.cur { cursor: default; z-index: 5; }
html.look-real .strip.t1 .sheet.rc { --hl-k: .15; --hl-min: 21; --pad: 12px; }
html.look-real .room.t2 .sheet.rc { --hl-k: .135; --hl-min: 20; }
html.look-real .room.t3 .sheet.rc { --hl-k: .115; --hl-min: 19; --pad: 10px; }
html.look-real .sheet.rc.ch-start { margin-left: 44px; }

/* shadows on the wall: GL draws them (and the cord's); without GL these DOM ones stand in */
.wall-shadow {
  position: absolute; left: 4px; right: 4px; top: -22px; bottom: 14px; pointer-events: none; border-radius: 4px;
  background: rgba(3, 3, 5, .3); box-shadow: 0 -10px 24px rgba(0, 0, 0, .5), 0 6px 16px rgba(0, 0, 0, .35); will-change: transform;
}
html.gl-on .wall-shadow { display: none; }
.clip-wall-shadow {
  position: absolute; top: -34px; width: 15px; height: 34px; pointer-events: none; border-radius: 6px;
  background: radial-gradient(ellipse at center, rgba(0, 0, 0, .64) 0%, rgba(0, 0, 0, 0) 76%);
  transform-origin: 50% 65%; transform: translate3d(-50%, 0, -8px); will-change: transform;
}
.clip-wall-shadow.clip-left, .clip-wrap.clip-left, .clip-dent.clip-left { left: 12%; }
.clip-wall-shadow.clip-right, .clip-wrap.clip-right, .clip-dent.clip-right { left: 88%; }

/* the two stainless clips */
.clip-wrap {
  position: absolute; top: -27px; width: 22px; height: 39px; pointer-events: none; transform-origin: 50% 13px;
  transform: translate3d(-50%, 0, 14px); will-change: transform; z-index: 7;
}
.clip-svg {
  display: block; width: 100%; height: 100%; overflow: visible;
  filter: drop-shadow(0 -1.5px 2.5px rgba(0, 0, 0, .5)) drop-shadow(0 1.5px 2px rgba(0, 0, 0, .35));
}
.clip-glint { will-change: transform, opacity; }
/* a tiny shadow and pinch mark on the paper under each clip */
.clip-dent {
  position: absolute; top: 0; width: 22px; height: 12px; transform: translateX(-50%); pointer-events: none; z-index: 6;
  background:
    radial-gradient(54% 78% at 50% 18%, rgba(16, 18, 22, .32) 0%, rgba(16, 18, 22, .13) 50%, rgba(16, 18, 22, 0) 84%),
    linear-gradient(to bottom, rgba(18, 20, 24, .24) 0%, rgba(18, 20, 24, .08) 54%, rgba(255, 252, 244, .68) 78%, rgba(255, 252, 244, 0) 100%);
  border-bottom-left-radius: 5px 4px; border-bottom-right-radius: 5px 4px;
}

/* the card: front sets the height, the back is at least as tall and may be taller */
html.look-real .rfaces { position: relative; display: block; width: 100%; -webkit-transform-style: preserve-3d; transform-style: preserve-3d; will-change: transform; }
html.look-real .rface {
  -webkit-backface-visibility: hidden; backface-visibility: hidden; background-color: var(--card-paper, #EFEEEA); color: var(--ink);
  padding: var(--pad); display: flex; flex-direction: column; border-radius: 1.5px;
  box-shadow: inset 0 -1.5px 0 rgba(255, 246, 228, .88), inset 0 1px 0 rgba(23, 24, 26, .14), inset 1px 0 0 rgba(255, 252, 245, .48), inset -1px 0 0 rgba(23, 24, 26, .1), 0 1px 2px rgba(0, 0, 0, .32);
}
html.look-real .rface.front { position: relative; transform: rotateY(0deg) translateZ(.5px); }
html.look-real .rface.back {
  position: absolute; left: 0; right: 0; top: 0; min-height: 100%; transform: rotateY(180deg) translateZ(.5px);
  background-color: var(--card-paper-back, #E7E3DA); justify-content: space-between;
}
html.look-real .rface :focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
/* paper grain, aged edge */
html.look-real .rface::before {
  content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 2; opacity: .85;
  background-image: var(--paper-tex), radial-gradient(90% 85% at 50% 50%, rgba(168, 128, 68, 0) 58%, rgba(145, 104, 48, calc(.12 * var(--age-warmth, 0))) 100%);
  background-size: 160px 160px, 100% 100%;
}
/* light from below: the beam's colour (from the slide) on the lower part, shade at the top */
html.look-real .rface::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 3;
  background: linear-gradient(to top, rgba(var(--beam-rgb, 255, 214, 170), .26) 0%, rgba(var(--beam-rgb, 255, 214, 170), .12) 26%, rgba(var(--beam-rgb, 255, 214, 170), .03) 54%, rgba(10, 11, 15, .09) 84%, rgba(8, 9, 13, .2) 100%);
}
.paper-sheen { position: absolute; inset: 0; pointer-events: none; z-index: 4; clip-path: inset(0 round 1.5px); }
.paper-sheen-band {
  position: absolute; inset: -40% -60%; will-change: transform, opacity;
  background: linear-gradient(112deg, rgba(255, 250, 240, 0) 32%, rgba(255, 246, 232, .05) 44%, rgba(255, 250, 242, .19) 50%, rgba(var(--beam-rgb, 255, 214, 170), .09) 54%, rgba(255, 250, 240, 0) 66%);
}
.corner-curl {
  position: absolute; inset: 0; pointer-events: none; z-index: 4;
  background:
    radial-gradient(90px 58px at 0% 100%, rgba(255, 248, 236, .52) 0%, rgba(24, 22, 20, .07) 44%, transparent 72%),
    radial-gradient(96px 62px at 100% 100%, rgba(255, 248, 236, .56) 0%, rgba(24, 22, 20, .08) 45%, transparent 74%),
    linear-gradient(to top, rgba(255, 248, 235, .45) 0, rgba(255, 248, 235, 0) 3.5px);
}
.dim-veil { position: absolute; inset: 0; pointer-events: none; z-index: 8; border-radius: 1.5px; background: rgba(8, 9, 13, .56); opacity: 0; transition: opacity .45s ease; }
html.look-real .sheet.rc:not(.cur) .dim-veil { opacity: 1; }

/* the print well inside the 14 px border */
html.look-real .print-well {
  position: relative; z-index: 5; flex: 1; display: flex; flex-direction: column; justify-content: space-between; gap: 12px;
  padding: 12px 11px 10px; background: rgba(23, 24, 26, .018); box-shadow: inset 0 0 0 1px rgba(23, 24, 26, .085), 0 1px 0 rgba(255, 253, 248, .72);
}
html.look-real .strip.t1 .print-well { padding: 10px 10px 8px; gap: 8px; }
html.look-real .room.t3 .print-well { padding: 7px 8px 5px; gap: 4px; }
html.look-real .rinner { display: flex; flex-direction: column; gap: 10px; position: relative; z-index: 5; }
html.look-real .strip.t1 .rinner { gap: 7px; }
html.look-real .room.t3 .rinner { gap: 4px; }

/* question: Plex Mono, red; the only red on the paper */
html.look-real .rc .q { font-family: var(--mono); font-size: 11.5px; font-weight: 500; letter-spacing: .03em; line-height: 1.35; color: var(--q); }
html.look-real .room.t3 .rc .q { font-size: 10.5px; letter-spacing: 0; }

/* title: Cabinet Grotesk 800, tight; size set by rcards.js (the largest that fits on 2 or 3 lines) */
html.look-real .rc .hl {
  margin: 0; font-family: "Cabinet Grotesk", "Helvetica Neue", Arial, sans-serif; font-weight: 800; font-stretch: normal;
  font-size: var(--hl-size, 34px); line-height: .96; letter-spacing: -.02em; color: var(--ink);
}
.hl-vis { display: block; }
.hl-lead { display: block; text-wrap: balance; }
.hl-line2 { display: block; white-space: nowrap; }
.hl.tail-wrap .hl-tail { display: block; }

/* the rolling word: always ink, never red; box width follows the word */
.roll-host {
  position: relative; display: inline-grid; vertical-align: bottom; overflow: clip; max-width: 100%; color: var(--ink);
  line-height: 1.06; padding-block: .06em; margin-block: -.06em; font-weight: inherit;
  transition: width .42s cubic-bezier(.3, .7, .2, 1);
}
.roll-host .roll-word { display: block; position: relative; grid-area: 1 / 1; justify-self: start; white-space: nowrap; opacity: 0; padding-right: .03em; align-self: center; }
.roll-host .roll-word.is-current, .roll-host.letters-ready > .roll-word.is-shown { opacity: 1; }
.roll-host.letters-ready .roll-source { visibility: hidden; }
.roll-host .letter-layer { position: absolute; inset: 0; display: inline-flex; white-space: pre; pointer-events: none; }
.roll-host .char { display: inline-block; will-change: transform; }
/* the same roll on a chapter question (when the title does not roll): mono, with the red underline */
.q .roll-host { line-height: 1.2; padding-block: .12em; margin-block: -.12em; box-shadow: inset 0 -2px 0 var(--thread); font-weight: 500; }

html.look-real .rc .copy { margin: 2px 0 0; font-family: var(--body); color: var(--ink-mute); font-size: 14.5px; line-height: 1.46; }
html.look-real .strip.t1 .rc .copy { font-size: 13.5px; line-height: 1.4; }
html.look-real .room.t2 .rc .copy { font-size: 13px; line-height: 1.38; }
html.look-real .room.t3 .rc .copy { font-size: 12px; line-height: 1.32; margin-top: 0; }
html.look-real .rc .note {
  margin: 2px 0 0; padding-top: 8px; border-top: 1px dashed rgba(23, 24, 26, .3); font-family: var(--mono); font-size: 11.5px; line-height: 1.45; color: var(--ink-mute);
}
html.look-real .strip.t1 .rc .note { font-size: 10.5px; }

/* Turn over: bottom right, beside the peeking edge of the next print */
.ractions { position: relative; z-index: 5; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0 8px; }
.rturn, .rfilm { min-height: 30px; padding: 0 4px; border: 0; background: transparent; cursor: pointer; white-space: nowrap; font-family: var(--mono); font-size: 11.5px; letter-spacing: .05em; color: var(--ink-mute); }
.rturn { margin-left: auto; text-decoration: underline; text-underline-offset: 3px; }
.rturn:hover { color: var(--ink); }
.rfilm { padding: 0 8px; border: 1px solid var(--ink-mute); color: var(--ink); font-size: 11px; letter-spacing: .02em; }
.rfilm ~ .rturn { font-size: 11px; letter-spacing: .02em; }
html.look-real .strip.t1 .rturn, html.look-real .strip.t1 .rfilm { min-height: 28px; }
html.look-real .room.t3 .rturn, html.look-real .room.t3 .rfilm { min-height: 24px; }
html.look-real .sheet.rc:not(.cur) .rturn, html.look-real .sheet.rc:not(.cur) .rfilm { visibility: hidden; }

/* back: handwritten lines in Caveat, ink bleeding into the paper */
.back-top { position: relative; z-index: 5; display: flex; flex-direction: column; gap: 8px; }
.rbackhead { padding: 2px 2px 0; font-family: var(--mono); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-mute); }
.rnotes { list-style: none; margin: 0; padding: 2px 4px; display: flex; flex-direction: column; gap: 4px; }
.rnotes li {
  font-family: var(--hand); font-size: 19.5px; line-height: 1.12; font-weight: 500; color: var(--pen); transform-origin: 0 50%;
  transform: translate(var(--line-x, 0), var(--line-y, 0)) rotate(var(--line-rot, 0deg));
  text-shadow: 0 0 .75px rgba(35, 48, 74, .58), .35px .45px 1.3px rgba(28, 40, 66, .28), -.25px .15px 2.1px rgba(35, 48, 74, .14);
}
.rnotes .ph { font-style: normal; text-decoration-thickness: 1.5px; }
html.look-real .strip.t1 .rnotes li { font-size: 17.5px; line-height: 1.08; }
html.look-real .room.t2 .rnotes li { font-size: 16.5px; }
html.look-real .room.t3 .rnotes li { font-size: 15.5px; line-height: 1.06; }
.rface.back > .rturn { position: relative; z-index: 5; align-self: flex-end; margin-top: 2px; }

/* the wide room: bigger paper, bigger type */
html.plate-on.plate-wide .sheet.rc { --w: clamp(330px, 23vw, 380px); --hl-k: .16; }
html.plate-wide .rc .q { font-size: 12.5px; }
html.plate-wide .rc .copy { font-size: 16px; }
html.plate-wide .rnotes li { font-size: 22px; }
html.plate-wide .rturn, html.plate-wide .rfilm { font-size: 12.5px; }

/* reduced motion: first word only, no roll, no tween */
@media (prefers-reduced-motion: reduce) {
  .roll-host, .dim-veil { transition: none !important; }
  .roll-host .letter-layer { display: none !important; }
  .roll-host .roll-source { visibility: visible !important; }
  .roll-host .roll-word { opacity: 0 !important; visibility: hidden !important; }
  .roll-host .roll-word:first-child { opacity: 1 !important; visibility: visible !important; }
}

/* ---------- film overlay ---------- */
.film {
  position: fixed; inset: 0; z-index: 20; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  padding: max(56px, env(safe-area-inset-top, 0px)) var(--pad-xr) max(16px, env(safe-area-inset-bottom, 0px)) var(--pad-x);
  background: rgba(5, 5, 6, .97); overscroll-behavior: contain; touch-action: none;
}
.film-close {
  position: absolute; top: max(10px, env(safe-area-inset-top, 0px)); right: max(12px, env(safe-area-inset-right, 0px));
  min-height: 44px; padding: 0 14px; border: 1px solid var(--line); background: rgba(11, 11, 13, .8); color: var(--fg);
  font-family: var(--mono); font-size: 12px; letter-spacing: .08em; text-transform: uppercase; cursor: pointer;
}
.film-title { font-family: var(--mono); font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: var(--mute); }
.film-video {
  display: block; background: #000; aspect-ratio: 9 / 16; height: auto;
  width: min(calc(100vw - 32px), calc((100svh - 120px) * 9 / 16));
}

/* ---------- tap the wall picture: framed view in front of the room ---------- */
.linezone, .strip { pointer-events: none; }
.strip .sheet { pointer-events: auto; }
.viewbtn {
  position: absolute; z-index: 1; margin: 0; padding: 0; border: 0; border-radius: 0; background: transparent; color: inherit;
  cursor: zoom-in; -webkit-tap-highlight-color: transparent;
}
.viewbtn:focus-visible { outline: 2px solid var(--fg); outline-offset: -3px; }
.view-hint {
  position: absolute; z-index: 3; pointer-events: none; padding: 4px 8px; font-family: var(--mono); font-size: 11px; letter-spacing: .08em;
  text-transform: uppercase; color: rgba(245, 240, 232, .92); background: rgba(8, 8, 10, .55); border-radius: 2px;
  opacity: 0; animation: view-hint-in .35s ease-out forwards; transition: opacity .45s ease;
}
.view-hint.out { opacity: 0 !important; animation: none; }
@keyframes view-hint-in { to { opacity: 1; } }
.view { position: absolute; inset: 0; z-index: 30; overflow: hidden; touch-action: none; overscroll-behavior: contain; }
.view[hidden] { display: none; }
.view-dim { position: absolute; inset: 0; background: #050404; opacity: 0; cursor: zoom-out; }
.view-pic { position: absolute; left: 0; top: 0; transform-origin: 0 0; background: #0b0908; box-shadow: 0 10px 40px rgba(0, 0, 0, .6); overflow: hidden; will-change: transform; }
.view-pic img, .view-pic canvas, .view-pic video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.view-pic video { opacity: 0; }
.view-pic video.on { opacity: 1; }
.view.fade .view-pic, .view.fade .view-dim { transition: opacity .15s linear; }
.view-tag {
  position: absolute; right: 8px; bottom: 8px; z-index: 2; padding: 2px 6px; font-family: var(--mono); font-size: 10px; letter-spacing: .08em;
  text-transform: uppercase; color: rgba(245, 240, 232, .85); background: rgba(8, 8, 10, .55); border-radius: 2px; pointer-events: none;
}
.view-close {
  position: absolute; z-index: 3; top: max(10px, env(safe-area-inset-top, 0px)); right: max(12px, env(safe-area-inset-right, 0px));
  width: 44px; height: 44px; padding: 0; border: 1px solid rgba(255, 255, 255, .28); border-radius: 50%; background: rgba(11, 11, 13, .7);
  color: var(--fg); font: 400 26px/1 var(--body); cursor: pointer;
}
.view-close:focus-visible { outline: 2px solid var(--fg); outline-offset: 2px; }

/* ---------- reduced motion: no flicker, drift, swing or roll; slide changes are instant ---------- */
@media (prefers-reduced-motion: reduce) {
  .flicker { animation: none; }
  .slide, .strip, .sheet, .proj, .faces, .roll, .roll .stack { transition: none; }
  .sheet.swing { animation: none; }
}

/* ---------- without JavaScript: the plain list ---------- */
.nojs { max-width: 42rem; margin: 0 auto; padding: 32px 20px 64px; }
.nojs h1 { font-size: 34px; font-weight: 850; font-stretch: 125%; line-height: 1; margin-bottom: 8px; }
.nojs .lede { color: var(--mute); font-family: var(--mono); font-size: 13px; margin-bottom: 32px; }
.nojs ol { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 28px; }
.nojs article { border-top: 1px solid var(--line); padding-top: 14px; }
.nojs .q { font-family: var(--mono); font-size: 12px; letter-spacing: .04em; color: #FF6B60; }
.nojs h2 { font-size: 24px; font-weight: 800; font-stretch: 112%; line-height: 1.1; margin: 4px 0 8px; }
.nojs .back { margin: 10px 0 0; padding-left: 18px; font-family: var(--hand); font-size: 22px; line-height: 1.2; color: var(--mute); }
.nojs .ph { color: var(--mute); background: none; }
