:root {
  --p: 0;                       /* progreso del scroll (0 = blanco, 1 = rosa) */
  --rose: #e44a68;
  --deep: #8e0b26;
  --ink: #5a0f22;
  --paper: #fffdf9;
  --font-display: "Cinzel Decorative", "Cinzel", Georgia, serif;
  --font-serif: "Cormorant Garamond", Georgia, "Times New Roman", serif;
  --ease-out: cubic-bezier(0.2, 0.7, 0.2, 1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font-serif);
  color: var(--ink);
  background: #ffffff;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Fondo y corazones ---------- */

#bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  background: #ffffff;
  pointer-events: none;
}
#bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(120% 70% at 50% 0%, rgba(255, 160, 180, 0.55), transparent 60%),
    radial-gradient(120% 60% at 50% 110%, rgba(110, 0, 30, 0.45), transparent 65%);
  opacity: var(--p);
}

#hearts {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  overflow: hidden;
}
.heart {
  position: absolute;
  top: 100%;
  will-change: transform, opacity;
}
.heart svg {
  display: block;
  width: 100%;
  height: 100%;
  fill: var(--heart-color, rgb(232, 72, 104));
}

main {
  position: relative;
  z-index: 2;
  overflow: hidden;
}

/* ---------- 1. Portada ---------- */

.hero {
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 0 16px 16svh;
  position: relative;
}
.hero-inner {
  transform: translateY(calc(var(--p) * -50px));
  opacity: calc(1 - var(--p) * 0.85);
}

.name {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: clamp(3rem, 17.5vw, 7.5rem);
  line-height: 1.05;
  letter-spacing: 0.03em;
  white-space: nowrap;
  filter:
    drop-shadow(0 1px 0 rgba(120, 80, 10, 0.35))
    drop-shadow(0 8px 18px rgba(200, 150, 40, 0.3));
}
.name .ch {
  display: inline-block;
  /* Oro metálico: degradado diagonal con un brillo que recorre las letras */
  background:
    linear-gradient(115deg, transparent 40%, rgba(255, 248, 220, 0.8) 50%, transparent 60%) 0 0 / 300% 100% no-repeat,
    linear-gradient(180deg, #f8de88 0%, #ebc257 24%, #cf9d30 50%, #a0700f 76%, #c4912f 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
  opacity: 0;
  transform: translateY(28px) scale(0.92);
}
.ready .name .ch {
  animation:
    letterIn 1.1s var(--ease-out) forwards,
    sheen 7s ease-in-out infinite;
  animation-delay:
    calc(var(--i) * 0.12s + 0.15s),
    calc(var(--i) * 0.09s + 2s);
}
@keyframes letterIn {
  to { opacity: 1; transform: none; }
}
@keyframes sheen {
  0% { background-position: 150% 0, 0 0; }
  35%, 100% { background-position: -50% 0, 0 0; }
}

/* Pájaros con corazoncitos volando sobre el nombre (todo el ancho de la pantalla) */
.birds {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 4px);
  width: 100vw;
  height: min(26vh, 220px);
  transform: translateX(-50%);
  pointer-events: none;
  opacity: 0;
  transition: opacity 1.6s ease;
}
.ready .birds { opacity: 1; transition-delay: 1s; }
.bird {
  position: absolute;
  left: 0;
  top: 0;
  will-change: transform;
}
.bird svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
  fill: #7a1530;
}
.bird .wings {
  transform-box: view-box;
  transform-origin: 20px 10.5px;
  animation: flap var(--flap) ease-in-out infinite alternate;
}
@keyframes flap {
  from { transform: scaleY(1); }
  to { transform: scaleY(-0.45); }
}
.trail-heart {
  position: absolute;
  left: 0;
  top: 0;
  pointer-events: none;
}
.trail-heart svg { display: block; width: 100%; height: 100%; }

