/* ═══════════════════════════════════════════════════════════
   RESET & CUSTOM PROPERTIES
═══════════════════════════════════════════════════════════ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  /* palette */
  --c-bg:         #fdf4ec;
  --c-blush:      #f9e0d8;
  --c-rose:       #d4877a;
  --c-deep-rose:  #b05a54;
  --c-petal:      #e8b5aa;
  --c-text:       #3d2b2b;
  --c-text-soft:  #7a5858;
  --c-cream:      #fef9f2;

  /* envelope */
  --env-bg:    #fef5e6;
  --env-flap:  #fce8cc;

  /* type */
  --serif: 'Cormorant Garamond', Georgia, serif;
  --sans:  'Lato', system-ui, sans-serif;

  /* layout */
  --section-py: clamp(4rem, 10vw, 8rem);
  --max-prose:  720px;
  --max-gallery: 1100px;
}

html { scroll-behavior: smooth; }

body {
  font-family: var(--sans);
  color: var(--c-text);
  background: var(--c-bg);
  overflow-x: hidden;
  min-height: 100vh;
}


/* ═══════════════════════════════════════════════════════════
   STAGE SYSTEM — mutual exclusivity
═══════════════════════════════════════════════════════════ */
.stage {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.stage.hidden { display: none; }

/* Main stage overrides: becomes a scrollable document */
#stage-main {
  display: block;
  overflow-y: auto;
  overflow-x: hidden;
}

#stage-main.fading-in {
  animation: fadeIn 0.9s ease both;
}


/* ═══════════════════════════════════════════════════════════
   FLOATING HEARTS (both stages)
═══════════════════════════════════════════════════════════ */
#hearts-container,
#main-hearts-container {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 0;
}

.floating-heart {
  position: absolute;
  bottom: -2rem;
  color: var(--c-rose);
  user-select: none;
  pointer-events: none;
  animation: floatUp linear forwards;
  opacity: var(--op, 0.22);
}

@keyframes floatUp {
  0%   { transform: translateY(0)       rotate(0deg);   opacity: var(--op, 0.22); }
  40%  { transform: translateY(-35vh)   rotate(12deg);  }
  80%  { transform: translateY(-75vh)   rotate(-8deg);  }
  100% { transform: translateY(-108vh)  rotate(4deg);   opacity: 0; }
}


/* ═══════════════════════════════════════════════════════════
   ENVELOPE STAGE — background
═══════════════════════════════════════════════════════════ */
#stage-envelope {
  background: radial-gradient(ellipse at 50% 40%,
    #fdeee6 0%, #faf0ea 45%, #f6e8ee 100%);
  z-index: 10;
}

/* ── Envelope scene wrapper ── */
#envelope-scene {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2rem;
  z-index: 1;
}

/* ── The envelope ── */
#envelope {
  position: relative;
  width: 320px;
  height: 210px;
  background: linear-gradient(160deg, var(--env-bg) 0%, #f6e4c8 100%);
  border-radius: 4px 4px 3px 3px;
  box-shadow:
    0 3px 6px rgba(180,100,80,0.08),
    0 10px 28px rgba(180,100,80,0.16),
    0 1px 0 rgba(255,255,255,0.7) inset;
  cursor: pointer;
  animation: envGlow 3.2s ease-in-out infinite;
  transition: transform 0.3s ease;
  overflow: visible;
}

#envelope:focus-visible {
  outline: 2px solid var(--c-rose);
  outline-offset: 4px;
}

/* Pulsing ambient glow */
@keyframes envGlow {
  0%, 100% { filter: drop-shadow(0 8px 18px rgba(212,135,120,0.18)); }
  50%       { filter: drop-shadow(0 14px 30px rgba(212,135,120,0.36)); }
}

/* Wiggle — layered on top of glow via JS class */
@keyframes wiggle {
  0%,  100% { transform: rotate(0deg)    translateY(0);   }
  12%        { transform: rotate(-2.8deg) translateY(-5px); }
  28%        { transform: rotate(2.2deg)  translateY(-3px); }
  44%        { transform: rotate(-1.8deg) translateY(-4px); }
  60%        { transform: rotate(1.2deg)  translateY(-2px); }
  76%        { transform: rotate(-0.6deg) translateY(-1px); }
}

