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

:root {
  --ease: cubic-bezier(0.2, 0.6, 0.2, 1);
  --font-display: "Great Vibes", cursive;
  --rose: #b76e79;
  --pink: #ffd1dc;
  --gold: #d4af37;
  --ivory: #fffdf8;
}

body,
html {
  margin: 0;
  padding: 0;
  width: 100vw;
  height: 100vh;
  overflow: hidden; /* Prevent scrolling */
  background-color: #030308; /* Deep space fallback color */
  font-family: sans-serif;
}

#webgl-canvas {
  display: block;
  width: 100%;
  height: 100%;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1;
}

/* Intro Overlay Styles */
#intro-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: opacity 1.5s ease-in-out;
  color: #fff;
  font-family: "Comic Sans MS", cursive, sans-serif;
}

#intro-overlay::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at center, #2a1f1f 0%, #030308 60%);
  z-index: -1;
  transition: opacity 2s ease-in-out;
}

#intro-overlay.fade-bg::before {
  opacity: 0;
}

#intro-overlay.fade-out {
  opacity: 0;
  pointer-events: none;
}

#intro-instruction {
  position: absolute;
  top: 5%;
  font-size: 3rem;
  margin-bottom: 1;
  max-height: 200px;
  overflow: hidden;
  transition:
    opacity 0.5s ease,
    max-height 0.5s ease,
    margin 0.5s ease;
}

#countdown {
  position: absolute;
  top: calc(10% + 5rem);
  font-size: 4rem;
  font-weight: bold;
  margin-bottom: 0;
  max-height: 200px;
  overflow: hidden;
  transition:
    opacity 0.5s ease,
    max-height 0.5s ease,
    margin 0.5s ease;
}

/* Candle Styles */
.candle-container {
  position: relative;
  width: 60px;
  height: 200px;
  margin-bottom: 40px;
  transition: opacity 0.5s ease;
  filter: drop-shadow(0 0 50px rgba(255, 165, 0, 0.6));
}

.candle-container.hidden {
  opacity: 0;
  pointer-events: none;
}

.wax {
  position: absolute;
  bottom: 0;
  left: 10px;
  width: 40px;
  height: 150px;
  background: repeating-linear-gradient(
    -45deg,
    #ff99cc,
    #ff99cc 10px,
    #ffffff 10px,
    #ffffff 20px
  ); /* Pink and white stripes */
  border: 2px solid #000;
  border-radius: 5px;
}

.wick {
  position: absolute;
  bottom: 150px;
  left: 28px;
  width: 4px;
  height: 15px;
  background-color: #333;
}

.flame {
  position: absolute;
  bottom: 165px;
  left: 20px;
  width: 20px;
  height: 35px;
  background: #ffcc00;
  border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
  box-shadow:
    0 0 20px #ff9900,
    0 0 40px #ff5500;
  animation: flicker 0.1s infinite alternate;
  transform-origin: bottom center;
}

@keyframes flicker {
  0% {
    transform: scale(1) rotate(-2deg);
    box-shadow:
      0 0 20px #ff9900,
      0 0 40px #ff5500;
  }
  100% {
    transform: scale(1.1) rotate(2deg);
    box-shadow:
      0 0 25px #ffaa00,
      0 0 50px #ff6600;
  }
}

#candle-prompt {
  font-size: 2.2rem;
  font-family: "Comic Sans MS", cursive, sans-serif;
  font-weight: bold;
  color: #ff4d94;
  text-shadow:
    0 0 8px #ff99cc,
    0 0 20px #ff4d94;
  margin-bottom: 24px;
  opacity: 0;
  transform: translateY(-10px);
  transition:
    opacity 0.8s ease,
    transform 0.8s ease;
  animation: none;
  letter-spacing: 3px;
}

#candle-prompt.visible {
  opacity: 1;
  transform: translateY(0);
  animation: shimmer-text 2s ease-in-out infinite alternate;
}

@keyframes shimmer-text {
  0% {
    text-shadow:
      0 0 8px #ff99cc,
      0 0 20px #ff4d94;
    color: #ff4d94;
  }
  50% {
    text-shadow:
      0 0 16px #ffb347,
      0 0 35px #ff6600;
    color: #ff9933;
  }
  100% {
    text-shadow:
      0 0 8px #ff99cc,
      0 0 20px #ff4d94;
    color: #ff4d94;
  }
}

#blow-candle-btn {
  display: none;
  margin-bottom: 30px;
  padding: 16px 40px;
  font-size: 1.6rem;
  font-family: "Comic Sans MS", cursive, sans-serif;
  font-weight: bold;
  color: #fff;
  background: linear-gradient(135deg, #ff6b9d, #ff4757);
  border: none;
  border-radius: 50px;
  cursor: pointer;
  box-shadow:
    0 0 15px #ff6b9d,
    0 0 30px #ff475755;
  animation: pulse-btn 1.2s ease-in-out infinite;
  transition:
    transform 0.15s ease,
    box-shadow 0.15s ease;
}

#blow-candle-btn:hover {
  transform: scale(1.07);
  box-shadow:
    0 0 25px #ff6b9d,
    0 0 50px #ff4757;
}

#blow-candle-btn:active {
  transform: scale(0.96);
}

#blow-candle-btn.visible {
  display: inline-block;
}

@keyframes pulse-btn {
  0%,
  100% {
    box-shadow:
      0 0 15px #ff6b9d,
      0 0 30px #ff475755;
  }
  50% {
    box-shadow:
      0 0 30px #ff6b9d,
      0 0 60px #ff4757aa;
  }
}

#happy-birthday-text {
  position: absolute;
  font-family: "Great Vibes", cursive;
  font-size: 4.5rem;
  line-height: 1.2;
  color: #fff2cc; /* Soft glowing gold/white */
  text-shadow:
    0 0 10px #ffaa00,
    0 0 20px #ffaa00,
    0 0 40px #ff5500;
  opacity: 0;
  transform: scale(0.8);
  letter-spacing: 0px;
  text-align: center;
  pointer-events: none;
}

#happy-birthday-text.show {
  animation: glow-expand 4s ease-out forwards;
}

@keyframes glow-expand {
  0% {
    opacity: 0;
    transform: scale(0.8);
    letter-spacing: 0px;
    text-shadow:
      0 0 5px #ffaa00,
      0 0 10px #ffaa00;
  }
  20% {
    opacity: 1;
  }
  100% {
    opacity: 1;
    transform: scale(1);
    letter-spacing: 5px;
    text-shadow:
      0 0 15px #ffaa00,
      0 0 30px #ffaa00,
      0 0 50px #ff5500;
  }
}

/* --- SCROLLABLE FOREGROUND --- */
#scroll-wrapper {
  position: absolute;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  overflow-y: scroll;
  overflow-x: hidden;
  z-index: 50;
  pointer-events: none; /* Initially locked */
  opacity: 0;
  transition: opacity 1.5s ease-in-out;
}

#scroll-wrapper.visible {
  opacity: 1;
  pointer-events: auto; /* Enables scrolling and clicking after intros */
}

/* Hide scrollbar for Chrome, Safari and Opera */
#scroll-wrapper::-webkit-scrollbar {
  display: none;
}
/* Hide scrollbar for IE, Edge and Firefox */
#scroll-wrapper {
  -ms-overflow-style: none; /* IE and Edge */
  scrollbar-width: none; /* Firefox */
}

.scroll-spacer {
  height: 100vh;
  width: 100%;
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 50px;
}

