/* v10 Comic Book: the inks, the paper, the lettering, the shared comic parts (captions, bubbles, panels, buttons). */
:root {
  --paper: #f6ecd6;
  --paper-2: #efe0bf;
  --ink: #17131b;
  --yellow: #ffd23a;
  --red: #e5322b;
  --red-dk: #b71f1a;
  --cyan: #21a7de;
  --pink: #f0609e;
  --green: #2fb24f;
  --grey: #d9d4c7;
  --white: #fffdf6;
  --f-title: 'Futura-CondensedExtraBold', 'Futura', Impact, 'Haettenschweiler', 'Arial Narrow', sans-serif;
  --f-letter: 'Comic Sans MS', 'Chalkboard SE', 'Comic Neue', 'Marker Felt', cursive;
  --f-ui: 'Avenir Next Condensed', 'Avenir Next', 'Helvetica Neue', system-ui, sans-serif;
  --line: 3.5px;
  --shadow: 5px 5px 0 var(--ink);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --dots: radial-gradient(circle, rgba(23, 19, 27, .07) 1.1px, transparent 1.5px);
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--paper);
  background-image: var(--dots);
  background-size: 7px 7px;
  color: var(--ink);
  font: 500 16px/1.35 var(--f-ui);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
}
button { font: inherit; color: inherit; }
img { display: block; max-width: 100%; }
[hidden] { display: none !important; }
.title { font-family: var(--f-title); font-stretch: condensed; font-weight: 800; }

