/* Bigby's Middle Finger: an illuminated spell page.
   Desktop reproduces the approved composition 1:1 in reference units (1199 x 1312).
   Under 760px the page is re-art-directed: art blocks scale as units, text reflows. */

@font-face { font-family: "Unifraktur"; src: url(../fonts/unifrakturmaguntia-400.woff2) format("woff2"); font-display: swap; }
@font-face { font-family: "Grenze"; font-weight: 400; src: url(../fonts/grenze-400.woff2) format("woff2"); font-display: swap; }
@font-face { font-family: "Grenze"; font-weight: 600; src: url(../fonts/grenze-600.woff2) format("woff2"); font-display: swap; }
@font-face { font-family: "Grenze Gotisch"; font-weight: 500; src: url(../fonts/grenze-gotisch-500.woff2) format("woff2"); font-display: swap; }

:root {
  --ink: #26150b; --title-ink: #150b06; --red: #7c2212; --red-hi: #a8361b; --ember: #ff9a3c;
  --pad: clamp(10px, 2.2vh, 24px);
  color-scheme: dark;
}
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
body {
  min-height: 100svh; display: grid; place-items: center; padding: var(--pad) 8px;
  background: radial-gradient(120% 85% at 50% 36%, #3e2515 0%, #1d1008 50%, #0a0503 100%) fixed;
  color: var(--ink); font-family: "Grenze", "Iowan Old Style", Georgia, serif;
  font-kerning: normal; text-rendering: optimizeLegibility; -webkit-font-smoothing: antialiased;
}
.sr-only { position: absolute !important; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* ---------------------------------------------------------------- folio */
.wrap { container-type: inline-size; width: clamp(min(720px, 96vw), calc((100svh - 2 * var(--pad)) * 0.9139), min(96vw, 1320px)); }
.folio {
  --U: calc(100cqw / 1199);
  position: relative; aspect-ratio: 1199 / 1312; isolation: isolate; border-radius: 1.1% / 1%;
  background: #d8b887 url(../assets/parchment.webp) center / 100% 100% no-repeat;
  box-shadow: 0 2.6cqw 7cqw rgba(0, 0, 0, .7), 0 .5cqw 1.4cqw rgba(0, 0, 0, .5);
}
.grain, .light { position: absolute; inset: 0; pointer-events: none; border-radius: inherit; z-index: 0; }
.grain {
  mix-blend-mode: multiply; opacity: .2;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='256' height='256'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.82' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .42 0 0 0 0 .28 0 0 0 0 .14 0 0 0 .6 0'/%3E%3C/filter%3E%3Crect width='256' height='256' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 256px;
}
/* warm light from the spell, washing the page */
.light { --lx: 70.5%; --ly: 33%; mix-blend-mode: soft-light; opacity: .22; transition: opacity 1.2s ease; }
.light::before {
  content: ""; position: absolute; inset: 0; border-radius: inherit;
  background: radial-gradient(46% 40% at var(--lx) var(--ly), rgba(255, 168, 86, .75), rgba(255, 128, 50, .22) 52%, transparent 78%);
  animation: candle 4.7s ease-in-out infinite;
}
.casting .light, .active .light { opacity: .9; }
.fading .light { opacity: .12; }
@keyframes candle { 0%, 100% { opacity: .82; } 23% { opacity: 1; } 47% { opacity: .74; } 71% { opacity: .94; } }

.frame-desk img { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 1; pointer-events: none; }
.cap, .top-orn { display: none; }

/* ---------------------------------------------------------------- blocks and pieces (reference units) */
.blk {
  position: absolute; z-index: 2; margin: 0;
  left: calc(var(--bx) * var(--U)); top: calc(var(--by) * var(--U));
  width: calc(var(--bw) * var(--U)); aspect-ratio: var(--bw) / var(--bh);
  container-type: inline-size;
  --k: calc(100cqw / var(--bw));
}
.p { position: absolute; display: block; left: calc(var(--x) * var(--k)); top: calc(var(--y) * var(--k)); width: calc(var(--w) * var(--k)); height: auto; max-width: none; user-select: none; -webkit-user-drag: none; pointer-events: none; }
.tx {
  position: absolute; margin: 0; white-space: nowrap;
  left: calc(var(--x) * var(--k)); top: calc(var(--y) * var(--k));
  font-size: calc(var(--fs) * var(--k)); line-height: calc(var(--lh) * var(--k));
}
.l { display: block; }
.in { padding-left: calc(var(--in) * var(--k)); }

/* title */
.title h1 { margin: 0; font: inherit; }
.t1, .t2 { font-family: "Unifraktur", serif; font-weight: 400; color: var(--title-ink); transform-origin: 0 0; -webkit-text-stroke: calc(.8 * var(--k)) var(--title-ink); paint-order: stroke fill; }
.t1 { transform: scaleX(.9); letter-spacing: .025em; }
.t2 { transform: scaleX(.86); }

/* subtitle */
.sub-t { font-family: "Grenze Gotisch", serif; font-weight: 500; color: var(--red); text-align: center; width: calc(435 * var(--k)); }
.dia { display: inline-block; width: .2em; height: .2em; margin: 0 .5em; background: currentColor; transform: translateY(-.16em) rotate(45deg); }

/* spell text */
.text b { color: var(--red); font-weight: 400; }
.text em { color: var(--red); font-style: normal; }
.dur b { font-family: "Grenze Gotisch", serif; font-weight: 500; }

/* ---------------------------------------------------------------- stage */
.stage .p.rip { z-index: 1; } .stage .p.hand { z-index: 2; }
.goblin { z-index: 3; transform-origin: 46% 98%; animation: breathe 3.8s ease-in-out infinite; }
.stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 4; pointer-events: none; opacity: 0; transition: opacity .3s; }
.stage .stage-ink, .stage .m3, .stage .m25 { z-index: 5; }
.boop { z-index: 6; transform-origin: 28% 78%; }
.stage.gl canvas { opacity: 1; }
.stage.gl .fb { visibility: hidden; }
.stage:not(.gl) .p.hand { transform-origin: 42.7% 79.6%; animation: fbglow 3.4s ease-in-out infinite; }
.active .goblin { pointer-events: auto; cursor: pointer; }
@keyframes breathe { 50% { transform: translateY(-.35%) scaleY(1.008); } }
@keyframes fbglow { 50% { filter: brightness(1.07) saturate(1.08); } }

/* ---------------------------------------------------------------- gesture */
.gesture::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  border: 0 solid transparent;
  border-image: url(../assets/gframe-m.webp) 0 fill / 0 stretch;
  border-image-source: image-set(url(../assets/gframe-m.webp) 1x, url(../assets/gframe-m@2x.webp) 2x);
}
.gesture h2 { font: 600 calc(24 * var(--k)) / calc(28 * var(--k)) "Grenze", serif; color: var(--ink); text-align: center; width: calc(549 * var(--k)); text-transform: uppercase; }
.steps { list-style: none; margin: 0; padding: 0; }
.lab { font-size: calc(26.5 * var(--k)); line-height: calc(30 * var(--k)); transition: color .3s, text-shadow .3s; }
.wiz { transform-origin: 50% 96%; transition: transform .35s cubic-bezier(.2, .8, .2, 1.2), filter .35s; }
.step.on .wiz { transform: translateY(-2%) scale(1.04); filter: drop-shadow(0 0 calc(6 * var(--k)) rgba(255, 150, 60, .95)) brightness(1.06); }
.step.on .lab { color: var(--red-hi); text-shadow: 0 0 .45em rgba(255, 150, 60, .75); }
.step.on .arrow { filter: drop-shadow(0 0 calc(4 * var(--k)) rgba(255, 150, 60, .9)); }

