/* ================================================================
   COMIC BOOK EXPERIENCE — style.css
   Design System + All Page Types + Animations
   ================================================================ */

/* ----------------------------------------------------------------
   1. DESIGN TOKENS
   ---------------------------------------------------------------- */
:root {
  --ink:         #0d0d0d;
  --ink-light:   #2a2a2a;
  --parchment:   #f5e6c8;
  --parchment-2: #ede0b8;
  --parchment-3: #e0cfa0;
  --crimson:     #c0392b;
  --gold:        #f0c040;
  --gold-dark:   #d4a520;
  --sky:         #4a90d9;
  --white:       #ffffff;
  --off-white:   #fffef5;
  --deep-dark:   #1a0a00;

  --font-title:  'Bangers', cursive;
  --font-body:   'Comic Neue', cursive;
  --font-hand:   'Caveat', cursive;
  --font-print:  'Patrick Hand', cursive;

  --panel-border:  5px solid var(--ink);
  --panel-shadow:  7px 7px 0 var(--ink);
  --bubble-border: 3px solid var(--ink);

  --flip-dur:    900ms;
  --flip-half:   450ms;
  --flip-ease:   cubic-bezier(0.645, 0.045, 0.355, 1.000);
}

/* ----------------------------------------------------------------
   2. RESET & GLOBAL
   ---------------------------------------------------------------- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  /* No min-width — comic scales to any viewport (PDF-viewer model) */
  background: #180800;
  color: var(--ink);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  touch-action: pan-x pan-y;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  outline: none;
  background: none;
}

button:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 2px;
}

img {
  display: block;
  max-width: 100%;
}

/* ----------------------------------------------------------------
   3. LOADING OVERLAY
   ---------------------------------------------------------------- */
#loading-overlay {
  position: fixed;
  inset: 0;
  background: #180800;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.6s ease, visibility 0.6s ease;
}

#loading-overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.loader-inner {
  text-align: center;
}

/* Animated book */
.loader-book {
  width: 60px;
  height: 45px;
  position: relative;
  margin: 0 auto 24px;
}

.loader-page {
  position: absolute;
  bottom: 0;
  width: 28px;
  height: 40px;
  background: var(--parchment);
  border: 2px solid var(--gold);
  transform-origin: left bottom;
  animation: bookFlip 1.5s ease-in-out infinite;
}

.loader-page:nth-child(1) { left: 2px; animation-delay: 0s; }
.loader-page:nth-child(2) { left: 16px; animation-delay: 0.15s; }
.loader-page:nth-child(3) { left: 30px; animation-delay: 0.3s; }

@keyframes bookFlip {
  0%, 100% { transform: rotateY(0deg); opacity: 0.4; }
  50%       { transform: rotateY(-60deg); opacity: 1; }
}

.loader-text {
  color: var(--parchment);
  font-family: var(--font-hand);
  font-size: 1.4rem;
  opacity: 0.85;
  animation: textPulse 2s ease-in-out infinite;
}

@keyframes textPulse {
  0%, 100% { opacity: 0.6; }
  50%       { opacity: 1; }
}

/* ----------------------------------------------------------------
   4. CONFETTI CANVAS
   ---------------------------------------------------------------- */
#confetti-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 800;
}

/* ----------------------------------------------------------------
   5. COMIC STAGE (MAIN CONTAINER)
   ---------------------------------------------------------------- */
#comic-stage {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: radial-gradient(ellipse at 50% 40%, #2a1200 0%, #160900 60%, #0d0400 100%);
}

/* ----------------------------------------------------------------
   6. BOOK WRAPPER (3D PERSPECTIVE CONTAINER)
   ---------------------------------------------------------------- */
#book-wrapper {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  overflow: hidden;
}

/* ----------------------------------------------------------------
   7. PAGE LAYERS
   ---------------------------------------------------------------- */
/* Pages: base overflow is hidden; scroll enabled per page-type where needed */
.page-layer {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  overflow: hidden;
  background: transparent;
  will-change: transform;
}

/* Paper texture — applied as a sibling .page-texture div instead of ::before
   to avoid stacking context issues */
.page-texture {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='300' height='300' filter='url(%23n)' opacity='0.03'/%3E%3C/svg%3E");
  mix-blend-mode: overlay;
  opacity: 0.35;
}

#page-back {
  z-index: 1;
  background: transparent;
}

#page-front {
  z-index: 2;
  transform-origin: center center;
  box-shadow: 8px 0 40px rgba(0,0,0,0.35);
}

/* ----------------------------------------------------------------
   8. FOLD EDGE LIGHT (slide mode — full-width shimmer)
   ---------------------------------------------------------------- */
#fold-light {
  position: absolute;
  top: 0;
  left: -20%;
  width: 40%;
  height: 100%;
  z-index: 500;
  pointer-events: none;
  opacity: 0;
}

/* ================================================================
   9. PANEL SYSTEM — Absolute-positioned clip-path polygons
   ================================================================ */

/* Comic-book panels: rotated, skewed clip-path, thick ink border.
   JS sets transform (rotation), clip-path (polygon wobble), z-index per panel. */
