/* The grimoire around the spell page: chapter tabs, page turns, and the flowing chapter pages. */

/* ---------------------------------------------------------------- page turns (cross-document view transitions) */
@view-transition { navigation: auto; }
.folio { view-transition-name: folio; }
::view-transition-old(folio) { animation: pageOut .42s cubic-bezier(.4, 0, .7, .2) both; transform-origin: 0 50%; }
::view-transition-new(folio) { animation: pageIn .5s cubic-bezier(.2, .7, .2, 1) both; transform-origin: 100% 50%; }
@keyframes pageOut { to { opacity: 0; transform: perspective(1600px) rotateY(16deg) translateX(-4%); } }
@keyframes pageIn { from { opacity: 0; transform: perspective(1600px) rotateY(-12deg) translateX(5%); } }
@media (prefers-reduced-motion: reduce) { @view-transition { navigation: none; } }

/* ---------------------------------------------------------------- chapter tabs: leather index tabs on the fore edge */
.wrap { position: relative; }
.tabs { position: absolute; left: 100%; top: 5%; z-index: 0; display: flex; flex-direction: column; gap: 10px; margin-left: -10px; }
.tab {
  position: relative; display: flex; align-items: center; gap: 9px; padding: 15px 11px 15px 19px; writing-mode: vertical-rl;
  border-radius: 0 12px 12px 0; text-decoration: none; color: #f3dcae; white-space: nowrap;
  background: linear-gradient(90deg, #4a140c, #8b2b18 60%, #9e3820); box-shadow: 4px 4px 10px rgba(0, 0, 0, .5), inset 0 1px 0 rgba(255, 210, 160, .25);
  font: 600 17px/1 "Grenze", Georgia, serif; letter-spacing: .03em; transition: transform .25s cubic-bezier(.2, .8, .2, 1.4), background .25s;
}
.tab b { font: 500 1.1em/1 "Grenze Gotisch", serif; color: #ffd98f; }
.tab .f { display: none; }
.tab:hover, .tab:focus-visible { transform: translateX(6px); }
.tab[aria-current="page"] { transform: translateX(11px); background: linear-gradient(90deg, #5d2a0c, #b8892e 65%, #d8ad4c); color: #2a1608; }
.tab[aria-current="page"] b { color: #5a1408; }
.tab:focus-visible { outline: 2px solid #f3c66b; outline-offset: 3px; }

.pager { display: flex; justify-content: space-between; gap: 16px; margin: 18px auto 6px; width: 100%; }
.pager a { display: inline-flex; flex-direction: column; gap: 2px; padding: 10px 16px; border-radius: 10px; text-decoration: none; color: #f0d9aa;
  background: rgba(24, 12, 6, .62); border: 1px solid rgba(214, 166, 90, .45); font: 600 19px/1.15 "Grenze", serif; transition: background .2s, transform .2s; }
.pager a small { font: 400 13px/1 "Grenze", serif; letter-spacing: .08em; text-transform: uppercase; opacity: .75; }
.pager a[rel="next"] { margin-left: auto; text-align: right; }
.pager a:hover { background: rgba(60, 28, 10, .8); transform: translateY(-1px); }
.pager a:focus-visible { outline: 2px solid #f3c66b; outline-offset: 3px; }
.folio .pager a { background: rgba(126, 34, 18, .08); color: var(--red); border-color: rgba(124, 34, 18, .35); }
.folio .pager a:hover { background: rgba(126, 34, 18, .16); }

/* without room beside the page, the tabs become a ribbon above it */
@media (max-width: 1179px), (max-aspect-ratio: 11/10) {
  .tabs { position: static; flex-direction: row; justify-content: center; flex-wrap: wrap; gap: 7px; margin: 0 auto 10px; }
  .tab { writing-mode: horizontal-tb; padding: 8px 14px 9px; border-radius: 999px; gap: 7px; font-size: 16px; }
  .tab .s { display: none; } .tab .f, .tab:first-child .s { display: inline; }
  .tab:hover, .tab:focus-visible, .tab[aria-current="page"] { transform: none; }
  .wrap:not(.book) { width: clamp(min(720px, 96vw), calc((100svh - 2 * var(--pad) - 54px) * 0.9139), min(96vw, 1320px)); }
}
@media (max-width: 759px) {
  .tabs { justify-content: flex-start; gap: 5px; padding-right: 48px; }
  .tab .f { display: none; } .tab .s { display: inline; }
  .tab { padding: 9px 10px 10px; font-size: 14px; gap: 5px; min-height: 40px; }
  .wrap:not(.book) { width: 100%; }
  .sound { width: 40px; height: 40px; padding: 0; justify-content: center; }
  .sound .lbl { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
}

/* ---------------------------------------------------------------- flowing chapter pages */
.wrap.book { width: min(96vw, 1060px); margin: 0 auto; }
.folio.flowpage {
  --fb: clamp(30px, 5vw, 58px);
  aspect-ratio: auto; display: block; border-radius: 12px;
  padding: calc(var(--fb) + 26px) calc(var(--fb) + 34px) calc(var(--fb) + 24px);
  background: #d8b887 url(../assets/parchment-tile.webp) 0 0 / 100% auto repeat-y;
}
.flowpage::after {
  content: ""; position: absolute; inset: 0; z-index: 1; pointer-events: none; border-radius: inherit;
  border: var(--fb) solid transparent;
  border-image: url(../assets/frame-m.webp) 11.34% / var(--fb) round;
  border-image-source: image-set(url(../assets/frame-m.avif) type("image/avif"), url(../assets/frame-m.webp) type("image/webp"));
}
.flowpage .cap { display: block; position: absolute; left: 0; right: 0; aspect-ratio: 1199 / 300; z-index: 0; pointer-events: none; background: 0 0 / 100% 100% no-repeat; }
.flowpage .cap.top { top: 0; background-image: url(../assets/parchment-top.webp); -webkit-mask: linear-gradient(#000 45%, transparent); mask: linear-gradient(#000 45%, transparent); border-radius: 12px 12px 0 0; }
.flowpage .cap.bot { bottom: 0; background-image: url(../assets/parchment-bottom.webp); -webkit-mask: linear-gradient(transparent, #000 55%); mask: linear-gradient(transparent, #000 55%); border-radius: 0 0 12px 12px; }
.flowpage .top-orn { display: block; position: absolute; z-index: 2; top: calc(var(--fb) * .1); left: 50%; width: calc(var(--fb) * .9); transform: translateX(-50%); }
.page-body { position: relative; z-index: 2; font-size: clamp(18px, 1.9vw, 21px); line-height: 1.5; color: var(--ink); }

.ch-head { text-align: center; margin-bottom: 10px; }
.ch-head h1 { display: flex; align-items: center; justify-content: center; gap: .1em; margin: 0; font: 400 clamp(44px, 6.6vw, 80px)/1 "Unifraktur", serif; color: var(--title-ink);
  -webkit-text-stroke: .012em var(--title-ink); paint-order: stroke fill; }
.ill { width: 1.32em; height: 1.32em; flex: none; margin-right: .04em; filter: drop-shadow(2px 3px 2px rgba(60, 25, 5, .35)); }
.kicker { display: flex; align-items: center; justify-content: center; gap: .3em; margin: .25em 0 0; font: 500 clamp(22px, 2.6vw, 31px)/1.2 "Grenze Gotisch", serif; color: var(--red); }
.kicker img { width: .62em; height: auto; }
.rule { display: block; width: min(560px, 86%); height: auto; margin: 6px auto; }
.page-body h2 { margin: 1.1em 0 .25em; font: 400 clamp(32px, 4vw, 46px)/1.05 "Unifraktur", serif; color: var(--title-ink); text-align: center; }
.page-body p { margin: 0 0 .6em; }
.page-body b, .stat b { font-family: "Grenze Gotisch", serif; font-weight: 500; color: var(--red); }
.page-body em { font-style: normal; color: var(--red); }
.lede { font-size: 1.06em; }
.quiet { opacity: .8; font-size: .92em; }

.btn {
  display: inline-flex; align-items: center; gap: .45em; padding: .5em 1.15em .55em; border-radius: 999px; cursor: pointer;
  font: 500 1.02em/1 "Grenze Gotisch", serif; color: #fbe6bf; letter-spacing: .02em;
  background: radial-gradient(120% 140% at 35% 25%, #c23b22, #861a10 55%, #5c0d07); border: 1px solid #3d0904;
  box-shadow: inset 0 1px 0 rgba(255, 215, 170, .35), 0 3px 0 #3d0904, 0 7px 14px rgba(60, 10, 0, .3);
  transition: transform .12s, box-shadow .12s, filter .2s;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(2px); box-shadow: inset 0 1px 0 rgba(255, 215, 170, .3), 0 1px 0 #3d0904, 0 3px 8px rgba(60, 10, 0, .3); }
.btn:focus-visible { outline: 2px solid #f3c66b; outline-offset: 3px; }
.btn[disabled] { filter: grayscale(.5) brightness(.85); cursor: default; }

/* comic speech bubbles */
.bubble {
  position: absolute; z-index: 6; pointer-events: none; width: max-content; max-width: min(15em, 88%); padding: .42em .75em .48em; border-radius: 16px;
  background: #fff8e6; border: 2px solid #2b1a10; color: #1c120a; box-shadow: 3px 4px 0 rgba(43, 26, 16, .25);
  font: 600 clamp(14px, 1.45vw, 17px)/1.25 "Grenze", serif; text-align: center;
  opacity: 0; transform: translate(-50%, -100%) scale(.6); transform-origin: 50% 100%; transition: opacity .18s, transform .25s cubic-bezier(.3, 1.6, .5, 1);
}
.bubble::after { content: ""; position: absolute; left: var(--tail, 50%); top: 100%; width: 14px; height: 14px; margin-left: -7px; margin-top: -7px;
  background: inherit; border: inherit; border-width: 0 2px 2px 0; transform: rotate(45deg); }
.bubble.below { transform: translate(-50%, 0) scale(.6); transform-origin: 50% 0; }
.bubble.below::after { top: 0; border-width: 2px 0 0 2px; }
.bubble.show { opacity: 1; transform: translate(-50%, -100%) scale(1); }
.bubble.below.show { transform: translate(-50%, 0) scale(1); }

/* twinkles */
.spark { position: absolute; z-index: 4; width: 3.2%; aspect-ratio: 1; pointer-events: none; translate: -50% -50%;
  background: radial-gradient(circle, #fff 0 14%, rgba(255, 246, 200, .9) 22%, rgba(255, 230, 150, 0) 62%);
  clip-path: polygon(50% 0, 58% 42%, 100% 50%, 58% 58%, 50% 100%, 42% 58%, 0 50%, 42% 42%);
  animation: twinkle 3.2s ease-in-out infinite; animation-delay: var(--d, 0s); opacity: 0; }
@keyframes twinkle { 0%, 100% { opacity: 0; transform: scale(.3) rotate(0); } 45% { opacity: 1; transform: scale(1) rotate(45deg); } 60% { opacity: .9; } }

/* ---------------------------------------------------------------- chapter II: the noodle incident */
.noodle-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.08fr); gap: 34px; align-items: start; margin-top: 18px; }
.stat { margin: 0 0 .7em; }
.knotbox { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 18px; margin: 16px 0 6px; }
.knots { font: 500 1.1em "Grenze Gotisch", serif; color: var(--red); }
.knots output { font: 400 1.5em/1 "Unifraktur", serif; color: var(--title-ink); vertical-align: -.08em; margin-left: .2em; }
.knotnote { min-height: 1.5em; font-style: italic; color: var(--ink-soft, #4a3020); }

.sketch { position: relative; margin: 6px 6px 0 0; transform: rotate(1.7deg); transition: transform .4s cubic-bezier(.2, .8, .2, 1.2); }
.sketch:hover { transform: rotate(.6deg) translateY(-3px); }
.sketch .paper { position: relative; border-radius: 3px; overflow: hidden; box-shadow: 0 2px 3px rgba(60, 30, 10, .35), 0 16px 30px rgba(60, 30, 10, .35); aspect-ratio: 1; }
.sketch img, .sketch canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.sketch canvas { opacity: 0; transition: opacity .3s; }
.sketch.gl canvas { opacity: 1; }
.tape { position: absolute; z-index: 5; width: 26%; height: 9%; background: linear-gradient(180deg, rgba(246, 236, 205, .78), rgba(225, 212, 175, .72));
  box-shadow: 0 1px 2px rgba(60, 40, 10, .25); -webkit-mask: linear-gradient(90deg, transparent 0, #000 4%, #000 96%, transparent); mask: linear-gradient(90deg, transparent 0, #000 4%, #000 96%, transparent); }
.tape.l { left: -6%; top: -2.5%; rotate: -34deg; } .tape.r { right: -6%; top: -2.5%; rotate: 31deg; }
.hit { position: absolute; z-index: 3; padding: 0; margin: 0; border: 0; background: none; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.hit:focus-visible { outline: 2px dashed #8b2b18; outline-offset: -4px; border-radius: 12px; }
.hit.hero { inset: 0; }
.hit.pencil { left: 75.8%; top: 53.8%; width: 24%; height: 35%; z-index: 4; }
.sweat { position: absolute; z-index: 4; width: 2.6%; aspect-ratio: .72; pointer-events: none; border-radius: 50% 50% 50% 50% / 62% 62% 38% 38%;
  background: radial-gradient(circle at 35% 60%, #e9fbff, #6fc4dd 55%, #2f7d98); border: 1.5px solid #234b5a;
  animation: drip 2.6s ease-in infinite; animation-delay: var(--d, 0s); opacity: 0; }
@keyframes drip { 0% { opacity: 0; transform: translate(0, 0) scale(.6); } 15% { opacity: 1; transform: translate(0, 0) scale(1); } 100% { opacity: 0; transform: translate(var(--dx, -40%), 260%) scale(.9); } }
.sketch .bubble.hero-b { left: 50%; top: 6%; }
.sketch .bubble.pencil-b { left: 79%; top: 52%; --tail: 72%; }

.surge { margin-top: 10px; }
.surge-top { display: grid; grid-template-columns: minmax(0, 1fr) minmax(260px, .9fr); gap: 26px; align-items: center; }
.tray { position: relative; border-radius: 22px; padding: 10px; aspect-ratio: 2.1;
  background: radial-gradient(120% 100% at 50% 30%, #2f5a3c, #1d3a26 60%, #12261a); box-shadow: inset 0 0 0 3px #6b4423, inset 0 0 0 7px #3a210f, inset 0 10px 24px rgba(0, 0, 0, .55), 0 8px 18px rgba(40, 20, 5, .35); }
.tray canvas { position: absolute; inset: 7px; width: calc(100% - 14px); height: calc(100% - 14px); border-radius: 16px; }
.tray .pip { display: none; }
.tray.nogl .pip { display: grid; place-items: center; position: absolute; inset: 0; font: 400 clamp(48px, 7vw, 84px)/1 "Unifraktur", serif; color: #ffd98f; text-shadow: 0 3px 0 #3a0c05; }
.tray.nogl canvas { display: none; }
.result { min-height: 3.2em; margin: 12px 0 0; padding: .6em .9em; border-radius: 12px; background: rgba(126, 34, 18, .07); border: 1px dashed rgba(124, 34, 18, .4); }
.result b { margin-right: .3em; }
.surges { columns: 2; column-gap: 34px; margin: 14px 0 0; padding: 0; list-style: none; counter-reset: s; font-size: .93em; }
.surges li { break-inside: avoid; display: grid; grid-template-columns: 2.1em 1fr; gap: .4em; padding: .28em .45em; border-radius: 8px; transition: background .3s, box-shadow .3s; }
.surges li .n { font: 500 1.05em/1.35 "Grenze Gotisch", serif; color: var(--red); text-align: right; }
.surges li.hit-row { background: rgba(255, 196, 90, .28); box-shadow: inset 0 0 0 1.5px rgba(160, 80, 20, .45); }

/* ---------------------------------------------------------------- chapter III: the natural one */
.plate { position: relative; margin: 18px auto 8px; max-width: 900px; padding: 12px; border-radius: 6px;
  background: linear-gradient(135deg, #f7dc8e, #a87a2a 22%, #f1d27a 45%, #8c6220 70%, #e8c467);
  box-shadow: 0 0 0 2px #3c240d, 0 0 0 5px rgba(58, 33, 12, .55), 0 18px 34px rgba(40, 20, 5, .45); }
.plate .canvas-wrap { position: relative; aspect-ratio: 1; overflow: hidden; border-radius: 2px; box-shadow: inset 0 0 0 2px #4a2e0f; }
.plate img.base, .plate canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.plate canvas { opacity: 0; transition: opacity .3s; }
.plate.gl canvas { opacity: 1; }
.die { position: absolute; z-index: 3; padding: 0; border: 0; background: none; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.die img { display: block; width: 100%; height: auto; }
.die:focus-visible { outline: 2px dashed #ffd27a; outline-offset: 2px; border-radius: 8px; }
.die .one { position: absolute; left: 50%; top: 0; translate: -50% -60%; pointer-events: none; font: 400 2.2em/1 "Unifraktur", serif; color: #ffd27a;
  -webkit-text-stroke: .04em #3a0c05; text-shadow: 0 2px 0 #3a0c05; opacity: 0; }
.die.pop .one { animation: onePop .9s cubic-bezier(.3, 1.6, .5, 1); }
@keyframes onePop { 0% { opacity: 0; transform: translateY(20%) scale(.4); } 25% { opacity: 1; transform: translateY(-30%) scale(1.15); } 80% { opacity: 1; } 100% { opacity: 0; transform: translateY(-70%) scale(1); } }
.spot { position: absolute; z-index: 5; width: clamp(28px, 4.4%, 40px); aspect-ratio: 1; translate: -50% -50%; padding: 0; border-radius: 50%; cursor: pointer;
  border: 2px solid #f6d58a; background: radial-gradient(circle at 35% 30%, #d4482c, #8a1c10 60%, #520a05); color: #ffe7b0;
  font: 600 clamp(14px, 1.8vw, 18px)/1 "Grenze", serif; box-shadow: 0 2px 6px rgba(0, 0, 0, .55), 0 0 0 0 rgba(255, 190, 90, .6); animation: spotPulse 2.8s ease-out infinite; }
.spot:hover, .spot:focus-visible, .spot.on { animation: none; box-shadow: 0 2px 6px rgba(0, 0, 0, .55), 0 0 0 6px rgba(255, 190, 90, .45); outline: none; }
@keyframes spotPulse { 0% { box-shadow: 0 2px 6px rgba(0, 0, 0, .55), 0 0 0 0 rgba(255, 190, 90, .55); } 70%, 100% { box-shadow: 0 2px 6px rgba(0, 0, 0, .55), 0 0 0 12px rgba(255, 190, 90, 0); } }
.zzz { position: absolute; z-index: 4; pointer-events: none; font: 400 clamp(18px, 2.4vw, 28px)/1 "Unifraktur", serif; color: #fff3cf; -webkit-text-stroke: .05em #2b1a10; }
.zzz span { position: absolute; opacity: 0; animation: zz 3.6s ease-in infinite; animation-delay: calc(var(--i) * 1.2s); }
.plate.loud .zzz span { animation-duration: 1.4s; }
@keyframes zz { 0% { opacity: 0; transform: translate(0, 0) scale(.5) rotate(-10deg); } 20% { opacity: 1; } 100% { opacity: 0; transform: translate(140%, -260%) scale(1.3) rotate(12deg); } }
.tear { position: absolute; z-index: 4; width: 1.1%; aspect-ratio: .7; pointer-events: none; border-radius: 50% 50% 50% 50% / 62% 62% 38% 38%;
  background: radial-gradient(circle at 35% 60%, #f2fdff, #8fd3ea 60%, #3d8eaa); opacity: 0; animation: tear 1.9s ease-in infinite; animation-delay: var(--d, 0s); animation-play-state: paused; }
.plate.sobbing .tear { animation-play-state: running; }
@keyframes tear { 0% { opacity: 0; transform: translateY(0) scale(.5); } 15% { opacity: 1; transform: translateY(0) scale(1); } 100% { opacity: 0; transform: translate(var(--dx, -60%), 700%) scale(.8); } }
.glint { position: absolute; z-index: 4; width: 5%; aspect-ratio: 1; translate: -50% -50%; pointer-events: none; opacity: 0;
  background: radial-gradient(circle, #fff 0 10%, rgba(255, 255, 255, .0) 55%); clip-path: polygon(50% 0, 56% 44%, 100% 50%, 56% 56%, 50% 100%, 44% 56%, 0 50%, 44% 44%); animation: glint 6s ease-in-out infinite 1.5s; }
@keyframes glint { 0%, 86%, 100% { opacity: 0; transform: scale(.2) rotate(0); } 90% { opacity: 1; transform: scale(1) rotate(30deg); } }
.glint.now { animation: glintNow .9s ease-out 1; }
@keyframes glintNow { 0% { opacity: 0; transform: scale(.2) rotate(0); } 35% { opacity: 1; transform: scale(1.25) rotate(35deg); } 100% { opacity: 0; transform: scale(.4) rotate(70deg); } }
.spark.burst { animation: twinkle 1.3s ease-in-out 1 both; animation-delay: var(--d, 0s); width: 2.6%; }
.plate .bubble { font-size: clamp(13px, 1.5vw, 17px); }
.legend { list-style: none; margin: 18px 0 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 10px 30px; font-size: .95em; }
.legend p { margin: 0; }
.legend li { display: grid; grid-template-columns: 2.2em 1fr; gap: .45em; padding: .35em .5em; border-radius: 10px; transition: background .25s; }
.legend li.on { background: rgba(255, 196, 90, .25); }
.legend .num { display: grid; place-items: center; width: 1.9em; height: 1.9em; border-radius: 50%; border: 1.5px solid #c99a3c; background: #8a1c12; color: #ffe7b0; font: 600 .95em/1 "Grenze", serif; cursor: pointer; }
.legend .num:focus-visible { outline: 2px solid #f3c66b; outline-offset: 2px; }
.cursed { margin-top: 8px; }
.stats { display: flex; flex-wrap: wrap; gap: 6px 22px; margin-top: 10px; font: 500 1em "Grenze Gotisch", serif; color: var(--red); }
.stats output { font: 400 1.35em/1 "Unifraktur", serif; color: var(--title-ink); margin-left: .25em; }

/* ---------------------------------------------------------------- contents */
.toc { list-style: none; margin: 18px 0 0; padding: 0; display: grid; gap: 16px; }
.toc a { display: grid; grid-template-columns: 116px 1fr; gap: 20px; align-items: center; padding: 12px; border-radius: 14px; text-decoration: none; color: inherit; transition: background .25s, transform .25s; }
.toc a:hover, .toc a:focus-visible { background: rgba(255, 196, 90, .22); transform: translateX(4px); outline: none; }
.toc img { width: 116px; height: 116px; object-fit: cover; border-radius: 4px; box-shadow: 0 0 0 2px #3c240d, 0 0 0 5px #b8892e, 0 0 0 6px #5b3b12, 0 8px 16px rgba(40, 20, 5, .4); }
.toc .t { display: flex; align-items: baseline; gap: .5em; font: 400 clamp(26px, 3.2vw, 38px)/1.1 "Unifraktur", serif; color: var(--title-ink); }
.toc .t i { font: 600 .56em "Grenze", serif; color: var(--red); font-style: normal; letter-spacing: .04em; }
.toc .t::after { content: ""; flex: 1; border-bottom: 2px dotted rgba(80, 40, 20, .45); translate: 0 -.18em; }
.toc .t small { order: 2; font: 500 .5em "Grenze Gotisch", serif; color: var(--red); }
.toc p { margin: .2em 0 0; }
.errata { margin: 22px auto 4px; max-width: 760px; padding: .8em 1.1em; border-radius: 12px; background: rgba(126, 34, 18, .07); border: 1px dashed rgba(124, 34, 18, .4); font-size: .95em; }

/* ---------------------------------------------------------------- narrow screens */
@media (max-width: 900px) {
  .noodle-grid, .surge-top { grid-template-columns: 1fr; }
  .noodle-grid .sketch { order: -1; max-width: 560px; margin: 0 auto 8px; }
  .legend { grid-template-columns: 1fr; }
}
@media (max-width: 759px) {
  .wrap.book { width: 100%; }
  .folio.flowpage { --fb: clamp(26px, 7vw, 38px); padding: calc(var(--fb) + 26px) calc(var(--fb) + 6px) calc(var(--fb) + 16px); }
  .surges { columns: 1; }
  .toc a { grid-template-columns: 78px 1fr; gap: 14px; }
  .toc img { width: 78px; height: 78px; }
  .pager { flex-direction: column; } .pager a[rel="next"] { margin-left: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .spark, .sweat, .zzz span, .tear, .glint, .spot { animation: none !important; }
  .spark { opacity: .7; }
  .spark.burst { opacity: 1; }
  .die.pop .one { animation: none; opacity: 1; }
  .glint.now { animation: none; opacity: 1; }
}

/* ---------------------------------------------------------------- small pieces */
.skip { position: fixed; left: 12px; top: -60px; z-index: 50; padding: 10px 16px; border-radius: 10px; background: #f3dcae; color: #2a1608; font: 600 17px "Grenze", serif; text-decoration: none; transition: top .2s; }
.skip:focus { top: 12px; outline: 2px solid #8b2b18; }
.page-body:focus { outline: none; }
.knots output { display: inline-block; min-width: 1.4em; }
.legend li { cursor: pointer; }
.legend li:hover { background: rgba(255, 196, 90, .14); }
.legend li.on { background: rgba(255, 196, 90, .28); }
.colophon { text-align: center; margin-top: 1.2em; }
.odds { margin: .3em 0 0; font-size: .95em; }
.odds output { font-family: "Grenze Gotisch", serif; color: var(--red); }
.roll-row { margin: 12px 0 0; text-align: center; }
.tray { cursor: pointer; }
.toc li { list-style: none; }
.sketch figcaption, .plate figcaption { margin-top: 12px; text-align: center; }
.plate figcaption { color: #2a1608; font-weight: 600; }

/* ---------------------------------------------------------------- living backdrops: a story keyframe behind every page */
body.has-backdrop { background: #120a06; }
.backdrop-still { position: fixed; inset: 0; z-index: -2; background: #120a06 center / cover no-repeat; }
.backdrop-still::after { content: ""; position: absolute; inset: 0; background: radial-gradient(120% 95% at 50% 42%, transparent 45%, rgba(10, 5, 2, .6)); }
.backdrop-gl { position: fixed; inset: 0; width: 100%; height: 100%; z-index: -1; opacity: 0; transition: opacity 1.4s ease; pointer-events: none; }
.backdrop-gl.on { opacity: 1; }
.wrap.book { --intro: clamp(300px, 58svh, 660px); }
.wrap.book > .tabs { top: calc(var(--intro) + 34px); }
.scene-intro { height: var(--intro, clamp(260px, 52svh, 520px)); display: flex; flex-direction: column; justify-content: flex-end; align-items: flex-start; gap: 12px; padding-bottom: 26px; }
.now-showing { margin: 0; max-width: min(92vw, 560px); padding: 10px 16px 11px; border-radius: 14px; color: #f3dcae; font: 500 16px/1.35 "Grenze", serif;
  background: rgba(18, 9, 4, .62); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); border: 1px solid rgba(214, 166, 90, .42); box-shadow: 0 8px 24px rgba(0, 0, 0, .35); }
.now-showing small { display: block; font: 500 12px/1.2 "Grenze", serif; letter-spacing: .14em; text-transform: uppercase; color: #e2b86a; margin-bottom: 3px; }
.now-showing a { color: #ffd98f; text-underline-offset: .18em; }
.scroll-cue { display: inline-flex; align-items: center; gap: 8px; color: #f3dcae; font: 500 14px "Grenze", serif; letter-spacing: .1em; text-transform: uppercase; text-shadow: 0 2px 6px rgba(0, 0, 0, .7); }
.scroll-cue::after { content: ""; width: 9px; height: 9px; border: solid currentColor; border-width: 0 2px 2px 0; rotate: 45deg; animation: cue 1.8s ease-in-out infinite; }
@keyframes cue { 0%, 100% { translate: 0 -3px; opacity: .5; } 50% { translate: 0 3px; opacity: 1; } }
.now-fixed { position: fixed; left: 14px; bottom: 14px; z-index: 4;
  max-width: calc((100vw - clamp(min(720px, 96vw), calc((100svh - 2 * var(--pad)) * 0.9139), min(96vw, 1320px))) / 2 - 28px); }
@media (max-aspect-ratio: 4/3) { .now-fixed { display: none; } }
@media (max-width: 759px) {
  .wrap.book { --intro: clamp(260px, 52svh, 520px); }
  .now-fixed { display: none; }
}
@media (min-width: 760px) { .scene-intro.mobile-only { display: none; } }
@media (prefers-reduced-motion: reduce) { .scroll-cue::after { animation: none; } }

/* six tabs now: short labels on the fore edge, numerals only on phones */
.tab .sr-only { position: absolute; }
@media (max-width: 759px) {
  .tab .s { display: none; } .tab:first-child .s { display: inline; }
  .tab { min-width: 40px; justify-content: center; padding: 9px 11px 10px; }
}

/* ---------------------------------------------------------------- the story so far: a film strip on the contents page */
.strip { margin: 20px 0 6px; }
.strip ol { list-style: none; margin: 0; padding: 4px 2px 12px; display: grid; grid-auto-flow: column; grid-auto-columns: 132px; gap: 10px; overflow-x: auto; scroll-snap-type: x proximity; }
.strip li { scroll-snap-align: start; }
.strip a { display: block; text-decoration: none; color: inherit; border-radius: 8px; transition: transform .25s; }
.strip a:hover, .strip a:focus-visible { transform: translateY(-3px); outline: none; }
.strip a:focus-visible .frame { box-shadow: 0 0 0 3px #f3c66b; }
.strip .frame { display: block; width: 132px; aspect-ratio: 16 / 9; border-radius: 6px; background: url(../assets/story-strip.webp) 0 0 / 400% 1500% no-repeat; box-shadow: 0 0 0 2px #3c240d, 0 6px 12px rgba(40, 20, 5, .35); }
.strip .fcap { display: block; margin-top: 6px; font: 500 14px/1.25 "Grenze", serif; }
.strip .fcap i { font-style: normal; color: var(--red); font-family: "Grenze Gotisch", serif; }
.strip h3 { margin: 0 0 4px; font: 500 1.05em "Grenze Gotisch", serif; color: var(--red); }

/* teasers that tie a chapter into the story */
.teaser { display: grid; grid-template-columns: minmax(0, 220px) 1fr; gap: 18px; align-items: center; margin: 26px 0 8px; padding: 14px; border-radius: 14px;
  background: rgba(126, 34, 18, .07); border: 1px dashed rgba(124, 34, 18, .4); text-decoration: none; color: inherit; transition: background .25s; }
a.teaser:hover, a.teaser:focus-visible { background: rgba(255, 196, 90, .2); outline: none; }
.teaser img { width: 100%; height: auto; border-radius: 6px; box-shadow: 0 0 0 2px #3c240d, 0 8px 16px rgba(40, 20, 5, .35); }
.teaser b { display: block; font: 400 clamp(24px, 2.6vw, 30px)/1.1 "Unifraktur", serif; color: var(--title-ink); margin-bottom: 4px; }
.teaser span { color: var(--red); font-family: "Grenze Gotisch", serif; }
@media (max-width: 600px) { .teaser { grid-template-columns: 1fr; } }
.teaser .frame { display: block; width: 100%; aspect-ratio: 16 / 9; border-radius: 6px; background: url(../assets/story-strip.webp) 0 0 / 400% 1500% no-repeat; box-shadow: 0 0 0 2px #3c240d, 0 8px 16px rgba(40, 20, 5, .35); }

/* without JavaScript, hide the controls that would do nothing; the text, pictures, tables and links remain */
html:not(.js) :is(.sound, [data-play], .knotbox, .knotnote, .roller, .result, .hit, .spot, .die) { display: none !important; }

/* ---------------------------------------------------------------- the real animation as the page background */
.backdrop-video { position: fixed; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: -1; opacity: 0; transform: scale(1.06);
  transition: opacity 1.4s ease; pointer-events: none; filter: brightness(.86); }
.backdrop-video.on { opacity: 1; }
body.has-backdrop::after { content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background: radial-gradient(120% 95% at 50% 42%, transparent 48%, rgba(10, 5, 2, .58)); }

/* ---------------------------------------------------------------- the film page */
.screen { position: relative; margin: 18px auto 10px; max-width: 980px; padding: 12px; border-radius: 6px;
  background: linear-gradient(135deg, #f7dc8e, #a87a2a 22%, #f1d27a 45%, #8c6220 70%, #e8c467);
  box-shadow: 0 0 0 2px #3c240d, 0 0 0 5px rgba(58, 33, 12, .55), 0 18px 34px rgba(40, 20, 5, .45); }
.screen video { display: block; width: 100%; height: auto; aspect-ratio: 16 / 9; background: #0d0704; border-radius: 2px; box-shadow: inset 0 0 0 2px #4a2e0f; }
.screen video:focus-visible { outline: 3px solid #8b2b18; outline-offset: 3px; }
.facts { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 22px; margin: 8px 0 4px; font: 500 1em "Grenze Gotisch", serif; color: var(--red); }
.facts span b { font-family: "Grenze", serif; font-weight: 600; color: var(--ink); }
.chapters { list-style: none; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px 14px; margin: 14px 0 0; padding: 0; }
.chapters button { display: flex; gap: .6em; align-items: baseline; width: 100%; text-align: left; padding: .45em .75em; border-radius: 10px; cursor: pointer;
  border: 1px solid rgba(124, 34, 18, .28); background: rgba(126, 34, 18, .05); color: inherit; font: inherit; font-size: .95em; transition: background .2s, border-color .2s; }
.chapters button:hover { background: rgba(255, 196, 90, .18); }
.chapters button:focus-visible { outline: 2px solid #8b2b18; outline-offset: 2px; }
.chapters button[aria-current] { background: rgba(255, 196, 90, .32); border-color: rgba(160, 80, 20, .55); }
.chapters time { min-width: 2.7em; font: 500 1em "Grenze Gotisch", serif; color: var(--red); }
.transcript { margin-top: 10px; }
.transcript ol { margin: .4em 0 0; padding-left: 1.4em; }
.transcript li { margin: 0 0 .45em; }
.transcript li time { font: 500 .95em "Grenze Gotisch", serif; color: var(--red); margin-right: .4em; }
.film-links { display: flex; flex-wrap: wrap; gap: 10px 14px; justify-content: center; margin: 16px 0 4px; }

/* tabs without a numeral (Contents, Film) always show their word, at every size */
.tab.word .s { display: inline; }
/* phones: the kicker breaks between its phrases, never inside one */
@media (max-width: 759px) { .kicker { flex-wrap: wrap; gap: 0 .35em; } .kicker > span:not(.sr-only) { white-space: nowrap; } }
/* links inside the film transcript and credits read as ink, not browser blue */
.transcript a { color: var(--red); font-weight: 600; text-decoration: underline; text-underline-offset: .18em; }
.transcript a:hover, .transcript a:focus-visible { color: #5a1408; }

@media (min-width: 1180px) and (min-aspect-ratio: 11/10) and (max-height: 1240px) {
  .tabs { gap: 6px; }
  .tab { padding-top: 11px; padding-bottom: 11px; }
  .tab:not(.word):not([aria-current="page"]):not(:hover):not(:focus-visible) .s { display: none; }
}

/* twenty three chapters: slimmer tabs */
.tabs { gap: 5px; }
@media (min-width: 760px) { .tab { padding: 9px 7px 9px 12px; font-size: 15px; } }
@media (max-width: 759px) { .tabs { gap: 4px; } .tab { padding: 7px 8px 8px; min-height: 34px; } .tab .s { display: none; } .tab:first-child .s, .tab.word .s { display: inline; } }
@media (max-width: 1240px) { .tabs { padding-right: 150px; } .tab .f { display: none; } .tab .s { display: inline; } .tab { padding: 6px 9px 7px; font-size: 14px; gap: 5px; } }
@media (max-width: 759px) { .tabs { padding-right: 48px; } .tab .s { display: none; } .tab:first-child .s, .tab.word .s { display: inline; } }
