/* ==========================================================================
   FOL. CCCCIV r. — ILLUMINATED 404 MANUSCRIPT
   Pure HTML + Modern CSS (Scroll-Driven Animations, @property, 3D Transforms)
   Zero JavaScript · Zero External Fonts · Zero Raster Images
   ========================================================================== */

/* --- Registered Custom Properties for Smooth Interpolation --- */
@property --stanza-p {
  syntax: '<number>';
  inherits: true;
  initial-value: 1;
}

@property --night-progress {
  syntax: '<number>';
  inherits: true;
  initial-value: 0;
}

@property --gold-angle {
  syntax: '<angle>';
  inherits: true;
  initial-value: 125deg;
}

/* --- Root Palette & Medieval Pigments --- */
:root {
  --vellum-light: #f6ead0;
  --vellum-mid: #efe0be;
  --vellum-edge: #dcc292;
  --vellum-shadow: #b5925c;

  --ink-dry: #24160e;
  --ink-brown: #3d2516;
  --ink-wet: #6e200b;
  --plummet-rule: rgba(154, 62, 44, 0.24);
  --margin-rule: rgba(148, 52, 36, 0.34);

  --vermilion: #ae2619;
  --vermilion-bright: #c93323;
  --lapis: #1c3f88;
  --lapis-deep: #112759;
  --verdigris: #2a684c;
  --ochre: #c9962c;

  --font-manuscript: 'Palatino', 'Palatino Linotype', 'Hoefler Text', 'Cochin', 'Book Antiqua', Georgia, serif;
  --font-rubric: 'Cochin', 'Hoefler Text', 'Palatino', 'Baskerville', Georgia, serif;

  --line-h: 2.05em;
  --dropcap-indent: 4.15em;
}

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

html {
  background-color: #160e09;
  color: var(--ink-dry);
  font-family: var(--font-manuscript);
  font-variant-ligatures: common-ligatures discretionary-ligatures historical-ligatures;
  font-feature-settings: "liga" 1, "dlig" 1, "onum" 1;
  -webkit-font-smoothing: antialiased;
}

html:has(.relight-link:hover, .relight-link:focus, .relight-link:active) {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  /* Monastic oak lectern wood grain */
  background:
    repeating-linear-gradient(
      91deg,
      rgba(255, 214, 165, 0.018) 0px,
      rgba(255, 214, 165, 0.018) 2px,
      transparent 2px,
      transparent 9px
    ),
    repeating-linear-gradient(
      89deg,
      rgba(0, 0, 0, 0.16) 0px,
      rgba(0, 0, 0, 0.16) 3px,
      transparent 3px,
      transparent 17px
    ),
    linear-gradient(180deg, #21140c 0%, #170e09 55%, #10131d 100%);

  /* Scroll-driven progression across the night (Vespers -> Lauds -> Cold Dawn) */
  animation: scriptorium-night linear both;
  animation-timeline: scroll(root block);
}

@keyframes scriptorium-night {
  0% {
    --night-progress: 0;
    --gold-angle: 118deg;
  }
  50% {
    --night-progress: 0.5;
    --gold-angle: 205deg;
  }
  100% {
    --night-progress: 1;
    --gold-angle: 295deg;
  }
}

.svg-defs {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
  pointer-events: none;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.sr-toggle {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  pointer-events: none;
}

/* ==========================================================================
   AMBIENT SCRIPTORIUM LIGHTING (Changes with scroll + flickers organically)
   ========================================================================== */

.ambient-lighting {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 30;
}

/* Warm tallow-candle light pool: bright honey at Vespers -> deep amber -> dies out */
.candle-wash {
  position: absolute;
  inset: -10%;
  background: radial-gradient(
    circle at 80% 62%,
    rgba(255, 188, 76, 0.24) 0%,
    rgba(242, 134, 38, 0.13) 34%,
    rgba(30, 14, 4, 0.28) 76%,
    rgba(10, 6, 4, 0.56) 100%
  );
  mix-blend-mode: multiply;
  animation:
    candle-wash-scroll linear both,
    ambient-breath 3.7s ease-in-out infinite alternate;
  animation-timeline: scroll(root block), auto;
}

@keyframes candle-wash-scroll {
  0% {
    opacity: 0.55;
    background: radial-gradient(
      circle at 78% 48%,
      rgba(255, 214, 128, 0.18) 0%,
      rgba(235, 158, 68, 0.10) 45%,
      rgba(42, 22, 10, 0.26) 85%
    );
  }
  45% {
    opacity: 0.92;
    background: radial-gradient(
      circle at 80% 62%,
      rgba(255, 176, 62, 0.22) 0%,
      rgba(214, 98, 24, 0.16) 36%,
      rgba(24, 11, 5, 0.48) 78%
    );
  }
  84% {
    opacity: 0.96;
    background: radial-gradient(
      circle at 81% 74%,
      rgba(255, 122, 34, 0.24) 0%,
      rgba(156, 48, 12, 0.20) 26%,
      rgba(16, 9, 8, 0.64) 70%
    );
  }
  96%, 100% {
    opacity: 0.12;
  }
}

@keyframes ambient-breath {
  0%   { transform: scale(1) translate(0, 0); }
  50%  { transform: scale(1.018) translate(-0.4%, 0.3%); }
  100% { transform: scale(0.99) translate(0.3%, -0.3%); }
}

/* Cold pre-dawn cloister light from high lancet window when candle gutters out */
.dawn-lancet {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(
      128deg,
      rgba(150, 188, 248, 0.22) 0%,
      rgba(92, 128, 194, 0.14) 38%,
      rgba(20, 30, 56, 0.42) 100%
    );
  mix-blend-mode: multiply;
  opacity: 0;
  animation: dawn-arrival linear both;
  animation-timeline: scroll(root block);
}

@keyframes dawn-arrival {
  0%, 76% { opacity: 0; }
  92%     { opacity: 0.72; }
  100%    { opacity: 0.96; }
}

.desk-vignette {
  position: absolute;
  inset: 0;
  box-shadow: inset 0 0 130px rgba(8, 5, 3, 0.65);
  animation: vignette-deepen linear both;
  animation-timeline: scroll(root block);
}

@keyframes vignette-deepen {
  0%   { opacity: 0.45; }
  65%  { opacity: 0.85; }
  100% { opacity: 0.95; }
}

/* ==========================================================================
   SCRIPTORIUM STAGE & VELLUM FOLIO MATERIALITY
   ========================================================================== */

.scriptorium {
  position: relative;
  max-width: 1080px;
  margin: 0 auto;
  padding: 2.2rem 1.5rem 9.5rem;
  display: grid;
  grid-template-columns: minmax(0, 820px) 130px;
  gap: 1.5rem;
  align-items: start;
  justify-content: center;
}

.vellum-folio {
  position: relative;
  min-width: 0;
  padding: clamp(1.5rem, 4vw, 3.3rem) clamp(1.1rem, 3.8vw, 3.1rem) 3.4rem;
  border-radius: 5px 9px 7px 6px;
  /* Layered calfskin vellum pores, warm aging, and subtle center crease */
  background:
    radial-gradient(circle at 18% 12%, rgba(168, 124, 62, 0.08) 0%, transparent 38%),
    radial-gradient(circle at 84% 46%, rgba(152, 104, 46, 0.09) 0%, transparent 42%),
    radial-gradient(circle at 32% 82%, rgba(138, 92, 38, 0.08) 0%, transparent 35%),
    radial-gradient(rgba(120, 82, 38, 0.11) 1px, transparent 0) 0 0 / 23px 29px,
    radial-gradient(rgba(96, 60, 24, 0.08) 1px, transparent 0) 11px 13px / 31px 37px,
    linear-gradient(
      90deg,
      #e2c896 0%,
      #f3e5c7 6%,
      #f7ecd4 54%,
      #f2e3c2 92%,
      #dec28e 100%
    );
  box-shadow:
    /* Inner darkened hide edge */
    inset 0 0 54px rgba(136, 88, 34, 0.34),
    inset 0 0 12px rgba(92, 54, 18, 0.38),
    inset 3px 0 0 rgba(255, 248, 228, 0.45),
    /* Stacked quaternion leaves beneath this folio */
    3px 4px 0 #d5ba88,
    4px 5px 0 #7a552b,
    7px 9px 0 #cbb07d,
    8px 10px 0 #5e3f1e,
    /* Deep shadow on oak lectern */
    0 26px 60px rgba(0, 0, 0, 0.78);

  /* Subtle warm-to-cool shift on the parchment itself as candle dies & dawn breaks */
  animation: folio-light-shift linear both;
  animation-timeline: scroll(root block);
}

@keyframes folio-light-shift {
  0% {
    filter: sepia(0.04) brightness(1.02) contrast(1);
  }
  55% {
    filter: sepia(0.14) saturate(1.08) brightness(0.97);
  }
  86% {
    filter: sepia(0.18) saturate(1.12) brightness(0.91);
  }
  100% {
    filter: sepia(0) hue-rotate(-8deg) saturate(0.88) brightness(0.87) contrast(1.03);
  }
}

/* Vertical red-plummet bounding rules across the folio */
.vellum-folio::before {
  content: "";
  position: absolute;
  top: 1.4rem;
  bottom: 1.4rem;
  left: clamp(1.1rem, 3vw, 2.5rem);
  right: clamp(1.1rem, 3vw, 2.4rem);
  border-left: 1px solid var(--margin-rule);
  border-right: 1px solid var(--margin-rule);
  pointer-events: none;
}

/* Awl pin-pricking marks down the outer right edge of the calfskin */
.pricking-holes {
  position: absolute;
  top: 4.5rem;
  bottom: 4.5rem;
  right: 0.55rem;
  width: 5px;
  background-image: radial-gradient(circle, rgba(58, 34, 16, 0.58) 1.3px, transparent 1.6px);
  background-size: 5px 28px;
  background-repeat: repeat-y;
  pointer-events: none;
}

/* ==========================================================================
   FOLIO HEADER, FRONTISPIECE & INCIPIT RUBRIC
   ========================================================================== */

.folio-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding: 0 0.5rem 0.65rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--margin-rule);
  font-family: var(--font-rubric);
  font-size: 0.92rem;
  letter-spacing: 0.04em;
  color: var(--ink-brown);
}

