/* =========================================================
   A Little Book For Cutie — pastel scrapbook diary
   3D scroll-driven page-turn book.
   Desktop: two-page spread, flip around vertical spine.
   Mobile:  single page, flip up around top edge (notepad).
   ========================================================= */

/* GSAP animates these. With @property they interpolate as numbers/lengths. */
@property --flip {
  syntax: '<angle>';
  initial-value: 0deg;
  inherits: false;
}
@property --depth {
  syntax: '<length>';
  initial-value: 0px;
  inherits: false;
}

:root {
  /* palette */
  --paper:        #FBF6EC;
  --paper-deep:   #F2EBDC;
  --paper-edge:   #E7DDC4;
  --peach:        #F4C9B5;
  --peach-deep:   #E8A98B;
  --rose:         #E5A1A1;
  --rose-deep:    #C77F7F;
  --sage:         #C7D2B7;
  --sage-deep:    #97AC85;
  --washi:        #FFD7B5;
  --gold:         #C9A96E;
  --ink:          #3A2E2A;
  --ink-soft:     #5A4843;
  --ink-faded:    #8A786F;

  /* type */
  --display: 'Fraunces', 'Cormorant Garamond', Georgia, serif;
  --body:    'Cormorant Garamond', Georgia, 'Times New Roman', serif;
  --hand:    'Caveat', 'Patrick Hand', cursive;

  /* scale — tuned for half-width pages */
  --step--1: clamp(0.78rem, 0.74rem + 0.2vw, 0.92rem);
  --step-0:  clamp(0.92rem, 0.86rem + 0.3vw, 1.05rem);
  --step-1:  clamp(1.05rem, 0.95rem + 0.6vw, 1.30rem);
  --step-2:  clamp(1.35rem, 1.10rem + 1.0vw, 1.75rem);
  --step-3:  clamp(1.6rem,  1.30rem + 1.6vw, 2.40rem);

  /* book sizing — TWO-PAGE SPREAD */
  --book-w: min(94vw, 60rem);
  --book-h: min(82svh, 40rem);
  --page-w: calc(var(--book-w) / 2);

  --shadow-paper:
    0 30px 60px -28px rgba(58, 46, 42, 0.45),
    0 12px 28px -16px rgba(58, 46, 42, 0.30);
}

/* ---------- reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
img, svg { display: block; max-width: 100%; }
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 2px solid var(--rose-deep); outline-offset: 3px; border-radius: 4px; }

html {
  font-size: 17px;
  -webkit-text-size-adjust: 100%;
}
body {
  font-family: var(--body);
  font-size: var(--step-0);
  line-height: 1.5;
  color: var(--ink);
  background:
    radial-gradient(1100px 700px at 50% -200px, var(--paper) 0%, var(--paper-deep) 60%, var(--paper-edge) 100%);
  min-height: 100svh;
  overflow-x: hidden;
}

.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  opacity: 0.4;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='240' height='240'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.23 0 0 0 0 0.18 0 0 0 0 0.16 0 0 0 0.18 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  background-size: 240px 240px;
}

/* =========================================================
   STAGE
   ========================================================= */
.scroll-spacer {
  width: 1px;
  pointer-events: none;
  /* JS sets the height */
}

.stage {
  position: fixed;
  inset: 0;
  z-index: 2;
  display: grid;
  place-items: center;
  perspective: 2600px;
  perspective-origin: 50% 50%;
  pointer-events: none;
}
.stage__desk {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(900px 600px at 50% 55%, rgba(255, 252, 244, 0.5) 0%, rgba(247, 238, 220, 0.0) 70%);
  pointer-events: none;
}

.book {
  position: relative;
  width: var(--book-w);
  height: var(--book-h);
  transform-style: preserve-3d;
  pointer-events: auto;
}
/* desk shadow under the open book */
.book::after {
  content: '';
  position: absolute;
  left: 5%;
  right: 5%;
  bottom: -22px;
  height: 30px;
  background: radial-gradient(closest-side, rgba(58, 46, 42, 0.30), rgba(58, 46, 42, 0));
  filter: blur(6px);
  z-index: -1;
}

/* underlying paper for left + right halves so the book always looks present.
   Pushed behind on the Z axis so flipped leaves (which travel to negative z
   based on their depth) always render on top of the underlying paper. */