/* Chispas doradas alrededor del nombre */
.name-wrap {
  position: relative;
  display: inline-block;
}
.sparks {
  position: absolute;
  inset: -22% -6%;
  pointer-events: none;
}
.spark {
  position: absolute;
  width: var(--s);
  height: var(--s);
  margin: calc(var(--s) / -2) 0 0 calc(var(--s) / -2);
  opacity: 0;
  animation: twinkle var(--d) ease-in-out forwards;
}
.spark svg {
  display: block;
  width: 100%;
  height: 100%;
  fill: #e0ad38;
  filter: drop-shadow(0 0 4px rgba(240, 190, 70, 0.95));
}
.spark.dot {
  border-radius: 50%;
  background: radial-gradient(circle, #fff3c4 0%, #e0ad38 45%, rgba(224, 173, 56, 0) 72%);
}
@keyframes twinkle {
  0%   { opacity: 0; transform: scale(0.2) rotate(0deg); }
  45%  { opacity: 0.95; transform: scale(1) rotate(40deg); }
  100% { opacity: 0; transform: scale(0.4) rotate(90deg) translateY(-6px); }
}

.divider {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin: 14px auto;
  opacity: 0;
}
.divider .line {
  height: 1px;
  width: min(26vw, 120px);
  background: linear-gradient(90deg, transparent, #d23a5c);
  transform: scaleX(0);
  transform-origin: right center;
}
.divider .line:last-child {
  background: linear-gradient(90deg, #d23a5c, transparent);
  transform-origin: left center;
}
.divider-heart {
  width: 12px;
  height: 12px;
  fill: #d23a5c;
}
.ready .divider {
  animation: fadeIn 0.6s ease forwards 0.9s;
}
.ready .divider .line {
  animation: drawLine 1s var(--ease-out) forwards 1s;
}
@keyframes drawLine { to { transform: scaleX(1); } }
@keyframes fadeIn { to { opacity: 1; } }

.title {
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: clamp(0.82rem, 3.7vw, 1.25rem);
  letter-spacing: 0.3em;
  padding-left: 0.3em; /* compensa el espaciado final para centrar */
  text-transform: uppercase;
  color: #b01e40;
  opacity: 0;
  transform: translateY(8px);
}
.ready .title {
  animation: rise 1s var(--ease-out) forwards 1.25s;
}
@keyframes rise { to { opacity: 1; transform: none; } }

.scroll-hint {
  position: absolute;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 22px);
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 0.8rem;
  letter-spacing: 0.3em;
  padding-left: 0.3em;
  text-transform: uppercase;
  color: #c0304f;
  opacity: calc(1 - var(--p) * 3);
}
.scroll-hint > * { opacity: 0; }
.scroll-hint svg { width: 20px; height: 20px; animation: bob 1.6s ease-in-out infinite; }
.ready .scroll-hint > * {
  animation: hintIn 1s ease forwards 2.2s;
}
.ready .scroll-hint svg {
  animation: hintIn 1s ease forwards 2.2s, bob 1.6s ease-in-out infinite;
}
@keyframes hintIn { to { opacity: 0.85; } }
@keyframes bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(5px); }
}

/* ---------- Collage de fotos (polaroids) ---------- */

.memories {
  position: relative;
  padding: 10svh 0 4svh;
}
.collage {
  position: relative;
  width: 100%;
  max-width: 980px;
  margin: 0 auto;
}
.polaroid {
  position: absolute;
  left: 0;
  top: 0;
  display: block;
  border: 0;
  margin: 0;
  background: #fffdf8;
  border-radius: 2px;
  box-shadow: 0 10px 22px rgba(70, 0, 20, 0.3), 0 2px 4px rgba(0, 0, 0, 0.18);
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  /* entrada: "lanzada" sobre la mesa */
  opacity: 0;
  transform: translateY(-50px) rotate(calc(var(--r) * 3)) scale(1.25);
  transition:
    transform 0.9s cubic-bezier(0.2, 0.85, 0.25, 1.08) var(--d, 0s),
    opacity 0.5s ease var(--d, 0s);
}
.polaroid.in {
  opacity: 1;
  transform: rotate(var(--r));
}
.polaroid .ph {
  display: block;
  width: 100%;
  overflow: hidden;
  background: #e9d7da;
}
.polaroid img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
/* Huellas de gato: tenues, como si un gatito hubiera caminado sobre la foto */
.paws {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 1;
}
.paw {
  position: absolute;
  width: var(--ps, 14%);
  aspect-ratio: 1;
  transform: translate(-50%, -50%) rotate(var(--pr, 0deg));
}
.paw svg {
  display: block;
  width: 100%;
  height: 100%;
  /* tono polvoso intermedio: se nota tanto en fotos oscuras como en claras */
  fill: #9a7e70;
  opacity: var(--po, 0.4);
}