.running-abbey {
  font-style: italic;
  opacity: 0.86;
}

.folio-ornament {
  color: var(--ochre);
  font-size: 0.85rem;
}

.folio-number {
  color: var(--vermilion);
  font-weight: 700;
  letter-spacing: 0.06em;
}

.frontispiece {
  margin: 0 auto 1.25rem;
  max-width: 650px;
}

.frontispiece-svg {
  display: block;
  width: 100%;
  height: auto;
  filter: drop-shadow(0 3px 6px rgba(46, 26, 8, 0.22));
}

.incipit {
  text-align: center;
  max-width: 610px;
  margin: 0 auto 2.1rem;
  padding-bottom: 1.15rem;
  border-bottom: 2px double var(--margin-rule);
}

.rubric-latin {
  margin: 0 0 0.35rem;
  color: var(--vermilion);
  font-family: var(--font-rubric);
  font-style: italic;
  font-size: clamp(0.95rem, 2vw, 1.1rem);
  line-height: 1.4;
}

.pilcrow {
  color: var(--vermilion);
  font-style: normal;
  font-weight: 700;
  margin-right: 0.2em;
}

.manuscript-title {
  margin: 0.15rem 0 0.55rem;
  font-family: var(--font-rubric);
  font-size: clamp(1.55rem, 3.6vw, 2.25rem);
  font-weight: 700;
  letter-spacing: 0.03em;
  color: var(--ink-dry);
  text-shadow: 0 1px 0 rgba(255, 248, 228, 0.7);
}

.scroll-invitation {
  margin: 0;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.88rem;
  font-style: italic;
  color: #6b4326;
}

.flip-x {
  transform: scaleX(-1);
}

/* ==========================================================================
   TWO-COLUMN FOLIO STRUCTURE (Ruled Text Column + Marginalia Lane)
   ========================================================================== */

.folio-columns {
  display: flex;
  flex-direction: column;
  gap: 2.5rem;
}

.manuscript-entry {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 215px;
  gap: 1.6rem;
  align-items: start;
  position: relative;
}

/* Dividing plummet line between main text column and marginalia lane */
.text-column {
  container-type: inline-size;
  min-width: 0;
  position: relative;
  padding-right: 1.25rem;
  border-right: 1px solid var(--margin-rule);
}

.chapter-rubric {
  margin: 0 0 0.55rem;
  font-family: var(--font-rubric);
  font-size: clamp(0.84rem, 3.3cqi, 1.08rem);
  font-weight: 700;
  color: var(--vermilion);
  letter-spacing: 0.02em;
}

