/* ==========================================================================
   VARIABLES & RESET (Estética Vintage Romántica Mobile-First)
   ========================================================================== */
:root {
  --bg-cream: #f6f3ec;
  --bg-card-white: #fbf9f5;
  --parchment-base: #efe2cb;
  --parchment-dark: #e3d1b3;
  --parchment-border: #d8c4a3;
  --terracotta: #a1583c;
  --terracotta-dark: #884329;
  --terracotta-light: #b86c4f;
  --text-dark: #4a3a2c;
  --text-brown: #6f5b49;
  --text-muted: #8c7865;
  --wax-red-light: #9e2928;
  --wax-red-mid: #741515;
  --wax-red-dark: #4c0909;
  --font-serif: 'Cormorant Garamond', Georgia, serif;
  --font-display: 'Playfair Display', Georgia, serif;
  --font-sans: 'Montserrat', -apple-system, BlinkMacSystemFont, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  width: 100%;
  min-height: 100dvh;
  background-color: #e8e2d7;
  color: var(--text-dark);
  font-family: var(--font-serif);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ==========================================================================
   CONTENEDOR MOBILE-FIRST
   En celulares ocupa toda la pantalla; en escritorio simula un móvil centrado
   ========================================================================== */
.mobile-wrapper {
  position: relative;
  width: 100%;
  max-width: 430px;
  min-height: 100dvh;
  margin: 0 auto;
  background-color: var(--bg-cream);
  background-image:
    radial-gradient(rgba(161, 88, 60, 0.03) 1px, transparent 0),
    linear-gradient(180deg, #f7f4ed 0%, #f4efe6 100%);
  background-size: 24px 24px, 100% 100%;
  box-shadow: 0 0 50px rgba(58, 40, 25, 0.15);
  overflow: hidden;
}

/* ==========================================================================
   PANTALLAS (Transición entre Pantalla 1 y Pantalla 2)
   ========================================================================== */
.screen {
  width: 100%;
  min-height: 100dvh;
  transition: opacity 0.75s cubic-bezier(0.22, 1, 0.36, 1),
              transform 0.75s cubic-bezier(0.22, 1, 0.36, 1);
}

.screen-intro {
  position: fixed;
  inset: 0;
  max-width: 430px;
  margin: 0 auto;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--bg-cream);
  padding: 2rem;
}

.screen-intro.hidden {
  opacity: 0;
  transform: translateY(-28px) scale(0.98);
  pointer-events: none;
}

.screen-story {
  position: relative;
  z-index: 10;
  opacity: 0;
  transform: translateY(20px);
  pointer-events: none;
  display: none;
}

.screen-story.active {
  display: block;
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

/* ==========================================================================
   PANTALLA 1: PORTADA ("♥ / Para ti / Te quiere Cristhian")
   ========================================================================== */
.intro-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 1.5rem;
  transform: translateY(-10px);
  animation: floatIn 1.1s ease-out forwards;
}

@keyframes floatIn {
  from {
    opacity: 0;
    transform: translateY(15px);
  }
  to {
    opacity: 1;
    transform: translateY(-10px);
  }
}

.intro-heart {
  color: var(--terracotta);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: gentleHeartbeat 2.4s infinite ease-in-out;
}

@keyframes gentleHeartbeat {
  0%, 100% { transform: scale(1); }
  18% { transform: scale(1.18); }
  34% { transform: scale(0.96); }
  50% { transform: scale(1.1); }
}

.intro-title {
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 500;
  font-size: 2.15rem;
  color: var(--text-brown);
  letter-spacing: 0.02em;
  margin-bottom: 0.35rem;
}

/* Botón Terracota (usado en Pantalla 1 y en "Sí, quiero ♥") */
.btn-terracotta {
  appearance: none;
  border: none;
  cursor: pointer;
  background: linear-gradient(135deg, var(--terracotta-light) 0%, var(--terracotta) 50%, var(--terracotta-dark) 100%);
  color: #fdfaf5;
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 500;
  font-size: 1.25rem;
  letter-spacing: 0.02em;
  padding: 0.9rem 2.35rem;
  border-radius: 999px;
  box-shadow:
    0 10px 24px rgba(154, 79, 50, 0.32),
    0 3px 8px rgba(154, 79, 50, 0.2),
    inset 0 1px 1px rgba(255, 255, 255, 0.25);
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1),
              box-shadow 0.25s ease,
              filter 0.25s ease;
}