/* ---------------------------------------------------------------- motto, seal, fuse */
.motto .tx { color: var(--red); text-align: center; width: calc(238 * var(--k)); }
.sealbox .seal {
  position: absolute; left: calc(50 * var(--k)); top: calc(84 * var(--k)); width: calc(260 * var(--k)); aspect-ratio: 260 / 250;
  padding: 0; margin: 0; border: 0; background: none; cursor: pointer; border-radius: 50%; z-index: 2;
  -webkit-tap-highlight-color: transparent; transition: transform .25s cubic-bezier(.2, .8, .2, 1.3), filter .25s;
}
.seal img { position: absolute; inset: 0; width: 100%; height: 100%; animation: sealIdle 5s ease-in-out infinite; }
.seal:hover { transform: translateY(-1%) rotate(-2deg) scale(1.02); }
.seal:focus-visible { outline: none; filter: drop-shadow(0 0 calc(5 * var(--k)) #ffd27a) drop-shadow(0 0 calc(2 * var(--k)) #ffd27a); }
.seal::after, .seal .glow { content: ""; position: absolute; inset: 0; pointer-events: none;
  -webkit-mask: var(--m) center / 100% 100% no-repeat; mask: var(--m) center / 100% 100% no-repeat; }
.seal::after { --m: url(../assets/seal.webp); background: linear-gradient(112deg, transparent 38%, rgba(255, 228, 200, .34) 50%, transparent 62%) -160% 0 / 260% 100% no-repeat; transition: background-position 1s ease; }
.seal:hover::after { background-position: 160% 0; }
.seal .glow { --m: url(../assets/seal-emboss.webp); background: radial-gradient(circle at 56% 48%, #fff2c8, #ffb050 22%, rgba(255, 90, 20, .85) 40%, rgba(255, 60, 10, 0) 62%); mix-blend-mode: screen; opacity: 0; transition: opacity .6s; }
.casting .seal .glow { opacity: .7; }
.active .seal .glow { opacity: calc(1 - var(--fuse, 0) * .85); }
@keyframes sealIdle { 50% { filter: brightness(1.05) saturate(1.05); } }
.hint { color: var(--red); text-align: center; width: calc(220 * var(--k)); opacity: .82; transition: opacity 1.2s ease; }
.hint.used { opacity: 0; }

.fuse { overflow: visible; opacity: 0; transition: opacity .6s ease; }
.fuse.lit { opacity: 1; }
.fuse .cord { fill: none; stroke: #7a5532; stroke-width: 1.4; stroke-linecap: round; stroke-dasharray: .03 .018; }
.fuse .burnt { fill: none; stroke: #1e120a; stroke-width: 1.9; stroke-linecap: round; stroke-dasharray: var(--fuse, 0) 2; }
.fuse .notch { stroke: #6b2a18; stroke-width: 1.4; stroke-linecap: round; transition: stroke .3s; }
.fuse .notch.spent { stroke: #1e120a; }
.fuse .halo { fill: rgba(255, 140, 40, .38); } .fuse .core { fill: #ffe7a6; }
.folio:not(.active) .fuse .ember { opacity: 0; }

/* ---------------------------------------------------------------- mobile: art direction for narrow screens */
@media (max-width: 759px) {
  body { padding: 8px; display: block; }
  .wrap { width: 100%; max-width: 560px; margin: 0 auto; }
  .folio {
    --fb: clamp(28px, 7.6vw, 40px);
    aspect-ratio: auto; display: flex; flex-direction: column; border-radius: 12px;
    padding: calc(var(--fb) + 12px) calc(var(--fb) + 4px) calc(var(--fb) + 18px);
    background: #d8b887 url(../assets/parchment-tile.webp) 0 0 / 100% auto repeat-y;
  }
  .folio::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"));
  }
  .frame-desk { display: none; }
  .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; }
  .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; }
  .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; }
  .top-orn { display: block; position: absolute; z-index: 2; top: calc(var(--fb) * .12); left: 50%; width: calc(var(--fb) * .85); transform: translateX(-50%); }
  .light { --lx: 50%; --ly: 22%; }

  .blk { position: relative; left: auto; top: auto; width: 100%; }
  .flow { aspect-ratio: auto; }
  .flow .p, .flow .tx { position: static; width: auto; white-space: normal; }
  .flow .tx { font-size: 1em; line-height: inherit; }
  .flow .l { display: inline; }
  .flow .in { padding-left: 0; }

  .title { order: 1; margin-bottom: 2px; } .sub { order: 2; } .stage { order: 3; } .text { order: 4; } .gesture { order: 5; } .motto { order: 6; } .sealbox { order: 7; }
  .sub { display: flex; flex-direction: column; align-items: center; margin-bottom: 10px; }
  .sub .sub-t { display: flex; align-items: center; justify-content: center; gap: .1em; font-size: clamp(22px, 6.8vw, 31px); line-height: 1.25; width: 100%; }
  .sub .star-l, .sub .star-r { width: .62em; flex: none; }
  .sub .star-l { margin-right: .3em; } .sub .star-r { margin-left: .3em; }
  .sub .div-sub { width: 96%; margin-top: 4px; }

  .stage { width: calc(100% + 14px); margin: 0 -7px 6px; }

  .text { font-size: clamp(17px, 4.9vw, 21px); line-height: 1.46; margin-top: 4px; }
  .text .tx { margin: 0 0 .55em; }
  .text .c-initial { float: left; width: 3.15em; margin: .2em .4em 0 0; }
  .text .nodmg { padding-left: 1.4em; }
  .text .nodmg .p { display: inline-block; width: 1.45em; vertical-align: -.1em; margin-left: .3em; }
  .text > .div-mid { width: 72%; margin: .1em auto .5em; }
  .text > .div-low { width: 90%; margin: .1em auto .55em; }
  .text .fuse { display: block; width: 50%; margin: -.1em auto 0; }

  .gesture { margin-top: 20px; padding: 50px 16px 18px; }
  .gesture::before { border-width: 20px; border-image-slice: 10.6% 4.66% fill; border-image-width: 20px; }
  .gesture .ribbon { position: absolute; top: -4px; left: 50%; width: 68%; transform: translateX(-50%); }
  .gesture .gh { position: absolute; top: 9px; left: 0; width: 100%; font-size: 17px; line-height: 22px; }
  .steps { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 12px; }
  .step { display: flex; flex-direction: column; align-items: center; }
  .step .lab { font-size: 18px; line-height: 1.2; margin-bottom: 4px; }
  .step .wiz { width: calc(var(--w) / 164 * 100%); }
  .step .arrow { display: none; }
  .step.s4 { justify-content: center; }
  .step .minifist { width: 60%; }

  .motto { display: flex; flex-direction: column; align-items: center; margin-top: 22px; font-size: 19px; line-height: 1.38; }
  .motto .motto-top { width: 38%; } .motto .motto-bot { width: 30%; margin-top: 4px; }
  .motto .tx { width: auto; margin: 4px 0; }
  .motto .l { display: block; }

  .sealbox { width: 76%; align-self: center; margin: 4px 0 30px; }
  .sealbox .hint { position: absolute; left: 0; top: 100%; width: 100%; font-size: 15px; line-height: 1.2; }
}

@media (prefers-reduced-motion: reduce) {
  .light::before, .goblin, .seal img, .stage:not(.gl) .p.hand { animation: none; }
  .wiz, .seal, .seal::after { transition: none; }
}

/* ---------------------------------------------------------------- living page: light, goblin, grawlix, links, sound */
.lightgl { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 3; pointer-events: none; border-radius: inherit; opacity: 0; transition: opacity 1s ease; }
.folio.lit .lightgl { opacity: 1; }

.goblin .inner { display: block; width: 100%; height: auto; }
.goblin { transition: rotate .45s cubic-bezier(.3, .7, .3, 1), translate .45s cubic-bezier(.3, .7, .3, 1), filter .3s; }
.goblin.wary { rotate: 5deg; translate: 1.5% 0; }
.lids { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.lid { fill: url(#skin); stroke: #2b1a0e; stroke-width: .9; transform-box: fill-box; transform-origin: 50% 0; transform: scaleY(0); }
.goblin.blink .lid { animation: blink .19s ease-in-out; }
@keyframes blink { 40%, 62% { transform: scaleY(1); } }
.stage.hl-goblin .goblin { filter: drop-shadow(0 0 calc(6 * var(--k)) rgba(255, 160, 70, .9)); }
.stage.hl-m3 .m3, .stage.hl-m25 .m25 { animation: refGlow 1.3s ease-out; }
@keyframes refGlow { 25% { filter: drop-shadow(0 0 calc(5 * var(--k)) rgba(255, 150, 60, .95)) brightness(1.35); } }

.wiz3box { container-type: inline-size; }
.wiz3box .inner { display: block; width: 100%; height: auto; }
.grawlix {
  position: absolute; pointer-events: none; white-space: nowrap; text-align: center; color: #170c06;
  left: calc(103 * 100cqw / 164); top: calc(15.6 * 100cqw / 164); width: calc(60 * 100cqw / 164);
  font: 600 calc(24 * 100cqw / 164) / calc(22.5 * 100cqw / 164) "Grenze", serif;
  -webkit-text-stroke: calc(.7 * 100cqw / 164) #170c06;
}
.grawlix span { display: block; }

.ref { cursor: help; text-decoration: underline dotted transparent; text-decoration-thickness: 1px; text-underline-offset: .2em; transition: text-decoration-color .25s, color .25s, text-shadow .25s; }
.ref:hover { text-decoration-color: currentColor; color: var(--red-hi); text-shadow: 0 0 .5em rgba(255, 150, 60, .45); }
.seal.hl .glow { opacity: .8; }
.fuse.peek { opacity: .85; }

.stage .fb { transition: opacity .6s ease; }
.boot .stage .p.hand, .boot .stage .m3, .boot .stage .m25, .boot .stage .boop { opacity: 0; animation: bootSafety .5s 3.5s forwards; }
@keyframes bootSafety { to { opacity: 1; } }

.sound {
  position: fixed; top: 12px; right: 12px; z-index: 20; display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 14px 7px 10px; border-radius: 999px; border: 1px solid rgba(214, 166, 90, .5);
  background: rgba(22, 11, 5, .66); color: #ecd6a8; font: 600 15px/1 "Grenze", Georgia, serif; letter-spacing: .02em; cursor: pointer;
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); box-shadow: 0 4px 14px rgba(0, 0, 0, .35); transition: background .2s, border-color .2s, color .2s;
}
.sound:hover { background: rgba(52, 26, 10, .78); border-color: rgba(240, 190, 110, .85); color: #fff1cf; }
.sound:focus-visible { outline: 2px solid #f3c66b; outline-offset: 3px; }
.sound svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.sound .spk { fill: currentColor; stroke: none; }
.sound .waves { opacity: 0; transition: opacity .2s; }
.sound[aria-pressed="true"] .waves { opacity: 1; }
.sound[aria-pressed="true"] .mute { opacity: 0; }

@media (max-width: 759px) {
  .lightgl { display: none; }
  .flow .wiz3box { position: relative; left: auto; top: auto; }
  .sound { top: 8px; right: 8px; padding: 6px 11px 6px 8px; font-size: 13px; }
}
@media (prefers-reduced-motion: reduce) {
  .goblin.blink .lid, .stage.hl-m3 .m3, .stage.hl-m25 .m25 { animation: none; }
  .goblin { transition: none; }
}