/* .wiggle keeps glow animation running too; we re-declare both */
.wiggle {
  animation:
    wiggle  2.9s ease-in-out infinite 0.8s,
    envGlow 3.2s ease-in-out infinite;
}

/* ── Interior fold-line decorations ── */
/*    These create the classic diamond / X pattern inside the envelope   */
.env-fold {
  position: absolute;
  width: 0;
  height: 0;
  pointer-events: none;
}

/* Left panel: triangle from left edge to center */
.env-fold-left {
  top: 0; left: 0;
  border-top:    105px solid transparent;
  border-bottom: 105px solid transparent;
  border-left:   160px solid rgba(195,145,105,0.11);
}

/* Right panel */
.env-fold-right {
  top: 0; right: 0;
  border-top:    105px solid transparent;
  border-bottom: 105px solid transparent;
  border-right:  160px solid rgba(195,145,105,0.11);
}

/* Bottom panel: upward-pointing triangle */
.env-fold-bottom {
  bottom: 0; left: 0;
  border-left:   160px solid transparent;
  border-right:  160px solid transparent;
  border-bottom: 105px solid rgba(200,150,110,0.14);
}

/* ── Top flap — a downward-pointing triangle via clip-path ── */
.env-flap {
  position: absolute;
  top: -1px;
  left: -1px;
  width: calc(100% + 2px);
  height: 120px;                /* tall enough that apex reaches the center */
  background: linear-gradient(172deg, #fdebd0 0%, #f8d8b5 100%);
  clip-path: polygon(0 0, 100% 0, 50% 87.5%); /* apex at ~105 / 120 px */
  transform-origin: 50% 0%;
  z-index: 2;
  border-radius: 4px 4px 0 0;
  transition:
    clip-path  0.65s cubic-bezier(0.4, 0, 0.2, 1),
    transform  0.65s cubic-bezier(0.4, 0, 0.2, 1),
    opacity    0.45s ease;
}

/* Subtle pre-lift after first tap */
.env-flap.flap-crack {
  clip-path: polygon(0 0, 100% 0, 50% 74%);
  transform: translateY(-3px);
}

/* Full open — collapses upward */
.env-flap.flap-open {
  clip-path: polygon(0 0, 100% 0, 50% 0%);
  transform: translateY(-22px) scaleY(0.08);
  opacity: 0;
}

/* ── Wax seal ── */
.env-seal {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) translateY(-8px);
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: radial-gradient(circle at 38% 35%, #da9088, #b05050);
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255,255,255,0.92);
  font-size: 18px;
  z-index: 3;
  box-shadow: 0 2px 8px rgba(140,55,55,0.35), 0 1px 0 rgba(255,255,255,0.18) inset;
  transition: transform 0.4s ease, opacity 0.4s ease;
  pointer-events: none;
}

.env-seal.seal-open {
  transform: translate(-50%, -50%) translateY(-8px) scale(0.5);
  opacity: 0;
}

/* ── Letter paper that rises during the opening animation ── */
.rising-paper {
  position: absolute;
  top: 18px;
  left: 50%;
  width: 230px;
  padding: 22px 26px;
  background: #fffdf9;
  border-radius: 3px;
  box-shadow: 0 4px 18px rgba(0,0,0,0.12);
  display: flex;
  flex-direction: column;
  gap: 12px;
  transform: translateX(-50%) translateY(80px);
  opacity: 0;
  z-index: 1;
  transition:
    transform 0.62s cubic-bezier(0.25, 0.46, 0.45, 0.94),
    opacity   0.45s ease;
}

.rising-paper.rising {
  transform: translateX(-50%) translateY(-120px);
  opacity: 1;
  z-index: 5;
}