/* "Hayden ❤️" escrito en cursiva en el borde de abajo (collage y foto ampliada) */
.cap {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: var(--chin, 20px);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "Dancing Script", "Segoe Script", "Brush Script MT", cursive;
  font-weight: 600;
  font-size: calc(var(--chin, 20px) * 0.62);
  /* dorado metálico, en tonos profundos para que se lea sobre el borde crema */
  color: #a8781c;
  background: linear-gradient(180deg, #e2b64e 0%, #b8862b 50%, #875a10 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0.5px 0 rgba(90, 55, 0, 0.25));
  line-height: 1;
  white-space: nowrap;
  pointer-events: none;
  transform: rotate(-2deg);
}
.cap:empty { display: none; }
.cap-heart {
  flex: none;
  width: 0.72em;
  height: 0.72em;
  margin: 0.12em 0.22em 0;
  fill: url(#goldInk);
}

/* Foto ampliada: la polaroid sale del collage y crece al centro; el fondo se difumina */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: flex;
  align-items: center;
  justify-content: center;
}
.lightbox[hidden] { display: none; }
.lightbox::before {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(40, 0, 12, 0.45);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  opacity: 0;
  transition: opacity 0.45s ease;
}
.lightbox.open::before { opacity: 1; }
.lb-card {
  position: relative;
  margin: 0;
  background: #fffdf8;
  border-radius: 3px;
  box-shadow: 0 28px 70px rgba(0, 0, 0, 0.45), 0 4px 10px rgba(0, 0, 0, 0.2);
  will-change: transform;
}
.lb-card img {
  display: block;
  width: 100%;
  object-fit: cover;
  background: #e9d7da;
}
.lb-close {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + 14px);
  right: 14px;
  z-index: 2;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  color: #5a0f22;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.3);
  cursor: pointer;
  opacity: 0;
  transform: scale(0.6);
  transition: opacity 0.3s ease, transform 0.35s cubic-bezier(0.2, 0.9, 0.3, 1.3);
  -webkit-appearance: none;
  appearance: none;
}
.lb-close svg { width: 22px; height: 22px; }
.lightbox.open .lb-close { opacity: 1; transform: none; transition-delay: 0.2s; }
.lb-close:active { transform: scale(0.9); }

/* ---------- Botón de música ---------- */

.music {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 12px);
  right: 12px;
  z-index: 65;
  width: 42px;
  height: 42px;
  padding: 0;
  display: grid;
  place-items: center;
  border: 1px solid rgba(190, 150, 70, 0.45);
  border-radius: 50%;
  color: #b48a2c;
  background: rgba(255, 255, 255, 0.72);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  box-shadow: 0 4px 14px rgba(120, 20, 40, 0.18);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  -webkit-appearance: none;
  appearance: none;
  animation: musicIn 0.6s ease 1.2s backwards;
  transition: transform 0.2s ease, opacity 0.3s ease;
}
.music[hidden] { display: none; }
.music:active { transform: scale(0.9); }
.music svg { width: 22px; height: 22px; overflow: visible; }
.music .slash { transition: opacity 0.25s ease; }
.music .note { opacity: 0.55; transition: opacity 0.25s ease; transform-origin: 12px 12px; }
.music.on .slash { opacity: 0; }
.music.on .note { opacity: 1; animation: noteBob 1.6s ease-in-out infinite; }
/* Un anillo suave que "late" mientras suena */
.music::after {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: 50%;
  border: 1px solid rgba(190, 150, 70, 0.5);
  opacity: 0;
  pointer-events: none;
}
.music.on::after { animation: musicPulse 2.2s ease-out infinite; }

@keyframes musicIn { from { opacity: 0; transform: scale(0.6); } }
@keyframes noteBob {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  25% { transform: translateY(-1.5px) rotate(-6deg); }
  75% { transform: translateY(0.5px) rotate(5deg); }
}
@keyframes musicPulse {
  0% { opacity: 0.8; transform: scale(1); }
  100% { opacity: 0; transform: scale(1.55); }
}
@media (prefers-reduced-motion: reduce) {
  .music.on .note, .music.on::after { animation: none; }
}

/* ---------- 2. Hayden es... ---------- */

.love {
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: #fff;
  padding: 10svh 16px calc(env(safe-area-inset-bottom, 0px) + 10svh);
}

.love-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(2rem, 10vw, 3.4rem);
  letter-spacing: 0.02em;
  text-shadow: 0 4px 24px rgba(110, 0, 30, 0.35);
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 1s ease, transform 1s var(--ease-out);
}
.love.visible .love-title { opacity: 1; transform: none; }