.scroll-indicator {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.scroll-indicator span {
  display: block;
  width: 26px;
  height: 44px;
  border: 1px solid rgba(255, 242, 204, 0.5);
  border-radius: 999px;
  position: relative;
}

.scroll-indicator span::after {
  content: "";
  position: absolute;
  width: 4px;
  height: 8px;
  background: #fff2cc;
  border-radius: 4px;
  left: 50%;
  transform: translateX(-50%);
  top: 8px;
  animation: scrollDot 2s ease-in-out infinite;
  box-shadow: 0 0 6px rgba(255, 170, 0, 0.6);
}

@keyframes scrollDot {
  0% {
    transform: translateX(-50%) translateY(0);
    opacity: 0.8;
  }
  70% {
    transform: translateX(-50%) translateY(18px);
    opacity: 0.2;
  }
  100% {
    transform: translateX(-50%) translateY(0);
    opacity: 0.8;
  }
}

/* ─── Gift Section Layout ───────────────────────────────────────────────────── */

.gift-section {
  min-height: 100vh;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: transparent;
  padding: 40px 20px;
  box-sizing: border-box;
}

.gift-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  max-width: 560px;
  width: min(560px, 92vw);
  position: relative;
  /* Cosmic glass — more transparent */
  background: linear-gradient(
    145deg,
    rgba(30, 10, 60, 0.18) 0%,
    rgba(50, 15, 80, 0.15) 55%,
    rgba(30, 10, 60, 0.17) 100%
  );
  backdrop-filter: blur(12px) saturate(140%) brightness(1.1);
  -webkit-backdrop-filter: blur(12px) saturate(140%) brightness(1.1);
  border: 1px solid rgba(255, 242, 204, 0.18);
  border-radius: 28px;
  padding: 44px 52px 40px;
  box-shadow:
    0 14px 60px rgba(0, 0, 0, 0.85),
    0 0 100px rgba(183, 110, 121, 0.1),
    0 0 50px rgba(30, 12, 50, 0.5),
    inset 0 1px 0 rgba(255, 242, 204, 0.15),
    inset 0 -1px 0 rgba(183, 110, 121, 0.1);
  animation: panelGlow 6s ease-in-out infinite;
}

/* ─── Gift Box Wrapper (collapses after open) ───────────────────────────────── */

.gift-box-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow: hidden;
  max-height: 320px;
  transition:
    max-height 0.9s cubic-bezier(0.4, 0, 0.2, 1),
    opacity 0.7s ease,
    margin 0.7s ease;
}

.gift-box-wrapper.collapse {
  max-height: 0;
  opacity: 0;
  margin: 0;
}

.gift-title {
  font-family: var(--font-display, "Great Vibes", cursive);
  font-size: clamp(2.6rem, 5.5vw, 4.2rem);
  color: #fff2cc;
  margin: 0 0 0 0;
  letter-spacing: 1px;
  line-height: 1.25;
  animation: titleShimmer 4.5s ease-in-out infinite;
}

/* NEW 3 — Ornamental divider below the title */
.gift-title::after {
  content: "\2605\00A0\2605\00A0\2605";
  display: block;
  font-size: 0.65rem;
  letter-spacing: 8px;
  color: rgba(212, 175, 55, 0.6);
  margin-top: 0.55rem;
  text-shadow: 0 0 10px rgba(212, 175, 55, 0.35);
}

/* ─── Gift Box Visual ────────────────────────────────────────────────────────── */

.gift-box {
  position: relative;
  width: 200px;
  height: 160px;
  margin: 1.6rem auto 0.6rem;
  cursor: pointer;
  animation: giftPulse 3s ease-in-out infinite;
  outline: none;
}

.gift-box:focus-visible {
  outline: 2px solid rgba(255, 170, 0, 0.7);
  outline-offset: 6px;
  border-radius: 4px;
}