.book__verso, .book__recto {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 50%;
  background:
    linear-gradient(180deg, var(--paper) 0%, var(--paper-deep) 100%);
  box-shadow: var(--shadow-paper);
  transform: translateZ(-15px);
  z-index: 0;
}
.book__verso {
  left: 0;
  border-radius: 4px 0 0 4px;
}
.book__verso::after {
  /* right edge spine shadow on the verso (left page) */
  content: '';
  position: absolute;
  top: 0; bottom: 0;
  right: 0;
  width: 24px;
  background: linear-gradient(-90deg,
    rgba(58, 46, 42, 0.25) 0%,
    rgba(58, 46, 42, 0.08) 40%,
    rgba(58, 46, 42, 0)    100%);
  pointer-events: none;
}
.book__recto {
  right: 0;
  border-radius: 0 4px 4px 0;
}
.book__recto::after {
  /* left edge spine shadow on the recto (right page) */
  content: '';
  position: absolute;
  top: 0; bottom: 0;
  left: 0;
  width: 24px;
  background: linear-gradient(90deg,
    rgba(58, 46, 42, 0.25) 0%,
    rgba(58, 46, 42, 0.08) 40%,
    rgba(58, 46, 42, 0)    100%);
  pointer-events: none;
}

/* central spine — also pushed behind so leaves render in front */
.book__spine {
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 2px;
  transform: translateX(-50%) translateZ(-14px);
  background: linear-gradient(180deg,
    rgba(58, 46, 42, 0.25),
    rgba(58, 46, 42, 0.55),
    rgba(58, 46, 42, 0.25));
  z-index: 1;
}

/* ribbon hangs from spine — top of book */
.book__ribbon {
  position: absolute;
  top: -8px;
  left: 50%;
  transform: translateX(-50%) translateX(38px);
  width: 22px;
  height: 96px;
  background: linear-gradient(90deg, #B95C5C 0%, #D77373 50%, #B95C5C 100%);
  box-shadow: 0 4px 8px -3px rgba(58, 46, 42, 0.5);
  z-index: 6;
}
.book__ribbon::after {
  content: '';
  position: absolute;
  bottom: -10px; left: 0;
  width: 0; height: 0;
  border-left: 11px solid transparent;
  border-right: 11px solid transparent;
  border-top: 11px solid #B95C5C;
}

/* =========================================================
   LEAVES — each occupies the right page, flips around the spine
   ========================================================= */
.leaf {
  position: absolute;
  top: 0;
  left: 50%;       /* anchor at the spine */
  width: 50%;      /* one page wide */
  height: 100%;
  transform-origin: left center;   /* pivot on the spine */
  transform-style: preserve-3d;
  will-change: transform;
  /* IMPORTANT order: rotate first, translateZ second in CSS reads as
     `translateZ then rotate` mathematically. So translateZ moves the leaf
     in its local frame BEFORE rotation; after a 180° flip, +Z becomes
     -Z in world space — which is exactly the stacking we want. */
  transform: rotateY(var(--flip)) translateZ(var(--depth));
}

.leaf__face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  background: var(--paper);
  border-radius: 0 4px 4px 0;
  overflow: hidden;
  box-shadow:
    var(--shadow-paper),
    inset 12px 0 18px -14px rgba(58, 46, 42, 0.35); /* binding shadow on the inner edge */
}
.leaf__face--back {
  transform: rotateY(180deg);
  border-radius: 4px 0 0 4px;
  box-shadow:
    var(--shadow-paper),
    inset -12px 0 18px -14px rgba(58, 46, 42, 0.35); /* binding shadow now on the new inner edge */
}
/* The back face is a clone of the front for visual purposes only. It must
   never receive clicks or hovers — otherwise the cloned answer-row in
   the epilogue's back face sits on top of (and intercepts events meant
   for) the real Yes/No buttons in the front face. pointer-events doesn't
   cascade, so we have to disable it on the back face AND every
   descendant. */
.leaf__face--back,
.leaf__face--back * {
  pointer-events: none;
}