.paper-line {
  height: 2px;
  border-radius: 2px;
  background: linear-gradient(90deg, #eacfbe, #d8b8a2);
  opacity: 0.55;
  width: 90%;
}
.paper-line:nth-child(1) { width: 78%; }
.paper-line:nth-child(3) { width: 86%; }
.paper-line--short       { width: 44%; }

/* ── Scene exit (scale + fade before main page appears) ── */
.scene-exit {
  animation: sceneExit 0.6s ease forwards;
}

@keyframes sceneExit {
  to { transform: scale(1.1); opacity: 0; pointer-events: none; }
}

/* ── Tap hint ── */
.tap-hint {
  font-family: var(--serif);
  font-style: italic;
  font-size: 0.93rem;
  color: var(--c-text-soft);
  letter-spacing: 0.07em;
  margin-top: -0.75rem;
  transition: opacity 0.4s ease;
  pointer-events: none;
}


/* ═══════════════════════════════════════════════════════════
   PASSCODE PANEL
═══════════════════════════════════════════════════════════ */
.passcode-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
}

.passcode-panel.hidden { display: none; }

.passcode-panel.visible {
  animation: riseIn 0.4s ease both;
}

.passcode-label {
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.02rem;
  color: var(--c-text-soft);
  letter-spacing: 0.06em;
}

.pin-boxes {
  display: flex;
  gap: 0.7rem;
}

.pin-box {
  width: 54px;
  height: 62px;
  border: 1.5px solid rgba(180,120,100,0.32);
  border-radius: 8px;
  background: rgba(255,252,248,0.88);
  text-align: center;
  font-family: var(--serif);
  font-size: 1.5rem;
  color: var(--c-text);
  caret-color: var(--c-rose);
  outline: none;
  transition:
    border-color 0.2s ease,
    box-shadow   0.2s ease,
    transform    0.15s ease,
    background   0.2s ease;
  /* hide typed character on browsers that don't honor type=password well */
  -webkit-text-security: disc;
}

.pin-box:focus {
  border-color: var(--c-rose);
  box-shadow: 0 0 0 3px rgba(212,135,122,0.22);
  transform: scale(1.06);
  background: #fffdf8;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  18%       { transform: translateX(-9px); }
  36%       { transform: translateX(7px); }
  54%       { transform: translateX(-5px); }
  72%       { transform: translateX(4px); }
  90%       { transform: translateX(-2px); }
}

.pin-boxes.shake { animation: shake 0.55s ease; }

.pin-error {
  font-family: var(--serif);
  font-style: italic;
  font-size: 0.88rem;
  color: var(--c-deep-rose);
  letter-spacing: 0.03em;
}

.pin-error.hidden { display: none; }


/* ═══════════════════════════════════════════════════════════
   MAIN STAGE — background gradient
═══════════════════════════════════════════════════════════ */
#stage-main {
  background: linear-gradient(180deg,
    #fdeee8 0%,
    #fdf5f0 18%,
    #fdf8f4 45%,
    #faf3ef 75%,
    #f8eff1 100%
  );
}


/* ═══════════════════════════════════════════════════════════
   MUSIC BUTTON
═══════════════════════════════════════════════════════════ */
.music-btn {
  position: fixed;
  top: 1.2rem;
  right: 1.2rem;
  z-index: 200;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1.5px solid rgba(180,120,100,0.28);
  background: rgba(255,252,248,0.82);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: var(--c-text-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s, background 0.2s, transform 0.15s;
}

.music-btn:hover {
  color: var(--c-rose);
  border-color: var(--c-rose);
  transform: scale(1.08);
}

.music-btn.active {
  color: var(--c-deep-rose);
  border-color: var(--c-petal);
  background: rgba(250,228,220,0.88);
  animation: musicPulse 2s ease-in-out infinite;
}

@keyframes musicPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(212,135,122,0); }
  50%       { box-shadow: 0 0 0 5px rgba(212,135,122,0.2); }
}


/* ═══════════════════════════════════════════════════════════
   HERO
═══════════════════════════════════════════════════════════ */
.section-hero {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 5rem 2rem 4rem;
  position: relative;
}