.gift-body {
  position: absolute;
  inset: 30px 0 0 0;
  border-radius: 18px;
  background: linear-gradient(140deg, #d9a2a9, #b76e79 55%, #8e4f58 100%);
  box-shadow:
    0 20px 30px rgba(0, 0, 0, 0.5),
    0 0 40px rgba(183, 110, 121, 0.3);
}

.gift-lid {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 50px;
  background: linear-gradient(140deg, #e7bcc3, #c27b86 55%, #9a5861 100%);
  border-radius: 18px;
  transform-origin: bottom center;
  transition: transform 0.7s var(--ease, cubic-bezier(0.2, 0.6, 0.2, 1));
}

.gift-ribbon {
  position: absolute;
  inset: 0 45% 0 45%;
  background: linear-gradient(180deg, #f7e6ba, #d4af37);
  border-radius: 10px;
  z-index: 1;
}

.gift-ribbon::after {
  content: "";
  position: absolute;
  left: -60px;
  right: -60px;
  top: 20px;
  height: 14px;
  background: linear-gradient(180deg, #f7e6ba, #d4af37);
  border-radius: 999px;
}

.gift-box.open {
  animation: none;
}

.gift-box.open .gift-lid {
  transform: translateY(-24px) rotateX(110deg);
}

.gift-hint {
  color: rgba(255, 209, 220, 0.8);
  font-size: 0.88rem;
  letter-spacing: 2.5px;
  text-transform: uppercase;
  margin: 0.2rem 0 0;
  animation: hintFloat 2.4s ease-in-out infinite;
  transition: opacity 0.5s ease;
}

/* ─── Gift Message ───────────────────────────────────────────────────────────── */

.gift-message {
  margin: 0 auto;
  max-width: 480px;
  max-height: 0;
  overflow: hidden;
  font-family: "Lora", Georgia, serif;
  font-style: italic;
  font-size: clamp(1.15rem, 2.4vw, 1.45rem);
  color: rgba(255, 245, 220, 0.92);
  opacity: 0;
  transform: translateY(10px);
  transition:
    opacity 0.9s ease 0.4s,
    transform 0.9s ease 0.4s,
    max-height 1s ease 0.1s,
    margin 0.6s ease 0.1s;
  text-align: center;
  text-shadow:
    0 1px 12px rgba(0, 0, 0, 0.6),
    0 0 20px rgba(255, 170, 0, 0.2);
  line-height: 1.9;
  letter-spacing: 0.3px;
}

.gift-message.show {
  max-height: 300px;
  margin: 1.6rem auto 0;
  opacity: 1;
  transform: translateY(0);
}

.gift-message::before {
  content: "";
  display: block;
  width: 80px;
  height: 1px;
  margin: 0 auto 1.2rem;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(212, 175, 55, 0.7),
    transparent
  );
}

/* ─── Heart Burst ────────────────────────────────────────────────────────────── */

.heart-burst {
  position: relative;
  width: 220px;
  height: 0; /* no layout space until active */
  margin: 0 auto;
  overflow: visible;
  opacity: 0;
  pointer-events: none;
}

.heart-burst span {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 12px;
  height: 12px;
  background: #b76e79;
  transform: rotate(45deg);
  border-radius: 3px;
  opacity: 0.5;
}

.heart-burst span::before,
.heart-burst span::after {
  content: "";
  position: absolute;
  width: 12px;
  height: 12px;
  background: inherit;
  border-radius: 50%;
}

.heart-burst span::before {
  top: -6px;
  left: 0;
}
.heart-burst span::after {
  left: -6px;
  top: 0;
}

.heart-burst.active {
  opacity: 1;
}

.heart-burst.active span {
  animation: heartPop 1.6s var(--ease, cubic-bezier(0.2, 0.6, 0.2, 1)) forwards;
}

.heart-burst span:nth-child(1) {
  --x: -60px;
  --y: -30px;
}
.heart-burst span:nth-child(2) {
  --x: -20px;
  --y: -50px;
}
.heart-burst span:nth-child(3) {
  --x: 20px;
  --y: -40px;
}
.heart-burst span:nth-child(4) {
  --x: 60px;
  --y: -20px;
}
.heart-burst span:nth-child(5) {
  --x: -50px;
  --y: 20px;
}
.heart-burst span:nth-child(6) {
  --x: -10px;
  --y: 30px;
}
.heart-burst span:nth-child(7) {
  --x: 10px;
  --y: 35px;
}
.heart-burst span:nth-child(8) {
  --x: 50px;
  --y: 20px;
}
.heart-burst span:nth-child(9) {
  --x: -30px;
  --y: 50px;
}
.heart-burst span:nth-child(10) {
  --x: 30px;
  --y: 45px;
}

@keyframes giftPulse {
  0%,
  100% {
    transform: translateY(0) scale(1);
  }
  50% {
    transform: translateY(-6px) scale(1.02);
  }
}

@keyframes heartPop {
  0% {
    transform: translate(-50%, -50%) scale(0.3) rotate(45deg);
    opacity: 0;
  }
  30% {
    opacity: 0.9;
  }
  100% {
    transform: translate(calc(-50% + var(--x)), calc(-50% + var(--y))) scale(1)
      rotate(45deg);
    opacity: 0;
  }
}

/* ─── NEW 1: Title golden shimmer ───────────────────────────────────────────── */
@keyframes titleShimmer {
  0%,
  100% {
    color: #fff2cc;
    text-shadow:
      0 0 20px rgba(255, 170, 0, 0.5),
      0 0 8px rgba(255, 242, 204, 0.4);
  }
  50% {
    color: #fffef4;
    text-shadow:
      0 0 35px rgba(255, 215, 0, 0.95),
      0 0 18px rgba(255, 242, 204, 0.85),
      0 0 55px rgba(255, 160, 0, 0.55);
  }
}

/* ─── NEW 2: Panel border breathing glow ────────────────────────────────────── */
@keyframes panelGlow {
  0%,
  100% {
    box-shadow:
      0 14px 60px rgba(0, 0, 0, 0.85),
      0 0 100px rgba(183, 110, 121, 0.1),
      0 0 50px rgba(30, 12, 50, 0.5),
      inset 0 1px 0 rgba(255, 242, 204, 0.15),
      inset 0 -1px 0 rgba(183, 110, 121, 0.1);
    border-color: rgba(255, 242, 204, 0.18);
  }
  50% {
    box-shadow:
      0 14px 60px rgba(0, 0, 0, 0.85),
      0 0 120px rgba(183, 110, 121, 0.22),
      0 0 70px rgba(212, 175, 55, 0.14),
      inset 0 1px 0 rgba(255, 242, 204, 0.3),
      inset 0 -1px 0 rgba(183, 110, 121, 0.2);
    border-color: rgba(255, 242, 204, 0.32);
  }
}

/* ─── NEW 3: Gift hint float (tap prompt) ───────────────────────────────────── */
@keyframes hintFloat {
  0%,
  100% {
    transform: translateY(0);
    opacity: 0.75;
  }
  50% {
    transform: translateY(-5px);
    opacity: 1;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════════
   LOVE LETTER SECTION
   ═══════════════════════════════════════════════════════════════════════════════ */

.letter-section {
  min-height: 100vh;
  width: 100%;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 20px;
  box-sizing: border-box;
  position: relative;
}

.letter-section.revealed {
  display: flex;
  animation: letterSectionIn 1.4s ease-out both;
}

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

/* ─── Floating Hearts (around the letter) ───────────────────────────────────── */

.letter-hearts {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.letter-hearts span {
  position: absolute;
  width: 10px;
  height: 10px;
  background: #b76e79;
  transform: rotate(45deg);
  border-radius: 2px;
  opacity: 0.35;
  animation: letterHeartDrift 8s ease-in-out infinite;
}

.letter-hearts span::before,
.letter-hearts span::after {
  content: "";
  position: absolute;
  width: 10px;
  height: 10px;
  background: inherit;
  border-radius: 50%;
}

.letter-hearts span::before {
  top: -5px;
  left: 0;
}
.letter-hearts span::after {
  left: -5px;
  top: 0;
}

.letter-hearts span:nth-child(1) {
  left: 4%;
  top: 18%;
  animation-duration: 9s;
  animation-delay: 0s;
}
.letter-hearts span:nth-child(2) {
  left: 92%;
  top: 22%;
  animation-duration: 7.5s;
  animation-delay: 1s;
}
.letter-hearts span:nth-child(3) {
  left: 6%;
  top: 62%;
  animation-duration: 10s;
  animation-delay: 2s;
}
.letter-hearts span:nth-child(4) {
  left: 90%;
  top: 68%;
  animation-duration: 8.5s;
  animation-delay: 0.5s;
}
.letter-hearts span:nth-child(5) {
  left: 2%;
  top: 42%;
  animation-duration: 11s;
  animation-delay: 3s;
}
.letter-hearts span:nth-child(6) {
  left: 94%;
  top: 48%;
  animation-duration: 9.5s;
  animation-delay: 1.5s;
}

@keyframes letterHeartDrift {
  0%,
  100% {
    transform: rotate(45deg) translate(0, 0);
    opacity: 0.25;
  }
  25% {
    transform: rotate(45deg) translate(6px, -14px);
    opacity: 0.45;
  }
  50% {
    transform: rotate(45deg) translate(-4px, -6px);
    opacity: 0.35;
  }
  75% {
    transform: rotate(45deg) translate(5px, -18px);
    opacity: 0.5;
  }
}

/* ─── Letter Inner Container ────────────────────────────────────────────────── */

.letter-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: min(980px, 90vw);
  max-height: 96vh;
  position: relative;
  z-index: 2;
}

.letter-title {
  font-family: var(--font-display, "Great Vibes", cursive);
  font-size: clamp(2.2rem, 5vw, 3.6rem);
  color: #d4af37;
  margin: 0 0 0.6rem 0;
  text-shadow:
    0 0 25px rgba(255, 170, 0, 0.5),
    0 4px 15px rgba(0, 0, 0, 0.5);
  animation: titleShimmer 4.5s ease-in-out infinite;
}

/* ─── Letter Card (Paper) ───────────────────────────────────────────────────── */

.letter-card {
  position: relative;
  background: linear-gradient(
    145deg,
    rgba(28, 8, 55, 0.84) 0%,
    rgba(48, 14, 72, 0.8) 55%,
    rgba(28, 8, 55, 0.83) 100%
  );
  backdrop-filter: blur(14px) saturate(140%) brightness(1.08);
  -webkit-backdrop-filter: blur(14px) saturate(140%) brightness(1.08);
  color: rgba(255, 245, 220, 0.92);
  padding: clamp(1.4rem, 2.5vw, 2.2rem) clamp(1.6rem, 3vw, 2.8rem);
  border-radius: 24px;
  box-shadow:
    0 24px 60px rgba(0, 0, 0, 0.65),
    0 0 100px rgba(183, 110, 121, 0.15),
    0 0 50px rgba(30, 12, 50, 0.45),
    inset 0 1px 0 rgba(255, 242, 204, 0.18),
    inset 0 -1px 0 rgba(183, 110, 121, 0.1);
  border: 1px solid rgba(255, 242, 204, 0.22);
  overflow: hidden;
  width: 100%;
  animation: panelGlow 6s ease-in-out infinite;
}

/* Subtle top-edge highlight overlay */
.letter-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    120deg,
    rgba(255, 242, 204, 0.06),
    transparent 45%
  );
  opacity: 1;
  pointer-events: none;
  z-index: 0;
}

.letter-card > * {
  position: relative;
  z-index: 2;
}

/* ─── NEW FEATURE 1: Candlelight Ambient Flicker ────────────────────────────── */

.candlelight {
  position: absolute;
  inset: 0;
  border-radius: 20px;
  pointer-events: none;
  z-index: 1;
  animation: candleFlicker 3s ease-in-out infinite;
}

@keyframes candleFlicker {
  0%,
  100% {
    opacity: 0.7;
    background: radial-gradient(
      ellipse 60% 50% at 30% 20%,
      rgba(255, 200, 100, 0.12),
      transparent 70%
    );
  }
  25% {
    opacity: 0.9;
    background: radial-gradient(
      ellipse 65% 55% at 32% 18%,
      rgba(255, 190, 80, 0.16),
      transparent 70%
    );
  }
  50% {
    opacity: 0.55;
    background: radial-gradient(
      ellipse 55% 45% at 28% 22%,
      rgba(255, 210, 110, 0.1),
      transparent 70%
    );
  }
  75% {
    opacity: 0.85;
    background: radial-gradient(
      ellipse 62% 52% at 34% 19%,
      rgba(255, 195, 90, 0.14),
      transparent 70%
    );
  }
}

/* ─── Letter Typography ─────────────────────────────────────────────────────── */

.letter-greeting {
  font-family: var(--font-display, "Great Vibes", cursive);
  font-size: clamp(1.3rem, 2.2vw, 1.7rem);
  color: #f0b8c3;
  margin: 0 0 0.5rem 0;
  line-height: 1.3;
  text-shadow: 0 0 18px rgba(183, 110, 121, 0.6);
}

.letter-para {
  font-family: "Lora", Georgia, serif;
  font-style: italic;
  font-size: clamp(1.1rem, 1.1vw, 0.95rem);
  line-height: 1.6;
  margin: 0 0 0.55rem 0;
  color: rgba(255, 245, 220, 0.9);
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.5);
}

.letter-para:last-of-type {
  margin-bottom: 0.7rem;
}

.letter-signoff-block {
  text-align: right;
  margin-top: 1.6rem;
}
.letter-signoff {
  font-family: var(--font-display, "Great Vibes", cursive);
  font-size: clamp(1.1rem, 1.8vw, 1.4rem);
  color: #e8c97a;
  margin: 0;
  line-height: 1.4;
  text-shadow: 0 0 15px rgba(212, 175, 55, 0.55);
}
.letter-name {
  margin-bottom: 0.4rem;
}

/* ─── NEW FEATURE 2: Word-by-Word Ink Reveal ────────────────────────────────── */

.letter-word {
  display: inline-block;
  opacity: 0;
  transform: translateY(5px);
  transition:
    opacity 0.35s ease,
    transform 0.35s ease;
  margin-right: 0.22em;
}

.letter-word.revealed {
  opacity: 1;
  transform: translateY(0);
}

/* ─── NEW FEATURE 3: Wax Seal Stamp ─────────────────────────────────────────── */

.wax-seal {
  display: flex;
  justify-content: flex-end;
  margin-top: 0.3rem;
  position: relative;
  z-index: 2;
}

.seal-body {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: radial-gradient(
    circle at 35% 35%,
    #c0392b,
    #922b21 50%,
    #7b241c 100%
  );
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display, "Great Vibes", cursive);
  font-size: 1.5rem;
  color: rgba(255, 240, 220, 0.9);
  box-shadow:
    0 4px 15px rgba(0, 0, 0, 0.3),
    inset 0 -2px 4px rgba(0, 0, 0, 0.2),
    inset 0 2px 4px rgba(255, 200, 150, 0.2);
  border: 2px solid rgba(150, 40, 30, 0.6);
  opacity: 0;
  transform: scale(2.5) rotate(-20deg);
  transition:
    opacity 0.4s ease,
    transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.seal-body.stamped {
  opacity: 1;
  transform: scale(1) rotate(0deg);
}

/* ─── NEW FEATURE 4: Golden Sparkle Cursor Trail ────────────────────────────── */

.sparkle {
  position: absolute;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: radial-gradient(circle, #ffd700, #d4af37);
  pointer-events: none;
  z-index: 10;
  animation: sparkleFloat 0.8s ease-out forwards;
}

@keyframes sparkleFloat {
  0% {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
  100% {
    opacity: 0;
    transform: scale(0) translateY(-20px);
  }
}

/* ─── Scroll Hint (appears in gift section after opening) ───────────────────── */

.letter-scroll-hint {
  display: none;
  flex-direction: column;
  align-items: center;
  margin-top: 1.5rem;
  opacity: 0;
  transition: opacity 1s ease 0.3s;
  color: rgba(255, 242, 204, 0.7);
  font-size: 0.78rem;
  letter-spacing: 2.5px;
  text-transform: uppercase;
}

.letter-scroll-hint.visible {
  display: flex;
  opacity: 1;
}

.letter-scroll-hint span {
  display: block;
  width: 20px;
  height: 34px;
  border: 1px solid rgba(255, 242, 204, 0.4);
  border-radius: 999px;
  position: relative;
  margin-top: 8px;
}

.letter-scroll-hint span::after {
  content: "";
  position: absolute;
  width: 3px;
  height: 6px;
  background: #fff2cc;
  border-radius: 3px;
  left: 50%;
  transform: translateX(-50%);
  top: 6px;
  animation: scrollDot 2s ease-in-out infinite;
  box-shadow: 0 0 4px rgba(255, 170, 0, 0.5);
}

/* ═══════════════════════════════════════════════════════════════════════════════
   COUNTDOWN SECTION — "And I'd choose you in every lifetime"
   ═══════════════════════════════════════════════════════════════════════════════ */

.countdown-section {
  min-height: 100vh;
  width: 100%;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  box-sizing: border-box;
  position: relative;
  overflow: hidden;
}

.countdown-section.revealed {
  display: flex;
  animation: letterSectionIn 1.4s ease-out both;
}

.countdown-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: min(1100px, 92vw);
  position: relative;
  z-index: 2;
}

/* ─── FEATURE 6: Title Glowing Pulse Wave ───────────────────────────────────── */

.countdown-title {
  font-family: var(--font-display, "Great Vibes", cursive);
  font-size: clamp(2.4rem, 5vw, 4.2rem);
  color: #d4af37;
  margin: 0 0 0.4rem 0;
  text-align: center;
  position: relative;
  background: linear-gradient(
    90deg,
    #d4af37 0%,
    #fff2cc 20%,
    #d4af37 40%,
    #d4af37 100%
  );
  background-size: 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: titlePulseWave 4s ease-in-out infinite;
  text-shadow: none;
  filter: drop-shadow(0 4px 20px rgba(212, 175, 55, 0.35));
}

@keyframes titlePulseWave {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

.countdown-subtitle {
  font-family: "Lora", Georgia, serif;
  font-style: italic;
  font-size: clamp(0.9rem, 1.8vw, 1.15rem);
  color: rgba(255, 209, 220, 0.7);
  margin: 0 0 2.4rem 0;
  text-align: center;
  letter-spacing: 1px;
}

/* ─── Countdown Grid ────────────────────────────────────────────────────────── */

.countdown-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 1.2rem;
  width: 100%;
}

@media (max-width: 900px) {
  .countdown-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
  }
}

@media (max-width: 480px) {
  .countdown-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.8rem;
  }
}

/* ─── Countdown Card ────────────────────────────────────────────────────────── */

.countdown-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: linear-gradient(
    145deg,
    rgba(20, 8, 40, 0.55) 0%,
    rgba(40, 12, 65, 0.5) 55%,
    rgba(20, 8, 40, 0.53) 100%
  );
  backdrop-filter: blur(12px) saturate(130%) brightness(1.05);
  -webkit-backdrop-filter: blur(12px) saturate(130%) brightness(1.05);
  border: 1px solid rgba(255, 242, 204, 0.14);
  border-radius: 20px;
  padding: 1.2rem 0.6rem 1rem;
  box-shadow:
    0 14px 40px rgba(0, 0, 0, 0.6),
    0 0 60px rgba(183, 110, 121, 0.08),
    inset 0 1px 0 rgba(255, 242, 204, 0.12),
    inset 0 -1px 0 rgba(183, 110, 121, 0.08);
  transition:
    transform 0.35s ease,
    box-shadow 0.35s ease;
  transform-style: preserve-3d;
  perspective: 600px;
  will-change: transform;
}