.chapter-rubric em {
  font-weight: 400;
  color: #7d2419;
}

.stanza-wrap {
  position: relative;
}

/* ==========================================================================
   ILLUMINATED HISTORIATED DROP CAPS (With Scroll-Glinting Burnished Gold!)
   ========================================================================== */

.dropcap {
  position: absolute;
  top: 0.14em;
  left: 0;
  width: 3.55em;
  height: 3.55em;
  font-size: clamp(0.62rem, 3.4cqi, 1.15rem);
  display: grid;
  place-items: center;
  border-radius: 4px;
  border: 2px solid #7d5612;
  box-shadow:
    inset 0 0 0 2px #f6dc86,
    inset 0 0 12px rgba(0, 0, 0, 0.36),
    2px 3px 6px rgba(42, 24, 8, 0.26);
  z-index: 2;
  user-select: none;
  overflow: hidden;
}

/* Filigree corner dots inside every drop cap */
.dropcap::before {
  content: "✦";
  position: absolute;
  top: 3px;
  right: 5px;
  font-size: 0.62em;
  color: rgba(255, 244, 204, 0.78);
  line-height: 1;
}

.dropcap-lapis {
  background:
    radial-gradient(circle at 25% 25%, rgba(255, 255, 255, 0.16), transparent 55%),
    linear-gradient(145deg, #244da3 0%, #142b63 100%);
}

.dropcap-vermilion {
  background:
    radial-gradient(circle at 25% 25%, rgba(255, 232, 185, 0.18), transparent 55%),
    linear-gradient(145deg, #bf2e20 0%, #78150c 100%);
}

.dropcap-verdigris {
  background:
    radial-gradient(circle at 25% 25%, rgba(255, 244, 200, 0.16), transparent 55%),
    linear-gradient(145deg, #2f7556 0%, #194230 100%);
}

.dropcap-gold {
  background:
    radial-gradient(circle at 30% 25%, rgba(255, 252, 224, 0.35), transparent 55%),
    linear-gradient(145deg, #732048 0%, #3d1026 100%);
}

.dropcap-filigree {
  position: absolute;
  inset: 2px;
  width: calc(100% - 4px);
  height: calc(100% - 4px);
  pointer-events: none;
}

/* Raised gesso + burnished gold leaf letter that glints as you scroll */
.dropcap-letter {
  position: relative;
  z-index: 1;
  font-family: var(--font-rubric);
  font-size: 2.55em;
  font-weight: 700;
  line-height: 1;
  background-image: linear-gradient(
    var(--gold-angle),
    #9e6f18 0%,
    #e5b849 26%,
    #fff4b8 48%,
    #c79126 68%,
    #fae18c 85%,
    #8f6214 100%
  );
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 1.5px 1px rgba(20, 10, 4, 0.65));
}

/* ==========================================================================
   SCROLL-DRIVEN LINE-BY-LINE INKING & ACTIVE GOOSE QUILL
   ========================================================================== */

.stanza-lines {
  position: relative;
  font-size: clamp(0.62rem, 3.4cqi, 1.15rem);
  line-height: var(--line-h);
  /* Faint horizontal drypoint / red-plummet ruled lines aligned directly under the serif baseline */
  background-image: repeating-linear-gradient(
    to bottom,
    transparent 0,
    transparent 1.44em,
    var(--plummet-rule) 1.44em,
    var(--plummet-rule) calc(1.44em + 1px),
    transparent calc(1.44em + 1px),
    transparent var(--line-h)
  );

  /* Drive --stanza-p from 0 -> 1 sequentially so one single quill moves down the folio */
  --stanza-p: 0;
  animation: write-stanza linear both;
  animation-timeline: view();
  animation-range: cover 19% cover 39%;
}

/* Stanza I starts mostly inked on load, with the single quill poised on Line 4! */
.stanza-lines.stanza-initial {
  animation-range: cover 24% cover 40%;
}

/* Final stanza completes slightly lower in viewport so tall screens always reach 100% */
.entry-explicit .stanza-lines {
  animation-range: cover 14% cover 32%;
}

@keyframes write-stanza {
  from { --stanza-p: 0; }
  to   { --stanza-p: 1; }
}

.ms-line {
  display: block;
  white-space: nowrap;
  color: var(--ink-dry);
  /* Strictly sequential line-by-line progress: line i waits until line i-1 hits 100% */
  --line-ink: clamp(0%, calc((var(--stanza-p) * var(--n) - var(--i)) * 100%), 100%);
  -webkit-mask-image: linear-gradient(
    90deg,
    #000 0%,
    #000 calc(var(--line-ink) - 2.5%),
    rgba(0, 0, 0, 0.45) calc(var(--line-ink) - 0.5%),
    transparent var(--line-ink)
  );
  mask-image: linear-gradient(
    90deg,
    #000 0%,
    #000 calc(var(--line-ink) - 2.5%),
    rgba(0, 0, 0, 0.45) calc(var(--line-ink) - 0.5%),
    transparent var(--line-ink)
  );
}

.ms-line.is-indented {
  margin-left: var(--dropcap-indent);
  width: calc(100% - var(--dropcap-indent));
}

.ms-url {
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.9em;
  color: #5e2212;
  background: rgba(174, 38, 25, 0.07);
  padding: 0 0.25em;
  border-radius: 2px;
}

.rubric-inline {
  color: var(--vermilion);
  font-weight: 700;
  letter-spacing: 0.02em;
}

.lapis-inline {
  color: var(--lapis);
  font-weight: 600;
}

.ink-blot {
  display: inline-block;
  color: var(--ink-dry);
  font-size: 0.9em;
  transform: rotate(18deg) scale(1.25);
  text-shadow: 3px 1px 0 rgba(36, 22, 14, 0.45), -2px 2px 0 rgba(94, 25, 11, 0.5);
}

/* Active Scribe's Goose Quill tracking the exact wet-ink point on each line! */
.stanza-quill {
  --qp: clamp(0, var(--stanza-p), 0.999);
  --row: round(down, calc(var(--qp) * var(--n)), 1);
  --col: mod(calc(var(--qp) * var(--n)), 1);
  --indent-on: clamp(0, calc(2 - var(--row)), 1);

  position: absolute;
  pointer-events: none;
  z-index: 6;
  width: 4.5em;
  height: 3.7em;
  /* Anchor SVG nib point (2, 58) right onto the 1.44em serif baseline */
  top: calc((var(--row) + 0.72) * var(--line-h) - 3.46em);
  left: calc(
    var(--indent-on) * var(--dropcap-indent) +
    var(--col) * (92% - var(--indent-on) * var(--dropcap-indent))
  );
  /* Smoothly appear when writing starts, lift away when stanza completes */
  opacity: calc(
    clamp(0, (var(--stanza-p) - 0.008) * 28, 1) *
    clamp(0, (0.992 - var(--stanza-p)) * 28, 1)
  );
}

/* Continuous lively nib scratching & feather sway even when scroll pauses! */
.quill-svg {
  display: block;
  width: 100%;
  height: 100%;
  transform-origin: 3% 94%;
  animation: quill-scratch 0.68s ease-in-out infinite alternate;
}

@keyframes quill-scratch {
  0%   { transform: rotate(0deg) translate(0, 0); }
  45%  { transform: rotate(-3.2deg) translate(0.5px, -1.2px); }
  100% { transform: rotate(2.4deg) translate(-0.4px, 0.4px); }
}

/* ==========================================================================
   MARGINALIA LANE & MISBEHAVING DRÔLERIES + ZERO-JS INTERACTIONS
   ========================================================================== */

.margin-lane {
  font-size: 0.84rem;
  line-height: 1.42;
  color: #54351e;
  padding-top: 1.5rem;
}

.margin-gloss-static {
  position: relative;
  padding: 0.55rem 0.65rem;
  border-left: 2px solid var(--vermilion);
  background: rgba(214, 182, 126, 0.18);
  font-style: italic;
}

.gloss-mark {
  display: block;
  font-style: normal;
  font-weight: 700;
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--vermilion);
  margin-bottom: 0.2rem;
}

.margin-gloss-static p {
  margin: 0;
}

/* --- Interaction #1 & Misbehaving Marginalia #1: Knight vs. 404 Snail --- */
.drolerie-snail-scene {
  position: relative;
  margin-top: -0.4rem;
}

.snail-stage {
  display: block;
  cursor: pointer;
  user-select: none;
  padding: 0.35rem;
  border-radius: 5px;
  border: 1px dashed rgba(148, 52, 36, 0.28);
  background: rgba(246, 234, 206, 0.42);
  transition: background-color 0.25s ease, border-color 0.25s ease;
}

.snail-stage:hover {
  background: rgba(252, 243, 220, 0.78);
  border-color: var(--vermilion);
}

.sr-toggle:focus-visible + label,
.sr-toggle:focus-visible ~ .bifolium-booklet .hinged-leaf {
  outline: 2px solid var(--lapis);
  outline-offset: 3px;
}

.snail-svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

/* Tiny knight trembling in terror */
.marginal-knight {
  transform-origin: 36px 90px;
  animation: knight-tremble 0.42s ease-in-out infinite alternate;
}

@keyframes knight-tremble {
  from { transform: rotate(-1.4deg) translateX(-0.6px); }
  to   { transform: rotate(1.6deg) translateX(0.8px); }
}

/* Misbehaving snail creeping relentlessly toward the knight & margin rule! */
.marginal-snail {
  animation: snail-creep 4.6s ease-in-out infinite alternate;
}

@keyframes snail-creep {
  0%   { transform: translateX(8px); }
  100% { transform: translateX(-18px); }
}

.snail-stalks {
  transform-origin: 108px 79px;
  animation: stalks-bob 1.3s ease-in-out infinite alternate;
}

@keyframes stalks-bob {
  from { transform: rotate(-5deg); }
  to   { transform: rotate(7deg); }
}

.snail-body {
  transform-origin: 145px 82px;
  transition: transform 0.38s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.25s ease;
}

.snail-shell {
  transform-origin: 146px 76px;
  transition: transform 0.38s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.stolen-pilcrow {
  opacity: 0;
  transform: translateY(-10px) rotate(-18deg);
  transition: opacity 0.3s ease, transform 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}

.snail-caption {
  display: block;
  text-align: center;
  font-size: 0.76rem;
  font-style: italic;
  color: #6b341c;
  margin-top: 0.15rem;
}

.poked-caption {
  display: none;
  color: var(--vermilion);
  font-weight: 600;
}

/* When Poked: Snail snaps inside shell, drops stolen pilcrow, knight relaxes! */
#poke-snail:checked + .snail-stage .marginal-snail {
  animation-play-state: paused;
}

#poke-snail:checked + .snail-stage .snail-body {
  transform: translateX(26px) scale(0.15);
  opacity: 0;
}

#poke-snail:checked + .snail-stage .snail-shell {
  transform: rotate(14deg) translateY(4px);
}