.cycler {
  min-height: 2.8em;
  font-size: clamp(2.6rem, 13vw, 4.4rem);
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 600;
  line-height: 1.1;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 3svh;
  text-shadow: 0 6px 30px rgba(110, 0, 30, 0.35);
}
.cycler.long { font-size: clamp(1.6rem, 7.5vw, 2.6rem); }

.cycler .word { display: inline-block; }
.cycler .w { display: inline-block; white-space: nowrap; }
.cycler .ch {
  display: inline-block;
  opacity: 0;
  transform: translateY(0.35em) scale(0.9);
  filter: blur(6px);
  animation: chIn 0.7s var(--ease-out) forwards;
  animation-delay: calc(var(--k) * var(--step, 0.06s));
}
@keyframes chIn { to { opacity: 1; transform: none; filter: blur(0); } }
.cycler .word.out {
  transition: opacity 0.5s ease, transform 0.5s ease, filter 0.5s ease;
  opacity: 0;
  transform: translateY(-0.3em);
  filter: blur(6px);
}

.dots {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-top: 6px;
  opacity: 0;
  transition: opacity 1s ease 0.4s;
}
.love.visible .dots { opacity: 1; }
.dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.35);
  transition: background 0.4s ease, transform 0.4s ease;
}
.dots span.on { background: #fff; transform: scale(1.35); }

/* Botón "Continuar" */
.continue-wrap {
  position: relative;
  margin-top: 7svh;
  min-height: 64px;
  display: flex;
  justify-content: center;
}
.continue {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 15px 30px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(180deg, #ffffff, #ffe9ee);
  color: #b3163a;
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 1.2rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  box-shadow: 0 10px 30px rgba(110, 0, 30, 0.35), 0 0 0 6px rgba(255, 255, 255, 0.18);
  animation: btnIn 0.9s var(--ease-out) backwards, btnPulse 2.4s ease-in-out 1s infinite;
  transition: transform 0.15s ease;
}
.continue[hidden] { display: none; }
.continue span { padding-left: 0.22em; }
.continue svg {
  width: 16px;
  height: 16px;
  fill: #e44a68;
  animation: beat 1.2s ease-in-out infinite;
}
.continue svg:last-of-type { animation-delay: 0.15s; }
.continue:active { transform: scale(0.96); }
@keyframes btnIn {
  from { opacity: 0; transform: translateY(18px) scale(0.9); }
  to { opacity: 1; transform: none; }
}
@keyframes btnPulse {
  0%, 100% { box-shadow: 0 10px 30px rgba(110, 0, 30, 0.35), 0 0 0 6px rgba(255, 255, 255, 0.18); }
  50% { box-shadow: 0 10px 30px rgba(110, 0, 30, 0.35), 0 0 0 12px rgba(255, 255, 255, 0.08); }
}
@keyframes beat {
  0%, 100% { transform: scale(1); }
  20% { transform: scale(1.3); }
  40% { transform: scale(1); }
}
/* Corazoncitos que salen del botón */
.btn-heart {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 14px;
  height: 14px;
  margin: -7px 0 0 -7px;
  pointer-events: none;
}
.btn-heart svg { width: 100%; height: 100%; fill: #fff; display: block; }

/* ---------- 3. Carta ---------- */

.letter-section {
  position: relative;
  overflow: hidden;
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  /* espacio arriba para las opciones SÍ / NO y la carita */
  padding: max(8svh, 160px) 16px calc(env(safe-area-inset-bottom, 0px) + 8svh);
}
.letter-section[hidden] { display: none; }

/* ---------- SÍ / NO ---------- */

.answer {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 60px);
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 18px;
  transform: translateX(-50%);
  white-space: nowrap;
  animation: answerIn 1s var(--ease-out) backwards;
  transition: opacity 0.5s ease, transform 0.5s ease;
}
.answer[hidden] { display: none; }
.answer.chosen {
  opacity: 0;
  transform: translateX(-50%) scale(0.85);
  pointer-events: none;
}
@keyframes answerIn {
  from { opacity: 0; transform: translateX(-50%) translateY(16px); }
  to { opacity: 1; transform: translateX(-50%); }
}
.opt {
  border: 0;
  background: none;
  padding: 6px 14px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(2.2rem, 11vw, 3rem);
  letter-spacing: 0.06em;
  color: #fff;
  text-shadow: 0 0 18px rgba(255, 255, 255, 0.55), 0 4px 18px rgba(110, 0, 30, 0.45);
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  transition: transform 0.15s ease;
  animation: optGlow 2.4s ease-in-out infinite;
}
.opt:last-child { animation-delay: 1.2s; }
.opt:active { transform: scale(0.9); }
@keyframes optGlow {
  0%, 100% { text-shadow: 0 0 14px rgba(255, 255, 255, 0.4), 0 4px 18px rgba(110, 0, 30, 0.45); }
  50% { text-shadow: 0 0 26px rgba(255, 255, 255, 0.85), 0 4px 18px rgba(110, 0, 30, 0.45); }
}
.opt-sep {
  width: 16px;
  height: 16px;
  fill: #fff;
  opacity: 0.85;
  animation: beat 1.2s ease-in-out infinite;
}

/* Caritas */
.face {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 50px);
  z-index: 3;
  width: 112px;
  height: 112px;
  margin-left: -56px;
  filter: drop-shadow(0 10px 18px rgba(80, 0, 20, 0.35));
}
.face[hidden] { display: none; }
.face svg { display: block; width: 100%; height: 100%; }
.face.happy svg {
  animation:
    faceIn 0.9s cubic-bezier(0.2, 0.9, 0.3, 1.45) both,
    faceBounce 1.6s ease-in-out 0.9s infinite;
}
.face.sad svg {
  animation:
    faceSadIn 1.4s ease both,
    faceDroop 4s ease-in-out 1.4s infinite;
}
@keyframes faceIn {
  from { transform: scale(0) rotate(-200deg); }
  to { transform: scale(1) rotate(0deg); }
}
@keyframes faceBounce {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  25% { transform: translateY(-10px) rotate(-6deg); }
  50% { transform: translateY(0) rotate(0deg); }
  75% { transform: translateY(-10px) rotate(6deg); }
}
@keyframes faceSadIn {
  from { opacity: 0; transform: translateY(-24px) scale(0.8); }
  to { opacity: 1; transform: none; }
}
@keyframes faceDroop {
  0%, 100% { transform: rotate(-4deg); }
  50% { transform: rotate(4deg) translateY(3px); }
}
.tear {
  transform-box: fill-box;
  animation: tear 2.2s ease-in 1.4s infinite;
  opacity: 0;
}
@keyframes tear {
  0% { opacity: 0; transform: translateY(0) scale(0.6); }
  20% { opacity: 1; transform: translateY(0) scale(1); }
  85% { opacity: 1; transform: translateY(26px) scale(1); }
  100% { opacity: 0; transform: translateY(32px) scale(0.9); }
}

/* ---------- NO: todo se vuelve gris ---------- */

#bg, #hearts, main { transition: filter 1.8s ease; }
.sad #bg, .sad #hearts, .sad main { filter: grayscale(1) brightness(0.92); }

/* Corazón roto (fuera de lo gris, por encima de todo) */
.broken {
  position: fixed;
  left: 50%;
  top: 50%;
  z-index: 60;
  width: 190px;
  height: 190px;
  margin: -95px 0 0 -95px;
  pointer-events: none;
  filter: drop-shadow(0 12px 30px rgba(0, 0, 0, 0.4));
  animation: bhIn 0.6s cubic-bezier(0.2, 0.9, 0.3, 1.35) both;
}
.broken svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
  animation: bhBeat 0.45s ease-in-out 0.65s 2;
}
.bh-half {
  transform-box: view-box;
  transform-origin: 12px 21.6px;
}
.bh-left { animation: bhLeft 1.9s cubic-bezier(0.5, 0, 0.8, 0.4) 2s forwards; }
.bh-right { animation: bhRight 1.9s cubic-bezier(0.5, 0, 0.8, 0.4) 2s forwards; }
.bh-crack {
  stroke-dasharray: 20;
  stroke-dashoffset: 20;
  animation: bhCrack 0.4s ease-out 1.55s forwards, bhFade 0.3s ease 2.1s forwards;
}
@keyframes bhIn { from { opacity: 0; transform: scale(0.3); } to { opacity: 1; transform: none; } }
@keyframes bhBeat { 50% { transform: scale(1.12); } }
@keyframes bhCrack { to { stroke-dashoffset: 0; } }
@keyframes bhFade { to { opacity: 0; } }
@keyframes bhLeft {
  0% { transform: none; opacity: 1; }
  22% { transform: translate(-1.4px, 0.3px) rotate(-16deg); opacity: 1; }
  100% { transform: translate(-5px, 34px) rotate(-55deg); opacity: 0; }
}
@keyframes bhRight {
  0% { transform: none; opacity: 1; }
  22% { transform: translate(1.4px, 0.3px) rotate(16deg); opacity: 1; }
  100% { transform: translate(5px, 34px) rotate(55deg); opacity: 0; }
}

