/* Chapter VII, I Cast: the casting stage above each spell, its live lettering, and the spell entries below. */
@font-face { font-family: "Bangers"; src: url(../fonts/bangers-400.woff2) format("woff2"); font-display: swap; }
@font-face { font-family: "Anton"; src: url(../fonts/anton.woff2) format("woff2"); font-display: swap; }

/* the page behind: the same plate, out of focus and in shadow */
html:has(body.cast-page) { overflow-x: clip; }
.backdrop-still.cast-bed { inset: -40px; filter: blur(22px) brightness(.42) saturate(1.25); }

/* ---------------------------------------------------------------- the stage: the plate as large as the screen allows */
.cast-page .wrap.book {
  --plate-ar: 1.5;
  --plate-w: min(96vw, 1440px, calc((100svh - 170px) * var(--plate-ar)));
  --plate-h: calc(var(--plate-w) / var(--plate-ar));
  --intro: calc(var(--plate-h) + 150px);
}
.cast-page.square .wrap.book { --plate-ar: 1; --plate-w: min(94vw, 900px, calc(100svh - 190px)); }
.cast-intro { height: var(--intro); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  margin-inline: calc((min(96vw, 1060px) - var(--plate-w)) / 2); }
.cast-stage { margin: 0; width: var(--plate-w); display: flex; flex-direction: column; align-items: center; gap: 14px; }
.cast-window { position: relative; width: 100%; aspect-ratio: var(--plate-ar); overflow-x: clip; }
.cast-cam { position: absolute; inset: 0; transform: var(--cam, none); transform-origin: 50% 50%;
  transition: transform var(--cam-t, 1.2s) cubic-bezier(.3, .1, .2, 1); will-change: transform; }
.cast-plate { position: absolute; inset: 0; overflow: hidden; border-radius: 6px; cursor: pointer; container-type: inline-size;
  box-shadow: 0 0 0 1px rgba(255, 214, 140, .25), 0 24px 70px rgba(0, 0, 0, .7), 0 0 120px rgba(255, 120, 60, .12); }