/* ---- layers: the 3D stage, the pages, the HUD ---- */
.stage { position: fixed; inset: 0; z-index: 1; }
.stage.is-clipped { pointer-events: none; }
.stage.is-reveal { visibility: hidden; }
.stage.is-reveal > .pt-clip { visibility: visible; object-fit: cover; background: var(--ink); }
.stage.is-placing .pt-mk { visibility: hidden; }
.screen {
  position: fixed; inset: 0; z-index: 2;
  overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
.page {
  position: relative;
  width: 100%; max-width: 560px; min-height: 100%;
  margin: 0 auto;
  padding: calc(var(--safe-t) + 14px) 16px calc(var(--safe-b) + 22px);
  display: flex; flex-direction: column; gap: 12px;
  overflow-x: clip;
}
.page.is-turn { animation: turn .48s cubic-bezier(.2, .9, .25, 1.05) both; transform-origin: 0 40%; }
@keyframes turn {
  0% { transform: perspective(1600px) rotateY(-24deg) scale(.96); opacity: 0; }
  60% { opacity: 1; }
  100% { transform: none; opacity: 1; }
}

/* ---- halftone: the printed dots ---- */
.halftone {
  position: absolute; inset: 0; pointer-events: none;
  background-image: radial-gradient(circle, rgba(23, 19, 27, .55) 1.3px, transparent 1.8px);
  background-size: 6px 6px;
  -webkit-mask-image: radial-gradient(130% 100% at 50% 40%, transparent 35%, #000 100%);
  mask-image: radial-gradient(130% 100% at 50% 40%, transparent 35%, #000 100%);
}

/* ---- the narrator caption box ---- */
.cap {
  margin: 0; align-self: flex-start; justify-self: start;
  background: var(--yellow); color: var(--ink);
  border: var(--line) solid var(--ink);
  box-shadow: 3px 3px 0 var(--ink);
  padding: 6px 11px 5px;
  font: 700 13.5px/1.25 var(--f-letter); text-transform: uppercase; letter-spacing: .02em;
}
.cap--top { transform: rotate(-1.2deg); margin-right: 56px; animation: pop .4s .05s cubic-bezier(.3, 1.6, .5, 1) both; }
.cap--red { background: var(--red); color: var(--white); }

/* ---- speech bubbles ---- */
.bubble {
  position: relative; margin: 0;
  background: var(--white); color: var(--ink);
  border: var(--line) solid var(--ink); border-radius: 26px;
  padding: 10px 16px;
  font: 700 15px/1.3 var(--f-letter); text-transform: uppercase; letter-spacing: .01em;
  box-shadow: 3px 3px 0 var(--ink);
}
.bubble::before, .bubble::after { content: ''; position: absolute; width: 0; height: 0; border-style: solid; }
.bubble--down::before { left: 28px; bottom: -19px; border-width: 19px 14px 0 0; border-color: var(--ink) transparent transparent; }
.bubble--down::after { left: 32.5px; bottom: -12px; border-width: 13px 9px 0 0; border-color: var(--white) transparent transparent; }
.bubble--left::before { left: -19px; top: 20px; border-width: 0 19px 14px 0; border-color: transparent var(--ink) transparent transparent; }
.bubble--left::after { left: -12px; top: 24.5px; border-width: 0 13px 9px 0; border-color: transparent var(--white) transparent transparent; }

/* ---- a comic panel ---- */
.panel {
  position: relative; overflow: hidden;
  background: var(--white);
  border: var(--line) solid var(--ink);
  box-shadow: var(--shadow);
}

/* ---- the one big forward button ---- */
.btn {
  appearance: none; cursor: pointer; border: 0; background: none; padding: 0;
  touch-action: manipulation;
}
.btn--go {
  position: relative; width: 100%; min-height: 62px;
  display: flex; align-items: center; justify-content: center; gap: 12px;
  padding: 10px 18px;
  background: var(--red); color: var(--white);
  border: var(--line) solid var(--ink); border-radius: 6px;
  box-shadow: var(--shadow);
  font: 800 27px/1 var(--f-title); font-stretch: condensed; text-transform: uppercase; letter-spacing: .03em;
  text-shadow: 2px 2px 0 var(--ink);
  transition: transform .08s, box-shadow .08s, background .2s;
  animation: pop .42s .18s cubic-bezier(.3, 1.6, .5, 1) both;
}
.btn--go:active, .btn--go.is-pressed { transform: translate(4px, 4px); box-shadow: 1px 1px 0 var(--ink); }
.btn--go:disabled { cursor: default; }
.btn--go:focus-visible { outline: 4px solid var(--cyan); outline-offset: 3px; }
.btn__arrow {
  display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%;
  background: var(--yellow); color: var(--ink); border: 3px solid var(--ink);
  font-size: 15px; text-shadow: none; padding-left: 2px;
  animation: nudge 1.2s 1s ease-in-out infinite;
}
@keyframes nudge { 0%, 70%, 100% { transform: translateX(0); } 80% { transform: translateX(5px); } 90% { transform: translateX(-1px); } }
@keyframes pop { 0% { transform: scale(.6) rotate(-4deg); opacity: 0; } 100% { opacity: 1; } }
.link { background: none; border: 0; padding: 0; text-decoration: underline; font-weight: 800; cursor: pointer; min-height: 44px; }

/* ---- the mute button (never a forward button) ---- */
.mute {
  position: fixed; z-index: 20; top: calc(var(--safe-t) + 10px); right: 12px;
  width: 44px; height: 44px; border-radius: 50%;
  display: grid; place-items: center; cursor: pointer;
  background: var(--ink); color: var(--yellow); border: 3px solid var(--ink);
  box-shadow: 2px 2px 0 rgba(0, 0, 0, .35);
}
.mute:active { transform: scale(.92); }
body[data-phase="play"] .mute { top: auto; bottom: calc(var(--safe-b) + 12px); }

/* ---- the first paint ---- */
.boot { justify-content: center; align-items: center; }
.boot__t { margin: 0; font: 800 64px/0.9 var(--f-title); font-stretch: condensed; color: var(--red); -webkit-text-stroke: 2px var(--ink); text-shadow: 4px 4px 0 var(--ink); }
.oops { justify-content: center; }

@media (min-width: 900px) {
  .page { max-width: 1120px; padding: calc(var(--safe-t) + 26px) 40px 40px; gap: 16px; }
  .cap { font-size: 15px; }
  .bubble { font-size: 17px; }
  .btn--go { min-height: 66px; font-size: 30px; }
  .mute { top: 18px; right: 22px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