.panel {
  position: absolute;
  overflow: hidden;
  background: #000;
  border: 3px solid var(--ink);
  filter: drop-shadow(3px 4px 8px rgba(0,0,0,0.3));
  transform-origin: center center;
  will-change: transform;
  transition: filter 0.3s ease;
}
.panel:hover {
  filter: drop-shadow(5px 7px 16px rgba(0,0,0,0.45));
}

.panel img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center center;
  display: block;
}

/* Caption bar — bottom of panel */
.panel-caption {
  position: absolute;
  bottom: 0;
  left: 0; right: 0;
  background: var(--ink);
  color: var(--gold);
  font-family: var(--font-title);
  font-size: 15px; /* fixed px — scales with zoom, not with viewport */
  font-weight: 400;
  padding: 6px 14px;
  z-index: 30;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  border-top: 2px solid var(--gold-dark);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Narration box — top of panel */
.panel-narration {
  position: absolute;
  top: 0;
  left: 0; right: 0;
  background: rgba(255,255,210,0.95);
  color: var(--ink);
  font-family: var(--font-hand);
  font-size: 15px; /* fixed px — scales with zoom, not with viewport */
  font-weight: 700;
  font-style: italic;
  padding: 6px 14px;
  z-index: 30;
  border-bottom: 2px solid var(--ink);
}

/* ================================================================
   10. COMIC WRAPPER + PAGE
   ================================================================ */

/* Comic page layer — scrolls when taller than viewport.
   Vertical centering handled by JS margin when content is short. */
.page-comic {
  overflow-x: hidden;
  overflow-y: auto;
  background: #000;
  display: block;
  padding: 0;
}

/* Comic wrapper — JS sets width/min-height inline.
   position:relative is the anchor for absolutely-placed panels + SVG overlay. */
.comic-wrapper {
  position: relative;
  background: #000;
  flex-shrink: 0;
}

.comic-wrapper::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: radial-gradient(circle, rgba(0,0,0,0.04) 1px, transparent 1px);
  background-size: 8px 8px;
  pointer-events: none;
  z-index: 0;
}

/* (legacy rows unused — kept here to avoid any residual render issues) */
.comic-row { display: none; }
.halftone-dots { display: none; }
.panel-inner { position: absolute; inset: 0; overflow: hidden; }



/* ================================================================
   11. SPEECH BUBBLES
   ================================================================ */
.bubble {
  position: absolute;
  z-index: 200;
  background: white;
  border: 3px solid var(--ink);
  border-radius: 16px;
  padding: 7px 13px;
  font-family: var(--font-body);
  font-size: 14px; /* fixed px — scales with zoom, not with viewport */
  font-weight: 700;
  line-height: 1.4;
  max-width: 72%;
  word-wrap: break-word;
  box-shadow: 2px 2px 0 var(--ink);
  animation: bubblePop 0.28s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;
  /* Reserve space below for the arr-down arrow (16px) */
  margin-bottom: 18px;
}

@keyframes bubblePop {
  from { opacity: 0; transform: scale(0.72); }
  to   { opacity: 1; transform: scale(1);    }
}

.bubble.shout {
  background: #fff7a0;
  border-radius: 4px;
  border-width: 3px;
  clip-path: polygon(3% 0%, 97% 0%, 100% 50%, 97% 100%, 3% 100%, 0% 50%);
  padding: 10px 20px;
}

.bubble.thought {
  border-radius: 28px;
  background: rgba(255,255,255,0.97);
  border-style: dashed;
}

/* ---- Oval ------------------------------------------------- */
.bubble.oval {
  border-radius: 999px;
  padding: 9px 22px;
  background: #e8f4ff;
  border-color: var(--ink);
}

/* ---- Cloud ----------------------------------------------- */
.bubble.cloud {
  background: white;
  border: none;
  padding: 18px 22px;
  clip-path: polygon(
    6% 48%, 9% 30%, 18% 16%, 28% 18%, 33% 8%,
    46% 2%, 58% 5%, 65% 16%, 75% 13%, 86% 22%,
    94% 35%, 95% 52%, 90% 66%,
    80% 76%, 64% 80%, 50% 82%, 36% 80%,
    20% 76%, 10% 66%
  );
  filter: drop-shadow(0 0 2px var(--ink)) drop-shadow(0 0 1.5px var(--ink));
  box-shadow: none;
}
.bubble.cloud::before,
.bubble.cloud::after { display: none; }