.stage {
  position: relative;
  z-index: 2;
  opacity: 0;
  transform: translateY(30px);
}
.letter-section.visible .stage {
  opacity: 1;
  transform: none;
  transition: opacity 1s ease 0.5s, transform 1s var(--ease-out) 0.5s;
}

/*
 * Ni .env-wrap ni .envelope crean un "stacking context" (sin transform,
 * opacity ni perspective) para que la carta (z 2) quede entre el fondo
 * del sobre y el bolsillo delantero (z 3).
 */
.env-wrap {
  --w: min(84vw, 340px);
  --h: calc(var(--w) * 0.64);
  position: relative;
  width: var(--w);
  height: var(--h);
  margin: 0 auto;
}
.envelope {
  position: absolute;
  inset: 0;
  cursor: pointer;
}
/* El sobre cae y desaparece */
.envelope.fall {
  transform: translateY(110vh) rotate(16deg);
  opacity: 0;
  transition:
    transform 1s cubic-bezier(0.55, 0, 0.8, 0.2),
    opacity 0.4s ease 0.6s;
  pointer-events: none;
}

.env-back {
  position: absolute;
  inset: 0;
  border-radius: 8px;
  background: linear-gradient(180deg, #f1cfd2, #e6b3b8);
  box-shadow: 0 26px 50px rgba(90, 0, 25, 0.35), 0 4px 10px rgba(90, 0, 25, 0.2);
}

.letter-holder {
  position: absolute;
  left: 5%;
  width: 90%;
  bottom: 4%;
  z-index: 2;
  transition: transform 1.3s cubic-bezier(0.3, 0.7, 0.2, 1);
}
.letter {
  position: relative;
  overflow: hidden;
  border-radius: 6px;
  background:
    linear-gradient(180deg, rgba(255, 230, 236, 0.5), transparent 40%),
    var(--paper);
  box-shadow: 0 -4px 14px rgba(90, 0, 25, 0.12);
  text-align: center;
  color: var(--ink);
  /* Oculta la parte de la carta que sobresaldría del sobre cerrado */
  -webkit-clip-path: inset(var(--clip-top, 0px) 0 0 0 round 6px);
  clip-path: inset(var(--clip-top, 0px) 0 0 0 round 6px);
  transition: -webkit-clip-path 1.3s cubic-bezier(0.3, 0.7, 0.2, 1), clip-path 1.3s cubic-bezier(0.3, 0.7, 0.2, 1), box-shadow 0.8s ease;
}
.letter-holder.out .letter { --clip-top: 0px; }

/* Estado final: solo la carta, centrada (con espacio abajo para el gatito) */
.env-wrap.done { height: auto; margin-bottom: 120px; }

/* Gatito sosteniendo la carta */
.cat {
  position: absolute;
  left: 74%;
  top: calc(100% - 14px);
  z-index: 3;
  width: 112px;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, 34px) scale(0.85);
  transform-origin: 50% 0;
  transition: transform 0.8s cubic-bezier(0.2, 0.9, 0.3, 1.35), opacity 0.4s ease;
}
.cat.show {
  opacity: 1;
  transform: translate(-50%, 0);
}
.cat svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
  filter: drop-shadow(0 6px 10px rgba(80, 0, 20, 0.28));
}
/* Los otros gatitos alrededor de la carta (aparecen uno tras otro) */
.kitty {
  position: absolute;
  z-index: 3;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, 24px) scale(0.85);
  transition:
    transform 0.8s cubic-bezier(0.2, 0.9, 0.3, 1.35) var(--kd, 0s),
    opacity 0.4s ease var(--kd, 0s);
}
.kitty.on-top { transform: translate(-50%, -24px) scale(0.85); } /* caen sobre el borde */
.kitty.show { opacity: 1; transform: translate(-50%, 0); }
.kitty svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
  filter: drop-shadow(0 5px 8px rgba(80, 0, 20, 0.25));
}
/* Abajo: los pies alineados con los del gatito naranja */
.kitty-black { left: 20%; top: calc(100% + 32px); width: 66px; --kd: 0.25s; }
.kitty-lilac { left: 46%; top: calc(100% + 87px); width: 62px; --kd: 0.45s; }
/* Arriba: acostados sobre el borde de la carta */
.kitty-grey { left: 27%; bottom: calc(100% - 4px); width: 84px; --kd: 0.65s; }
.kitty-cream { left: 73%; bottom: calc(100% - 4px); width: 100px; --kd: 0.85s; }