.hero-inner {
  max-width: 640px;
  z-index: 1;
  position: relative;
}

.hero-eyebrow {
  display: block;
  font-family: var(--sans);
  font-weight: 300;
  font-size: 0.72rem;
  letter-spacing: 0.26em;
  text-transform: uppercase;
  color: var(--c-rose);
  margin-bottom: 1.4rem;
}

.hero-title {
  font-family: var(--serif);
  font-weight: 300;
  font-style: italic;
  font-size: clamp(2.8rem, 8.5vw, 5.6rem);
  line-height: 1.08;
  letter-spacing: -0.01em;
  color: var(--c-text);
  margin-bottom: 1rem;
  /* subtle text-shadow for depth */
  text-shadow: 0 2px 12px rgba(180,100,80,0.08);
}

.hero-since {
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.08rem;
  color: var(--c-text-soft);
  letter-spacing: 0.04em;
}

.divider-heart {
  margin: 2rem auto 0;
  color: var(--c-petal);
  font-size: 1.5rem;
  display: block;
  animation: heartbeat 2.8s ease-in-out infinite;
}

@keyframes heartbeat {
  0%, 100% { transform: scale(1);    opacity: 0.65; }
  40%       { transform: scale(1.18); opacity: 1; }
  60%       { transform: scale(1.1);  opacity: 0.9; }
}

.scroll-down {
  position: absolute;
  bottom: 2.5rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  color: var(--c-text-soft);
  font-family: var(--sans);
  font-size: 0.68rem;
  font-weight: 300;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  opacity: 0.55;
  animation: scrollBounce 2.4s ease-in-out infinite;
}

@keyframes scrollBounce {
  0%, 100% { transform: translateX(-50%) translateY(0); }
  50%       { transform: translateX(-50%) translateY(6px); }
}


/* ═══════════════════════════════════════════════════════════
   SECTION EYEBROW LABEL (reused across sections)
═══════════════════════════════════════════════════════════ */
.section-eyebrow {
  font-family: var(--sans);
  font-weight: 300;
  font-size: 0.7rem;
  letter-spacing: 0.26em;
  text-transform: uppercase;
  color: var(--c-rose);
  text-align: center;
  margin-bottom: 3rem;
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

.section-eyebrow.in-view {
  opacity: 1;
  transform: translateY(0);
}


/* ═══════════════════════════════════════════════════════════
   LETTER SECTION
═══════════════════════════════════════════════════════════ */
.section-letter {
  padding: var(--section-py) 2rem;
  max-width: var(--max-prose);
  margin: 0 auto;
}

.letter-card {
  background: #fffdf8;
  border-radius: 3px;
  padding: clamp(2rem, 6vw, 4rem) clamp(1.75rem, 6vw, 3.5rem);
  box-shadow:
    0 2px 5px rgba(180,120,80,0.07),
    0 8px 28px rgba(180,120,80,0.11),
    0 1px 0 rgba(255,255,255,0.85) inset;
  position: relative;
  /* top accent line */
  border-top: 2.5px solid rgba(212,135,122,0.22);
  /* scroll-reveal handled below */
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.7s ease, transform 0.7s ease;
}

.letter-card.in-view {
  opacity: 1;
  transform: translateY(0);
}

/* Thin rule below the accent line */
.letter-card::before {
  content: '';
  position: absolute;
  top: 0.6rem;
  left: 2.5rem;
  right: 2.5rem;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(212,135,122,0.14), transparent);
}

/* Decorative corner stamp */
.letter-card::after {
  content: '♥';
  position: absolute;
  top: 1.1rem;
  right: 1.4rem;
  font-size: 0.7rem;
  color: var(--c-petal);
  opacity: 0.5;
}

.letter-body {
  font-family: var(--serif);
  font-weight: 300;
  font-size: clamp(1.05rem, 2.5vw, 1.22rem);
  line-height: 2;
  color: var(--c-text);
}

.letter-body p {
  margin-bottom: 1.6em;
}

.letter-body p:last-child { margin-bottom: 0; }