/* ---- Heart ----------------------------------------------- */
.bubble.heart {
  background: #ffcdd6;
  border-color: #cc005a;
  clip-path: polygon(
    50% 96%, 8%  55%, 2%  34%, 6%  16%,
    20% 6%,  36% 4%,  50% 18%,
    64% 4%,  80% 6%,  94% 16%,
    98% 34%, 92% 55%
  );
  padding: 22px 18px 30px;
  text-align: center;
  color: #7a0033;
  min-width: 90px;
  min-height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  box-shadow: none;
  filter: drop-shadow(1px 2px 0 #cc005a) drop-shadow(0 0 1.5px #cc005a);
}
.bubble.heart::before,
.bubble.heart::after { display: none; }

/* ---- Burst (spiky star) ---------------------------------- */
.bubble.burst {
  background: #fff176;
  border: none;
  box-shadow: none;
  clip-path: polygon(
    50% 0%,  60% 36%, 96% 8%,  68% 44%,
    100% 50%, 68% 56%, 96% 92%, 60% 64%,
    50% 100%, 40% 64%, 4%  92%, 32% 56%,
    0%  50%, 32% 44%, 4%  8%,  40% 36%
  );
  padding: 26px 20px;
  text-align: center;
  color: var(--ink);
  min-width: 90px;
  min-height: 90px;
  display: flex;
  align-items: center;
  justify-content: center;
  filter: drop-shadow(1px 2px 0 var(--ink));
}
.bubble.burst::before,
.bubble.burst::after { display: none; }

/* ============================================================
   Arrow tails — each arrow is OUTSIDE the bubble box.
   The ::before is the dark outline stroke;
   the ::after is the white fill on top.
   They sit at the EDGE of the bubble, not overlapping content.
   ============================================================ */

/* --- DOWN arrow (most common: bubble above speaker) --- */
.bubble.arr-down::before,
.bubble.arr-down::after {
  content: '';
  position: absolute;
  left: 22px;
  border-style: solid;
  border-left-color: transparent;
  border-right-color: transparent;
}
.bubble.arr-down::before {
  bottom: -17px;          /* outside the bubble */
  border-width: 17px 12px 0 12px;
  border-top-color: var(--ink);
}
.bubble.arr-down::after {
  bottom: -12px;          /* slightly inside to create fill */
  border-width: 13px 9px 0 9px;
  border-top-color: white;
}

/* --- UP arrow (bubble below speaker) --- */
.bubble.arr-up::before,
.bubble.arr-up::after {
  content: '';
  position: absolute;
  left: 22px;
  border-style: solid;
  border-left-color: transparent;
  border-right-color: transparent;
}
.bubble.arr-up::before {
  top: -17px;
  border-width: 0 12px 17px 12px;
  border-bottom-color: var(--ink);
}
.bubble.arr-up::after {
  top: -12px;
  border-width: 0 9px 13px 9px;
  border-bottom-color: white;
}

/* --- LEFT arrow (points left, tail on right side) --- */
.bubble.arr-left::before,
.bubble.arr-left::after {
  content: '';
  position: absolute;
  top: 14px;
  border-style: solid;
  border-top-color: transparent;
  border-bottom-color: transparent;
}
.bubble.arr-left::before {
  right: -17px;
  border-width: 10px 0 10px 17px;
  border-left-color: var(--ink);
}
.bubble.arr-left::after {
  right: -12px;
  border-width: 7px 0 7px 13px;
  border-left-color: white;
}

/* --- RIGHT arrow (points right, tail on left side) --- */
.bubble.arr-right::before,
.bubble.arr-right::after {
  content: '';
  position: absolute;
  top: 14px;
  border-style: solid;
  border-top-color: transparent;
  border-bottom-color: transparent;
}
.bubble.arr-right::before {
  left: -17px;
  border-width: 10px 17px 10px 0;
  border-right-color: var(--ink);
}
.bubble.arr-right::after {
  left: -12px;
  border-width: 7px 13px 7px 0;
  border-right-color: white;
}


/* ----------------------------------------------------------------
   11. COVER PAGE
   ---------------------------------------------------------------- */
.page-cover {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  overflow: hidden;
  background: #0d0d0d;
  padding-bottom: 60px;
}

.cover-bg {
  position: absolute;
  inset: 0;
  z-index: 1;
}

.cover-bg img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center center;
  filter: brightness(0.55) saturate(1.1);
}

.cover-gradient {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to bottom,
    rgba(0,0,0,0.2)  0%,
    rgba(0,0,0,0.05) 30%,
    rgba(0,0,0,0.55) 70%,
    rgba(0,0,0,0.92) 100%
  );
  z-index: 2;
}

.cover-frame {
  position: absolute;
  inset: 10px;
  border: 3px solid rgba(240,192,64,0.5);
  z-index: 8;
  pointer-events: none;
}

.cover-corner {
  position: absolute;
  width: 22px;
  height: 22px;
  border-color: var(--gold);
  border-style: solid;
  opacity: 0.7;
  z-index: 9;
}
.cTL { top: 6px;    left: 6px;    border-width: 3px 0 0 3px; }
.cTR { top: 6px;    right: 6px;   border-width: 3px 3px 0 0; }
.cBL { bottom: 6px; left: 6px;    border-width: 0 0 3px 3px; }
.cBR { bottom: 6px; right: 6px;   border-width: 0 3px 3px 0; }

.cover-content {
  position: relative;
  z-index: 10;
  text-align: center;
  padding: 20px;
  margin-top: 60px;
  animation: coverEntrance 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;
  animation-delay: 0.2s;
}

@keyframes coverEntrance {
  from { opacity: 0; transform: scale(0.92) translateY(30px); }
  to   { opacity: 1; transform: scale(1)    translateY(0);    }
}

.cover-badge {
  display: inline-block;
  background: var(--crimson);
  color: white;
  font-family: var(--font-title);
  font-size: clamp(0.85rem, 1.8vw, 1.2rem);
  letter-spacing: 0.2em;
  padding: 5px 18px;
  margin-bottom: 18px;
  transform: rotate(-1.5deg);
  box-shadow: 3px 3px 0 rgba(0,0,0,0.45);
}