.k-tail {
  transform-box: view-box;
  animation: tailSwish 3s ease-in-out infinite;
}
.k-blink {
  transform-box: fill-box;
  transform-origin: center;
  animation: catBlink 5s infinite;
}
.kitty-black .k-blink { animation-delay: 0.8s; }
.kitty-cream .k-blink { animation-delay: 2.2s; }
.kitty-cream .k-tail { animation-duration: 3.8s; }
.k-breathe {
  transform-box: fill-box;
  transform-origin: 50% 100%;
  animation: catBreathe 3.2s ease-in-out infinite;
}
@keyframes catBreathe {
  0%, 100% { transform: scaleY(1); }
  50% { transform: scaleY(1.05); }
}
.zz {
  fill: #fff;
  font: 700 8px "Cormorant Garamond", Georgia, serif;
  opacity: 0;
  transform-box: fill-box;
  animation: zzFloat 3s ease-out infinite;
}
.zz2 { font-size: 6px; animation-delay: 1.5s; }
@keyframes zzFloat {
  0% { opacity: 0; transform: translate(0, 0) scale(0.6); }
  30% { opacity: 0.9; }
  100% { opacity: 0; transform: translate(6px, -12px) scale(1.1); }
}

.cat-tail {
  transform-box: view-box;
  transform-origin: 84px 144px;
  animation: tailSwish 2.6s ease-in-out infinite;
}
@keyframes tailSwish {
  0%, 100% { transform: rotate(0deg); }
  50% { transform: rotate(-14deg); }
}
.cat-eyes > g {
  transform-box: fill-box;
  transform-origin: center;
  animation: catBlink 4.5s infinite;
}
@keyframes catBlink {
  0%, 92%, 100% { transform: scaleY(1); }
  95% { transform: scaleY(0.1); }
}
.cat-ear-r {
  transform-box: view-box;
  transform-origin: 78px 40px;
  animation: earTwitch 6s ease-in-out 2s infinite;
}
@keyframes earTwitch {
  0%, 90%, 100% { transform: rotate(0deg); }
  93% { transform: rotate(12deg); }
  96% { transform: rotate(-4deg); }
}
.env-wrap.done .envelope { display: none; }
.env-wrap.done .letter-holder {
  position: relative;
  left: auto;
  bottom: auto;
  margin: 0 auto;
}
.env-wrap.done .letter {
  box-shadow: 0 24px 50px rgba(90, 0, 25, 0.35), 0 4px 12px rgba(90, 0, 25, 0.18);
}