/* ═══════════════════════════════════════════════════════════
   GALLERY
═══════════════════════════════════════════════════════════ */
.section-gallery {
  padding: var(--section-py) 2rem;
  max-width: var(--max-gallery);
  margin: 0 auto;
}

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr));
  gap: 1.75rem;
}

/* scroll-reveal for photo cards */
.observe {
  opacity: 0;
  transform: translateY(22px);
  transition: opacity 0.55s ease, transform 0.55s ease;
}

.observe.in-view {
  opacity: 1;
  transform: translateY(0);
}

.photo-card {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.photo-wrap {
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  aspect-ratio: 4 / 3;
  background: linear-gradient(135deg, #fde8dc 0%, #f5d0c2 100%);
  box-shadow: 0 3px 12px rgba(180,100,80,0.09);
  transition: transform 0.38s ease, box-shadow 0.38s ease;
}

.photo-wrap:focus-visible {
  outline: 2px solid var(--c-rose);
  outline-offset: 3px;
}

.photo-wrap:hover {
  transform: translateY(-5px) scale(1.012);
  box-shadow: 0 14px 36px rgba(180,100,80,0.22);
}

.photo-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.5s ease;
}

.photo-wrap:hover img { transform: scale(1.05); }

.photo-overlay {
  position: absolute;
  inset: 0;
  background: rgba(155, 72, 65, 0.22);
  backdrop-filter: blur(1px);
  -webkit-backdrop-filter: blur(1px);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.photo-wrap:hover .photo-overlay { opacity: 1; }

.overlay-icon {
  font-size: 1.8rem;
  color: rgba(255,255,255,0.9);
  text-shadow: 0 1px 6px rgba(0,0,0,0.25);
  transition: transform 0.2s ease;
}

.photo-wrap:hover .overlay-icon { transform: scale(1.15); }

.photo-caption {
  font-family: var(--serif);
  font-style: italic;
  font-size: 0.96rem;
  color: var(--c-text-soft);
  text-align: center;
  letter-spacing: 0.02em;
}


/* ═══════════════════════════════════════════════════════════
   CLOSING
═══════════════════════════════════════════════════════════ */
.section-closing {
  padding: var(--section-py) 2rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.closing-sign {
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.1rem;
  color: var(--c-text-soft);
  letter-spacing: 0.04em;
}

.closing-name {
  font-family: var(--serif);
  font-weight: 300;
  font-style: italic;
  font-size: clamp(2.4rem, 6.5vw, 3.5rem);
  line-height: 1.05;
  color: var(--c-text);
  text-shadow: 0 2px 10px rgba(180,100,80,0.07);
}

.closing-hearts {
  margin-top: 1.2rem;
  color: var(--c-petal);
  font-size: 0.95rem;
  letter-spacing: 0.35em;
  animation: heartbeat 2.8s ease-in-out infinite;
}


/* ═══════════════════════════════════════════════════════════
   LIGHTBOX
═══════════════════════════════════════════════════════════ */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(28, 12, 12, 0.88);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  cursor: pointer;
}

.lightbox.hidden  { display: none; }

.lightbox.visible {
  animation: fadeIn 0.3s ease both;
}

.lightbox.closing {
  animation: fadeOut 0.32s ease forwards;
}

.lightbox-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.2rem;
  max-width: min(90vw, 900px);
  max-height: 90vh;
  cursor: default;
}

#lightbox-img {
  max-width: 100%;
  max-height: 76vh;
  object-fit: contain;
  border-radius: 6px;
  box-shadow: 0 10px 50px rgba(0,0,0,0.5);
  display: block;
  animation: lbImgIn 0.35s ease both;
}

@keyframes lbImgIn {
  from { transform: scale(0.93); opacity: 0; }
  to   { transform: scale(1);    opacity: 1; }
}

.lightbox-caption {
  font-family: var(--serif);
  font-style: italic;
  font-size: 1rem;
  color: rgba(255,245,240,0.84);
  text-align: center;
  letter-spacing: 0.03em;
}