.btn-terracotta:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow:
    0 14px 28px rgba(154, 79, 50, 0.38),
    0 4px 10px rgba(154, 79, 50, 0.24),
    inset 0 1px 1px rgba(255, 255, 255, 0.3);
}

.btn-terracotta:active {
  transform: translateY(1px) scale(0.97);
}

/* ==========================================================================
   PANTALLA 2: CONTENEDOR SCROLLEABLE
   ========================================================================== */
.story-scroll-container {
  width: 100%;
  padding: 2.6rem 1.35rem 4.2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* 1. Fecha superior */
.story-header {
  text-align: center;
  margin-bottom: 1.55rem;
}

.story-date {
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 500;
  font-size: 2.15rem;
  color: var(--text-brown);
  letter-spacing: 0.01em;
}

/* 2. Polaroid con Carrusel de 3 Fotos */
.polaroid-wrapper {
  width: 100%;
  max-width: 345px;
  perspective: 1000px;
  margin-bottom: 1.55rem;
}

.polaroid-card {
  background: #ffffff;
  padding: 13px 13px 22px 13px;
  border-radius: 3px;
  box-shadow:
    0 14px 32px rgba(72, 52, 34, 0.12),
    0 3px 10px rgba(72, 52, 34, 0.07);
  transform: rotate(-1.35deg);
  transition: transform 0.4s ease;
}

.polaroid-card:hover {
  transform: rotate(-0.4deg);
}

.photo-carousel-container {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1.02;
  overflow: hidden;
  background-color: #ece6dd;
}

.photo-carousel {
  display: flex;
  width: 100%;
  height: 100%;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  scrollbar-width: none;
  -ms-overflow-style: none;
  cursor: grab;
}

.photo-carousel::-webkit-scrollbar {
  display: none;
}

.photo-carousel:active {
  cursor: grabbing;
}

.photo-slide {
  flex: 0 0 100%;
  width: 100%;
  height: 100%;
  scroll-snap-align: center;
  position: relative;
  overflow: hidden;
}

.photo-slide img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  user-select: none;
  -webkit-user-drag: none;
}

/* Mano animada indicando swipe en las fotos (como la imagen 2) */
.swipe-hint {
  position: absolute;
  bottom: -4px;
  left: 50%;
  transform: translateX(-42%);
  width: 120px;
  height: 92px;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.45));
  transition: opacity 0.45s ease, transform 0.45s ease;
  z-index: 4;
}

.swipe-hint.hidden {
  opacity: 0;
  transform: translateX(-60%) scale(0.9);
}

.swipe-arrow {
  width: 72px;
  height: 26px;
  margin-bottom: -8px;
  margin-left: 16px;
}

.swipe-hand {
  width: 58px;
  height: 58px;
  animation: handSwipeGesture 2.2s infinite ease-in-out;
  transform-origin: bottom center;
}

@keyframes handSwipeGesture {
  0%, 100% { transform: translateX(8px) rotate(6deg); }
  50% { transform: translateX(-12px) rotate(-8deg); }
}

/* Puntos indicadores del carrusel */
.carousel-dots {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 7px;
  margin-top: 12px;
  margin-bottom: 8px;
}

.carousel-dots .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  border: none;
  background-color: #dcd3c8;
  padding: 0;
  cursor: pointer;
  transition: background-color 0.3s ease, transform 0.3s ease;
}

.carousel-dots .dot.active {
  background-color: #7c5844;
  transform: scale(1.2);
}

.polaroid-caption {
  text-align: center;
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 500;
  color: #3f352c;
  letter-spacing: 0.01em;
}

