/* ============================================================
   ESTILOS - EXPERIENCIA INTERACTIVA & EMOCIONAL (v3.1 ESMERALDA)
   ============================================================ */

:root {
  --font-serif: 'Cormorant Garamond', Georgia, serif;
  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
  --gold-accent: #f59e0b;
  --gold-vivid: #fbbf24;
  --gold-soft: #fef08a;
  --gold-glow: rgba(245, 158, 11, 0.45);
  --emerald-accent: #10b981;
  --emerald-dark: #062f22;
  --emerald-glow: rgba(16, 185, 129, 0.4);
  --text-light: #fffdfa;
  --text-muted: rgba(255, 253, 250, 0.7);
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: var(--font-serif);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
}

body {
  transition: background 3.5s ease, color 2.5s ease;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

/* --- Fondos por Acto --- */
body.theme-act1 {
  background: radial-gradient(circle at center, #06261d 0%, #03130e 65%, #010806 100%);
  color: var(--text-light);
}

body.theme-act2 {
  background: radial-gradient(circle at center, #113426 0%, #092117 55%, #020b07 100%);
  color: #fff6e8;
  transition: background 1.5s ease;
}

/* Acto 3: Esmeralda aterciopelado dinámico y fluido */
body.theme-act3 {
  background: linear-gradient(135deg, #031c15 0%, #06392b 30%, #094736 60%, #021a13 100%);
  background-size: 220% 220%;
  animation: emerald-flow 18s ease-in-out infinite alternate;
  color: #fffdf9;
}

@keyframes emerald-flow {
  0% { background-position: 0% 30%; }
  50% { background-position: 100% 70%; }
  100% { background-position: 0% 30%; }
}

body.theme-act4 {
  background: radial-gradient(circle at center, #061922 0%, #031018 60%, #01080e 100%);
  color: #f7eedd;
  transition: background 6s ease, color 4s ease;
}

/* Acto 5: Intimidad cálida, ambiente nocturno con halo iluminado por la llama de la vela */
body.theme-act5-dawn {
  background: radial-gradient(circle at 50% 65%, #071c16 0%, #03100c 45%, #010605 85%, #000302 100%);
  color: #fffdf5;
  transition: background 6s ease, color 3s ease;
}

/* --- Canvas Unificado de Efectos --- */
#fx-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 4; /* Debajo de los textos para que los lazos no opaquen las letras */
}

/* --- Contenedor Principal --- */
.experience-container {
  width: 100%;
  max-width: 620px;
  min-height: 100vh;
  min-height: 100dvh;
  padding: max(2rem, env(safe-area-inset-top, 2rem)) 1.5rem max(2rem, env(safe-area-inset-bottom, 2rem)) 1.5rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  position: relative;
  z-index: 10;
  text-align: center;
  box-sizing: border-box;
}

/* --- Secciones de Actos --- */
.act {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  opacity: 1;
  transition: opacity 1.2s ease, transform 1.2s ease;
}

.hidden {
  display: none !important;
}

.act.hidden {
  display: none !important;
  opacity: 0;
}

.act.fade-out {
  opacity: 0;
  transform: translateY(-10px);
}

/* --- ACTO 1: Apertura --- */
.envelope-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
}

.gift-glow {
  position: absolute;
  width: 150px;
  height: 150px;
  top: -25px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--emerald-glow) 0%, var(--gold-glow) 70%, transparent 100%);
  filter: blur(30px);
  animation: pulse-glow 3.5s infinite ease-in-out;
  pointer-events: none;
}

.gift-icon {
  width: 68px;
  height: 68px;
  color: var(--gold-vivid);
  margin-bottom: 2rem;
  position: relative;
  z-index: 2;
  filter: drop-shadow(0 0 16px rgba(16, 185, 129, 0.5));
  animation: float 4s ease-in-out infinite;
}

.act-title {
  font-size: 2.6rem;
  font-weight: 400;
  letter-spacing: 0.05em;
  color: #ffffff;
  margin-bottom: 3rem;
  line-height: 1.2;
  text-shadow: 0 2px 16px rgba(0, 0, 0, 0.95), 0 0 16px rgba(16, 185, 129, 0.35);
}

/* Botón: Esmeralda oscuro con borde oro vívido */
.btn-primary {
  font-family: var(--font-sans);
  font-size: 0.98rem;
  font-weight: 500;
  letter-spacing: 0.09em;
  color: #fff8e8;
  background: linear-gradient(135deg, #073527 0%, #031b14 100%);
  border: 2px solid #fbbf24; /* Borde oro vívido */
  padding: 0.95rem 2.6rem;
  border-radius: 9999px;
  cursor: pointer;
  box-shadow: 0 0 22px rgba(245, 158, 11, 0.45), inset 0 0 14px rgba(16, 185, 129, 0.35);
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.3s ease;
}

.btn-primary:active {
  transform: scale(0.96);
  box-shadow: 0 0 30px rgba(245, 158, 11, 0.75), inset 0 0 18px rgba(16, 185, 129, 0.5);
}

/* --- ACTO 2: Sorpresa --- */
.typewriter-text {
  font-size: 2.65rem;
  font-weight: 600;
  line-height: 1.25;
  color: #fff0d4;
  text-shadow: 0 0 20px rgba(244, 208, 111, 0.65), 0 0 38px rgba(16, 185, 129, 0.5);
}

/* --- ACTOS 3 y 4: Frases y Susurros --- */
.phrase-container {
  min-height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.phrase-text {
  font-size: 2.15rem;
  line-height: 1.48;
  font-weight: 400;
  font-style: italic;
  letter-spacing: 0.02em;
  max-width: 530px;
  color: #ffffff;
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 1.2s ease, transform 1.2s ease;
  text-shadow: 0 2px 16px rgba(0, 0, 0, 0.95), 0 0 10px rgba(0, 0, 0, 0.85);
}

/* Acto 3: Blanco puro brillante con sombra oscura profunda para máxima legibilidad */
.theme-act3 .phrase-text {
  color: #ffffff;
  text-shadow: 0 2px 18px rgba(0, 0, 0, 0.98), 0 0 12px rgba(0, 0, 0, 0.90);
}

.phrase-text.visible {
  opacity: 1;
  transform: translateY(0);
}

.phrase-text.fade-out {
  opacity: 0;
  transform: translateY(-10px);
}

/* Palabras interactivas con susurro */
.whisper-word {
  cursor: pointer;
  position: relative;
  font-style: normal;
  font-weight: 600;
  color: #ffd885;
  border-bottom: 1px dashed var(--gold-vivid);
  padding-bottom: 2px;
  display: inline-block;
  transition: color 0.3s ease, text-shadow 0.3s ease;
}

.whisper-word::after {
  content: '✦';
  font-size: 0.65rem;
  color: var(--gold-vivid);
  position: absolute;
  top: -5px;
  right: -9px;
  opacity: 0.85;
  animation: pulse-soft 2s infinite ease-in-out;
}

.whisper-word:active {
  color: #ffffff;
  text-shadow: 0 0 12px var(--gold-vivid);
}

/* Burbuja flotante de susurros */
.whisper-bubble {
  position: fixed;
  bottom: 12%;
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  max-width: 380px;
  width: 86%;
  background: rgba(4, 24, 18, 0.95);
  color: #fff9ed;
  border: 1px solid rgba(251, 191, 36, 0.55);
  box-shadow: 0 12px 35px rgba(0, 0, 0, 0.6), 0 0 20px rgba(16, 185, 129, 0.35);
  padding: 1.1rem 1.5rem;
  border-radius: 14px;
  font-size: 1.18rem;
  font-style: italic;
  line-height: 1.48;
  text-align: center;
  z-index: 60;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s ease, transform 0.5s ease;
}

.whisper-bubble.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* --- ACTO 5: Calidez, Admiración & Vela Interactiva --- */
#act-5 {
  width: 100%;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  margin: auto 0;
  padding: 1.5rem 0;
}

.dawn-container {
  width: 100%;
  max-width: 520px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin: auto 0;
  padding: 1.5rem 0;
}

.stacked-phrases {
  display: flex;
  flex-direction: column;
  gap: 1.15rem;
  margin-bottom: 1.8rem;
  max-width: 520px;
  width: 100%;
}

.dawn-line {
  font-size: 1.32rem;
  line-height: 1.48;
  font-weight: 400;
  font-style: italic;
  color: #ffffff; /* Blanco puro intenso para máxima legibilidad */
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 1.2s ease, transform 1.2s ease;
  text-shadow: 0 2px 16px rgba(0, 0, 0, 0.95), 0 0 10px rgba(0, 0, 0, 0.85);
}

@media (min-width: 600px) {
  .dawn-line {
    font-size: 1.48rem;
    line-height: 1.52;
  }
  .stacked-phrases {
    gap: 1.35rem;
    margin-bottom: 2rem;
  }
}

.theme-act5-dawn .whisper-word {
  color: #ffd885;
  border-bottom: 1px dashed var(--gold-vivid);
}

.dawn-line.visible {
  opacity: 1;
  transform: translateY(0);
}

/* Vela de cumpleaños y resplandor ambiental de la llama */
.candle-box {
  margin: 1.2rem auto 0 auto;
  padding: 0.8rem 2rem 1.2rem 2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  border-radius: 20px;
  position: relative;
  touch-action: manipulation;
  transition: transform 0.2s ease;
}

/* El resplandor expansivo que convierte a la llama en la auténtica fuente de luz de la escena */
.candle-light-halo {
  position: absolute;
  top: 52px; /* Centrado directamente en la llama */
  left: 50%;
  transform: translate(-50%, -50%);
  width: 580px;
  height: 580px;
  max-width: 95vw;
  max-height: 95vw;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 220, 90, 0.42) 0%, rgba(245, 158, 11, 0.25) 30%, rgba(16, 185, 129, 0.08) 58%, transparent 78%);
  filter: blur(38px);
  pointer-events: none;
  animation: flame-lantern-glow 2.4s infinite ease-in-out alternate;
  transition: opacity 0.9s ease, transform 0.9s ease;
  z-index: 1;
}

@keyframes flame-lantern-glow {
  0% { transform: translate(-50%, -50%) scale(0.92); opacity: 0.82; }
  50% { transform: translate(-50%, -50%) scale(1.08); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(0.95); opacity: 0.86; }
}

.candle-box:active {
  transform: scale(0.97);
}

.candle {
  width: 32px;
  height: 64px;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  z-index: 2;
}

.candle-flame {
  width: 24px;
  height: 35px;
  background: radial-gradient(ellipse at bottom, #ffffff 20%, #ffd43b 48%, #ff922b 82%, rgba(255, 146, 43, 0) 100%);
  border-radius: 50% 50% 20% 20% / 60% 60% 40% 40%;
  box-shadow: 0 0 25px #ffd43b, 0 0 45px #ff922b, 0 0 70px rgba(245, 158, 11, 0.45);
  animation: flicker 1.2s infinite ease-in-out alternate;
  cursor: pointer;
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.candle-wick {
  width: 2px;
  height: 8px;
  background: #2b211b;
}

.candle-body {
  width: 18px;
  height: 38px;
  background: linear-gradient(to right, #fbf2e9 0%, #e8d7c3 50%, #d8c2aa 100%);
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}

.candle-hint {
  font-family: var(--font-serif);
  font-size: 1.25rem;
  font-style: italic;
  color: #fef08a;
  margin-top: 0.95rem;
  letter-spacing: 0.05em;
  max-width: 320px;
  text-shadow: 0 0 14px rgba(251, 191, 36, 0.65);
  opacity: 0;
  pointer-events: none;
  transition: opacity 1s ease;
  position: relative;
  z-index: 2;
}

.candle-hint.visible {
  opacity: 1;
  pointer-events: auto;
  animation: pulse-soft 2.5s infinite ease-in-out;
}

.finale-group {
  margin-top: 1.4rem;
  opacity: 0;
  transform: scale(0.95);
  transition: opacity 2s ease, transform 2s ease;
}

.finale-group.visible {
  opacity: 1;
  transform: scale(1);
}

.finale-title {
  font-size: 2.6rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: #fbbf24;
  background: none;
  -webkit-background-clip: unset;
  -webkit-text-fill-color: #fbbf24;
  text-shadow: 0 2px 18px rgba(0, 0, 0, 0.98), 0 0 20px rgba(251, 191, 36, 0.45);
  margin-bottom: 0.85rem;
  line-height: 1.25;
}

.finale-title .whisper-word {
  display: inline-block;
  color: #fbbf24;
  -webkit-text-fill-color: #fbbf24;
  border-bottom: 1.5px dashed #f59e0b;
  padding-bottom: 2px;
  position: relative;
  cursor: pointer;
  pointer-events: auto;
}

.finale-title .whisper-word::after {
  content: '✦';
  font-size: 0.75rem;
  color: #fbbf24;
  -webkit-text-fill-color: #fbbf24;
  position: absolute;
  top: -6px;
  right: -10px;
  opacity: 0.95;
  animation: pulse-soft 2s infinite ease-in-out;
}

.finale-subtext {
  font-size: 1.35rem;
  font-style: italic;
  color: #ffffff;
  margin-top: 0.6rem;
  max-width: 480px;
  line-height: 1.55;
  text-shadow: 0 2px 16px rgba(0, 0, 0, 0.95), 0 0 10px rgba(0, 0, 0, 0.85);
}

/* --- Botón "No toques" --- */
.btn-secret {
  display: none;
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  font-family: var(--font-sans);
  font-size: 0.72rem;
  font-weight: 400;
  letter-spacing: 0.08em;
  color: #f7f3ec;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.35);
  padding: 0.35rem 0.75rem;
  border-radius: 9999px;
  opacity: 0;
  cursor: pointer;
  transition: opacity 0.8s ease, transform 0.2s ease;
  z-index: 20;
  pointer-events: none;
}

.btn-secret.visible {
  display: block !important;
  opacity: 0.42;
  pointer-events: auto;
}

.btn-secret:hover, .btn-secret:active {
  opacity: 0.85;
  transform: scale(1.05);
}

/* --- OVERLAY: Mensaje Oculto + "Una última cosa..." --- */
.overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(4, 12, 10, 0.94);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  z-index: 70;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.6s ease;
  overflow-y: auto;
}

.overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.overlay-card {
  max-width: 480px;
  width: 100%;
  background: rgba(10, 28, 22, 0.96);
  border: 1px solid rgba(251, 191, 36, 0.4);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.75), 0 0 25px rgba(16, 185, 129, 0.25);
  border-radius: 20px;
  padding: 2.2rem 1.8rem;
  text-align: center;
  color: #f7f3ec;
  transform: translateY(12px);
  transition: transform 0.5s ease;
}

.overlay.active .overlay-card {
  transform: translateY(0);
}

.secret-text {
  font-size: 1.25rem;
  line-height: 1.6;
  font-style: italic;
  font-weight: 400;
  margin-bottom: 1.6rem;
}

.secret-paragraph-2 {
  margin-top: 1.35rem;
}

.btn-subtle-gold {
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 400;
  letter-spacing: 0.08em;
  color: var(--gold-soft);
  background: rgba(245, 158, 11, 0.15);
  border: 1px solid rgba(251, 191, 36, 0.45);
  padding: 0.6rem 1.5rem;
  border-radius: 9999px;
  cursor: pointer;
  margin-bottom: 1.5rem;
  transition: background 0.3s ease, transform 0.2s ease;
}

.btn-subtle-gold:active {
  transform: scale(0.97);
  background: rgba(245, 158, 11, 0.3);
}

/* Mensaje final de despedida (tipografía pequeña y delicada) */
.farewell-message {
  font-size: 0.95rem;
  line-height: 1.62;
  font-style: italic;
  text-align: left;
  border-left: 2px solid var(--gold-vivid);
  padding-left: 1.1rem;
  margin-bottom: 1.8rem;
  color: #f5eedf;
  opacity: 0;
  max-height: 0;
  overflow: hidden;
  transition: opacity 1.2s ease, max-height 1.2s ease, margin 0.8s ease;
}

.farewell-message.visible {
  opacity: 1;
  max-height: 600px;
  margin-top: 1rem;
}

.farewell-message p {
  margin-bottom: 0.75rem;
}

.farewell-highlight {
  color: #ffe6a7;
  font-weight: 600;
}

.farewell-sig {
  text-align: right;
  font-size: 0.92rem;
  color: var(--gold-soft);
  margin-top: 1rem;
}

.btn-secondary {
  font-family: var(--font-sans);
  font-size: 0.62rem;
  font-weight: 400;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: rgba(247, 243, 236, 0.35);
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.10);
  padding: 0.2rem 0.65rem;
  border-radius: 9999px;
  cursor: pointer;
  margin-top: 1rem;
  opacity: 0.45;
  transition: opacity 0.25s ease, color 0.25s ease, border-color 0.25s ease;
}

.btn-secondary:hover, .btn-secondary:active {
  opacity: 0.85;
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.35);
}