/* Once a leaf has flipped past 90° its front face is hidden by
   backface-visibility, but its layout box still occupies the same screen
   rectangle as the unflipped epilogue below it. pointer-events does NOT
   cascade, so we have to disable it on the leaf AND every descendant —
   otherwise the leaf's children (front face, inner content, etc.) still
   intercept clicks meant for the epilogue's Yes/No buttons. */
.leaf--past-half,
.leaf--past-half * {
  pointer-events: none;
}

.leaf__inner {
  position: relative;
  width: 100%;
  height: 100%;
  padding: clamp(1.1rem, 2vw + 0.6rem, 1.8rem);
  padding-left: clamp(1.6rem, 3vw + 0.8rem, 2.4rem); /* gutter near the spine */
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  overflow: hidden;
}
.leaf__inner--centered {
  justify-content: center;
  align-items: center;
  text-align: center;
  gap: 1rem;
}
/* On the back face, the gutter swaps sides */
.leaf__face--back .leaf__inner {
  padding-left: clamp(1.1rem, 2vw + 0.6rem, 1.8rem);
  padding-right: clamp(1.6rem, 3vw + 0.8rem, 2.4rem);
}

/* =========================================================
   COVER LEAF
   ========================================================= */
.leaf--cover .leaf__face {
  background:
    linear-gradient(160deg, #F4DCC9 0%, var(--peach) 55%, #E5B498 100%);
  box-shadow:
    var(--shadow-paper),
    inset 12px 0 18px -14px rgba(58, 46, 42, 0.4),
    inset 0 0 0 1px rgba(255, 255, 255, 0.35);
}
.leaf--cover .leaf__face::before {
  content: '';
  position: absolute;
  inset: 0.9rem;
  border: 1.5px solid rgba(94, 60, 42, 0.35);
  border-radius: 3px;
  box-shadow: inset 0 0 0 4px rgba(255, 255, 255, 0.18);
  pointer-events: none;
  z-index: 2;
}
.leaf--cover .leaf__face::after {
  /* linen weave */
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    repeating-linear-gradient(0deg,   rgba(94, 60, 42, 0.04) 0 1px, transparent 1px 3px),
    repeating-linear-gradient(90deg,  rgba(94, 60, 42, 0.04) 0 1px, transparent 1px 3px);
  pointer-events: none;
  opacity: 0.85;
}
.leaf--cover .leaf__face {
  display: grid;
  place-items: center;
  text-align: center;
  padding: clamp(1.6rem, 4vw, 2.4rem) clamp(1rem, 3vw, 1.6rem);
}
.cover__plate {
  position: relative;
  color: #4A2E22;
  z-index: 3;
}
.cover__eyebrow {
  margin: 0;
  font-family: var(--hand);
  font-size: clamp(0.95rem, 0.85rem + 0.3vw, 1.2rem);
  letter-spacing: 0.08em;
  color: rgba(74, 46, 34, 0.72);
}
.cover__title {
  margin: 0.4rem 0 0.9rem;
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(1.9rem, 1.2rem + 4vw, 3.6rem);
  line-height: 0.95;
  letter-spacing: -0.01em;
  font-variation-settings: 'opsz' 144, 'SOFT' 100;
  text-shadow:
    0 1px 0 rgba(255, 255, 255, 0.5),
    0 -1px 0 rgba(80, 50, 35, 0.35);
}
.cover__byline {
  margin: 0.9rem 0 0;
  font-family: var(--hand);
  font-size: clamp(1rem, 0.85rem + 0.5vw, 1.3rem);
  line-height: 1.25;
  color: rgba(74, 46, 34, 0.78);
}
.cover__ornament {
  display: block;
  margin-top: 1.1rem;
  font-family: var(--display);
  letter-spacing: 0.4em;
  color: rgba(74, 46, 34, 0.45);
}
.cover__corner {
  position: absolute;
  width: 18px;
  height: 18px;
  border: 1.5px solid rgba(94, 60, 42, 0.45);
  z-index: 3;
}
.cover__corner--tl { top: 1.2rem;    left: 1.2rem;    border-right: 0; border-bottom: 0; }
.cover__corner--tr { top: 1.2rem;    right: 1.2rem;   border-left: 0;  border-bottom: 0; }
.cover__corner--bl { bottom: 1.2rem; left: 1.2rem;    border-right: 0; border-top: 0; }
.cover__corner--br { bottom: 1.2rem; right: 1.2rem;   border-left: 0;  border-top: 0; }

/* =========================================================
   DEDICATION
   ========================================================= */
.dedication {
  font-family: var(--hand);
  font-size: clamp(1.3rem, 1rem + 1.2vw, 1.9rem);
  line-height: 1.4;
  color: var(--ink-soft);
  max-width: 18rem;
  margin: 0 auto;
  transform: rotate(-1deg);
}
.dedication__sub {
  display: inline-block;
  margin-top: 0.4rem;
  font-size: 0.78em;
  color: var(--ink-faded);
}

/* =========================================================
   CHAPTER HEAD
   ========================================================= */
.chapter-head {
  text-align: center;
  margin: 0 auto 0.5rem;
  flex-shrink: 0;
}
.chapter-head__eyebrow {
  margin: 0 0 0.25rem;
  font-family: var(--hand);
  font-size: 0.95rem;
  letter-spacing: 0.18em;
  text-transform: lowercase;
  color: var(--rose-deep);
}
.chapter-head__title {
  margin: 0;
  font-family: var(--display);
  font-weight: 800;
  font-size: var(--step-3);
  line-height: 0.98;
  letter-spacing: -0.015em;
  font-variation-settings: 'opsz' 144, 'SOFT' 80;
  color: var(--ink);
}
.chapter-head__ornament {
  display: block;
  margin-top: 0.5rem;
  letter-spacing: 0.5em;
  color: var(--peach-deep);
  font-family: var(--display);
  font-size: 0.8rem;
}

/* =========================================================
   BODY COPY
   ========================================================= */
.chapter-body {
  position: relative;
  margin: 0 auto;
  max-width: 22rem;
  font-size: var(--step-0);
  line-height: 1.5;
  color: var(--ink-soft);
  flex: 1;
  overflow: hidden;
}
.chapter-body p { margin: 0 0 0.7em; }
.chapter-body .lede {
  font-size: calc(var(--step-0) * 1.05);
  color: var(--ink);
}
.chapter-body .emph {
  font-family: var(--hand);
  font-size: calc(var(--step-0) * 1.5);
  line-height: 1.2;
  color: var(--rose-deep);
  transform: rotate(-0.5deg);
  margin-top: 0.9em;
}
.chapter-body--ask {
  text-align: center;
  flex: 0 1 auto;
}

/* drop cap */
.dropcap {
  float: left;
  font-family: var(--display);
  font-weight: 800;
  font-size: 3.4em;
  line-height: 0.85;
  margin: 0.05em 0.1em -0.05em -0.04em;
  color: var(--peach-deep);
  text-shadow:
    1px 1px 0 var(--paper),
    2px 2px 0 rgba(232, 169, 139, 0.25);
  font-variation-settings: 'opsz' 144;
  transform: rotate(-2deg);
}

.margin-note {
  display: block;
  margin-top: 0.5rem;
  font-family: var(--hand);
  color: var(--rose-deep);
  font-size: 1rem;
  line-height: 1.2;
  max-width: 12rem;
  transform: rotate(-3deg);
  opacity: 0.95;
}

/* =========================================================
   SCRAPBOOK ARTEFACTS — sized for narrow page
   ========================================================= */
.scrap {
  position: relative;
  margin: 0 auto 0.5rem;
  transform: rotate(var(--rotate, 0deg));
  filter: drop-shadow(0 8px 12px rgba(58, 46, 42, 0.18));
  flex-shrink: 0;
}
/* Polaroid and GIF wrappers don't have an explicit width — they hold a
   narrower child. Make them flex-center so the inner photo/gif sits in
   the middle of the page (and the absolutely-positioned washi tape
   lines up over it). */
.scrap--polaroid,
.scrap--gif {
  display: flex;
  flex-direction: column;
  align-items: center;
}
.polaroid {
  background: #FFFDF7;
  padding: 10px 10px 30px;
  width: min(12rem, 78%);
  border-radius: 2px;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.8) inset,
    0 8px 22px -10px rgba(58, 46, 42, 0.32);
}
.polaroid__photo {
  aspect-ratio: 1 / 1;
  background:
    radial-gradient(120% 100% at 30% 25%, #FFE8D4 0%, transparent 55%),
    linear-gradient(155deg, var(--peach) 0%, var(--rose) 55%, #B98DA0 80%, var(--sage) 100%);
  border-radius: 1px;
  position: relative;
  overflow: hidden;
  width: 100%;
  /* When this is an <img>, object-fit fills the square box created by
     aspect-ratio + width:100%. */
  object-fit: cover;
  display: block;
}
.polaroid__photo::after {
  /* gentle film grain to soften the gradient */
  content: '';
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='100' height='100'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='1.4' numOctaves='1' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0.18 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  background-size: 100px 100px;
  mix-blend-mode: overlay;
  opacity: 0.4;
  pointer-events: none;
}
.polaroid__photo--placeholder {
  display: grid;
  place-items: center;
  color: rgba(255, 255, 255, 0.92);
  font-family: var(--hand);
  font-size: 1.05rem;
  text-align: center;
  text-shadow: 0 1px 2px rgba(58, 46, 42, 0.4);
}
/* second polaroid (Ch4) — different palette so the two photos don't twin */
.polaroid__photo--alt {
  background:
    radial-gradient(120% 100% at 70% 25%, #FFEDDA 0%, transparent 55%),
    linear-gradient(155deg, #B7C9B5 0%, var(--peach) 50%, #C77F7F 80%, #8E5E72 100%);
}
.polaroid__caption {
  margin: 8px 0 0;
}
.polaroid__caption {
  margin: 8px 0 0;
  font-family: var(--hand);
  text-align: center;
  font-size: 0.95rem;
  color: var(--ink-soft);
}

.washi {
  position: absolute;
  width: 64px;
  height: 16px;
  background:
    repeating-linear-gradient(45deg,
      rgba(255, 255, 255, 0.55) 0 5px,
      rgba(255, 215, 181, 0.0) 5px 12px),
    linear-gradient(90deg, var(--washi) 0%, #FFE2C4 100%);
  border-left: 1px dashed rgba(255, 255, 255, 0.6);
  border-right: 1px dashed rgba(255, 255, 255, 0.6);
  opacity: 0.9;
  box-shadow: 0 2px 4px -2px rgba(58, 46, 42, 0.25);
}
.washi--top {
  top: -8px;
  left: 50%;
  transform: translateX(-50%) rotate(-4deg);
}

/* GIF inside a polaroid-style frame — Ch4 */
.scrap--gif {
  background: #FFFDF7;
  padding: 10px 10px 30px;
  width: min(14rem, 78%);
  border-radius: 2px;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.8) inset,
    0 8px 22px -10px rgba(58, 46, 42, 0.32);
}
.scrap__gif {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: 1px;
  background: linear-gradient(135deg, var(--peach), var(--rose), var(--sage));
}
.scrap--gif .scrap__caption {
  font-family: var(--hand);
  text-align: center;
  font-size: 1.05rem;
  color: var(--ink-soft);
  margin: 10px 0 0;
}

/* sticky-note artefact */
.scrap--note {
  background: #FFF6C8;
  background-image:
    repeating-linear-gradient(0deg,
      rgba(58, 46, 42, 0.04) 0 1px,
      transparent 1px 18px);
  padding: 14px 14px;
  width: min(10.5rem, 78%);
  border-radius: 1px;
  font-family: var(--hand);
  font-size: 1rem;
  color: var(--ink-soft);
  text-align: left;
  line-height: 1.3;
  position: relative;
  box-shadow:
    0 4px 0 rgba(58, 46, 42, 0.08),
    0 10px 20px -10px rgba(58, 46, 42, 0.32);
}
.scrap--note p { margin: 0 0 4px; }
.scrap--note p:last-child { margin-bottom: 0; }
.scrap--note .scrap__title {
  font-size: 1.15rem;
  color: var(--rose-deep);
  font-weight: 700;
  margin-bottom: 6px;
}

/* ticket stub artefact */
.scrap--ticket {
  background: #FFF8E6;
  padding: 12px 16px;
  width: min(12rem, 84%);
  font-family: var(--hand);
  font-size: 1rem;
  color: var(--ink-soft);
  text-align: center;
  position: relative;
  box-shadow: 0 8px 18px -10px rgba(58, 46, 42, 0.32);
  border: 1.5px dashed rgba(58, 46, 42, 0.32);
  border-radius: 2px;
}
.scrap--ticket::before, .scrap--ticket::after {
  content: '';
  position: absolute;
  top: 50%;
  width: 12px;
  height: 12px;
  background: var(--paper);
  border: 1.5px dashed rgba(58, 46, 42, 0.32);
  border-radius: 50%;
  transform: translateY(-50%);
}
.scrap--ticket::before { left: -8px; }
.scrap--ticket::after  { right: -8px; }
.scrap--ticket p { margin: 0 0 3px; }
.scrap--ticket p:last-child { margin-bottom: 0; }
.scrap--ticket .scrap__caption {
  letter-spacing: 0.18em;
  font-size: 0.7rem;
  text-transform: uppercase;
  color: var(--ink-faded);
  font-family: var(--display);
  font-style: italic;
  margin-bottom: 4px;
}
.scrap--ticket .scrap__title {
  font-size: 1.25rem;
  color: var(--rose-deep);
  font-weight: 700;
  margin-bottom: 4px;
  letter-spacing: 0.02em;
}

/* hand-drawn / SVG doodle artefact */
.scrap--doodle {
  width: min(10rem, 72%);
  filter: drop-shadow(0 6px 10px rgba(58, 46, 42, 0.16));
}
.scrap--doodle svg {
  display: block;
  width: 100%;
  height: auto;
}
.scrap--doodle-clock { width: min(6.5rem, 48%); }
.scrap--doodle .scrap__caption {
  font-family: var(--hand);
  font-size: 0.95rem;
  color: var(--ink-faded);
  text-align: center;
  margin: 4px 0 0;
  letter-spacing: 0.04em;
}

.sticker {
  position: absolute;
  font-family: var(--display);
  filter: drop-shadow(0 4px 6px rgba(58, 46, 42, 0.25));
  pointer-events: none;
  user-select: none;
}
.sticker--heart {
  bottom: 2.5rem;
  left: 1.2rem;
  font-size: 2rem;
  color: var(--rose);
  transform: rotate(-12deg);
}
.sticker--music {
  bottom: 2.5rem; right: 1.2rem;
  font-size: 2rem;
  color: var(--rose-deep);
  transform: rotate(8deg);
}
.sticker--sun {
  top: 1.5rem; right: 1.4rem;
  font-size: 2rem;
  color: var(--peach-deep);
}
.sticker--arrow {
  bottom: 2.4rem; right: 1.2rem;
  font-size: 2rem;
  color: var(--peach-deep);
  transform: rotate(-12deg);
}
.sticker--star {
  top: 1.3rem; right: 1.5rem;
  font-size: 1.7rem;
  color: var(--gold);
  transform: rotate(-15deg);
}
.sticker--sparkle {
  top: 4.5rem; right: 1rem;
  font-size: 1.6rem;
  color: var(--peach-deep);
  transform: rotate(20deg);
}

.page-number {
  position: absolute;
  bottom: 0.8rem;
  right: 1.1rem;
  font-family: var(--display);
  font-style: italic;
  color: var(--ink-faded);
  font-size: 0.85rem;
  letter-spacing: 0.05em;
}
/* Don't echo the page number on the flipped back face — otherwise the
   previous chapter's number bleeds into the visible page above on mobile. */
.leaf__face--back .page-number { display: none; }

/* =========================================================
   YES / NO STAMPS
   ========================================================= */
.ask-line {
  font-family: var(--display);
  font-weight: 600;
  font-size: var(--step-2);
  line-height: 1.15;
  color: var(--ink);
  font-variation-settings: 'opsz' 144;
  margin: 0 0 0.9rem;
  text-align: center;
}
.answer-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  justify-content: center;
  align-items: center;
  margin-top: 0.4rem;
}
.stamp {
  --stamp-color: #B5524F;
  --stamp-bg: rgba(229, 161, 161, 0.08);
  position: relative;
  background: var(--stamp-bg);
  border: 2.5px solid var(--stamp-color);
  border-radius: 6px;
  padding: 0.55rem 0.85rem;
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(0.82rem, 0.78rem + 0.2vw, 1rem);
  line-height: 1.05;
  color: var(--stamp-color);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  min-width: 6.4rem;
  min-height: 2.7rem;
  transform: rotate(var(--tilt, -2deg));
  transition: transform 200ms cubic-bezier(0.2,0.7,0.2,1), background-color 200ms ease;
  box-shadow:
    inset 0 0 0 6px var(--stamp-bg),
    inset 0 0 0 7px rgba(255, 255, 255, 0.4);
}
.stamp__line { display: block; }
.stamp { transition:
  transform 220ms cubic-bezier(0.2, 0.7, 0.2, 1),
  background-color 220ms ease,
  box-shadow 220ms ease,
  color 220ms ease; }
.stamp:hover, .stamp:focus-visible, .stamp.is-hover {
  transform: rotate(0deg) scale(1.06);
  background-color: rgba(229, 161, 161, 0.22);
  box-shadow:
    inset 0 0 0 6px var(--stamp-bg),
    inset 0 0 0 7px rgba(255, 255, 255, 0.55),
    0 8px 22px -8px rgba(58, 46, 42, 0.3);
}
.stamp:active {
  transform: rotate(0deg) scale(0.97);
  transition-duration: 90ms;
}
.stamp--yes { --tilt: -3deg; --stamp-color: #B5524F; }
.stamp--no  { --tilt:  2.5deg; --stamp-color: #6F8A6A; --stamp-bg: rgba(151, 172, 133, 0.08); }
.stamp--no:hover, .stamp--no:focus-visible, .stamp--no.is-hover { background-color: rgba(151, 172, 133, 0.22); }

/* =========================================================
   STAGE HUD
   ========================================================= */
.stage__hud {
  position: absolute;
  bottom: max(1rem, env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  font-family: var(--hand);
  color: var(--ink-faded);
  pointer-events: none;
  z-index: 10;
}
.stage__counter { font-size: 0.95rem; letter-spacing: 0.08em; }
.stage__hint    { font-size: 0.9rem; opacity: 0.8; display: inline-flex; gap: 0.4rem; align-items: center; }
.stage__hint-arrow {
  display: inline-block;
  animation: bob 2.6s ease-in-out infinite;
}
@keyframes bob {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(4px); }
}
.stage__hud.is-faded { opacity: 0; transition: opacity 400ms ease; }

/* =========================================================
   CONFIRM OVERLAY
   ========================================================= */
.confirm {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(58, 46, 42, 0.35);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 50;
  padding: 1.5rem;
  opacity: 0;
  transition: opacity 350ms ease;
}
.confirm[hidden] { display: none; }
.confirm.is-open { opacity: 1; }
.confirm__card {
  background: var(--paper);
  border-radius: 8px;
  padding: 2rem 1.6rem 1.6rem;
  max-width: 22rem;
  width: 100%;
  text-align: center;
  box-shadow: var(--shadow-paper), inset 0 0 0 1px rgba(255, 255, 255, 0.6);
  transform: scale(0.92) translateY(8px);
  transition: transform 400ms cubic-bezier(0.2, 0.7, 0.2, 1);
}
.confirm.is-open .confirm__card { transform: scale(1) translateY(0); }
.confirm__headline {
  margin: 0 0 0.6rem;
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.6rem;
  color: var(--ink);
  font-variation-settings: 'opsz' 144;
}
.confirm__body {
  margin: 0 0 1.2rem;
  font-family: var(--hand);
  font-size: 1.25rem;
  color: var(--ink-soft);
}
.confirm__undo {
  background: transparent;
  border: none;
  font-family: var(--body);
  font-style: italic;
  font-size: 0.95rem;
  color: var(--ink-faded);
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* =========================================================
   MOBILE — single-page notepad: flip up around the top edge.
   The 2-page spread chrome is hidden, leaf takes full width,
   transform-origin moves to the top, and the rotation axis
   switches from Y (vertical spine) to X (horizontal binding).
   ========================================================= */
@media (max-width: 540px) {
  :root {
    --book-w: 94vw;
    --book-h: 84svh;
    --page-w: var(--book-w);

    /* with full-width pages there's room for a slightly larger type scale */
    --step-0:  clamp(0.98rem, 0.92rem + 0.5vw, 1.10rem);
    --step-1:  clamp(1.15rem, 1.0rem + 0.8vw, 1.35rem);
    --step-2:  clamp(1.5rem,  1.2rem + 1.4vw, 1.95rem);
    --step-3:  clamp(2.0rem,  1.5rem + 2.4vw, 2.85rem);
  }

  /* hide the 2-page chrome — single page now */
  .book__verso, .book__recto, .book__spine, .book__ribbon { display: none; }

  /* every leaf is the whole page, hinged at the top.
     JS animates --flip to +180deg on mobile (vs -180deg on desktop) so
     the page swings FORWARD (toward the viewer) — like turning a notepad
     page over toward you — instead of falling backward into the screen. */
  .leaf {
    left: 0;
    width: 100%;
    transform-origin: center top;
    transform: rotateX(var(--flip)) translateZ(var(--depth));
  }

  /* No left-spine binding shadow on mobile; the page has soft paper shadow only. */
  .leaf__face {
    border-radius: 4px;
    box-shadow: var(--shadow-paper);
  }
  /* Back face stays visible on mobile so flipped pages remain on screen at
     full 180° (notepad style). Pre-rotate around X (not Y) so the cloned
     content reads correctly once the leaf has rotated rotateX(+180). */
  .leaf__face--back {
    display: block;
    transform: rotateX(180deg);
    border-radius: 4px;
    box-shadow: var(--shadow-paper);
  }
  .leaf--cover .leaf__face {
    box-shadow:
      var(--shadow-paper),
      inset 0 0 0 1px rgba(255, 255, 255, 0.35);
  }

  /* leaf inner padding: no spine gutter needed, even pad on both sides */
  .leaf__inner {
    padding: clamp(1.4rem, 4vw, 2rem) clamp(1.2rem, 4vw, 1.8rem);
    gap: 0.8rem;
  }

  /* artefacts get full-page room — bump them up so they read prominently */
  .scrap { margin-bottom: 0.7rem; }
  .polaroid       { width: min(19rem, 78%); padding: 12px 12px 36px; }
  .polaroid__photo--placeholder { font-size: 1.2rem; }
  .polaroid__caption { font-size: 1.1rem; margin-top: 10px; }
  .scrap--gif     { width: min(19rem, 78%); padding: 12px 12px 36px; }
  .scrap--gif .scrap__caption { font-size: 1.1rem; margin-top: 10px; }
  .scrap--note    { width: min(16rem, 72%); padding: 16px 16px; font-size: 1.1rem; }
  .scrap--note .scrap__title { font-size: 1.25rem; }
  .scrap--ticket  { width: min(17rem, 78%); padding: 14px 18px; font-size: 1.1rem; }
  .scrap--ticket .scrap__title { font-size: 1.4rem; }
  .scrap--doodle  { width: min(15rem, 66%); }
  .scrap--doodle-clock { width: min(8rem, 42%); }
  .washi          { width: 88px; height: 20px; top: -9px; }

  /* stickers in slightly more visible positions */
  .sticker--heart { font-size: 2rem; bottom: 3rem; left: 1.4rem; }
  .sticker--music { font-size: 2rem; bottom: 3rem; right: 1.4rem; }
  .sticker--sun, .sticker--star { font-size: 2rem; right: 1.4rem; }

  /* drop cap looks great with more horizontal room */
  .dropcap { font-size: 3.6em; }

  /* the ask page on mobile — comfortable side-by-side stamps */
  .stamp {
    min-width: 7rem;
    min-height: 3rem;
    padding: 0.7rem 1rem;
    font-size: 1rem;
  }
}

/* =========================================================
   REDUCED MOTION FALLBACK
   No 3D book — pages render as a normal vertical scroll.
   ========================================================= */
@media (prefers-reduced-motion: reduce) {
  .scroll-spacer { display: none; }
  .stage {
    position: static;
    perspective: none;
    display: block;
  }
  .book {
    width: var(--book-w);
    height: auto;
    margin: 2rem auto;
    transform-style: flat;
  }
  .book__verso, .book__recto, .book__spine, .book__ribbon { display: none; }
  .leaf {
    position: relative;
    left: 0;
    width: 100%;
    height: var(--book-h);
    transform: none !important;
    margin-bottom: 1.5rem;
    z-index: auto !important;
  }
  .leaf__face--back { display: none; }
  .stage__hud { display: none; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