#poke-snail:checked + .snail-stage .stolen-pilcrow {
  opacity: 1;
  transform: translateY(0) rotate(-12deg);
}

#poke-snail:checked + .snail-stage .marginal-knight {
  animation: none;
}

#poke-snail:checked + .snail-stage .default-caption {
  display: none;
}

#poke-snail:checked + .snail-stage .poked-caption {
  display: block;
}

/* --- Interaction #2: Sewn Vellum Patch (Schedula) Hiding Secret Doodle --- */
.schedula-wrapper {
  position: relative;
  z-index: 10;
  perspective: 750px;
}

.schedula-container {
  display: block;
  position: relative;
  height: 128px;
  cursor: pointer;
  user-select: none;
}

.schedula-underneath {
  position: absolute;
  inset: 0;
  padding: 0.3rem;
  border-radius: 3px;
  background: #e3cca0;
  box-shadow: inset 0 2px 7px rgba(54, 30, 10, 0.32);
  border: 1px solid rgba(112, 72, 34, 0.38);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.broken-img-svg {
  width: 100%;
  max-height: 92px;
  display: block;
}

.underneath-note {
  font-size: 0.7rem;
  color: var(--vermilion);
  font-style: italic;
  text-align: center;
}

.schedula-flap {
  position: absolute;
  inset: 0;
  transform-origin: top center;
  transform-style: preserve-3d;
  transition: transform 0.65s cubic-bezier(0.25, 1, 0.4, 1);
}

.schedula-container:hover .schedula-flap {
  transform: rotateX(16deg);
}

#lift-schedula:checked + .schedula-container .schedula-flap {
  transform: rotateX(162deg);
}