/* --- Keyframes --- */
@keyframes pulse-glow {
  0%, 100% { transform: scale(0.95); opacity: 0.4; }
  50% { transform: scale(1.15); opacity: 0.8; }
}

@keyframes pulse-soft {
  0%, 100% { opacity: 0.55; }
  50% { opacity: 0.95; }
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

@keyframes spin-slow {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes pulse-heart {
  0%, 100% { transform: scale(1); }
  15% { transform: scale(1.18); }
  30% { transform: scale(1.05); }
  45% { transform: scale(1.22); }
  60% { transform: scale(1); }
}

@keyframes flicker {
  0% { transform: scale(1) rotate(-1deg); }
  25% { transform: scale(1.05, 0.95) rotate(2deg); }
  50% { transform: scale(0.97, 1.03) rotate(-2deg); }
  75% { transform: scale(1.03, 0.98) rotate(1deg); }
  100% { transform: scale(1) rotate(0deg); }
}

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

@media (max-width: 360px) {
  .act-title { font-size: 2.2rem; }
  .typewriter-text { font-size: 2.2rem; }
  .phrase-text { font-size: 1.75rem; }
  .dawn-line { font-size: 1.25rem; }
  .finale-title { font-size: 1.9rem; }
  .secret-text { font-size: 1.15rem; }
}