.cover-title {
  font-family: var(--font-title);
  font-size: clamp(4rem, 13vw, 10rem);
  color: var(--gold);
  line-height: 0.88;
  letter-spacing: 0.04em;
  text-shadow:
    4px 4px 0 var(--crimson),
    8px 8px 0 rgba(0,0,0,0.35);
  margin-bottom: 8px;
}

.cover-subtitle {
  font-family: var(--font-title);
  font-size: clamp(1.2rem, 3.5vw, 2.2rem);
  color: white;
  letter-spacing: 0.18em;
  text-shadow: 2px 2px 0 var(--ink);
  margin-bottom: 12px;
}

.cover-author {
  font-family: var(--font-hand);
  font-size: clamp(0.9rem, 1.8vw, 1.3rem);
  color: rgba(255,255,255,0.65);
  margin-bottom: 48px;
}

.cover-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: var(--gold);
  color: var(--ink);
  border: 4px solid var(--ink);
  font-family: var(--font-title);
  font-size: clamp(1.2rem, 3vw, 1.9rem);
  letter-spacing: 0.12em;
  padding: 13px 40px;
  box-shadow: 6px 6px 0 var(--ink);
  transform: rotate(1deg);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.cover-btn:hover {
  transform: rotate(1deg) translate(-2px, -2px);
  box-shadow: 8px 8px 0 var(--ink);
}
.cover-btn:active {
  transform: rotate(1deg) translate(3px, 3px);
  box-shadow: 3px 3px 0 var(--ink);
}

/* ----------------------------------------------------------------
   12. LETTER PAGE
   ---------------------------------------------------------------- */
.page-letter {
  display: flex;
  align-items: center;
  justify-content: center;
  overflow-y: auto;            /* allow letter to scroll if very long */
  background: #f0e8d0;
  background-image: repeating-linear-gradient(
    transparent,
    transparent 31px,
    #b5c9d8 31px,
    #b5c9d8 32px
  );
  background-size: 100% 32px;
  background-position: 0 28px;
}

.letter-paper {
  position: relative;
  z-index: 10;
  width: min(700px, 92vw);
  max-height: 88vh;
  background: var(--off-white);
  padding: 48px 55px 48px 90px;
  box-shadow:
    4px 6px 20px rgba(0,0,0,0.18),
    7px 7px 0 var(--ink);
  overflow: hidden;
  animation: paperSlide 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;
  animation-delay: 0.1s;
}

@keyframes paperSlide {
  from { opacity: 0; transform: translateY(40px) rotate(-1deg); }
  to   { opacity: 1; transform: translateY(0) rotate(0deg); }
}

/* Red margin line */
.letter-paper::before {
  content: '';
  position: absolute;
  top: 0; bottom: 0;
  left: 70px;
  width: 2px;
  background: rgba(220, 80, 80, 0.35);
}

.letter-holes {
  position: absolute;
  left: 22px;
  top: 0; bottom: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  padding: 40px 0;
}

.letter-hole {
  width: 18px;
  height: 18px;
  background: #f0e8d0;
  border-radius: 50%;
  box-shadow: inset 0 2px 5px rgba(0,0,0,0.3);
}

.letter-from {
  font-family: var(--font-hand);
  font-size: clamp(1.2rem, 2.2vw, 1.6rem);
  color: var(--crimson);
  margin-bottom: 22px;
  font-weight: 600;
}

.letter-body {
  min-height: 200px;
}

.letter-line {
  display: block;
  font-family: var(--font-hand);
  font-size: clamp(1.25rem, 2.4vw, 1.75rem);
  line-height: 1.5;
  color: #2c3e50;
  min-height: 1.5em;
}

.letter-cursor {
  display: inline-block;
  width: 2px;
  height: 1.2em;
  background: var(--ink);
  vertical-align: middle;
  animation: cursorBlink 0.7s step-end infinite;
}

@keyframes cursorBlink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}