.letter-inner {
  padding: 34px 30px 40px;
}

/* Enredadera con rosas alrededor de la carta */
.vines {
  position: absolute;
  left: -16px;
  top: -16px;
  overflow: visible;
  pointer-events: none;
  filter: drop-shadow(0 2px 3px rgba(60, 0, 20, 0.25));
}
.vine {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  animation: vineGrow var(--dur) cubic-bezier(0.4, 0, 0.3, 1) forwards var(--delay);
}
@keyframes vineGrow { to { stroke-dashoffset: 0; } }
.leaf-grow,
.rose-bloom {
  transform-box: fill-box;
  transform: scale(0);
}
.leaf-grow {
  transform-origin: 0% 50%;
  animation: sprout 0.8s cubic-bezier(0.2, 0.9, 0.3, 1.25) forwards var(--delay);
}
.rose-bloom {
  transform-origin: 50% 50%;
  animation: bloom 1.2s cubic-bezier(0.2, 0.9, 0.3, 1.15) forwards var(--delay);
}
@keyframes sprout { to { transform: scale(1); } }
@keyframes bloom {
  from { transform: scale(0) rotate(-120deg); }
  to { transform: scale(1) rotate(0deg); }
}
.letter-heart {
  width: 18px;
  height: 18px;
  fill: #d23a5c;
  margin-bottom: 10px;
}
.letter-text p {
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 500;
  font-size: 1.22rem;
  line-height: 1.42;
}
.letter-text p + p { margin-top: 0.8em; }
.letter-sign {
  margin-top: 1.1em;
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 1rem;
  letter-spacing: 0.08em;
  color: #b01e40;
}
.letter-sign:empty { display: none; }