.polaroid-caption .amp {
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 400;
  color: var(--terracotta);
  padding: 0 2px;
}

/* Ornamento divisorio */
.ornament-divider {
  margin: 0.35rem 0 1.35rem;
  display: flex;
  justify-content: center;
  align-items: center;
  opacity: 0.85;
}

/* ==========================================================================
   3. SOBRE / CARTA CON ANIMACIÓN DE APERTURA MEDIANTE BOTÓN
   ========================================================================== */
.letter-section {
  width: 100%;
  max-width: 365px;
  margin-bottom: 2.2rem;
  perspective: 1200px;
}

.envelope-card {
  position: relative;
  width: 100%;
  background-color: var(--parchment-base);
  border: 1px solid var(--parchment-border);
  border-radius: 10px;
  box-shadow:
    0 14px 34px rgba(84, 58, 34, 0.13),
    0 3px 10px rgba(84, 58, 34, 0.07),
    inset 0 0 40px rgba(212, 184, 140, 0.35);
  overflow: hidden;
  transition: min-height 0.8s cubic-bezier(0.22, 1, 0.36, 1),
              box-shadow 0.6s ease;
  min-height: 220px;
  cursor: default;
}

.envelope-card.is-open {
  cursor: default;
  box-shadow:
    0 18px 40px rgba(84, 58, 34, 0.16),
    0 4px 12px rgba(84, 58, 34, 0.08),
    inset 0 0 50px rgba(212, 184, 140, 0.3);
}

/* Líneas diagonales sutiles que simulan el interior del sobre (como en Imagen 3) */
.envelope-creases {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  background:
    /* Pliegue diagonal superior izquierdo a centro */
    linear-gradient(132deg, transparent 49.3%, rgba(188, 158, 118, 0.28) 49.7%, rgba(188, 158, 118, 0.28) 50.3%, transparent 50.7%),
    /* Pliegue diagonal superior derecho a centro */
    linear-gradient(228deg, transparent 49.3%, rgba(188, 158, 118, 0.28) 49.7%, rgba(188, 158, 118, 0.28) 50.3%, transparent 50.7%);
}

/* Solapa triangular superior (cerrada al inicio, gira 180deg al abrirse) */
.envelope-top-flap {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 145px;
  z-index: 3;
  transform-origin: top center;
  transition: transform 0.85s cubic-bezier(0.4, 0, 0.2, 1),
              opacity 0.65s ease 0.25s;
  pointer-events: none;
  background: linear-gradient(180deg, #eadac0 0%, #e4d0b0 100%);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  filter: drop-shadow(0 4px 6px rgba(95, 65, 35, 0.15));
}

.envelope-card.is-open .envelope-top-flap {
  transform: rotateX(180deg);
  opacity: 0;
}

/* Contenedor del sello de lacre rojo ("Descúbrelo") */
.wax-seal-wrapper {
  position: relative;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4.5rem 1rem 2.6rem;
  transition: opacity 0.55s ease, transform 0.65s cubic-bezier(0.34, 1.56, 0.64, 1),
              max-height 0.7s ease, padding 0.7s ease;
  max-height: 260px;
}

.envelope-card.is-open .wax-seal-wrapper {
  opacity: 0;
  transform: scale(1.25) translateY(-20px);
  max-height: 0;
  padding-top: 0;
  padding-bottom: 0;
  pointer-events: none;
  overflow: hidden;
}

.wax-seal-btn {
  width: 90px;
  height: 90px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  padding: 6px;
  background: radial-gradient(circle at 35% 30%, var(--wax-red-light) 0%, var(--wax-red-mid) 58%, var(--wax-red-dark) 100%);
  box-shadow:
    0 8px 18px rgba(68, 12, 12, 0.38),
    0 2px 5px rgba(68, 12, 12, 0.28),
    inset 0 2px 4px rgba(255, 190, 180, 0.28),
    inset 0 -3px 6px rgba(30, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: sealPulse 2.6s infinite ease-in-out;
  transition: transform 0.3s ease;
}

.wax-seal-btn:hover {
  transform: scale(1.06);
}

.wax-seal-btn:active {
  transform: scale(0.95);
}

@keyframes sealPulse {
  0%, 100% {
    box-shadow:
      0 8px 18px rgba(68, 12, 12, 0.38),
      0 0 0 0 rgba(158, 41, 40, 0.25),
      inset 0 2px 4px rgba(255, 190, 180, 0.28);
  }
  50% {
    box-shadow:
      0 10px 22px rgba(68, 12, 12, 0.45),
      0 0 0 10px rgba(158, 41, 40, 0),
      inset 0 2px 4px rgba(255, 190, 180, 0.35);
  }
}

.wax-seal-ring {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 1.5px solid rgba(215, 155, 130, 0.38);
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
}

.wax-seal-text {
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 600;
  font-size: 1rem;
  color: #e8b89a;
  letter-spacing: 0.02em;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.55);
}

.scroll-open-hint {
  margin-top: 0.85rem;
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 0.95rem;
  color: var(--text-muted);
  opacity: 0.85;
  animation: bounceDown 2s infinite ease-in-out;
}

@keyframes bounceDown {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(4px); }
}