.letter-signature {
  font-family: var(--font-hand);
  font-size: clamp(1.5rem, 3vw, 2.1rem);
  color: var(--crimson);
  margin-top: 28px;
  font-weight: 700;
  opacity: 0;
  transform: translateX(-10px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

.letter-signature.show {
  opacity: 1;
  transform: translateX(0);
}

/* ----------------------------------------------------------------
   13. BIRTHDAY PAGE
   ---------------------------------------------------------------- */
.page-birthday {
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #a8404a 0%, #a0527a 35%, #8a6040 65%, #3a5a8a 100%);
}

.birthday-balloons {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 1;
}

.balloon {
  position: absolute;
  border-radius: 50% 50% 52% 52% / 45% 45% 55% 55%;
  bottom: -120px;
  animation: riseUp linear infinite;
}

.balloon::after {
  content: '';
  position: absolute;
  bottom: -25px;
  left: 50%;
  transform: translateX(-50%);
  width: 1px;
  height: 28px;
  background: rgba(0,0,0,0.4);
}

@keyframes riseUp {
  0%   { transform: translateY(0) translateX(0); opacity: 1; }
  25%  { transform: translateY(-25vh) translateX(12px); }
  50%  { transform: translateY(-50vh) translateX(-8px); }
  75%  { transform: translateY(-80vh) translateX(10px); opacity: 0.9; }
  100% { transform: translateY(-115vh) translateX(0); opacity: 0; }
}

.birthday-content {
  position: relative;
  z-index: 10;
  text-align: center;
  padding: 20px;
  animation: bdEntrance 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;
  animation-delay: 0.2s;
}

@keyframes bdEntrance {
  from { opacity: 0; transform: scale(0.85) translateY(30px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.bd-emoji {
  font-size: clamp(3rem, 9vw, 6rem);
  display: block;
  margin-bottom: 16px;
  animation: wobble 2.5s ease-in-out infinite;
}

@keyframes wobble {
  0%,100% { transform: translateY(0) rotate(-6deg); }
  50%      { transform: translateY(-22px) rotate(6deg); }
}

.bd-title {
  font-family: var(--font-title);
  font-size: clamp(3.5rem, 12vw, 8rem);
  color: var(--gold);
  text-shadow:
    3px 3px 0 var(--crimson),
    6px 6px 0 rgba(0,0,0,0.18);
  line-height: 0.9;
  margin-bottom: 20px;
  letter-spacing: 0.04em;
}

.bd-tagline {
  font-family: var(--font-hand);
  font-size: clamp(1.1rem, 2.8vw, 1.9rem);
  color: var(--ink-light);
  margin-bottom: 36px;
  font-weight: 600;
}

.bd-date-box {
  display: inline-block;
  background: var(--ink);
  color: var(--gold);
  font-family: var(--font-title);
  font-size: clamp(0.9rem, 2.2vw, 1.5rem);
  padding: 8px 28px;
  letter-spacing: 0.2em;
  transform: rotate(-1.5deg);
  box-shadow: 4px 4px 0 rgba(0,0,0,0.3);
}

.bd-hearts {
  display: flex;
  justify-content: center;
  gap: 8px;
  font-size: clamp(1.5rem, 4vw, 2.5rem);
  margin-top: 30px;
}

.bd-hearts span {
  animation: heartBeat 1.2s ease-in-out infinite;
}
.bd-hearts span:nth-child(2) { animation-delay: 0.15s; }
.bd-hearts span:nth-child(3) { animation-delay: 0.3s; }
.bd-hearts span:nth-child(4) { animation-delay: 0.45s; }
.bd-hearts span:nth-child(5) { animation-delay: 0.6s; }

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

/* ----------------------------------------------------------------
   14. TRANSITION PAGE
   ---------------------------------------------------------------- */
.page-transition {
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: #0d0d0d;
}

.trans-rays {
  position: absolute;
  inset: -50%;
  z-index: 1;
  background: repeating-conic-gradient(
    rgba(240,192,64,0.04) 0deg,
    rgba(240,192,64,0)    8deg
  );
  animation: spinRays 30s linear infinite;
}

@keyframes spinRays {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

.trans-content {
  position: relative;
  z-index: 10;
  text-align: center;
  padding: 20px;
}

.trans-main {
  font-family: var(--font-title);
  font-size: clamp(3.5rem, 8vw, 8.5rem);
  color: var(--gold);
  letter-spacing: 0.08em;
  line-height: 1;
  text-shadow: 0 0 50px rgba(240,192,64,0.55), 4px 4px 0 rgba(0,0,0,0.3);
  animation: goldGlow 3s ease-in-out infinite;
}

@keyframes goldGlow {
  0%,100% { text-shadow: 0 0 40px rgba(240,192,64,0.45), 4px 4px 0 rgba(0,0,0,0.3); }
  50%      { text-shadow: 0 0 90px rgba(240,192,64,0.85), 4px 4px 0 rgba(0,0,0,0.3); }
}

.trans-sub {
  font-family: var(--font-hand);
  font-size: clamp(1.1rem, 2.8vw, 2rem);
  color: rgba(255,255,255,0.55);
  margin-top: 24px;
  animation: arrowPulse 1.8s ease-in-out infinite;
}

@keyframes arrowPulse {
  0%,100% { transform: translateX(0); opacity: 0.55; }
  50%      { transform: translateX(12px); opacity: 1; }
}

/* (page-comic styles are in section 10 above) */

/* ----------------------------------------------------------------
   16. PROPOSAL PAGE
   ---------------------------------------------------------------- */
.page-proposal {
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: #0d0010;
}

.proposal-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  background: radial-gradient(ellipse at 50% 50%, #1e0035 0%, #0d000f 60%, #000 100%);
}

.proposal-stars {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
}

.p-star {
  position: absolute;
  width: 2px;
  height: 2px;
  background: white;
  border-radius: 50%;
  animation: twinkle ease-in-out infinite;
}

@keyframes twinkle {
  0%,100% { opacity: 0.15; transform: scale(1); }
  50%      { opacity: 1;    transform: scale(1.6); }
}

.proposal-content {
  position: relative;
  z-index: 10;
  text-align: center;
  padding: 40px 20px;
  max-width: min(820px, 90vw);
}

.prop-line {
  display: block;
  font-family: var(--font-hand);
  font-size: clamp(1.2rem, 2.8vw, 2rem);
  color: transparent;
  line-height: 1.9;
  margin-bottom: 8px;
  transition: color 0.9s ease;
}

.prop-line.lit {
  color: rgba(255,255,255,0.92);
}

.prop-final {
  font-family: var(--font-title);
  font-size: clamp(2.2rem, 6.5vw, 4.5rem);
  color: var(--gold);
  letter-spacing: 0.06em;
  margin-top: 32px;
  opacity: 0;
  transform: scale(0.75);
  transition: opacity 0.9s ease, transform 0.9s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.prop-final.lit {
  opacity: 1;
  transform: scale(1);
}

.prop-ring {
  font-size: clamp(2.5rem, 7vw, 5rem);
  display: block;
  margin-top: 18px;
  animation: ringPulse 2s ease-in-out infinite;
}

@keyframes ringPulse {
  0%,100% { transform: scale(1) rotate(-10deg); }
  50%      { transform: scale(1.18) rotate(12deg); }
}

/* ----------------------------------------------------------------
   17. YES/NO PAGE
   ---------------------------------------------------------------- */
/* ================================================================
   YES / NO PAGE  — 3-phase redesign
   Phase 1 : full-viewport intro video (autoplay)
   Phase 2 : question + YES / NO buttons
   Phase 3 : small second video + "Click to open the box" button
   ================================================================ */
.page-yesno {
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: #000;
}

/* Black fade overlay — sits on top of everything during transitions */
.yn-overlay {
  position: absolute;
  inset: 0;
  background: #000;
  opacity: 0;
  z-index: 500;
  pointer-events: none;
  transition: opacity 0.8s ease;
}
.yn-overlay.active {
  opacity: 1;
  pointer-events: all;
}

/* Generic phase container — fills the whole page-yesno absolutely */
.yn-phase {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

/* ── Phase 1: Intro video ── */
.yn-vid1 {
  height: 100vh;
  width: auto;
  max-width: 100%;
  object-fit: contain;
  display: block;
}

/* ── Phase 2: Question ── */
.yn-phase-question {
  background: #000;
  padding: 40px 20px;
}

.yesno-q {
  font-family: var(--font-title);
  font-size: 42px;
  color: var(--gold);
  margin-bottom: 60px;
  text-align: center;
  text-shadow: 3px 3px 0 var(--crimson);
  animation: questionWobble 4s ease-in-out infinite;
}

@keyframes questionWobble {
  0%,100% { transform: rotate(0deg); }
  25%      { transform: rotate(-0.5deg); }
  75%      { transform: rotate(0.5deg); }
}

.yn-btns {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 50px;
  flex-wrap: wrap;
}

.btn-yes {
  font-family: var(--font-title);
  font-size: 28px;
  background: #27ae60;
  color: white;
  border: 4px solid var(--ink);
  padding: 16px 52px;
  box-shadow: 6px 6px 0 var(--ink);
  letter-spacing: 0.1em;
  transform: rotate(-1.5deg);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.btn-yes:hover {
  background: #2ecc71;
  transform: rotate(-1.5deg) translate(-2px, -2px);
  box-shadow: 8px 8px 0 var(--ink);
}
.btn-yes:active {
  transform: rotate(-1.5deg) translate(3px, 3px);
  box-shadow: 3px 3px 0 var(--ink);
}

.btn-no {
  font-family: var(--font-title);
  font-size: 22px;
  background: var(--crimson);
  color: white;
  border: 4px solid var(--ink);
  padding: 14px 38px;
  box-shadow: 5px 5px 0 var(--ink);
  letter-spacing: 0.08em;
  transform: rotate(2deg);
  cursor: pointer;
  transition: opacity 0.3s ease;
}
.btn-no.frozen {
  opacity: 0.4;
  cursor: not-allowed;
  filter: grayscale(0.6);
}

/* ── Phase 3: Second video + open-box button ── */
.yn-phase-reveal {
  background: #000;
}
.yn-vid2 {
  width: 420px;
  max-width: 80vw;
  border: 4px solid var(--gold);
  box-shadow: 0 0 40px rgba(255,215,0,0.25);
  display: block;
}
.btn-open-box {
  position: absolute;
  bottom: 48px;
  left: 50%;
  transform: translateX(-50%) rotate(-1deg);
  font-family: var(--font-title);
  font-size: 22px;
  background: var(--gold);
  color: var(--ink);
  border: 4px solid var(--ink);
  padding: 16px 48px;
  box-shadow: 6px 6px 0 var(--ink);
  cursor: pointer;
  letter-spacing: 0.08em;
  transition: box-shadow 0.15s ease;
}
.btn-open-box:hover {
  transform: translateX(-50%) rotate(-1deg);
  box-shadow: 8px 8px 0 var(--ink);
}
.btn-open-box:active {
  transform: translateX(-50%) rotate(-1deg);
  box-shadow: 3px 3px 0 var(--ink);
}

/* ── Phase 4: pic slides ── */
.yn-phase-pics {
  background: #000;
}

.yn-pic-slide {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity 0.9s ease;
  pointer-events: none;
  overflow: hidden;
}
.yn-pic-slide.yn-pic-active {
  opacity: 1;
  pointer-events: auto;
}

.yn-pic-img {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  height: 100%;
  width: auto;
  display: block;
}

/* Bubble overlaid on the pic — positioned bottom-center */
.yn-pic-slide .bubble {
  position: absolute;
  bottom: 50%;
  left: 50%;
  transform: translateX(-50%);
  font-size: clamp(15px, 2.5vw, 20px);
  max-width: min(380px, 85vw);
  text-align: center;
  z-index: 10;
  white-space: normal;
}

.yn-continue-btn {
  position: absolute;
  bottom: 48px;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-title);
  font-size: 22px;
  background: var(--gold);
  color: var(--ink);
  border: 4px solid var(--ink);
  padding: 14px 44px;
  box-shadow: 6px 6px 0 var(--ink);
  cursor: pointer;
  letter-spacing: 0.08em;
  display: none;
  align-items: center;
  gap: 8px;
  animation: bubblePop 0.4s cubic-bezier(0.175,0.885,0.32,1.275) both;
  z-index: 10;
}
.yn-continue-btn:hover {
  transform: translateX(-50%) translate(-2px,-2px);
  box-shadow: 8px 8px 0 var(--ink);
}

/* ── Escape tooltip — comic speech bubble ── */
.yn-escape-tooltip {
  position: fixed;
  background: white;
  border: 3px solid var(--ink);
  border-radius: 16px;
  padding: 10px 18px;
  font-family: var(--font-body);
  font-size: 15px;
  font-weight: 700;
  line-height: 1.4;
  max-width: 260px;
  text-align: center;
  z-index: 9999;
  box-shadow: 3px 3px 0 var(--ink);
  pointer-events: none;
  opacity: 0;
  transform: scale(0.75);
  transition: opacity 0.25s ease, transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275),
              left 0.28s cubic-bezier(0.175, 0.885, 0.32, 1.275),
              top  0.28s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.yn-escape-tooltip.show {
  opacity: 1;
  transform: scale(1);
}


/* Hide nav prev/next buttons on yesno page */
.yn-hide-nav {
  display: none !important;
}

/* ----------------------------------------------------------------
   18. RING BOX PAGE
   ---------------------------------------------------------------- */
.page-ringbox {
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: #100020;
}

.ringbox-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  background: radial-gradient(ellipse at 50% 30%, #2a1060 0%, #150030 50%, #080010 100%);
}

.ringbox-spotlight {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: clamp(200px, 50vw, 400px);
  height: 100%;
  background: radial-gradient(ellipse at top, rgba(200,180,255,0.22) 0%, transparent 65%);
  pointer-events: none;
  z-index: 2;
}

.ringbox-content {
  position: relative;
  z-index: 10;
  text-align: center;
  padding: 20px;
}

.ringbox-wrap {
  position: relative;
  width: clamp(180px, 38vw, 340px);
  height: clamp(180px, 38vw, 340px);
  margin: 0 auto 24px;
  cursor: pointer;
  transition: transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.ringbox-wrap:hover {
  transform: scale(1.04);
}

.ringbox-wrap img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 20px 45px rgba(0,0,0,0.6));
  transition: filter 0.6s ease, transform 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.ringbox-wrap.opened img {
  transform: scale(1.08);
  filter: drop-shadow(0 0 50px rgba(200,160,255,0.7));
}

.ringbox-emoji {
  font-size: clamp(6rem, 16vw, 12rem);
  display: block;
  transition: filter 0.6s ease, transform 0.6s ease;
  cursor: pointer;
}

.ringbox-emoji.opened {
  transform: scale(1.15) rotate(15deg);
  filter: drop-shadow(0 0 30px rgba(255,220,100,0.8));
}

.ringbox-hint {
  font-family: var(--font-hand);
  color: rgba(255,255,255,0.5);
  font-size: clamp(0.9rem, 1.8vw, 1.3rem);
  margin-bottom: 20px;
  animation: hintPulse 2.5s ease-in-out infinite;
}

@keyframes hintPulse {
  0%,100% { opacity: 0.5; }
  50%      { opacity: 0.9; }
}

.ringbox-dialogue {
  font-family: var(--font-hand);
  font-size: clamp(1rem, 2.2vw, 1.5rem);
  color: white;
  margin-bottom: 16px;
  max-width: min(420px, 90vw);
  margin-left: auto;
  margin-right: auto;
  opacity: 0;
  transform: translateY(25px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}

.ringbox-dialogue.show {
  opacity: 1;
  transform: translateY(0);
}

.ringbox-reply {
  font-family: var(--font-hand);
  font-size: clamp(0.95rem, 2vw, 1.35rem);
  color: var(--gold);
  max-width: min(420px, 90vw);
  margin-left: auto;
  margin-right: auto;
  opacity: 0;
  transform: translateY(25px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}

.ringbox-reply.show {
  opacity: 1;
  transform: translateY(0);
}

/* ----------------------------------------------------------------
   19. ENDING PAGE
   ---------------------------------------------------------------- */
.page-ending {
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: #000;
}

.ending-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
}

.ending-bg img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  filter: brightness(0.38) saturate(1.2);
}

.ending-vignette {
  position: absolute;
  inset: 0;
  z-index: 1;
  background: linear-gradient(
    to top,
    rgba(0,0,0,0.9)  0%,
    rgba(0,0,0,0.55) 40%,
    rgba(0,0,0,0.25) 75%,
    rgba(0,0,0,0.7)  100%
  );
}

.ending-content {
  position: relative;
  z-index: 10;
  text-align: center;
  padding: 20px;
  animation: endingRise 1s ease both;
  animation-delay: 0.3s;
}

@keyframes endingRise {
  from { opacity: 0; transform: translateY(40px); }
  to   { opacity: 1; transform: translateY(0); }
}

.ending-main {
  font-family: var(--font-title);
  font-size: clamp(3rem, 11vw, 8rem);
  color: var(--gold);
  letter-spacing: 0.04em;
  text-shadow:
    4px 4px 0 var(--crimson),
    0 0 70px rgba(240,192,64,0.45);
  margin-bottom: 20px;
}

.ending-sub {
  font-family: var(--font-hand);
  font-size: clamp(1rem, 2.5vw, 1.7rem);
  color: rgba(255,255,255,0.65);
  font-style: italic;
  margin-bottom: 40px;
}

.ending-hearts {
  display: flex;
  justify-content: center;
  gap: 12px;
  font-size: clamp(1.8rem, 4.5vw, 3rem);
}

.ending-hearts span {
  animation: endHeart 1.5s ease-in-out infinite;
}
.ending-hearts span:nth-child(2) { animation-delay: 0.2s; }
.ending-hearts span:nth-child(3) { animation-delay: 0.4s; }
.ending-hearts span:nth-child(4) { animation-delay: 0.6s; }

@keyframes endHeart {
  0%,100% { transform: translateY(0) scale(1); }
  50%      { transform: translateY(-12px) scale(1.25); }
}

.ending-restart {
  margin-top: 36px;
  font-family: var(--font-title);
  font-size: 20px;
  background: transparent;
  color: rgba(255,255,255,0.7);
  border: 3px solid rgba(255,255,255,0.4);
  border-radius: 50px;
  padding: 12px 36px;
  cursor: pointer;
  letter-spacing: 0.08em;
  transition: color 0.2s ease, border-color 0.2s ease, transform 0.15s ease;
}
.ending-restart:hover {
  color: var(--gold);
  border-color: var(--gold);
  transform: scale(1.05);
}

/* ----------------------------------------------------------------
   20. NAVIGATION BUTTONS
   ---------------------------------------------------------------- */
.nav-btn {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  z-index: 600;
  width: clamp(44px, 6vw, 58px);
  height: clamp(44px, 6vw, 58px);
  background: rgba(13,13,13,0.72);
  border: 2px solid rgba(255,255,255,0.18);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  backdrop-filter: blur(6px);
}

.nav-btn--prev { left: 10px; }
.nav-btn--next { right: 10px; }

.nav-inner {
  width: 55%;
  height: 55%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.nav-inner svg {
  width: 100%;
  height: 100%;
}

.nav-btn:hover {
  background: rgba(240,192,64,0.92);
  border-color: var(--ink);
  color: var(--ink);
  transform: translateY(-50%) scale(1.06);
}

.nav-btn:active {
  transform: translateY(-50%) scale(0.94);
}

.nav-btn:disabled {
  opacity: 0;
  pointer-events: none;
}

/* ----------------------------------------------------------------
   21. PAGE INDICATOR
   ---------------------------------------------------------------- */
/* Comic-book star-burst page number */
#page-indicator {
  position: fixed;
  bottom: 35px;
  right: 0%;
  transform: translateX(-50%) rotate(-3deg);
  z-index: 600;
  background: var(--gold);
  color: var(--ink);
  font-family: var(--font-title);
  font-size: 1.05rem;
  font-weight: 900;
  padding: 10px 20px;
  letter-spacing: 0.08em;
  white-space: nowrap;
  border: 3px solid var(--ink);
  box-shadow: 3px 3px 0 var(--ink);
  /* 12-point star burst via clip-path */
  clip-path: polygon(
    50% 0%, 63% 10%, 78% 2%, 80% 18%, 98% 20%, 90% 35%,
    100% 50%, 90% 65%, 98% 80%, 80% 82%, 78% 98%, 63% 90%,
    50% 100%, 37% 90%, 22% 98%, 20% 82%, 2% 80%, 10% 65%,
    0% 50%, 10% 35%, 2% 20%, 20% 18%, 22% 2%, 37% 10%
  );
}

.pg-sep {
  opacity: 0.5;
  margin: 0 2px;
  font-weight: 400;
}

/* ----------------------------------------------------------------
   22. RESPONSIVE TWEAKS
   ---------------------------------------------------------------- */
@media (max-width: 600px) {
  .letter-paper {
    padding: 36px 24px 36px 56px;
  }
  .letter-paper::before {
    left: 44px;
  }
  .letter-holes {
    left: 14px;
  }
  .yn-btns {
    flex-direction: column;
    gap: 24px;
  }
  .nav-btn--prev { left: 4px; }
  .nav-btn--next { right: 4px; }
}

/* ----------------------------------------------------------------
   23. PAGE FLIP GLOW UTILITY
   ---------------------------------------------------------------- */
.page-layer {
  transition: filter 0ms linear;
}