.env-front {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 3;
  border-radius: 8px;
  overflow: hidden;
  filter: drop-shadow(0 -1px 1px rgba(120, 20, 40, 0.12));
}
.pocket-side { fill: #f8e3e3; }
.pocket-bottom { fill: #fbeceb; }

.flap {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 58%;
  z-index: 4;
  transform-origin: 50% 0;
  transform: perspective(900px) rotateX(0deg);
  transition: transform 0.9s cubic-bezier(0.45, 0, 0.25, 1);
}
.flap svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
  filter: drop-shadow(0 3px 3px rgba(120, 20, 40, 0.15));
}
.flap path { fill: #f6dcdd; transition: fill 0.9s ease; }

.envelope.flap-open .flap { transform: perspective(900px) rotateX(180deg); }
.envelope.flap-open .flap path { fill: #e9bcc0; }
.envelope.flap-behind .flap { z-index: 1; }

/* Sello */
.seal {
  position: absolute;
  left: 50%;
  top: 57%;
  z-index: 5;
  width: 70px;
  height: 70px;
  transform: translate(-50%, -50%);
  border: 0;
  padding: 0;
  background: none;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  transition: opacity 0.5s ease, transform 0.5s var(--ease-out);
}
.seal::before,
.seal::after {
  content: "";
  position: absolute;
  inset: 4px;
  border-radius: 50%;
  border: 2px solid rgba(178, 20, 52, 0.55);
  animation: ripple 2.2s ease-out infinite;
  pointer-events: none;
}
.seal::after { animation-delay: 1.1s; }
@keyframes ripple {
  0% { transform: scale(0.9); opacity: 0.9; }
  100% { transform: scale(1.8); opacity: 0; }
}
.seal-wax {
  position: relative;
  width: 100%;
  height: 100%;
  display: block;
  filter: drop-shadow(0 4px 6px rgba(80, 0, 20, 0.45));
  animation: breathe 2.2s ease-in-out infinite;
}
@keyframes breathe {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.06); }
}
.wax { fill: #b3143a; }
.wax-ring { fill: none; stroke: #8a0c2a; stroke-width: 3; opacity: 0.7; }
.wax-heart { fill: #8a0c2a; stroke: #d8506e; stroke-width: 0.6; }

.seal-label {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  transform: translateX(-50%);
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 0.85rem;
  letter-spacing: 0.35em;
  padding-left: 0.35em;
  color: #a3102f;
  white-space: nowrap;
  animation: blink 1.6s ease-in-out infinite;
}
@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

.envelope.is-opening .seal {
  opacity: 0;
  transform: translate(-50%, -50%) scale(1.5);
  pointer-events: none;
}

/* Explosión de corazones: primero por delante de todo, luego de fondo */
.explosion {
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  overflow: hidden;
}
.explosion.behind { z-index: 1; }
.boom-canvas {
  position: absolute;
  left: 0;
  top: 0;
}
.flash {
  position: absolute;
  width: 40px;
  height: 40px;
  margin: -20px 0 0 -20px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.95) 0%, rgba(255, 220, 230, 0.6) 35%, rgba(255, 220, 230, 0) 70%);
}

/* Corazones que se quedan alrededor de la carta */
.halo {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.halo-heart {
  position: absolute;
  width: var(--s);
  height: var(--s);
  margin: calc(var(--s) / -2) 0 0 calc(var(--s) / -2);
  opacity: 0;
  animation:
    haloIn 1.2s ease forwards var(--in),
    float var(--fd) ease-in-out infinite var(--in);
}
.halo-heart svg {
  display: block;
  width: 100%;
  height: 100%;
  transform: rotate(var(--r));
  filter: drop-shadow(0 3px 6px rgba(110, 0, 30, 0.25));
}
@keyframes haloIn { to { opacity: 1; } }
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

/* ---------- Movimiento reducido ---------- */
@media (prefers-reduced-motion: reduce) {
  .seal::before, .seal::after, .seal-wax, .seal-label, .scroll-hint svg, .bird .wings,
  .cat-tail, .cat-eyes > g, .cat-ear-r, .k-tail, .k-blink, .k-breathe, .zz { animation: none; }
}