.cast-plate > * { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.cast-plate picture img { width: 100%; height: 100%; display: block; }
.cast-video { object-fit: fill; opacity: 0; transition: opacity 1.1s ease; pointer-events: none; }
.cast-plate.rolling .cast-video { opacity: 1; transition: none; }
.cast-frame { pointer-events: none; }
.cast-dim { pointer-events: none; opacity: 0; transition: opacity .9s ease; background: radial-gradient(70% 80% at var(--hx, 35%) var(--hy, 35%), transparent 10%, rgba(10, 2, 14, .62) 75%); }
.cast-plate.dim .cast-dim { opacity: 1; }
.cast-flash { pointer-events: none; opacity: 0; mix-blend-mode: screen;
  background: radial-gradient(60% 75% at var(--fx, 50%) var(--fy, 40%), #fff 0%, rgba(255, 236, 214, .85) 30%, rgba(255, 190, 220, .25) 70%, transparent); }
.cast-fx { position: absolute; left: -6%; top: -9%; width: 112%; height: 118%; pointer-events: none; }
@media (max-width: 699px) { .cast-window { overflow: clip; border-radius: 6px; } }

/* the banner and its lettering: real text, set where the painter lettered it */
.cast-letters { pointer-events: none; overflow: visible; }
.cast-letters text { font-family: "Grenze", Georgia, serif; font-weight: 600; font-style: italic; paint-order: stroke fill; stroke-linejoin: round; }
.cast-letters .pre { fill: #3d0d07; stroke: #f7e2b2; stroke-width: 2.5; letter-spacing: .02em; }
.cast-letters .pre.crimson { fill: url(#crimson); stroke: #3a0704; stroke-width: 3; font-variant: small-caps; letter-spacing: 0; }
.cast-letters .name { fill: url(#crimson); stroke: #3a0704; stroke-width: 3; font-variant: small-caps; transform-box: fill-box; transform-origin: 50% 62%; }
.cast-letters .name.sub { fill: #2b0c05; stroke: #f7e2b2; stroke-width: 2; font-variant: normal; }
.cast-letters .name.ital { font-style: italic; }
.js.cast-ready .cast-letters .pre:not(.on), .js.cast-ready .cast-letters .name:not(.on) { opacity: 0; }
.cast-letters .name.on:not(.still) { animation: slam .66s cubic-bezier(.2, .9, .25, 1.18) both; }
@keyframes slam { 0% { opacity: 0; transform: scale(1.75); } 50% { opacity: 1; transform: scale(.95); } 100% { opacity: 1; transform: scale(1); } }

/* SQUEAK! as live comic lettering that pops with every step */
.cast-letters .sq { font: 400 64px "Bangers", "Impact", sans-serif; letter-spacing: .03em; fill: url(#squeak); stroke: #2a1205; stroke-width: 7; transform-box: fill-box; transform-origin: 50% 50%; }
.cast-letters .wedge { fill: #ffd23a; stroke: #2a1205; stroke-width: 3.5; transform-box: fill-box; transform-origin: 100% 50%; }
.js.cast-ready .cast-letters .sq:not(.on) { opacity: 0; }
.js.cast-ready .cast-letters .squeaks .wedge { opacity: 0; transition: opacity .2s; }
.js.cast-ready .cast-letters .squeaks:has(.sq.on) .wedge { opacity: 1; }
.cast-letters .sq.pop { animation: pop .5s cubic-bezier(.2, 1.4, .4, 1) both; }
@keyframes pop { 0% { transform: scale(.2) rotate(-14deg); } 60% { transform: scale(1.22) rotate(4deg); } 100% { transform: scale(1) rotate(0); } }

/* if the script never runs or stalls, the lettering still appears */
.js:not(.cast-ready) .cast-letters text { animation: failsafe 0s 3.5s both; }
@keyframes failsafe { from { opacity: 0; } to { opacity: 1; } }

/* the bar under the plate */
.cast-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 10px 16px; }
.cast-label { margin: 0; padding: 8px 14px 9px; border-radius: 12px; color: #f3dcae; font: 500 16px/1.3 "Grenze", serif; text-align: center;
  background: rgba(18, 9, 4, .62); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); border: 1px solid rgba(214, 166, 90, .42); }
.cast-label small { display: block; font: 500 12px/1.2 "Grenze", serif; letter-spacing: .14em; text-transform: uppercase; color: #e2b86a; }
.cast-btn { min-width: 11em; }
.cast-intro .scroll-cue { margin: 0; }
.cast-stage.casting .cast-plate { cursor: default; }
@media (max-width: 759px) {
  .cast-page .wrap.book { --intro: calc(var(--plate-h) + 170px); }
  .cast-label { font-size: 15px; }
}

/* ---------------------------------------------------------------- the spell entry */
.school { text-align: center; margin: .2em 0 .9em; font: 500 1.08em "Grenze Gotisch", serif; color: var(--red); }
.school i { font-style: normal; color: var(--title-ink); }
.spellblock { display: grid; grid-template-columns: max-content 1fr; gap: .35em 1.1em; margin: 0 auto 1.1em; padding: .9em 1.1em; max-width: 46em;
  border-block: 2px solid rgba(124, 34, 18, .55); background: linear-gradient(rgba(255, 236, 196, .28), rgba(255, 236, 196, .08)); }
.spellblock dt { font: 500 1em/1.45 "Grenze Gotisch", serif; color: var(--red); }
.spellblock dd { margin: 0; }
.spelltext { max-width: 46em; margin-inline: auto; }
.gag { max-width: 46em; margin: 1.4em auto 0; padding: 1em 1.2em 1.1em; border-radius: 14px; border: 1px dashed rgba(124, 34, 18, .45); background: rgba(255, 236, 196, .18); }
.gag h2 { margin-top: .1em; }
.gag-row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 22px; }
.gag-row .stats { margin-top: 0; }
.gag-note { min-height: 3em; margin: .6em 0 0; font-style: italic; color: var(--ink-soft, #4a3020); }

/* the five spells of the chapter, as a strip of seals */
.ch7 { margin: 1.6em 0 0; }
.ch7 h2 { font-size: clamp(26px, 3vw, 34px); }
.ch7 ol { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; }
.ch7 a { display: grid; gap: 6px; justify-items: center; text-align: center; text-decoration: none; color: var(--ink); font: 500 .82em/1.2 "Grenze", serif; }
.ch7 img { width: 100%; max-width: 128px; aspect-ratio: 1; height: auto; border-radius: 50%; object-fit: cover;
  border: 3px solid #b8892e; box-shadow: 0 0 0 2px #5d2a0c, 0 6px 14px rgba(60, 30, 10, .35); transition: transform .25s cubic-bezier(.2, .8, .2, 1.4); }
.ch7 a:hover img, .ch7 a:focus-visible img { transform: translateY(-3px) rotate(-3deg); }
.ch7 a:focus-visible { outline: 2px solid #8b2b18; outline-offset: 4px; border-radius: 8px; }
.ch7 [aria-current="page"] img { border-color: #d8ad4c; box-shadow: 0 0 0 3px #8b2b18, 0 0 18px rgba(216, 173, 76, .7); }
.ch7 i { font-style: normal; color: var(--red); font-family: "Grenze Gotisch", serif; }
@media (max-width: 759px) {
  .spellblock { grid-template-columns: 1fr; gap: .1em; }
  .spellblock dd { margin-bottom: .45em; }
  .ch7 ol { grid-template-columns: repeat(5, minmax(84px, 1fr)); overflow-x: auto; padding-bottom: 6px; }
}

/* ---------------------------------------------------------------- the forbidden one: the meme plate (spell 5) */
.meme { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: space-between; align-items: center; margin: 0;
  padding: 2.5cqi 3cqi 3.2cqi; pointer-events: none; text-align: center; font-family: "Anton", "Impact", sans-serif; font-weight: 400;
  text-transform: uppercase; color: #fff; -webkit-text-stroke: .1em #000; paint-order: stroke fill; line-height: 1.02; letter-spacing: .01em; }
.meme span { display: block; font-size: calc(var(--fit, 1) * 12.2cqi); white-space: nowrap; }
.meme .bottom { width: 86cqi; white-space: normal; }
.meme .w { display: inline-block; }
.js.cast-ready .meme:not(.on) { visibility: hidden; }
.js:not(.cast-ready) .meme { animation: failsafe 0s 3.5s both; }
.tb-gl, .tb-fx { pointer-events: none; }
.tb-gl { opacity: 0; transition: opacity .6s; }
.cast-plate.gl .tb-gl { opacity: 1; }

.cast-page.square .cast-plate { cursor: pointer;
  box-shadow: 0 0 0 1px rgba(255, 214, 140, .25), 0 24px 70px rgba(0, 0, 0, .7), 0 0 calc(30px + var(--charge, 0) * 140px) rgba(130, 150, 255, calc(.12 + var(--charge, 0) * .7)); }
.credit { text-align: center; margin: 1.2em 0 0; }

/* ---------------------------------------------------------------- the second wave of plates: VII.5 to VII.9 */
.cast-letters .up { font-style: normal; }
.cast-letters .sc { font-variant: small-caps; }
.cast-letters .ink { fill: #1b1714; stroke: #fffaf0; stroke-width: 3; }
.cast-letters .pre.ink { font-variant: normal; letter-spacing: .01em; }
.cast-letters .name.ink { font-family: "Grenze", Georgia, serif; }

/* Noodle Teeth is a tall card with rounded corners: the plate takes the card's shape */
.cast-page.portrait .wrap.book { --plate-ar: .9139; --plate-w: min(92vw, 820px, calc((100svh - 190px) * .9139)); }
.cast-page.portrait .cast-plate { border-radius: 0; box-shadow: none;
  -webkit-mask: url(../assets/spell-noodle-shape.png) center / 100% 100% no-repeat; mask: url(../assets/spell-noodle-shape.png) center / 100% 100% no-repeat; }
.cast-page.portrait .cast-window::before { content: ""; position: absolute; inset: .3%; border-radius: 4% / 3.65%;
  box-shadow: 0 0 0 1px rgba(255, 214, 140, .25), 0 24px 70px rgba(0, 0, 0, .7), 0 0 120px rgba(190, 120, 255, .16); }

/* plates painted more than once: pick the painting, or let Fireball cut between them */
.cast-page.takes .wrap.book { --plate-w: min(96vw, 1440px, calc((100svh - 270px) * var(--plate-ar))); --intro: calc(var(--plate-h) + 260px); }
.cast-takes { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; width: 100%; margin: 0; }
.cast-takes[hidden] { display: none; }
.cast-takes a { text-decoration: none; display: grid; gap: 4px; justify-items: center; width: 96px; padding: 4px 4px 6px; border-radius: 10px; cursor: pointer;
  border: 1.5px solid rgba(255, 214, 140, .3); background: rgba(20, 8, 4, .6); color: #f3dcae; font: 500 13px/1.1 "Grenze", serif; }
.cast-takes img { width: 100%; height: auto; aspect-ratio: 3 / 2; object-fit: cover; border-radius: 6px; display: block; transition: filter .2s; }
.cast-takes a[aria-pressed="true"] { border-color: #ffd98f; box-shadow: 0 0 0 2px #8b2b18, 0 0 16px rgba(255, 190, 90, .55); }
.cast-takes a:hover img, .cast-takes a:focus-visible img { filter: brightness(1.18); }
.cast-takes a:focus-visible { outline: 2px solid #ffd98f; outline-offset: 2px; }
.cast-stage.casting .cast-takes a { cursor: progress; }
@media (max-width: 759px) {
  .cast-page.takes .wrap.book { --intro: calc(var(--plate-h) + 300px); }
  .cast-takes { gap: 6px; }
  .cast-takes a { width: 64px; font-size: 11px; padding: 3px 3px 5px; }
}

/* cast on a friend: both names land on the painting */
.cast-plate > .cast-tag { inset: auto; width: auto; height: auto; z-index: 3; pointer-events: none; white-space: nowrap;
  transform: translate(-50%, -50%) rotate(var(--r, -4deg)); padding: .2em .55em .08em; border-radius: .45em;
  font: 400 clamp(15px, 3.2cqi, 42px)/1 "Bangers", "Impact", sans-serif; letter-spacing: .04em;
  color: #fff6e0; background: #a3180f; border: .1em solid #2a0904; text-shadow: 0 .06em 0 #2a0904;
  box-shadow: 0 .16em 0 #2a0904, 0 .5em 1.2em rgba(0, 0, 0, .45); }
.cast-plate > .cast-tag.caster { --r: 3deg; color: #2a1205; background: #ffd23a; font-size: clamp(13px, 2.3cqi, 30px); text-shadow: none; }
.cast-plate > .cast-tag.caster::before { content: "Cast by "; font-size: .72em; letter-spacing: .06em; }
.cast-plate > .cast-tag[hidden] { display: none; }
.cast-tag.pop { animation: tag .6s cubic-bezier(.2, 1.4, .4, 1) both; }
@keyframes tag {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(.2) rotate(-18deg); }
  60% { opacity: 1; transform: translate(-50%, -50%) scale(1.18) rotate(var(--r, -4deg)); }
  100% { opacity: 1; transform: translate(-50%, -50%) scale(1) rotate(var(--r, -4deg)); } }
.cast-intro:has(> .hexed:not([hidden])) { height: calc(var(--intro) + 64px); }

/* Fireball's toy: eight real six sided dice */
.dice { display: flex; flex-wrap: wrap; gap: 9px; margin: .5em 0 .3em; }
.d6 { --pip: radial-gradient(circle closest-side, #6e0c07 70%, transparent 82%); width: 40px; height: 40px; border-radius: 9px;
  background-color: #fbf0d6; background-repeat: no-repeat; background-size: 24% 24%;
  box-shadow: inset 0 -3px 0 rgba(110, 12, 7, .22), inset 0 0 0 1.5px rgba(110, 12, 7, .5), 0 3px 7px rgba(0, 0, 0, .25); }
.d6[data-v="1"] { background-image: var(--pip); background-position: 50% 50%; }
.d6[data-v="2"] { background-image: var(--pip), var(--pip); background-position: 14% 14%, 86% 86%; }
.d6[data-v="3"] { background-image: var(--pip), var(--pip), var(--pip); background-position: 14% 14%, 50% 50%, 86% 86%; }
.d6[data-v="4"] { background-image: var(--pip), var(--pip), var(--pip), var(--pip); background-position: 14% 14%, 86% 14%, 14% 86%, 86% 86%; }
.d6[data-v="5"] { background-image: var(--pip), var(--pip), var(--pip), var(--pip), var(--pip); background-position: 14% 14%, 86% 14%, 50% 50%, 14% 86%, 86% 86%; }
.d6[data-v="6"] { background-image: var(--pip), var(--pip), var(--pip), var(--pip), var(--pip), var(--pip); background-position: 14% 14%, 86% 14%, 14% 50%, 86% 50%, 14% 86%, 86% 86%; }
.d6.roll { animation: roll .72s cubic-bezier(.2, .7, .3, 1) both; }
@keyframes roll { 0% { transform: translateY(-34px) rotate(var(--spin, 360deg)) scale(.7); } 65% { transform: translateY(3px) rotate(-6deg) scale(1.06); } 100% { transform: none; } }

/* ---------------------------------------------------------------- motion preferences */
@media (prefers-reduced-motion: reduce) {
  .cast-cam { transition: none; }
  .cast-letters .name.on:not(.still), .cast-letters .sq.pop, .cast-tag.pop, .d6.roll { animation: none; }
  .ch7 img, .cast-takes img { transition: none; }
}

/* ---------------------------------------------------------------- the full spellbook page, after chapter I */
.folio-spell .wrap.book { --plate-w: min(100%, calc((100svh - 150px) * var(--plate-ar))); --intro: 0px; }
.folio-spell .wrap.book > .tabs { top: 5%; }
.folio-spell .cast-intro { height: auto; margin: 6px 0 18px; }
.folio-spell .cast-stage { margin-inline: auto; }
.folio-spell .cast-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 12px 22px; width: 100%; }
.folio-spell .cast-bar .cast-label { color: #f3dcae; }
.fo-title { display: flex; align-items: center; gap: clamp(12px, 2.4vw, 24px); margin: 4px 0 2px; }
.fo-initial { flex: none; width: clamp(92px, 13vw, 150px); aspect-ratio: 172 / 208; display: grid; place-items: center; background: url(../assets/initial-field.webp) center / 100% 100% no-repeat;
  font: 400 clamp(62px, 9vw, 104px)/1 "Unifraktur", serif; color: #f6dfa2; text-shadow: 0 1px 0 #6b3d09, 0 0 2px #2b0805, 2px 3px 3px rgba(0, 0, 0, .55); padding-top: .06em; }
.fo-title h1 { margin: 0; text-align: left; font: 400 clamp(38px, 6vw, 72px)/1.04 "Unifraktur", serif; color: var(--title-ink); }
.fo-sub { display: flex; align-items: center; gap: 10px; margin: 8px 0 0; font: 600 clamp(20px, 2.5vw, 30px)/1.1 "Grenze Gotisch", serif; color: var(--red); }
.fo-sub i { font-style: normal; } .fo-sub img { width: 24px; height: auto; }
.fo-ch { margin: 4px 0 0 !important; font: 500 clamp(15px, 1.6vw, 18px)/1.2 "Grenze", serif; letter-spacing: .04em; opacity: .8; }
.cast-seal { position: relative; width: 132px; height: 127px; padding: 0; border: 0; background: none; cursor: pointer; transition: transform .25s; filter: drop-shadow(0 6px 8px rgba(0, 0, 0, .5)); }
.cast-seal[hidden] { display: none; }
.cast-seal img { position: absolute; inset: 0; width: 100%; height: 100%; }
.cast-seal:hover { transform: translateY(-2%) rotate(-3deg) scale(1.04); }
.cast-seal:disabled { filter: grayscale(.35) brightness(.8); cursor: progress; }
.cast-seal:focus-visible { outline: 2px solid #ffd27a; outline-offset: 3px; border-radius: 50%; }
.cast-seal .glow { display: none; }
.cast-hint { margin: 0 !important; font: 500 16px/1.2 "Grenze", serif; color: var(--ink); font-style: italic; }
.fo-gesture { margin: 1.4em 0 .6em; padding: 14px 10px 10px; border: 2px double rgba(90, 20, 8, .6); }
.fo-gesture h2 { margin: 0 0 8px !important; font: 600 24px/1.2 "Grenze", serif !important; letter-spacing: .08em; text-transform: uppercase; }
.fo-gesture ol { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.fo-gesture li { text-align: center; position: relative; }
.fo-gesture li img { display: block; width: 100%; height: auto; }
.fo-gesture li span { font: 600 clamp(19px, 2.2vw, 26px)/1.1 "Grenze Gotisch", serif; color: var(--ink); }
.fo-gesture li + li::before { content: "→"; position: absolute; left: -12px; top: 40%; color: var(--red); font-size: 24px; }
.fo-motto { text-align: center; margin: 1em auto; max-width: 30em; }
.fo-motto p { margin: .2em 0 !important; font-style: italic; }
.fo-motto img { display: block; margin: 0 auto; width: 110px; height: auto; }
.spelltext a { color: var(--red); text-decoration: underline; text-underline-offset: .15em; }
.spelltext a:hover { color: var(--red-hi, #a3180f); }
body.folio-spell.takes .wrap.book, body.folio-spell.square .wrap.book, body.folio-spell.portrait .wrap.book { --plate-w: min(100%, calc((100svh - 150px) * var(--plate-ar))); --intro: 0px; }
.folio-spell .cast-takes { max-width: 100%; flex-wrap: wrap; justify-content: center; }
.folio-spell .cast-intro:has(> .hexed:not([hidden])) { height: auto; }
