/* ============================================================
   YE ILLUMINATED 404 — a chronicle hand-copied by ye monks.
   No JavaScripte was used herein. Ye Abbot holdeth it witchcrafte.
   ============================================================ */

:root {
  --ink: #3a2413;
  --ink-soft: #553c22;
  --rubric: #a3261f;
  --gold: #caa22e;
  --marg: #7b5a2e;
  --hand: "Snell Roundhand", "Segoe Script", "Savoye LET", "Lucida Handwriting", "Apple Chancery", cursive;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, "Times New Roman", serif;
}

*, *::before, *::after { box-sizing: border-box; }

html {
  background: #100b06;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  overflow-x: hidden;
  background:
    radial-gradient(120% 55% at 50% 0%, #261c10 0%, #17100a 55%, #100b06 100%);
  font-family: var(--serif);
  color: var(--ink);
  scrollbar-color: #8a6f4d #17110b;
}

::selection { background: #a3261f; color: #f5e7c4; }

:focus-visible { outline: 2px dashed var(--rubric); outline-offset: 5px; }

/* ============================================================
   AMBIENT LIGHT — four curtains of light, faded by the scroll
   ============================================================ */

.tint {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 40;
}

.tint-day {
  background: linear-gradient(180deg,
    rgba(255, 246, 220, .14),
    rgba(255, 246, 220, .03) 45%,
    rgba(24, 16, 8, .08));
  opacity: .55;
  animation: t-day linear both;
  animation-timeline: scroll(root);
}

.tint-dusk {
  background:
    radial-gradient(85% 65% at 50% 42%, rgba(255, 152, 54, .12), rgba(255, 152, 54, 0) 55%),
    linear-gradient(180deg, rgba(94, 42, 8, .34), rgba(48, 18, 4, .48));
  opacity: 0;
  animation: t-dusk linear both;
  animation-timeline: scroll(root);
}

.tint-night {
  background:
    radial-gradient(30rem 24rem at 12% 88%,
      rgba(255, 172, 72, .20), rgba(255, 172, 72, .05) 40%, rgba(255, 172, 72, 0) 62%),
    radial-gradient(130% 110% at 50% 38%,
      rgba(7, 9, 22, .42) 34%, rgba(3, 4, 12, .82) 76%, rgba(1, 2, 7, .94) 100%);
  opacity: 0;
  animation: t-night linear both;
  animation-timeline: scroll(root);
}

.tint-dawn {
  background: linear-gradient(112deg,
    rgba(206, 222, 250, .34),
    rgba(255, 224, 196, .20) 42%,
    rgba(60, 60, 80, .06) 75%);
  opacity: 0;
  animation: t-dawn linear both;
  animation-timeline: scroll(root);
}

@keyframes t-day  { 0% { opacity: .55 } 22% { opacity: 0 } 100% { opacity: 0 } }
@keyframes t-dusk { 0% { opacity: 0 } 16% { opacity: 0 } 40% { opacity: .85 } 55% { opacity: .5 } 66% { opacity: 0 } 100% { opacity: 0 } }
@keyframes t-night { 0% { opacity: 0 } 58% { opacity: 0 } 74% { opacity: .96 } 90% { opacity: .98 } 96.5% { opacity: 0 } 100% { opacity: 0 } }
@keyframes t-dawn { 0% { opacity: 0 } 90% { opacity: 0 } 100% { opacity: 1 } }

/* ============================================================
   THE CANDLE — burns down as the tale proceeds
   ============================================================ */

.candle {
  position: fixed;
  left: clamp(8px, 5vw, 64px);
  bottom: 14px;
  width: 80px;
  height: 240px;
  pointer-events: none;
  z-index: 60;
}

.wax {
  position: absolute;
  bottom: 24px;
  left: calc(50% - 11px);
  width: 22px;
  height: 168px;
  border-radius: 7px 7px 3px 3px;
  background: linear-gradient(90deg, #cdb37f 0%, #f3e6c3 30%, #f7eccf 50%, #e2cda0 78%, #b89b68 100%);
  box-shadow: inset 0 -6px 8px rgba(90, 60, 20, .35);
  animation: burn linear both;
  animation-timeline: scroll(root);
}

/* molten crown of the wax */
.wax::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 9px;
  border-radius: 50% 50% 45% 45%;
  background: #f9f1da;
  box-shadow: inset 0 -2px 3px rgba(140, 100, 40, .4);
}

@keyframes burn {
  0%   { height: 168px }
  82%  { height: 44px }
  100% { height: 16px }
}

.wick {
  position: absolute;
  bottom: 100%;
  left: calc(50% - 1.5px);
  width: 3px;
  height: 8px;
  background: linear-gradient(#0d0905, #2c2013);
  border-radius: 1px;
}

.flame-place {
  position: absolute;
  bottom: calc(100% + 4px);
  left: calc(50% - 7px);
  width: 14px;
  height: 27px;
  transform-origin: 50% 100%;
  animation: flame-life linear both;
  animation-timeline: scroll(root);
}

.flame {
  width: 100%;
  height: 100%;
  border-radius: 50% 50% 50% 50% / 62% 62% 38% 38%;
  background: radial-gradient(50% 65% at 50% 70%,
    #fffdf0 0 12%, #ffe9a0 30%, #ffc23e 55%,
    rgba(255, 120, 20, .75) 78%, rgba(255, 80, 0, 0));
  transform-origin: 50% 100%;
  animation: flick .66s ease-in-out infinite;
}

.flame::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 1px;
  width: 8px;
  height: 7px;
  margin-left: -4px;
  border-radius: 50%;
  background: radial-gradient(circle, #6f9fd8 0 30%, rgba(111, 159, 216, 0) 70%);
}

@keyframes flick {
  0%   { transform: scale(1, 1) rotate(-1.5deg) translateX(0);      opacity: .94 }
  25%  { transform: scale(.96, 1.08) rotate(2deg) translateX(.5px); opacity: 1 }
  50%  { transform: scale(1.04, .95) rotate(-2.5deg) translateX(-.5px); opacity: .9 }
  75%  { transform: scale(.97, 1.05) rotate(1deg);                  opacity: .98 }
  100% { transform: scale(1, 1) rotate(-1.5deg) translateX(0);      opacity: .94 }
}

/* flame is unlit by day, kindled at dusk, gutters at the end */
@keyframes flame-life {
  0%    { opacity: 0;   transform: scale(.35) }
  17%   { opacity: 0;   transform: scale(.35) }
  24%   { opacity: 1;   transform: scale(1) }
  80%   { opacity: 1;   transform: scale(.92) }
  86%   { opacity: .35; transform: scale(.7) }
  89%   { opacity: 1;   transform: scale(.78) }
  92%   { opacity: .25; transform: scale(.55) }
  95%   { opacity: .9;  transform: scale(.62) }
  97.5% { opacity: .75; transform: scale(.42) }
  99%   { opacity: 0;   transform: scale(.15) }
  100%  { opacity: 0;   transform: scale(.15) }
}

.glow {
  position: absolute;
  bottom: calc(100% - 10px);
  left: calc(50% - 95px);
  width: 190px;
  height: 190px;
  border-radius: 50%;
  background: radial-gradient(circle,
    rgba(255, 190, 90, .34), rgba(255, 150, 50, .12) 45%, rgba(255, 140, 40, 0) 70%);
  filter: blur(2px);
  transform-origin: 50% 25%;
  animation: glow-life linear both;
  animation-timeline: scroll(root);
}

.glow-pulse {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  animation: g-pulse 2.4s ease-in-out infinite;
  background: radial-gradient(circle,
    rgba(255, 210, 120, .16), rgba(255, 170, 60, 0) 65%);
}

@keyframes glow-life {
  0%    { opacity: .12; transform: scale(.75) }
  17%   { opacity: .12; transform: scale(.75) }
  30%   { opacity: .9;  transform: scale(1) }
  80%   { opacity: 1;   transform: scale(1.06) }
  92%   { opacity: .45; transform: scale(.8) }
  97%   { opacity: .7;  transform: scale(.6) }
  99%   { opacity: 0;   transform: scale(.3) }
  100%  { opacity: 0;   transform: scale(.3) }
}

@keyframes g-pulse {
  0%, 100% { transform: scale(1);    opacity: .85 }
  50%      { transform: scale(1.05); opacity: 1 }
}

.smoke {
  position: absolute;
  bottom: calc(100% + 10px);
  left: calc(50% - 4px);
  width: 8px;
  height: 30px;
  opacity: 0;
  animation: smoke-in linear both;
  animation-timeline: scroll(root);
}

.puff {
  width: 100%;
  height: 14px;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(160, 164, 172, .8), rgba(160, 164, 172, 0));
  filter: blur(2.5px);
  animation: rise 3.2s linear infinite;
}

@keyframes smoke-in {
  0%     { opacity: 0 }
  97.5%  { opacity: 0 }
  99%    { opacity: .6 }
  100%   { opacity: .55 }
}

@keyframes rise {
  0%   { transform: translateY(4px) translateX(0) scale(.7); }
  50%  { transform: translateY(-16px) translateX(4px) scale(1.15) rotate(6deg); }
  100% { transform: translateY(-36px) translateX(7px) scale(1.5) rotate(10deg); }
}

.saucer {
  position: absolute;
  bottom: 8px;
  left: calc(50% - 38px);
  width: 76px;
  height: 16px;
  border-radius: 50%;
  background: radial-gradient(60% 100% at 50% 20%, #8f7439, #5c4620 60%, #3a2c12);
  box-shadow: 0 3px 7px rgba(0, 0, 0, .55);
}

.inkpot {
  position: absolute;
  bottom: 4px;
  left: 82px;
  opacity: .95;
}

/* ============================================================
   THE QUILL — scratches away in the corner, follows your reading
   ============================================================ */

.quill {
  position: fixed;
  right: clamp(6px, 4vw, 58px);
  top: 15vh;
  z-index: 60;
  pointer-events: none;
  animation: descend linear both;
  animation-timeline: scroll(root);
}

@keyframes descend {
  from { transform: translateY(0) }
  to   { transform: translateY(42vh) }
}

.quill-tilt { transform: rotate(24deg); }

.quill-scratch { animation: scratch 1.1s ease-in-out infinite; }

@keyframes scratch {
  0%   { transform: rotate(-3deg) translate(-1px, 0) }
  60%  { transform: rotate(2deg) translate(1px, 2px) }
  100% { transform: rotate(-3deg) translate(-1px, 0) }
}

/* ============================================================
   THE PARCHMENT SHEET
   ============================================================ */

main { position: relative; z-index: 1; }

.sheet {
  position: relative;
  width: min(92vw, 52rem);
  margin: 9vh auto 16vh;
  padding: clamp(2rem, 6vw, 4rem) clamp(1rem, 8vw, 6.75rem) 30vh;
  background:
    radial-gradient(120% 90% at 20% 0%, rgba(255, 248, 222, .55), rgba(255, 248, 222, 0) 50%),
    radial-gradient(100% 100% at 80% 100%, rgba(120, 84, 40, .22), rgba(120, 84, 40, 0) 55%),
    linear-gradient(160deg, #efe0bd, #e6d3a8 45%, #dfc99b 75%, #d9c08e);
  border-radius: 14px 18px 12px 20px / 10px 14px 12px 16px;
  box-shadow:
    0 24px 70px rgba(0, 0, 0, .65),
    0 4px 18px rgba(0, 0, 0, .5),
    inset 0 0 90px rgba(122, 82, 30, .28),
    inset 0 0 8px rgba(80, 50, 15, .25);
}

/* stains and weathering */
.sheet::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background:
    radial-gradient(14rem 9rem at 78% 12%, rgba(112, 74, 28, .10), rgba(112, 74, 28, 0) 60%),
    radial-gradient(10rem 14rem at 12% 66%, rgba(112, 74, 28, .12), rgba(112, 74, 28, 0) 60%),
    radial-gradient(8rem 5rem at 55% 92%, rgba(60, 40, 14, .10), rgba(60, 40, 14, 0) 60%);
}

.chapter { position: relative; margin: 0 0 15vh; }
.chapter:last-of-type { margin-bottom: 0; }

/* ============================================================
   TYPOGRAPHY
   ============================================================ */

p {
  font-size: clamp(1.02rem, .95rem + .45vw, 1.22rem);
  line-height: 1.78;
  margin: 0 0 1.15em;
  text-align: justify;
  hyphens: auto;
}

.speak { font-style: italic; color: #4a2c12; }
em { color: #4a2c12; }

.pagename {
  color: var(--rubric);
  font-weight: 600;
  letter-spacing: .03em;
  border-bottom: 2px dotted rgba(202, 162, 46, .8);
}

.rub { color: var(--rubric); font-weight: 700; }

.rubric {
  font-variant: small-caps;
  letter-spacing: .06em;
  font-weight: 600;
  color: var(--rubric);
  text-align: center;
  font-size: clamp(1.15rem, 2.6vw, 1.5rem);
  margin: .4rem 0 1.6rem;
}

.flourish {
  display: block;
  width: 9.5rem;
  height: auto;
  margin: 0 auto .2rem;
  color: #7b5a2e;
  opacity: .9;
  /* the pen draws the vine as it enters view */
  stroke-dasharray: 1;
  stroke-dashoffset: 0;
  animation: draw-on linear both;
  animation-timeline: view();
  animation-range: entry 10% entry 90%;
}

@keyframes draw-on {
  from { stroke-dashoffset: 1 }
  to   { stroke-dashoffset: 0 }
}

.endmark {
  text-align: center;
  color: var(--rubric);
  margin: 2rem 0 0;
  font-size: .9em;
  opacity: .8;
}

/* the illuminated initial */
.graf-first::first-letter {
  float: left;
  font-size: 3.6em;
  line-height: .82;
  padding: .30em .26em .26em;
  margin: .07em .16em 0 0;
  color: #eec95f;
  background: radial-gradient(120% 120% at 30% 20%, #3b4f8f 0%, #25325e 45%, #1b2547 100%);
  border: 2px solid var(--rubric);
  box-shadow: inset 0 0 0 2px rgba(238, 201, 95, .45), inset 0 0 14px rgba(0, 0, 0, .5);
  text-shadow: 0 1px 0 #7a5a10, 0 0 6px rgba(238, 201, 95, .5);
}

/* incipit — the title panel */
.incipit { text-align: center; margin-bottom: 3rem; }

.masthead {
  font-size: .8rem;
  letter-spacing: .18em;
  color: #6b4a22;
  font-variant: small-caps;
  text-align: center;
  margin-bottom: 1.8rem;
}

.frame {
  display: inline-block;
  padding: 1.1rem 2.4rem 1.3rem;
  border: 2px solid var(--rubric);
  outline: 1px solid rgba(163, 38, 31, .45);
  outline-offset: 6px;
  background: rgba(163, 38, 31, .045);
}

.status-line {
  font-size: .78rem;
  letter-spacing: .34em;
  color: var(--rubric);
  font-variant: small-caps;
  font-weight: 600;
  text-align: center;
  margin: 0;
}

.big404 {
  margin: .3rem 0;
  font-size: clamp(2.8rem, 7vw, 4.4rem);
  font-weight: 700;
  color: var(--rubric);
  letter-spacing: .12em;
  line-height: 1;
  text-align: center;
  text-shadow: 2px 2px 0 rgba(202, 162, 46, .55), 0 0 18px rgba(163, 38, 31, .25);
}

.epigraph {
  font-family: var(--hand);
  color: #7b5a2e;
  text-align: center;
  margin-top: 1.4rem;
  font-size: 1.05rem;
}

/* colophon */
.colophon { text-align: center; margin-top: 4vh; }
.colophon .reader { font-size: 1.28rem; }
.explicit { font-variant: small-caps; letter-spacing: .22em; font-weight: 600; text-align: center; }
.keepe { font-family: var(--hand); color: var(--rubric); font-size: 1.1rem; text-align: center; }
.deo {
  font-variant: small-caps;
  letter-spacing: .34em;
  color: var(--rubric);
  margin-top: 2.2rem;
  font-size: .95rem;
  text-align: center;
}
.sparki { width: .7em; height: .7em; fill: var(--gold); vertical-align: -0.08em; }

/* ============================================================
   THE INKING — lines are written as you read
   ============================================================ */

.ink {
  animation: ink-in linear both;
  animation-timeline: view();
  animation-range: entry 5% entry 80%;
}

@keyframes ink-in {
  0%   { opacity: 0; clip-path: inset(0 100% 0 0); filter: blur(2px); transform: translateX(-4px); }
  55%  { opacity: .95; filter: blur(.5px); }
  100% { opacity: 1; clip-path: inset(0 0 0 0); filter: blur(0); transform: none; }
}

.ink-m {
  animation: marg-in linear both;
  animation-timeline: view();
  animation-range: entry 0% entry 70%;
}

@keyframes marg-in {
  from { opacity: 0; translate: 0 10px; }
  to   { opacity: 1; translate: 0 0; }
}

/* ============================================================
   MARGINALIA
   ============================================================ */

.marg {
  position: absolute;
  width: 5.6rem;
  font-family: var(--hand);
  font-size: .82rem;
  line-height: 1.5;
  color: var(--rubric);
  opacity: .95;
  rotate: -1.4deg;
}

/* live in the parchment margin, outside the text column */
.marg.l { right: calc(100% + .7rem); text-align: right; }
.marg.r { left: calc(100% + .7rem); text-align: left; rotate: 1.4deg; }

/* Pangur */
.cat {
  position: absolute;
  left: calc(100% + .5rem);
  top: 24%;
  width: 5.6rem;
  height: auto;
  rotate: 2deg;
  animation: marg-in linear both;
  animation-timeline: view();
  animation-range: entry 0% entry 70%;
}

.cat-body {
  transform-box: fill-box;
  transform-origin: 50% 80%;
  animation: breathe 4.4s ease-in-out infinite;
}

@keyframes breathe {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.025); }
}

.cat-tail {
  transform-box: fill-box;
  transform-origin: 100% 100%;
  animation: tailflick 5.2s ease-in-out infinite;
}

@keyframes tailflick {
  0%, 70%  { transform: rotate(0); }
  78%      { transform: rotate(9deg); }
  86%      { transform: rotate(-4deg); }
  94%, 100% { transform: rotate(0); }
}

/* the knight, trembling */
.knight {
  position: absolute;
  left: calc(100% + .8rem);
  top: 42%;
  width: 3.4rem;
  height: auto;
  animation: marg-in linear both, tremble 3s ease-in-out infinite;
  animation-timeline: view(), auto;
  animation-range: entry 0% entry 70%, normal;
}

@keyframes tremble {
  0%, 100% { transform: rotate(-2deg); }
  50%      { transform: rotate(2deg); }
}

/* the snail, who misbehaves */
.snailbox {
  position: absolute;
  left: calc(100% + .5rem);
  top: 60%;
  width: 4.6rem;
  height: auto;
  animation: marg-in linear both, creep 18s ease-in-out infinite;
  animation-timeline: view(), auto;
  animation-range: entry 0% entry 70%, normal;
}

@keyframes creep {
  0%   { transform: translateX(0) rotate(-1deg); }
  50%  { transform: translateX(-16px) translateY(-1px) rotate(1deg); }
  100% { transform: translateX(0) rotate(-1deg); }
}

/* Pangur's testimony */
.paws {
  position: absolute;
  left: 32%;
  bottom: .3rem;
  display: flex;
  gap: 1rem;
  color: rgba(40, 25, 10, .5);
  animation: marg-in linear both;
  animation-timeline: view();
  animation-range: entry 0% entry 60%;
}

.paw { width: 1.1rem; height: 1.1rem; fill: currentColor; }
.paw:nth-child(1) { transform: rotate(-14deg); opacity: .5; }
.paw:nth-child(2) { transform: rotate(6deg) translateY(-7px); opacity: .7; }
.paw:nth-child(3) { transform: rotate(-6deg) translateY(-3px); opacity: .85; }
.paw:nth-child(4) { transform: rotate(10deg) translateY(-10px); }

/* the face in the margin */
.peekclip {
  position: absolute;
  left: calc(100% + 6px);
  top: 12%;
  width: 54px;
  height: 70px;
  overflow: hidden;
}

.peeker {
  width: 52px;
  height: auto;
  animation: peek 17s ease-in-out infinite;
}

@keyframes peek {
  0%, 70%  { transform: translateX(115%) rotate(4deg); }
  78%, 86% { transform: translateX(12%) rotate(-2deg); }
  93%, 100% { transform: translateX(115%) rotate(4deg); }
}

/* ============================================================
   INTERACTION ONE — the Abbot's folded note (<details>, no JS)
   ============================================================ */

.gloss-slip {
  position: absolute;
  top: 100%;
  right: 0;
  width: 10.5rem;
  margin-top: -1.6rem;
  padding: .55rem .65rem .65rem;
  background: linear-gradient(160deg, #e2ce9d, #d5bd85);
  border: 1px solid rgba(120, 80, 25, .4);
  box-shadow: 0 6px 14px rgba(0, 0, 0, .25);
  rotate: 1.5deg;
  font-family: var(--hand);
  font-size: .84rem;
  line-height: 1.45;
  color: #4a2c12;
  z-index: 3;
}

.gloss-slip summary {
  cursor: pointer;
  list-style: none;
  color: var(--rubric);
  font-variant: small-caps;
  letter-spacing: .04em;
  font-weight: 600;
}

.gloss-slip summary::-webkit-details-marker { display: none; }
.gloss-slip summary::before { content: "☞ "; }

.w-open { display: none; }
.gloss-slip[open] .w-open { display: inline; }
.gloss-slip[open] .w-closed { display: none; }

.gloss-body { padding-top: .45rem; }

.gloss-slip[open] .gloss-body {
  animation: unfold .55s ease both;
}

@keyframes unfold {
  from { clip-path: inset(0 0 96% 0); opacity: .2; transform: translateY(-6px); }
  to   { clip-path: inset(0 0 0 0);   opacity: 1;  transform: none; }
}

/* ============================================================
   INTERACTION TWO — the blot that hides a sin (hover / focus)
   ============================================================ */

.blot-fig {
  position: relative;
  width: 13rem;
  margin: 2.4rem auto;
  text-align: center;
}

.blot-stage {
  position: relative;
  width: 11.5rem;
  height: 7.6rem;
  margin-inline: auto;
}

.doodle {
  position: absolute;
  inset: 6% 5%;
  width: 90%;
  height: 88%;
}

.blot {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 10.6rem;
  height: 7.8rem;
  transform: translate(-50%, -50%);
  border-radius: 46% 54% 58% 42% / 52% 44% 56% 48%;
  background: radial-gradient(closest-side,
    #120e0a 42%, #16110d 62%,
    rgba(22, 17, 13, .92) 78%, rgba(22, 17, 13, 0));
  transition: opacity .8s ease, transform .8s ease;
}

/* a stray splash of the same spill */
.blot::after {
  content: "";
  position: absolute;
  right: -13%;
  top: -8%;
  width: 30%;
  height: 26%;
  border-radius: 60% 40% 55% 45% / 50% 55% 45% 50%;
  background: radial-gradient(closest-side,
    #16110d 40%, rgba(22, 17, 13, .85) 65%, rgba(22, 17, 13, 0));
  transform: rotate(18deg);
}

.blot-fig:hover .blot,
.blot-fig:focus-visible .blot,
.blot-fig:focus-within .blot {
  opacity: .06;
  transform: translate(-50%, -50%) rotate(10deg) scale(1.12);
}

.blot-fig figcaption {
  margin-top: .8rem;
  font-size: .82rem;
  color: var(--ink-soft);
  font-style: italic;
}

.hinthand {
  font-family: var(--hand);
  font-style: normal;
  color: var(--rubric);
  font-size: .9rem;
}

/* ============================================================
   INTERACTION THREE — turn the folio corner
   ============================================================ */

.curlwrap {
  position: absolute;
  right: 1.1rem;
  bottom: 1.1rem;
  width: 9rem;
  height: 9rem;
}

.curlwrap .under {
  position: absolute;
  right: .3rem;
  bottom: .5rem;
  width: 8rem;
  text-align: right;
  font-family: var(--hand);
  font-size: .86rem;
  line-height: 1.4;
  color: var(--rubric);
  transform: rotate(-5deg) scale(.94);
  opacity: 0;
  transition: opacity .7s ease, transform .7s ease;
}

.curlwrap .fold {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 3.4rem;
  height: 3.4rem;
  clip-path: polygon(100% 0, 0 100%, 100% 100%);
  background: linear-gradient(to bottom right,
    #f3e7c4 0%, #d9c08e 45%, #b89b68 80%, #8f7439 100%);
  filter: drop-shadow(-3px -3px 4px rgba(0, 0, 0, .3));
  transform-origin: 100% 100%;
  transition: transform .7s ease, opacity .7s ease;
}

.curlwrap .curlhint {
  position: absolute;
  right: 3.1rem;
  bottom: .15rem;
  font-family: var(--hand);
  font-size: .85rem;
  color: var(--rubric);
  white-space: nowrap;
  rotate: -3deg;
  transition: opacity .5s ease;
  animation: hint-nod 3.5s ease-in-out infinite;
}

@keyframes hint-nod {
  0%, 100% { translate: 0 0; }
  50%      { translate: 4px 0; }
}

.curlwrap:hover .fold,
.curlwrap:focus-visible .fold,
.curlwrap:focus-within .fold {
  transform: rotate(-16deg) scale(.5);
  opacity: .75;
}

.curlwrap:hover .under,
.curlwrap:focus-visible .under,
.curlwrap:focus-within .under {
  opacity: 1;
  transform: rotate(-5deg) scale(1);
}

.curlwrap:hover .curlhint,
.curlwrap:focus-visible .curlhint,
.curlwrap:focus-within .curlhint {
  opacity: 0;
}

/* ============================================================
   SMALL SCREENS
   ============================================================ */

@media (max-width: 1100px) {
  .marg {
    position: static;
    left: auto;
    right: auto;
    display: block;
    width: auto;
    max-width: 22rem;
    text-align: left;
    margin: -.4rem 0 1rem;
    padding: .15rem .4rem;
    border-block: 1px dashed rgba(163, 38, 31, .3);
    font-size: .8rem;
  }

  .cat, .knight, .snailbox {
    position: static;
    left: auto;
    display: block;
    margin: .8rem auto;
  }

  .paws {
    position: static;
    justify-content: center;
    margin: 0 0 1.4rem;
  }

  .gloss-slip {
    position: static;
    width: auto;
    max-width: 20rem;
    margin: 1rem auto;
    rotate: 0;
  }

  .peekclip { display: none; }
}

@media (max-width: 820px) {
  .sheet {
    padding: 2rem 1.4rem 26vh;
  }

  .quill { display: none; }

  .candle { transform: scale(.7); transform-origin: bottom left; left: 2px; }

  .curlwrap { scale: .85; transform-origin: bottom right; }
}

/* ============================================================
   REDUCED MOTION — a still, silent scriptorium
   ============================================================ */

@media (prefers-reduced-motion: reduce) {
  .ink, .ink-m, .flourish, .cat, .knight, .snailbox, .paws { animation: none !important; }
  .flame, .glow-pulse, .quill-scratch, .cat-tail, .cat-body, .peeker,
  .puff, .curlhint, .tremble, .creep { animation: none !important; }
  .wax, .flame-place, .glow, .smoke, .tint-day, .tint-dusk,
  .tint-night, .tint-dawn, .quill { animation: none !important; }
  /* keep a readable, lit, daytime scene */
  .tint-day { opacity: .55; }
  .tint-dusk, .tint-night, .tint-dawn { opacity: 0; }
  .flame-place { opacity: 1; transform: none; }
  .glow { opacity: .5; transform: none; }
  .wax { height: 168px; }
  html { scroll-behavior: auto; }
}