.countdown-card:hover {
  box-shadow:
    0 18px 50px rgba(0, 0, 0, 0.7),
    0 0 80px rgba(212, 175, 55, 0.12),
    inset 0 1px 0 rgba(255, 242, 204, 0.2),
    inset 0 -1px 0 rgba(183, 110, 121, 0.12);
}

/* ─── FEATURE 4: Orbital Dot Animation ──────────────────────────────────────── */

.card-orbital {
  position: absolute;
  inset: -8px;
  pointer-events: none;
  z-index: 0;
}

.card-orbital span {
  position: absolute;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: radial-gradient(
    circle,
    rgba(212, 175, 55, 0.9),
    rgba(212, 175, 55, 0.2)
  );
  box-shadow: 0 0 6px rgba(212, 175, 55, 0.6);
  top: 50%;
  left: 50%;
  animation: orbitalSpin 6s linear infinite;
}

.countdown-card:nth-child(1) .card-orbital span {
  animation-duration: 5s;
}
.countdown-card:nth-child(2) .card-orbital span {
  animation-duration: 6.5s;
  animation-direction: reverse;
}
.countdown-card:nth-child(3) .card-orbital span {
  animation-duration: 7s;
}
.countdown-card:nth-child(4) .card-orbital span {
  animation-duration: 5.5s;
  animation-direction: reverse;
}
.countdown-card:nth-child(5) .card-orbital span {
  animation-duration: 8s;
}
.countdown-card:nth-child(6) .card-orbital span {
  animation-duration: 4.5s;
  animation-direction: reverse;
}