#lift-schedula:checked + .schedula-container:hover .schedula-flap {
  transform: rotateX(154deg);
}

.schedula-front,
.schedula-back {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  border-radius: 3px 3px 6px 4px;
  padding: 0.45rem 0.6rem;
}

.schedula-front {
  background: linear-gradient(175deg, #f8edd6 0%, #ead3a5 88%, #dcc08a 100%);
  border: 1px solid #b8945c;
  box-shadow:
    0 5px 10px rgba(42, 24, 8, 0.24),
    inset 0 0 14px rgba(158, 110, 48, 0.22);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.stitch-top {
  display: block;
  text-align: center;
  font-size: 0.66rem;
  letter-spacing: 0.32em;
  color: var(--vermilion);
  font-weight: 700;
  border-bottom: 1px dashed rgba(174, 38, 25, 0.35);
  padding-bottom: 0.15rem;
}

.schedula-rubric {
  margin: 0.2rem 0 0;
  font-family: var(--font-rubric);
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--vermilion);
  text-align: center;
}

.schedula-text {
  margin: 0;
  font-size: 0.77rem;
  font-style: italic;
  text-align: center;
  color: #4f321b;
}

.schedula-cta {
  align-self: flex-end;
  font-size: 0.72rem;
  font-weight: 600;
  color: #7d2419;
  background: rgba(255, 248, 232, 0.65);
  padding: 0.05rem 0.35rem;
  border-radius: 3px 0 0 0;
  border-top: 1px solid rgba(154, 108, 52, 0.35);
  border-left: 1px solid rgba(154, 108, 52, 0.35);
}

.schedula-back {
  transform: rotateX(180deg);
  background:
    radial-gradient(rgba(120, 84, 42, 0.16) 1px, transparent 0) 0 0 / 8px 8px,
    #e6d0a4;
  border: 1px solid #a8844c;
  display: grid;
  place-items: center;
  text-align: center;
  font-size: 0.74rem;
  font-style: italic;
  color: #6e4b26;
  box-shadow: 0 -4px 10px rgba(0, 0, 0, 0.18);
}

/* --- Misbehaving Marginalia #2: Pangur Bán & Scurrying Cursor-Mouse --- */
.pangur-border {
  margin-top: 0.35rem;
}

.pangur-svg {
  display: block;
  width: 100%;
  max-width: 430px;
  height: auto;
  overflow: visible;
}

.pangur-tail {
  transform-origin: 4px 30px;
  animation: tail-swish 1.9s ease-in-out infinite alternate;
}

@keyframes tail-swish {
  from { transform: rotate(-10deg); }
  to   { transform: rotate(14deg); }
}

.pangur-paw {
  transform-origin: 39px 27px;
  animation: paw-bat 2.6s ease-in-out infinite;
}

@keyframes paw-bat {
  0%, 58%, 100% { transform: rotate(4deg); }
  68%           { transform: rotate(-22deg) translateX(2px); }
  78%           { transform: rotate(8deg); }
  88%           { transform: rotate(-16deg); }
}

.cursor-mouse {
  animation: mouse-dart 2.6s ease-in-out infinite;
}

@keyframes mouse-dart {
  0%, 55%  { transform: translateX(0); }
  66%      { transform: translateX(-24px) translateY(-1px); }
  78%      { transform: translateX(48px) translateY(1px); }
  92%      { transform: translateX(18px); }
  100%     { transform: translateX(0); }
}

/* --- Sleepy Brother Cuthbert Vignette (Face-first in Ultramarine) --- */
.cuthbert-vignette {
  margin: -0.5rem 0 0.55rem;
}

.cuthbert-svg {
  display: block;
  width: 100%;
  height: auto;
}

.cuthbert-head {
  transform-origin: 78px 46px;
  animation: cuthbert-doze 3.2s ease-in-out infinite alternate;
}

@keyframes cuthbert-doze {
  from { transform: translateY(0) rotate(0deg); }
  to   { transform: translateY(1.4px) rotate(2deg); }
}

.snore-1 {
  animation: snore-drift 3.2s ease-in-out infinite;
}

@keyframes snore-drift {
  0%   { opacity: 0.2; transform: translate(0, 2px); }
  50%  { opacity: 0.92; transform: translate(3px, -3px); }
  100% { opacity: 0.15; transform: translate(6px, -7px); }
}

/* --- Interaction #3: Unfolding Fore-Edge Marginal Gloss (Glossa Ordinaria) --- */
.glossa-tab-wrap {
  position: relative;
  margin-right: -0.9rem;
}

.glossa-trigger {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
  user-select: none;
  padding: 0.42rem 0.65rem;
  background: linear-gradient(90deg, #eed9af 0%, #f7ead0 100%);
  border: 1px solid #b58c52;
  border-left: 3px solid var(--vermilion);
  border-radius: 2px 5px 5px 2px;
  box-shadow: 2px 2px 6px rgba(46, 26, 8, 0.16);
  font-family: var(--font-rubric);
  font-size: 0.82rem;
  font-weight: 700;
  color: #691f15;
  transition: transform 0.2s ease, background-color 0.2s ease;
}

.glossa-trigger:hover {
  transform: translateX(2px);
  background: #fbf1dc;
}

.glossa-ribbon {
  color: var(--vermilion);
  font-size: 0.95rem;
}

.glossa-label-open {
  display: none;
}

#open-glossa:checked + .glossa-trigger .glossa-label-closed {
  display: none;
}

#open-glossa:checked + .glossa-trigger .glossa-label-open {
  display: inline;
}

.glossa-drawer {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.42s cubic-bezier(0.22, 1, 0.36, 1);
}

#open-glossa:checked ~ .glossa-drawer {
  grid-template-rows: 1fr;
}

.glossa-drawer-inner {
  min-height: 0;
  overflow: hidden;
  background: #f5e6c6;
  border-inline: 1px solid #bfa06d;
  border-bottom: 1px solid transparent;
  border-radius: 0 0 5px 3px;
  padding: 0 0.65rem;
  transition: padding 0.42s ease, border-color 0.3s ease;
}

#open-glossa:checked ~ .glossa-drawer .glossa-drawer-inner {
  padding: 0.55rem 0.65rem 0.65rem;
  border-bottom-color: #bfa06d;
  box-shadow: 2px 4px 10px rgba(42, 24, 8, 0.18);
}