/* Cuerpo desplegable de la carta */
.letter-body-wrapper {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-rows: 0fr;
  opacity: 0;
  transition: grid-template-rows 0.95s cubic-bezier(0.22, 1, 0.36, 1),
              opacity 0.8s ease 0.15s;
}

.envelope-card.is-open .letter-body-wrapper {
  grid-template-rows: 1fr;
  opacity: 1;
}

.letter-body {
  overflow: hidden;
  padding: 0 1.65rem;
  transition: padding 0.85s ease;
}

.envelope-card.is-open .letter-body {
  padding: 2.2rem 1.65rem 2.5rem;
}

.letter-body p {
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 500;
  font-size: 1.24rem;
  line-height: 1.58;
  color: var(--text-dark);
  margin-bottom: 1.45rem;
}

/* Bloque final dentro de la carta: "¿Quieres seguir escribiendo esta historia juntos?" */
.letter-question-block {
  margin-top: 2.2rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.4rem;
}

.letter-question {
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 500;
  font-size: 1.78rem;
  line-height: 1.28;
  color: var(--terracotta);
}

.btn-yes {
  min-width: 195px;
  font-size: 1.3rem;
  padding: 0.85rem 2.2rem;
}

.btn-yes .btn-heart {
  font-style: normal;
  display: inline-block;
  margin-left: 4px;
  font-size: 1.05rem;
  transition: transform 0.3s ease;
}

.btn-yes:hover .btn-heart {
  transform: scale(1.25);
}

/* Sombra triangular inferior del sobre */
.envelope-bottom-fold {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 90px;
  pointer-events: none;
  z-index: 1;
  background: linear-gradient(0deg, rgba(196, 166, 125, 0.32) 0%, transparent 100%);
  clip-path: polygon(0 100%, 50% 15%, 100% 100%);
}

/* ==========================================================================
   4. RECUADRO CONTADOR: "Han sido los mejores / 6m 5d 18hrs / de mi vida"
   ========================================================================== */
.counter-section {
  width: 100%;
  max-width: 365px;
  margin-bottom: 2.1rem;
}

.counter-card {
  background-color: var(--bg-card-white);
  border-radius: 22px;
  padding: 2.1rem 1.5rem;
  text-align: center;
  box-shadow:
    0 10px 28px rgba(80, 58, 38, 0.06),
    0 2px 6px rgba(80, 58, 38, 0.04);
  border: 1px solid rgba(220, 208, 192, 0.55);
}

.counter-top-text,
.counter-bottom-text {
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 500;
  font-size: 1.55rem;
  color: var(--text-brown);
}

.counter-top-text {
  margin-bottom: 1.15rem;
}

.counter-bottom-text {
  margin-top: 1.15rem;
}

.counter-numbers-row {
  display: flex;
  justify-content: center;
  align-items: baseline;
  gap: 2.1rem;
}