@keyframes orbitalSpin {
  0% {
    transform: rotate(0deg) translateX(calc(50% + 52px)) rotate(0deg);
    opacity: 0.9;
  }
  50% {
    opacity: 0.4;
  }
  100% {
    transform: rotate(360deg) translateX(calc(50% + 52px)) rotate(-360deg);
    opacity: 0.9;
  }
}

/* ─── FEATURE 2: SVG Circular Progress Rings ────────────────────────────────── */

.progress-ring-wrap {
  position: relative;
  width: 100px;
  height: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
}

@media (min-width: 901px) {
  .progress-ring-wrap {
    width: 110px;
    height: 110px;
  }
}

.progress-ring {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.progress-ring__bg {
  fill: none;
  stroke: rgba(255, 242, 204, 0.06);
  stroke-width: 3;
}

.progress-ring__fill {
  fill: none;
  stroke: url(#countdown-gradient);
  stroke-width: 3.5;
  stroke-linecap: round;
  stroke-dasharray: 339.292;
  stroke-dashoffset: 339.292;
  transition: stroke-dashoffset 0.6s ease;
  filter: drop-shadow(0 0 4px rgba(212, 175, 55, 0.5));
}

/* Fallback stroke color */
.progress-ring__fill {
  stroke: url(#countdown-gradient);
}

.countdown-value-wrap {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
}

/* ─── FEATURE 1: Digit Roller Animation ─────────────────────────────────────── */

.countdown-value {
  font-size: clamp(1.6rem, 2.8vw, 2.4rem);
  font-weight: 700;
  color: #fff2cc;
  display: block;
  text-shadow:
    0 0 15px rgba(255, 170, 0, 0.6),
    0 0 30px rgba(212, 175, 55, 0.3);
  transition: color 0.3s ease;
}

.countdown-value.tick {
  animation: digitRoll 0.45s ease-out;
}

@keyframes digitRoll {
  0% {
    transform: translateY(-30%) scale(0.85);
    opacity: 0.3;
    filter: blur(2px);
  }
  60% {
    transform: translateY(4%) scale(1.05);
    opacity: 1;
    filter: blur(0);
  }
  100% {
    transform: translateY(0) scale(1);
    opacity: 1;
    filter: blur(0);
  }
}

.countdown-label {
  font-size: 0.8rem;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: rgba(255, 209, 220, 0.65);
  margin-top: 0.5rem;
  z-index: 1;
}

/* ─── FEATURE 3: Cosmic Particle Burst ──────────────────────────────────────── */

.countdown-particles {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
  border-radius: 20px;
}

.cd-particle {
  position: absolute;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  pointer-events: none;
  animation: cdParticleBurst 1.4s ease-out forwards;
}

@keyframes cdParticleBurst {
  0% {
    opacity: 1;
    transform: translate(0, 0) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(var(--dx), var(--dy)) scale(0);
  }
}

/* ─── FEATURE 5: Interactive 3D Tilt (enhanced via JS) ──────────────────────── */

.countdown-card.tilt-active {
  transition:
    transform 0.1s ease,
    box-shadow 0.35s ease;
}

/* ─── Card Glow Pulse on Second Tick ────────────────────────────────────────── */

.countdown-card[data-unit="seconds"].pulse {
  animation: cardSecondPulse 0.6s ease-out;
}

@keyframes cardSecondPulse {
  0% {
    box-shadow:
      0 14px 40px rgba(0, 0, 0, 0.6),
      0 0 60px rgba(183, 110, 121, 0.08),
      0 0 20px rgba(212, 175, 55, 0.35),
      inset 0 1px 0 rgba(255, 242, 204, 0.12);
    border-color: rgba(212, 175, 55, 0.5);
  }
  100% {
    box-shadow:
      0 14px 40px rgba(0, 0, 0, 0.6),
      0 0 60px rgba(183, 110, 121, 0.08),
      inset 0 1px 0 rgba(255, 242, 204, 0.12);
    border-color: rgba(255, 242, 204, 0.14);
  }
}

/* ═══════════════════════════════════════════════════════════════════════════════
   OUR STORY — SECTION 4
   7 features beyond the demo site
   ═══════════════════════════════════════════════════════════════════════════════ */

/* ─── Section Shell ──────────────────────────────────────────────────────────── */

.story-section {
  min-height: 100vh;
  width: 100%;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 80px 20px 120px;
  box-sizing: border-box;
  position: relative;
  overflow: hidden;
}

.story-section.revealed {
  display: flex;
  animation: storySectionIn 1.6s cubic-bezier(0.22, 1, 0.36, 1) both;
}

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

/* ─── FEATURE 6 · Ambient pulsing nebula nodes ───────────────────────────────── */

.story-nebula {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 0;
}

.story-nebula-node {
  position: absolute;
  border-radius: 50%;
  /* Reduced from 90px to lower GPU cost while keeping a soft glow */
  filter: blur(60px);
  opacity: 0;
  animation: storyNebulaFloat 10s ease-in-out infinite;
}

.snn-1 {
  width: 520px;
  height: 380px;
  background: radial-gradient(
    circle,
    rgba(183, 110, 121, 0.22) 0%,
    transparent 70%
  );
  top: 2%;
  left: -12%;
  animation-duration: 11s;
  animation-delay: 0s;
}

.snn-2 {
  width: 600px;
  height: 460px;
  background: radial-gradient(
    circle,
    rgba(212, 175, 55, 0.14) 0%,
    transparent 70%
  );
  top: 28%;
  right: -16%;
  animation-duration: 14s;
  animation-delay: 3.5s;
}

/* Performance safeguards for smaller screens and reduced-motion users:
   - Further reduce blur radius
   - Shrink nebula node sizes
   - Lengthen animation duration slightly to reduce per-second work */
@media (max-width: 768px), (prefers-reduced-motion: reduce) {
  .story-nebula-node {
    filter: blur(40px);
    opacity: 0.7;
    animation-duration: 14s;
  }

  .snn-1 {
    width: 360px;
    height: 260px;
  }

  .snn-2 {
    width: 420px;
    height: 320px;
  }
}

.snn-3 {
  width: 420px;
  height: 420px;
  background: radial-gradient(
    circle,
    rgba(90, 50, 200, 0.14) 0%,
    transparent 70%
  );
  bottom: 8%;
  left: 15%;
  animation-duration: 9s;
  animation-delay: 7s;
}

.snn-4 {
  width: 360px;
  height: 280px;
  background: radial-gradient(
    circle,
    rgba(255, 209, 220, 0.1) 0%,
    transparent 70%
  );
  top: 55%;
  left: 40%;
  animation-duration: 12s;
  animation-delay: 1.5s;
}

@keyframes storyNebulaFloat {
  0%,
  100% {
    opacity: 0.35;
    transform: scale(1) translate(0, 0);
  }
  33% {
    opacity: 0.7;
    transform: scale(1.12) translate(18px, -20px);
  }
  66% {
    opacity: 0.45;
    transform: scale(0.94) translate(-14px, 12px);
  }
}

/* ─── Inner layout ───────────────────────────────────────────────────────────── */

.story-inner {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: min(960px, 94vw);
}

/* ─── Header ─────────────────────────────────────────────────────────────────── */

.story-header {
  text-align: center;
  margin-bottom: 3.2rem;
  position: relative;
}

/* ─── FEATURE 7 · Animated constellation decoration ─────────────────────────── */

.story-constellation {
  position: relative;
  width: 260px;
  height: 40px;
  margin: 0 auto 0.6rem;
}

.sc-star {
  position: absolute;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #fff2cc;
  box-shadow:
    0 0 6px rgba(255, 242, 204, 0.9),
    0 0 14px rgba(212, 175, 55, 0.6);
  transform: translate(-50%, -50%);
  animation: scStarPulse 3s ease-in-out infinite;
}

.sc-s1 {
  left: 5%;
  top: 50%;
  animation-delay: 0s;
}
.sc-s2 {
  left: 25%;
  top: 12%;
  animation-delay: 0.6s;
}
.sc-s3 {
  left: 50%;
  top: 60%;
  animation-delay: 1.2s;
}
.sc-s4 {
  left: 75%;
  top: 15%;
  animation-delay: 1.8s;
}
.sc-s5 {
  left: 95%;
  top: 50%;
  animation-delay: 2.4s;
}

@keyframes scStarPulse {
  0%,
  100% {
    transform: translate(-50%, -50%) scale(1);
    opacity: 0.65;
  }
  50% {
    transform: translate(-50%, -50%) scale(2);
    opacity: 1;
  }
}

.sc-lines {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.sc-polyline {
  fill: none;
  stroke: url(#countdown-gradient);
  stroke-width: 1px;
  stroke-dasharray: 600;
  stroke-dashoffset: 600;
  opacity: 0.55;
}

.story-section.revealed .sc-polyline {
  animation: scLinesDraw 2.4s ease-out 0.4s forwards;
}

@keyframes scLinesDraw {
  to {
    stroke-dashoffset: 0;
  }
}

/* ─── Title & subtitle ───────────────────────────────────────────────────────── */

.story-title {
  font-family: var(--font-display, "Great Vibes", cursive);
  font-size: clamp(3rem, 7vw, 5.5rem);
  margin: 0 0 0.3rem;
  background: linear-gradient(
    135deg,
    #d4af37 0%,
    #fff2cc 30%,
    #f0b8c3 55%,
    #d4af37 80%,
    #b76e79 100%
  );
  background-size: 300% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: storyTitleShimmer 6s ease-in-out infinite;
  filter: drop-shadow(0 4px 28px rgba(212, 175, 55, 0.5));
  line-height: 1.1;
}

@keyframes storyTitleShimmer {
  0% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0% 50%;
  }
}

.story-subtitle {
  font-family: "Lora", Georgia, serif;
  font-style: italic;
  font-size: clamp(0.85rem, 1.6vw, 1.05rem);
  color: rgba(255, 209, 220, 0.62);
  margin: 0;
  letter-spacing: 1.8px;
}

/* ─── Timeline container ─────────────────────────────────────────────────────── */

.story-timeline {
  position: relative;
  width: 100%;
  display: flex;
  flex-direction: column;
  padding: 24px 0 48px;
}

/* ─── FEATURE 3 · Animated cosmic timeline line ──────────────────────────────── */

.story-tl-line {
  position: absolute;
  left: 50%;
  top: 24px;
  bottom: 48px;
  width: 2px;
  transform: translateX(-50%);
  pointer-events: none;
  z-index: 1;
  background: rgba(255, 242, 204, 0.07);
  border-radius: 2px;
}

.story-tl-line-fill {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 0%;
  border-radius: 2px;
  background: linear-gradient(
    180deg,
    rgba(212, 175, 55, 0.9) 0%,
    rgba(240, 184, 195, 0.8) 40%,
    rgba(183, 110, 121, 0.75) 70%,
    rgba(100, 60, 200, 0.6) 100%
  );
  box-shadow:
    0 0 10px rgba(212, 175, 55, 0.65),
    0 0 24px rgba(212, 175, 55, 0.3);
}

.story-section.revealed .story-tl-line-fill {
  animation: storyLineDraw 4.5s ease-out 0.8s forwards;
}

@keyframes storyLineDraw {
  from {
    height: 0%;
  }
  to {
    height: 100%;
  }
}

/* Comet dot that races down the line once on reveal */
.story-tl-line-comet {
  position: absolute;
  left: 50%;
  top: -6px;
  transform: translateX(-50%);
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #fff2cc;
  box-shadow:
    0 0 8px #d4af37,
    0 0 20px rgba(212, 175, 55, 0.7);
  opacity: 0;
  pointer-events: none;
}

.story-section.revealed .story-tl-line-comet {
  animation: storyCometRun 4.5s ease-in-out 0.8s forwards;
}

@keyframes storyCometRun {
  0% {
    top: 0%;
    opacity: 1;
  }
  95% {
    opacity: 1;
  }
  100% {
    top: 100%;
    opacity: 0;
  }
}

/* ─── Timeline item ──────────────────────────────────────────────────────────── */

.story-item {
  display: grid;
  grid-template-columns: 1fr 64px 1fr;
  align-items: center;
  padding: 1.6rem 0;
  position: relative;
}

/* ─── FEATURE 5 · Meteor/comet entrance animation ───────────────────────────── */

/* Left items: card-wrap slides in from the left */
.story-item--left .story-card-wrap {
  opacity: 0;
  transform: translateX(-70px) skewX(-4deg);
  transition:
    opacity 0.85s cubic-bezier(0.22, 1, 0.36, 1),
    transform 0.85s cubic-bezier(0.22, 1, 0.36, 1);
}

/* Right items: card-wrap slides in from the right */
.story-item--right .story-card-wrap {
  opacity: 0;
  transform: translateX(70px) skewX(4deg);
  transition:
    opacity 0.85s cubic-bezier(0.22, 1, 0.36, 1),
    transform 0.85s cubic-bezier(0.22, 1, 0.36, 1);
}

.story-item.animate-in .story-card-wrap {
  opacity: 1;
  transform: translateX(0) skewX(0);
}

/* Node pops in after the card */
.story-node {
  opacity: 0;
  transform: scale(0) rotate(-30deg);
  transition:
    opacity 0.5s ease,
    transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
  transition-delay: 0.35s;
  grid-column: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 2;
}

.story-item.animate-in .story-node {
  opacity: 1;
  transform: scale(1) rotate(0deg);
}

/* Staggered entrance delay by index */
.story-item[data-story-idx="0"] .story-card-wrap {
  transition-delay: 0s;
}
.story-item[data-story-idx="1"] .story-card-wrap {
  transition-delay: 0.05s;
}
.story-item[data-story-idx="2"] .story-card-wrap {
  transition-delay: 0.05s;
}
.story-item[data-story-idx="3"] .story-card-wrap {
  transition-delay: 0.05s;
}
.story-item[data-story-idx="4"] .story-card-wrap {
  transition-delay: 0.05s;
}
.story-item[data-story-idx="5"] .story-card-wrap {
  transition-delay: 0.05s;
}

/* ─── Timeline node ──────────────────────────────────────────────────────────── */

.story-node-ring {
  position: absolute;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1.5px solid rgba(212, 175, 55, 0.35);
  animation: storyNodeRingSpin 8s linear infinite;
}

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

.story-node-pulse {
  position: absolute;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(212, 175, 55, 0.08);
  animation: storyNodePulse 2.4s ease-in-out infinite;
}

@keyframes storyNodePulse {
  0%,
  100% {
    transform: scale(1);
    opacity: 0.6;
  }
  50% {
    transform: scale(1.5);
    opacity: 0;
  }
}

.story-node-core {
  position: relative;
  z-index: 2;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(
    135deg,
    rgba(28, 8, 55, 0.92),
    rgba(48, 14, 72, 0.88)
  );
  border: 1.5px solid rgba(212, 175, 55, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  box-shadow:
    0 0 14px rgba(212, 175, 55, 0.4),
    inset 0 1px 0 rgba(255, 242, 204, 0.15);
}

/* ─── Card wrap + orb ring container ────────────────────────────────────────── */

.story-card-wrap {
  position: relative;
  padding: 8px;
}

.story-spacer {
  display: block;
}

/* ─── FEATURE 4 · Per-card orbital sparkle dots ─────────────────────────────── */

.story-orb-ring {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  border-radius: 22px;
}

.story-orb {
  position: absolute;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  top: 50%;
  left: 50%;
  background: radial-gradient(
    circle,
    rgba(212, 175, 55, 0.95),
    rgba(212, 175, 55, 0.2)
  );
  box-shadow: 0 0 7px rgba(212, 175, 55, 0.65);
}

.story-orb-a {
  animation: storyOrbA 7s linear infinite;
}

.story-orb-b {
  animation: storyOrbB 11s linear infinite reverse;
  background: radial-gradient(
    circle,
    rgba(183, 110, 121, 0.9),
    rgba(183, 110, 121, 0.15)
  );
  box-shadow: 0 0 7px rgba(183, 110, 121, 0.55);
}

/* Each item gets a slightly different orbit speed */
.story-item[data-story-idx="1"] .story-orb-a {
  animation-duration: 9s;
}
.story-item[data-story-idx="2"] .story-orb-a {
  animation-duration: 6s;
}
.story-item[data-story-idx="3"] .story-orb-a {
  animation-duration: 8s;
}
.story-item[data-story-idx="4"] .story-orb-a {
  animation-duration: 10s;
}
.story-item[data-story-idx="5"] .story-orb-a {
  animation-duration: 5.5s;
}

@keyframes storyOrbA {
  0% {
    transform: rotate(0deg) translateX(calc(50% + 60px)) rotate(0deg);
    opacity: 0.9;
  }
  50% {
    opacity: 0.35;
  }
  100% {
    transform: rotate(360deg) translateX(calc(50% + 60px)) rotate(-360deg);
    opacity: 0.9;
  }
}

@keyframes storyOrbB {
  0% {
    transform: rotate(0deg) translateX(calc(50% + 80px)) rotate(0deg);
    opacity: 0.7;
  }
  50% {
    opacity: 0.2;
  }
  100% {
    transform: rotate(360deg) translateX(calc(50% + 80px)) rotate(-360deg);
    opacity: 0.7;
  }
}

/* ─── FEATURE 1 · 3-D Flip Card ─────────────────────────────────────────────── */

.story-card {
  position: relative;
  z-index: 1;
  perspective: 1000px;
  cursor: pointer;
  width: 100%;
  outline: none;
}

.story-card:focus-visible {
  outline: 2px solid rgba(212, 175, 55, 0.6);
  outline-offset: 4px;
  border-radius: 22px;
}

.story-card-inner {
  position: relative;
  width: 100%;
  min-height: 220px;
  transform-style: preserve-3d;
  transition: transform 0.72s cubic-bezier(0.34, 1.3, 0.64, 1);
  border-radius: 20px;
}

.story-card:hover .story-card-inner,
.story-card.flipped .story-card-inner {
  transform: rotateY(180deg);
}

.story-card-front {
  position: relative;
  width: 100%;
}

.story-card-back {
  position: absolute;
  inset: 0;
}

.story-card-front,
.story-card-back {
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: 20px;
  padding: 1.5rem 1.4rem 1.3rem;
  overflow: hidden;
}

/* Front face */
.story-card-front {
  background: linear-gradient(
    145deg,
    rgba(20, 8, 42, 0.62) 0%,
    rgba(40, 12, 65, 0.58) 55%,
    rgba(20, 8, 42, 0.6) 100%
  );
  backdrop-filter: blur(14px) saturate(140%) brightness(1.06);
  -webkit-backdrop-filter: blur(14px) saturate(140%) brightness(1.06);
  border: 1px solid rgba(255, 242, 204, 0.16);
  box-shadow:
    0 16px 48px rgba(0, 0, 0, 0.6),
    0 0 70px rgba(183, 110, 121, 0.08),
    inset 0 1px 0 rgba(255, 242, 204, 0.14),
    inset 0 -1px 0 rgba(183, 110, 121, 0.08);
  animation: panelGlow 6s ease-in-out infinite;
}

/* Front face top-left shimmer overlay */
.story-card-front::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    118deg,
    rgba(255, 242, 204, 0.055),
    transparent 44%
  );
  pointer-events: none;
  border-radius: 20px;
}

/* Back face — deeper rose/violet tint for the reveal */
.story-card-back {
  background: linear-gradient(
    145deg,
    rgba(50, 10, 55, 0.88) 0%,
    rgba(90, 18, 70, 0.82) 50%,
    rgba(50, 10, 55, 0.86) 100%
  );
  backdrop-filter: blur(14px) saturate(160%) brightness(1.08);
  -webkit-backdrop-filter: blur(14px) saturate(160%) brightness(1.08);
  border: 1px solid rgba(183, 110, 121, 0.35);
  box-shadow:
    0 16px 48px rgba(0, 0, 0, 0.65),
    0 0 80px rgba(183, 110, 121, 0.18),
    inset 0 1px 0 rgba(255, 209, 220, 0.2),
    inset 0 -1px 0 rgba(183, 110, 121, 0.12);
  transform: rotateY(180deg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 0.8rem;
}

.story-card-back::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(
    ellipse 80% 60% at 50% 40%,
    rgba(183, 110, 121, 0.12),
    transparent 70%
  );
  pointer-events: none;
  border-radius: 20px;
  animation: candleFlicker 3s ease-in-out infinite;
}

/* ─── Card content typography ────────────────────────────────────────────────── */

.story-date-wrap {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.55rem;
}

.story-date-icon {
  font-size: 0.95rem;
  flex-shrink: 0;
}

/* FEATURE 2: Typewriter date — starts empty, JS types in text */
.story-date {
  font-family: "Lora", Georgia, serif;
  font-style: italic;
  font-size: clamp(0.78rem, 1.3vw, 0.9rem);
  color: #d4af37;
  letter-spacing: 0.8px;
  text-shadow: 0 0 12px rgba(212, 175, 55, 0.5);
  position: relative;
}

/* Blinking cursor appended during typewriter */
.story-date.typing::after {
  content: "|";
  animation: storyBlink 0.7s step-end infinite;
  color: rgba(212, 175, 55, 0.8);
  margin-left: 1px;
}

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

.story-event-title {
  font-family: var(--font-display, "Great Vibes", cursive);
  font-size: clamp(1.35rem, 2.2vw, 1.75rem);
  color: #fff2cc;
  margin: 0 0 0.5rem;
  line-height: 1.2;
  text-shadow:
    0 0 20px rgba(255, 170, 0, 0.4),
    0 2px 10px rgba(0, 0, 0, 0.4);
}

.story-desc {
  font-family: "Lora", Georgia, serif;
  font-style: italic;
  font-size: clamp(0.82rem, 1.2vw, 0.92rem);
  line-height: 1.65;
  color: rgba(255, 245, 220, 0.82);
  margin: 0 0 0.6rem;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.4);
}

.story-flip-hint {
  display: block;
  font-size: 0.68rem;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: rgba(212, 175, 55, 0.45);
  margin-top: 0.3rem;
  transition: opacity 0.3s ease;
}

.story-card:hover .story-flip-hint {
  opacity: 0;
}

/* Back face content */
.story-cb-icon {
  font-size: 2.2rem;
  display: block;
  filter: drop-shadow(0 0 14px rgba(183, 110, 121, 0.7));
  animation: storyIconFloat 3s ease-in-out infinite;
}

@keyframes storyIconFloat {
  0%,
  100% {
    transform: translateY(0) scale(1);
  }
  50% {
    transform: translateY(-7px) scale(1.08);
  }
}

.story-cb-msg {
  font-family: var(--font-display, "Great Vibes", cursive);
  font-size: clamp(1.2rem, 2vw, 1.55rem);
  color: rgba(255, 209, 220, 0.92);
  margin: 0;
  line-height: 1.4;
  text-shadow:
    0 0 20px rgba(183, 110, 121, 0.6),
    0 2px 10px rgba(0, 0, 0, 0.4);
}

/* ─── FEATURE 5 · Floating ambient particles per card ────────────────────────── */

.story-item-ptcl {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 3;
  overflow: visible;
  border-radius: 20px;
}

.story-ptcl-dot {
  position: absolute;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  pointer-events: none;
  animation: storyPtclFloat 2.8s ease-out forwards;
}

@keyframes storyPtclFloat {
  0% {
    opacity: 0.9;
    transform: translate(0, 0) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(var(--ptcl-dx), var(--ptcl-dy)) scale(0.2);
  }
}

/* ─── FEATURE 1 (extended) · Cursor sparkle trail on cards ──────────────────── */

.story-sparkle {
  position: absolute;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  pointer-events: none;
  z-index: 10;
  background: radial-gradient(circle, #ffd700, #d4af37 60%, transparent);
  box-shadow: 0 0 6px rgba(255, 215, 0, 0.7);
  animation: storySparkleUp 0.75s ease-out forwards;
}

@keyframes storySparkleUp {
  0% {
    opacity: 1;
    transform: scale(1) translate(0, 0);
  }
  100% {
    opacity: 0;
    transform: scale(0) translate(var(--sx, 0px), var(--sy, -20px));
  }
}

/* ─── Footer seal ────────────────────────────────────────────────────────────── */

.story-footer {
  margin-top: 3.5rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.8rem;
}

.story-footer-stars {
  display: flex;
  gap: 1.2rem;
  align-items: center;
}

.story-footer-stars span {
  display: block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #d4af37;
  box-shadow: 0 0 8px rgba(212, 175, 55, 0.8);
  animation: storyFooterStarPulse 2.4s ease-in-out infinite;
}

.story-footer-stars span:nth-child(1) {
  animation-delay: 0s;
  width: 3px;
  height: 3px;
}
.story-footer-stars span:nth-child(2) {
  animation-delay: 0.4s;
}
.story-footer-stars span:nth-child(3) {
  animation-delay: 0.8s;
  width: 7px;
  height: 7px;
}
.story-footer-stars span:nth-child(4) {
  animation-delay: 1.2s;
}
.story-footer-stars span:nth-child(5) {
  animation-delay: 1.6s;
  width: 3px;
  height: 3px;
}

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

.story-footer-text {
  font-family: var(--font-display, "Great Vibes", cursive);
  font-size: clamp(1.1rem, 2vw, 1.4rem);
  color: rgba(212, 175, 55, 0.55);
  margin: 0;
  letter-spacing: 1px;
  animation: storyTitleShimmer 7s ease-in-out infinite;
  filter: drop-shadow(0 2px 10px rgba(212, 175, 55, 0.2));
}

/* ─── PHOTO placeholder & loaded states ─────────────────────────────────────── */

.story-card-photo {
  width: 100%;
  aspect-ratio: 3 / 4; /* Portrait ratio to accommodate most photos */
  max-height: 400px;
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 0.75rem;
  position: relative;
  flex-shrink: 0;
  /* Placeholder background shown when src is empty */
  background: linear-gradient(
    135deg,
    rgba(28, 8, 55, 0.85) 0%,
    rgba(60, 16, 80, 0.78) 50%,
    rgba(28, 8, 55, 0.82) 100%
  );
  border: 1px dashed rgba(212, 175, 55, 0.28);
}

/* Camera icon centred in the placeholder */
.story-card-photo::before {
  content: "📷";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, calc(-50% - 10px));
  font-size: 1.9rem;
  opacity: 0.35;
  pointer-events: none;
  z-index: 1;
}

/* "your photo here" label below the icon */
.story-card-photo::after {
  content: "your photo here";
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  font-family: "Lora", Georgia, serif;
  font-style: italic;
  font-size: 0.65rem;
  letter-spacing: 1.4px;
  color: rgba(212, 175, 55, 0.38);
  white-space: nowrap;
  pointer-events: none;
  z-index: 1;
}

/* The actual <img> inside the figure */
.story-card-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  border-radius: 12px;
  display: block;
  transition:
    opacity 0.5s ease,
    transform 0.45s ease;
}

/* Hide broken-image icon when src is empty */
.story-card-img[src=""] {
  display: none;
}

/* When a real image is loaded, hide the placeholder decorations */
.story-card-photo:has(.story-card-img:not([src=""])) {
  background: none;
  border-color: transparent;
}

.story-card-photo:has(.story-card-img:not([src=""]))::before,
.story-card-photo:has(.story-card-img:not([src=""]))::after {
  display: none;
}

/* Subtle ken-burns / zoom on card hover (only when image is present) */
.story-card:hover
  .story-card-photo:has(.story-card-img:not([src=""]))
  .story-card-img {
  transform: scale(1.06);
}

/* Thin gold shimmer border on the photo when the card is hovered */
.story-card:hover .story-card-photo {
  border-color: rgba(212, 175, 55, 0.42);
  box-shadow: 0 0 14px rgba(212, 175, 55, 0.18);
  transition:
    border-color 0.35s ease,
    box-shadow 0.35s ease;
}

/* Increase card inner min-height to accommodate the photo */
.story-card-inner {
  min-height: 330px;
}

/* ─── Responsive ─────────────────────────────────────────────────────────────── */

@media (max-width: 640px) {
  .story-section {
    padding: 60px 12px 80px;
  }

  .story-item {
    grid-template-columns: 1fr 48px 0;
    padding: 1.2rem 0;
  }

  /* On mobile all cards go on the left column */
  .story-item--right {
    grid-template-columns: 0 48px 1fr;
  }

  .story-item--right .story-spacer {
    display: none;
  }

  .story-item--left .story-spacer {
    display: none;
  }

  .story-constellation {
    width: 180px;
  }

  .story-card-inner {
    min-height: 300px;
  }

  .story-card-photo {
    height: 120px;
  }

  .story-orb-ring {
    display: none; /* hide orbital dots on very small screens for perf */
  }
}

@media (max-width: 420px) {
  .story-item {
    grid-template-columns: 1fr 40px 0;
  }

  .story-item--right {
    grid-template-columns: 0 40px 1fr;
  }

  .story-node-ring {
    width: 36px;
    height: 36px;
  }

  .story-node-core {
    width: 28px;
    height: 28px;
    font-size: 0.82rem;
  }
}