.glossa-heading {
  margin: 0 0 0.35rem;
  font-weight: 700;
  font-size: 0.78rem;
  color: var(--vermilion);
}

.glossa-list {
  margin: 0;
  padding-left: 1rem;
  font-size: 0.76rem;
  line-height: 1.38;
  color: var(--ink-brown);
}

.glossa-list li + li {
  margin-top: 0.28rem;
}

.glossa-list code {
  font-size: 0.88em;
  color: #6e200b;
}

/* ==========================================================================
   INTERACTION #4: HINGED BIFOLIUM LEAF THAT TURNS (Fol. 404r ↔ Fol. 404v)
   ========================================================================== */

.turning-leaf-stage {
  position: relative;
  margin-top: 2.8rem;
  padding-top: 1.8rem;
  border-top: 2px double var(--margin-rule);
}

.bifolium-booklet {
  position: relative;
  max-width: 660px;
  margin: 0 auto;
  min-height: 196px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  perspective: 1300px;
  border-radius: 6px;
  background:
    linear-gradient(90deg, #e5cea0 0%, #edd9b0 48.5%, #9c7542 50%, #e7d1a4 51.5%, #e2c998 100%);
  border: 1px solid #b5915b;
  box-shadow:
    inset 0 0 22px rgba(96, 58, 20, 0.24),
    0 6px 18px rgba(38, 22, 8, 0.22);
}

/* Spine stitching down the center of the booklet */
.bifolium-booklet::before {
  content: "";
  position: absolute;
  top: 10px;
  bottom: 10px;
  left: 50%;
  width: 2px;
  transform: translateX(-50%);
  background: repeating-linear-gradient(
    to bottom,
    var(--vermilion) 0 8px,
    transparent 8px 15px
  );
  z-index: 4;
  pointer-events: none;
}

/* Left page of the open booklet (visible before turning; receives turned leaf) */
.booklet-left-page {
  grid-column: 1 / 2;
  grid-row: 1;
  padding: 1.15rem 1.3rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  text-align: center;
  border-right: 1px solid rgba(116, 76, 34, 0.28);
}

.left-page-rubric {
  margin: 0 0 0.45rem;
  font-family: var(--font-rubric);
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--vermilion);
  letter-spacing: 0.03em;
}

.left-page-verse {
  margin: 0 0 0.55rem;
  font-size: 0.82rem;
  font-style: italic;
  line-height: 1.45;
  color: #523319;
}

.left-page-ornament {
  font-size: 0.75rem;
  letter-spacing: 0.45em;
  color: var(--ochre);
}

/* Right recessed bed (hidden beneath hinged-leaf until leaf is turned left!) */
.booklet-bed {
  grid-column: 2 / 3;
  grid-row: 1;
  position: relative;
  padding: 1.15rem 1.25rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.cuthbert-smudge {
  position: absolute;
  right: 18px;
  top: 16px;
  width: 34px;
  height: 22px;
  border-radius: 55% 45% 60% 40%;
  background: radial-gradient(ellipse, rgba(28, 63, 136, 0.34) 0%, rgba(28, 63, 136, 0.12) 58%, transparent 76%);
  transform: rotate(-18deg);
  pointer-events: none;
}

.bed-inscription {
  margin: 0 0 0.45rem;
  font-family: var(--font-rubric);
  font-size: 0.94rem;
  color: #5c381c;
  line-height: 1.45;
}

.bed-inscription strong {
  color: var(--vermilion);
  letter-spacing: 0.06em;
}

.bed-sub {
  margin: 0;
  font-size: 0.8rem;
  font-style: italic;
  color: #6b492a;
  line-height: 1.42;
}

/* Hinged Right Parchment Leaf */
.hinged-leaf {
  grid-column: 2 / 3;
  grid-row: 1;
  position: relative;
  min-height: 196px;
  cursor: pointer;
  user-select: none;
  transform-origin: left center;
  transform-style: preserve-3d;
  transition: transform 0.85s cubic-bezier(0.25, 1, 0.35, 1);
  z-index: 5;
}

.hinged-leaf:hover {
  transform: rotateY(-12deg);
}

#turn-folio-leaf:checked ~ .bifolium-booklet .hinged-leaf {
  transform: rotateY(-175deg);
}

#turn-folio-leaf:checked ~ .bifolium-booklet .hinged-leaf:hover {
  transform: rotateY(-166deg);
}