.counter-item {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.counter-value {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 2.45rem;
  line-height: 1.05;
  color: #2c2219;
}

.counter-value .unit-inline {
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 500;
  font-size: 1.25rem;
  color: var(--terracotta);
  margin-left: 2px;
}

.counter-label {
  margin-top: 0.35rem;
  font-family: var(--font-sans);
  font-size: 0.65rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  color: var(--text-muted);
  text-transform: uppercase;
}

/* ==========================================================================
   5. FOTOGRAFÍA FINAL SIN RECUADRO + MENSAJE BONITO ABAJO
   ========================================================================== */
.final-photo-section {
  width: 100%;
  max-width: 365px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.final-photo-container {
  width: 100%;
  aspect-ratio: 1 / 1.02;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 12px 28px rgba(68, 48, 30, 0.14);
  margin-bottom: 1.75rem;
  cursor: pointer;
  user-select: none;
}

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

.final-photo-container:hover .final-photo-img {
  transform: scale(1.03);
}

.final-message {
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 500;
  font-size: 1.65rem;
  line-height: 1.32;
  color: var(--text-brown);
}

/* ==========================================================================
   MIXTURA DE CORAZONES (Efecto al dar click en "Sí, quiero ♥")
   ========================================================================== */
.hearts-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  overflow: hidden;
}

.floating-heart {
  position: absolute;
  will-change: transform, opacity;
  pointer-events: none;
  user-select: none;
  line-height: 1;
  filter: drop-shadow(0 3px 6px rgba(140, 50, 40, 0.18));
}

/* Ajustes para pantallas pequeñas */
@media (max-width: 360px) {
  .story-date {
    font-size: 1.85rem;
  }
  .letter-body p {
    font-size: 1.12rem;
  }
  .letter-question {
    font-size: 1.55rem;
  }
  .counter-numbers-row {
    gap: 1.4rem;
  }
  .counter-value {
    font-size: 2.1rem;
  }
}

/* ==========================================================================
   BOTÓN FLOTANTE DE CONTROL DE MÚSICA
   ========================================================================== */
.btn-music-toggle {
  position: fixed;
  top: 18px;
  right: calc(50% - 215px + 16px);
  z-index: 100;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid rgba(161, 88, 60, 0.28);
  background: rgba(251, 249, 245, 0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: var(--terracotta);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 18px rgba(136, 67, 41, 0.14);
  transition: opacity 0.4s ease, transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), background-color 0.25s ease, border-color 0.25s ease;
  opacity: 1;
  transform: scale(1);
}

@media (max-width: 430px) {
  .btn-music-toggle {
    right: 16px;
    top: 16px;
  }
}

.btn-music-toggle.hidden {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.6);
}

.btn-music-toggle:hover {
  transform: scale(1.08);
  background: #ffffff;
  border-color: var(--terracotta);
  box-shadow: 0 6px 22px rgba(136, 67, 41, 0.2);
}

.btn-music-toggle:active {
  transform: scale(0.94);
}

.btn-music-toggle.is-paused {
  color: var(--text-muted);
  border-color: rgba(140, 120, 101, 0.28);
  background: rgba(246, 243, 236, 0.88);
}

.music-waves {
  display: inline-flex;
  align-items: flex-end;
  gap: 2px;
  height: 12px;
  margin-right: 4px;
}

.music-waves span {
  display: block;
  width: 2px;
  background-color: currentColor;
  border-radius: 2px;
  animation: wavePulse 1.1s ease-in-out infinite alternate;
}

.music-waves span:nth-child(1) { height: 5px; animation-delay: 0.1s; }
.music-waves span:nth-child(2) { height: 11px; animation-delay: 0.3s; }
.music-waves span:nth-child(3) { height: 7px; animation-delay: 0.15s; }

.btn-music-toggle.is-paused .music-waves span {
  animation: none;
  height: 2.5px;
}

@keyframes wavePulse {
  0% {
    height: 3px;
  }
  100% {
    height: 12px;
  }
}