.lightbox-close {
  position: fixed;
  top: 1.4rem;
  right: 1.4rem;
  z-index: 1020;
  background: transparent;
  border: 1.5px solid rgba(255,255,255,0.28);
  color: rgba(255,255,255,0.78);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 1.45rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s, border-color 0.2s, transform 0.2s;
}

.lightbox-close:hover {
  color: #fff;
  border-color: rgba(255,255,255,0.6);
  transform: scale(1.1) rotate(90deg);
}


/* ═══════════════════════════════════════════════════════════
   UTILITY ANIMATIONS
═══════════════════════════════════════════════════════════ */
@keyframes fadeIn  { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeOut { from { opacity: 1; } to { opacity: 0; } }

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


/* ═══════════════════════════════════════════════════════════
   RESPONSIVE
═══════════════════════════════════════════════════════════ */
@media (max-width: 520px) {
  /* Slightly smaller envelope on phones */
  #envelope {
    width: 280px;
    height: 184px;
  }

  .env-flap {
    height: 105px;
    /* apex: 92/105 ≈ 87.6% — keeps it at center */
    clip-path: polygon(0 0, 100% 0, 50% 87.6%);
  }

  .env-fold-left,
  .env-fold-right {
    border-top-width:    92px;
    border-bottom-width: 92px;
    border-left-width:   140px;
    border-right-width:  140px;
  }

  .env-fold-bottom {
    border-left-width:   140px;
    border-right-width:  140px;
    border-bottom-width: 92px;
  }

  .pin-box {
    width: 46px;
    height: 54px;
    font-size: 1.3rem;
  }

  .photo-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
  }

  .hero-title {
    font-size: clamp(2.3rem, 10vw, 3.5rem);
  }
}

@media (max-width: 360px) {
  .pin-box { width: 40px; height: 48px; }
  .pin-boxes { gap: 0.5rem; }
}

/* ═══════════════════════════════════════════════════════════
   THREE.JS CANVAS ELEMENTS
═══════════════════════════════════════════════════════════ */

/* 3D envelope canvas — fills the whole envelope stage */
#envelope-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  display: none; /* shown only when WebGL is confirmed (body.webgl) */
  cursor: pointer;
}

/* Particle-heart canvas — fixed fullscreen behind main page content.
   position:fixed inside a position:fixed parent renders at viewport
   coords but remains in the parent's stacking context (hidden with it). */
#heart-canvas {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  display: none; /* shown only in WebGL mode */
}

/* White-flash overlay used at the end of the 3D opening sequence */
#gl-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: #fff8f4;
  opacity: 0;
  pointer-events: none;
  display: none;
  transition: opacity 0.05s linear; /* JS drives opacity directly */
}

/* ── WebGL-active overrides (body gets class "webgl" from JS) ── */

/* Show the 3D canvases */
body.webgl #envelope-canvas { display: block; }
body.webgl #heart-canvas    { display: block; }
body.webgl #gl-overlay      { display: block; }

/* Hide the CSS envelope div — the 3D canvas replaces it */
body.webgl #envelope        { display: none !important; }

/* Hide CSS floating-heart systems — the particle canvas replaces them */
body.webgl #hearts-container      { display: none; }
body.webgl #main-hearts-container { display: none; }

/* Make the main stage transparent so the body gradient shows through
   and the particle canvas (z-index:0 inside the stage stacking context)
   is visible behind the content sections. */
body.webgl #stage-main {
  background: transparent;
}

/* Warm body gradient visible through the transparent stage */
body.webgl {
  background: linear-gradient(180deg,
    #fdeee8 0%, #fdf5f0 18%, #fdf8f4 45%, #faf3ef 75%, #f8eff1 100%
  );
}

/* Content sections must sit above the canvas (z-index:0) in the
   stage's stacking context. position:relative promotes them to
   a new stacking level so z-index takes effect. */
body.webgl .section-hero,
body.webgl .section-letter,
body.webgl .section-gallery,
body.webgl .section-closing {
  position: relative;
  z-index: 1;
}

/* Respect reduced-motion preference */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration:   0.01ms !important;
    transition-duration:  0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