.leaf-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  padding: 1rem 1.15rem 1.85rem;
  border-radius: 0 5px 5px 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.leaf-recto {
  background: linear-gradient(135deg, #f9efd9 0%, #efe0bc 70%, #dfc694 100%);
  box-shadow:
    -3px 0 8px rgba(48, 28, 10, 0.14),
    4px 5px 14px rgba(38, 20, 6, 0.24),
    inset 0 0 18px rgba(154, 108, 48, 0.22);
}

.seal-cartouche {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.wax-seal-svg {
  width: 84px;
  height: 84px;
  flex-shrink: 0;
  filter: drop-shadow(1px 3px 4px rgba(42, 12, 6, 0.38));
}

.proclamation-code {
  margin: 0;
  font-family: var(--font-rubric);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--vermilion);
}

.proclamation-title {
  margin: 0.15rem 0 0.25rem;
  font-family: var(--font-rubric);
  font-size: 1.08rem;
  font-weight: 700;
  color: var(--ink-dry);
}

.proclamation-desc {
  margin: 0;
  font-size: 0.8rem;
  line-height: 1.35;
  color: var(--ink-brown);
}

.leaf-corner-cue {
  position: absolute;
  right: 0.65rem;
  bottom: 0.4rem;
  font-size: 0.76rem;
  font-style: italic;
  font-weight: 600;
  color: var(--vermilion);
}

/* Verso Face (Back of the Turned Leaf) */
.leaf-verso {
  transform: rotateY(180deg);
  border-radius: 5px 0 0 5px;
  background: linear-gradient(225deg, #f5e8cc 0%, #ead6ab 85%, #d9be8b 100%);
  box-shadow:
    -5px 5px 14px rgba(32, 18, 6, 0.26),
    inset 0 0 20px rgba(142, 98, 42, 0.26);
  overflow: hidden;
}

/* Reversed ink ghosting bleeding faintly through thin calfskin! */
.bleedthrough-ghost {
  position: absolute;
  right: 12px;
  top: 16px;
  font-family: var(--font-rubric);
  font-size: 3.1rem;
  font-weight: 700;
  color: rgba(138, 32, 22, 0.085);
  transform: scaleX(-1) rotate(-6deg);
  pointer-events: none;
}

.verso-header {
  margin: 0 0 0.35rem;
  font-family: var(--font-rubric);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--vermilion);
}

.verso-body {
  margin: 0 0 0.35rem;
  font-size: 0.78rem;
  line-height: 1.38;
  color: var(--ink-dry);
}

.verso-moral {
  margin: 0;
  font-size: 0.76rem;
  font-style: italic;
  color: #1c3f88;
}

.verso-cue {
  right: auto;
  left: 0.65rem;
}

.folio-footer {
  margin-top: 1.45rem;
  text-align: center;
}

.relight-link {
  display: inline-block;
  padding: 0.42rem 1rem;
  font-family: var(--font-rubric);
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: var(--vermilion);
  text-decoration: none;
  border: 1px solid rgba(174, 38, 25, 0.42);
  border-radius: 3px;
  background: rgba(250, 239, 214, 0.65);
  transition: background-color 0.2s ease, transform 0.2s ease, color 0.2s ease;
}

.relight-link:hover,
.relight-link:focus-visible {
  background: var(--vermilion);
  color: #fdf5e4;
  transform: translateY(-1px);
}

/* ==========================================================================
   THE SCRIPTORIUM CANDLESTICK (Fixed Rail — Burns Down & Gutters Out!)
   ========================================================================== */

.candlestick-rail {
  position: sticky;
  top: calc(100vh - 390px);
  height: 360px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 35;
  user-select: none;
}

.candle-sconce {
  position: relative;
  width: 118px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  cursor: pointer;
}

.candle-burn-column {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
}

/* Rising wisp of smoke when the tallow candle gutters out near bottom of page */
.candle-smoke {
  width: 40px;
  height: 78px;
  margin-bottom: -14px;
  opacity: 0;
  pointer-events: none;
  animation: smoke-appear linear both;
  animation-timeline: scroll(root block);
}

@keyframes smoke-appear {
  0%, 87% { opacity: 0; transform: translateY(10px); }
  95%     { opacity: 0.85; transform: translateY(0); }
  100%    { opacity: 0.95; transform: translateY(-4px); }
}

.smoke-svg {
  width: 100%;
  height: 100%;
  overflow: visible;
  animation: smoke-curl 3.4s ease-in-out infinite alternate;
}

@keyframes smoke-curl {
  0%   { transform: skewX(-5deg) scaleY(0.96); }
  50%  { transform: skewX(6deg) scaleY(1.04) translateY(-3px); }
  100% { transform: skewX(-4deg) scaleY(1.01) translateY(-6px); }
}

/* Multi-layered organic flickering flame */
.flame-assembly {
  position: relative;
  width: 34px;
  height: 54px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  transform-origin: center calc(100% - 4px);
  transition: transform 0.25s ease;

  /* Flame shrinks & gutters to an ember as scroll approaches 100% */
  animation: flame-lifecycle linear both;
  animation-timeline: scroll(root block);
}

@keyframes flame-lifecycle {
  0%, 72% {
    transform: scale(1);
    opacity: 1;
  }
  86% {
    transform: scale(0.76, 0.68);
    opacity: 0.95;
  }
  94% {
    transform: scale(0.32, 0.26) translateY(6px);
    opacity: 0.72;
  }
  98%, 100% {
    transform: scale(0.14, 0.10) translateY(9px);
    opacity: 0.35;
  }
}

/* Hovering the candle stirs a cloister draft! */
.candle-sconce:hover .flame-outer,
.candle-sconce:hover .flame-mid,
.candle-sconce:hover .flame-core {
  animation-duration: 0.28s;
  transform: skewX(-18deg) scaleY(0.86);
}

.flame-halo {
  position: absolute;
  bottom: 4px;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: radial-gradient(
    circle,
    rgba(255, 198, 88, 0.46) 0%,
    rgba(255, 132, 28, 0.18) 44%,
    transparent 72%
  );
  pointer-events: none;
  animation: halo-pulse 2.1s ease-in-out infinite alternate;
}

@keyframes halo-pulse {
  from { transform: scale(0.92); opacity: 0.82; }
  to   { transform: scale(1.08); opacity: 1; }
}

.flame-outer {
  position: absolute;
  bottom: 7px;
  width: 20px;
  height: 38px;
  border-radius: 50% 50% 36% 36% / 68% 68% 32% 32%;
  background: radial-gradient(
    ellipse at 50% 72%,
    rgba(90, 140, 255, 0.45) 0%,
    #ff9824 34%,
    rgba(224, 72, 12, 0.78) 78%,
    transparent 100%
  );
  filter: blur(0.6px);
  transform-origin: 50% 92%;
  animation: flicker-outer 1.7s ease-in-out infinite alternate;
}

.flame-mid {
  position: absolute;
  bottom: 8px;
  width: 13px;
  height: 29px;
  border-radius: 50% 50% 35% 35% / 70% 70% 30% 30%;
  background: linear-gradient(to top, #ff7b14 0%, #ffd257 65%, #fff3b8 100%);
  transform-origin: 50% 92%;
  animation: flicker-mid 1.13s ease-in-out infinite alternate;
}

.flame-core {
  position: absolute;
  bottom: 8px;
  width: 6px;
  height: 15px;
  border-radius: 50% 50% 40% 40%;
  background: linear-gradient(to top, #4d88ff 0%, #ffffff 55%, #fffbe0 100%);
  transform-origin: 50% 95%;
  animation: flicker-core 0.79s ease-in-out infinite alternate;
}

@keyframes flicker-outer {
  0%   { transform: skewX(-3deg) scale(0.97, 1.04); }
  37%  { transform: skewX(4deg) scale(1.03, 0.95); }
  71%  { transform: skewX(-2deg) scale(0.99, 1.06); }
  100% { transform: skewX(3.5deg) scale(1.02, 0.97); }
}

@keyframes flicker-mid {
  0%   { transform: skewX(2.5deg) scaleY(1.05); }
  50%  { transform: skewX(-4deg) scaleY(0.93); }
  100% { transform: skewX(3deg) scaleY(1.03); }
}

@keyframes flicker-core {
  0%   { transform: rotate(-2deg) scaleY(0.96); }
  100% { transform: rotate(2.5deg) scaleY(1.05); }
}

.wick {
  width: 2.5px;
  height: 9px;
  background: linear-gradient(to bottom, #ff5912 0%, #1c120d 45%, #1c120d 100%);
  border-radius: 2px;
  z-index: 2;
}

/* Beeswax Tallow Pillar — Shrinks steadily from 176px to 18px as you scroll! */
.wax-shaft {
  position: relative;
  width: 34px;
  height: 176px;
  border-radius: 5px 5px 2px 2px;
  background:
    /* Warm translucent subsurface glow at top of candle */
    linear-gradient(
      to bottom,
      rgba(255, 196, 78, 0.72) 0px,
      rgba(245, 168, 62, 0.25) 18px,
      transparent 38px
    ),
    linear-gradient(
      90deg,
      #c4a268 0%,
      #efe0bc 34%,
      #fbf3dc 56%,
      #d6b87e 86%,
      #ab884e 100%
    );
  box-shadow:
    inset 0 2px 4px rgba(255, 245, 210, 0.8),
    2px 4px 10px rgba(0, 0, 0, 0.55);

  animation: wax-burn-down linear both;
  animation-timeline: scroll(root block);
}

@keyframes wax-burn-down {
  0%   { height: 176px; }
  90%  { height: 22px; }
  100% { height: 16px; }
}

.wax-rim {
  position: absolute;
  top: -3px;
  left: -1px;
  right: -1px;
  height: 7px;
  border-radius: 50%;
  background: radial-gradient(circle, #ffd97d 0%, #ebd5a7 72%, #cbb07c 100%);
}

/* Wax tear-drips growing down the candle sides as it burns */
.wax-drip {
  position: absolute;
  top: 2px;
  width: 5px;
  border-radius: 3px 3px 5px 5px;
  background: linear-gradient(90deg, #dfd0aa, #fcf5e3 60%, #bfa16b);
  box-shadow: 0 2px 2px rgba(54, 34, 12, 0.28);
  transform-origin: top center;
  animation: drip-lengthen linear both;
  animation-timeline: scroll(root block);
}

.drip-1 { left: 4px; height: 34px; }
.drip-2 { right: 5px; height: 48px; }
.drip-3 { left: 15px; height: 24px; }

@keyframes drip-lengthen {
  0%   { transform: scaleY(0.22); }
  55%  { transform: scaleY(1); }
  90%  { transform: scaleY(0.32); }
  100% { transform: scaleY(0.25); }
}

/* Wrought Brass Pricket Drip-Pan & Base */
.brass-holder {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.melted-wax-pool {
  width: 56px;
  height: 7px;
  margin-bottom: -4px;
  border-radius: 50%;
  background: radial-gradient(circle, #f7e6be 0%, #d9bc82 78%, #ab8b52 100%);
  z-index: 2;
  animation: pool-fill linear both;
  animation-timeline: scroll(root block);
}

@keyframes pool-fill {
  0%   { transform: scaleX(0.55); opacity: 0.5; }
  85%  { transform: scaleX(1.12); opacity: 1; }
  100% { transform: scaleX(1.15); opacity: 0.95; }
}

.brass-pan {
  width: 76px;
  height: 12px;
  border-radius: 50% 50% 42% 42%;
  background: linear-gradient(90deg, #543b14 0%, #c99b42 32%, #f5d984 52%, #9e7324 80%, #47300e 100%);
  border: 1px solid #382408;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.65);
}

.brass-stem {
  width: 14px;
  height: 28px;
  background:
    radial-gradient(ellipse at center, rgba(255, 236, 170, 0.55) 0%, transparent 65%) 0 7px / 14px 10px no-repeat,
    linear-gradient(90deg, #4a3310 0%, #c7983e 38%, #f0d27a 55%, #7d5918 88%, #3b270b 100%);
  border-inline: 1px solid #362208;
}

.brass-foot {
  width: 88px;
  height: 20px;
  border-radius: 45% 45% 5px 5px / 75% 75% 20% 20%;
  background: linear-gradient(90deg, #47300e 0%, #ba8c34 30%, #f5da87 50%, #996e20 76%, #3d280a 100%);
  border: 1px solid #301e06;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.85);
  display: grid;
  place-items: center;
}

.brass-motto {
  font-family: var(--font-rubric);
  font-size: 0.54rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: #3b2406;
  text-shadow: 0 1px 0 rgba(255, 236, 175, 0.55);
}

/* ==========================================================================
   RESPONSIVE ADAPTATION (Tablets & Narrow Viewports)
   ========================================================================== */

@media (max-width: 960px) {
  .scriptorium {
    grid-template-columns: minmax(0, 1fr);
    padding: 1.25rem 0.85rem 8.5rem;
  }

  /* Anchor compact candlestick sconce in bottom-right corner on smaller viewports */
  .candlestick-rail {
    position: fixed;
    top: auto;
    right: 0.5rem;
    bottom: 0.55rem;
    height: auto;
    transform: scale(0.78);
    transform-origin: bottom right;
  }
}

@media (max-width: 720px) {
  .manuscript-entry {
    grid-template-columns: minmax(0, 1fr);
    gap: 0.9rem;
  }

  .text-column {
    padding-right: 0;
    border-right: none;
  }

  .margin-lane {
    padding-top: 0;
    max-width: 320px;
  }

  .glossa-tab-wrap {
    margin-right: 0;
  }

  .bifolium-booklet {
    grid-template-columns: 1fr;
  }

  .bifolium-booklet::before,
  .booklet-left-page,
  .booklet-bed {
    display: none;
  }

  .hinged-leaf {
    grid-column: 1 / -1;
    transform-origin: center center;
  }

  #turn-folio-leaf:checked ~ .bifolium-booklet .hinged-leaf {
    transform: rotateY(-180deg);
  }

  .leaf-face,
  .leaf-verso {
    border-radius: 5px;
  }
}

/* ==========================================================================
   REDUCED MOTION PREFERENCE
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .candle-wash,
  .quill-svg,
  .marginal-knight,
  .marginal-snail,
  .snail-stalks,
  .pangur-tail,
  .pangur-paw,
  .cursor-mouse,
  .cuthbert-head,
  .snore-1,
  .flame-halo,
  .flame-outer,
  .flame-mid,
  .flame-core,
  .smoke-svg {
    animation: none !important;
  }

  .stanza-lines {
    --stanza-p: 1;
    animation: none;
  }

  .stanza-quill {
    display: none;
  }
}
