/* ============================================================
   ESTILOS - EXPERIENCIA INTERACTIVA & EMOCIONAL
   ============================================================ */

:root {
  --font-serif: 'Cormorant Garamond', Georgia, serif;
  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
  --gold-accent: #d4af37;
  --gold-soft: #f4d06f;
  --gold-glow: rgba(212, 175, 55, 0.4);
  --text-dark: #27221f;
  --text-light: #f7f3ec;
  --text-muted: rgba(247, 243, 236, 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: manipulation;
}

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

/* --- Transiciones de Fondo por Acto --- */
body.theme-act1 {
  background: #0a0a0f;
  color: var(--text-light);
}

body.theme-act2 {
  background: radial-gradient(circle at center, #2e1707 0%, #110903 100%);
  color: #fff2e0;
}

body.theme-act3 {
  background: #faf4ec;
  color: var(--text-dark);
}

body.theme-act4 {
  background: #080e1d;
  color: #f0e9df;
}

body.theme-act4.heartbeat-active {
  background: #17101f;
  transition: background 0.8s ease;
}

body.theme-act5-dawn {
  background: linear-gradient(180deg, #18233c 0%, #a4637e 45%, #e8a87c 75%, #fbe8c5 100%);
  background-size: 100% 250%;
  background-position: bottom;
  color: #2b211b;
  transition: background 8s ease, color 4s ease;
}

/* --- Canvas Unificado de Efectos (Stardust & Confeti) --- */
#fx-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 15;
}

/* --- Contenedor Principal --- */
.experience-container {
  width: 100%;
  max-width: 620px;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 2rem 1.5rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  position: relative;
  z-index: 5;
  text-align: center;
}

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

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

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

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

.gift-glow {
  position: absolute;
  width: 140px;
  height: 140px;
  top: -20px;
  border-radius: 50%;
  background: var(--gold-glow);
  filter: blur(28px);
  animation: pulse-glow 3s infinite ease-in-out;
  pointer-events: none;
}

.gift-icon {
  width: 64px;
  height: 64px;
  color: var(--gold-accent);
  margin-bottom: 2rem;
  position: relative;
  z-index: 2;
  filter: drop-shadow(0 0 12px var(--gold-glow));
  animation: float 4s ease-in-out infinite;
}

.act-title {
  font-size: 2.2rem;
  font-weight: 400;
  letter-spacing: 0.04em;
  margin-bottom: 0.75rem;
  line-height: 1.2;
}

.act-subtitle {
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 300;
  color: var(--text-muted);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 2.8rem;
}

.btn-primary {
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  color: #1a1610;
  background: linear-gradient(135deg, #f3d47c 0%, #d4af37 100%);
  border: none;
  padding: 0.9rem 2.2rem;
  border-radius: 9999px;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(212, 175, 55, 0.35);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.btn-primary:active {
  transform: scale(0.97);
}

/* --- ACTO 2: Sorpresa --- */
.typewriter-text {
  font-size: 2.4rem;
  font-weight: 600;
  line-height: 1.25;
  margin-bottom: 1.2rem;
  color: #ffe6a7;
  text-shadow: 0 0 15px rgba(244, 208, 111, 0.4);
}

.fade-sub {
  font-family: var(--font-sans);
  font-size: 1.05rem;
  font-weight: 300;
  letter-spacing: 0.06em;
  color: #ffdeb3;
  opacity: 0;
  transition: opacity 1.5s ease;
}

.fade-sub.visible {
  opacity: 1;
}

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

.phrase-text {
  font-size: 2.05rem;
  line-height: 1.45;
  font-weight: 400;
  font-style: italic;
  letter-spacing: 0.02em;
  max-width: 520px;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 1s ease, transform 1s ease;
}

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

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

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

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

.whisper-word:active {
  color: #c49520;
}

/* Burbuja flotante de susurros */
.whisper-bubble {
  position: fixed;
  bottom: 12%;
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  max-width: 380px;
  width: 86%;
  background: rgba(22, 20, 28, 0.94);
  color: #f7ede2;
  border: 1px solid rgba(212, 175, 55, 0.45);
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.55);
  padding: 1rem 1.4rem;
  border-radius: 14px;
  font-size: 1.15rem;
  font-style: italic;
  line-height: 1.45;
  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);
}

/* --- Constelación de Recuerdos (Acto 3) --- */
.constellation {
  margin-top: 1.5rem;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.2rem;
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 1.2s ease, transform 1.2s ease;
}

.constellation.visible {
  opacity: 1;
  transform: translateY(0);
}

.constellation-prompt {
  font-family: var(--font-sans);
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  color: rgba(39, 34, 31, 0.65);
}

.stars-row {
  display: flex;
  gap: 2.2rem;
  justify-content: center;
  align-items: center;
}

.star-btn {
  background: transparent;
  border: none;
  font-size: 2.4rem;
  color: #c59828;
  cursor: pointer;
  padding: 0.5rem;
  transition: transform 0.3s ease, color 0.3s ease, filter 0.3s ease;
  filter: drop-shadow(0 0 6px rgba(212, 175, 55, 0.4));
  animation: float-star 3s ease-in-out infinite;
}

.star-btn:nth-child(2) {
  animation-delay: 1s;
}

.star-btn:nth-child(3) {
  animation-delay: 2s;
}

.star-btn.opened {
  color: #7a5812;
  filter: drop-shadow(0 0 12px rgba(212, 175, 55, 0.8));
  transform: scale(1.18);
}

.star-card {
  max-width: 440px;
  width: 90%;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(212, 175, 55, 0.3);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
  border-radius: 12px;
  padding: 1.1rem 1.4rem;
  font-size: 1.25rem;
  font-style: italic;
  color: #2b231d;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}

.star-card.visible {
  opacity: 1;
  transform: translateY(0);
}

.btn-subtle {
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  color: #1a1610;
  background: linear-gradient(135deg, #f3d47c 0%, #d4af37 100%);
  border: none;
  padding: 0.75rem 2rem;
  border-radius: 9999px;
  cursor: pointer;
  box-shadow: 0 4px 18px rgba(212, 175, 55, 0.35);
  margin-top: 1.2rem;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.btn-subtle:active {
  transform: scale(0.97);
}

/* --- ACTO 4: El Latido --- */
.heartbeat-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-top: 1.5rem;
  width: 100%;
}

.heartbeat-trigger {
  width: 96px;
  height: 96px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: 50%;
  padding: 10px;
  touch-action: none;
}

.heartbeat-ring {
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 2px dashed rgba(212, 175, 55, 0.5);
  animation: spin-slow 12s linear infinite;
  transition: border-color 0.3s ease, transform 0.3s ease;
}

.heartbeat-core {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: radial-gradient(circle, #e6b800 0%, #a43820 100%);
  box-shadow: 0 0 16px rgba(230, 184, 0, 0.6);
  animation: pulse-heart 1.6s ease-in-out infinite;
  transition: transform 0.2s ease;
}

.heartbeat-box.holding .heartbeat-ring {
  border-color: #ff6b6b;
  transform: scale(1.2);
  border-style: solid;
}

.heartbeat-box.holding .heartbeat-core {
  transform: scale(1.3);
  background: radial-gradient(circle, #ff8787 0%, #c92a2a 100%);
  box-shadow: 0 0 28px rgba(255, 107, 107, 0.9);
}

.heartbeat-label {
  font-family: var(--font-sans);
  font-size: 0.85rem;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-top: 1.1rem;
}

.heartbeat-quote {
  font-size: 1.45rem;
  font-style: italic;
  line-height: 1.45;
  color: #ffe8cc;
  max-width: 480px;
  margin-top: 1.8rem;
  text-shadow: 0 0 12px rgba(244, 208, 111, 0.4);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 1.2s ease, transform 1.2s ease;
}

.heartbeat-quote.visible {
  opacity: 1;
  transform: translateY(0);
}

/* --- ACTO 5: Amanecer + Vela Interactiva --- */
.dawn-container {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.stacked-phrases {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  margin-bottom: 2rem;
  max-width: 540px;
}

.dawn-line {
  font-size: 1.45rem;
  line-height: 1.4;
  font-weight: 400;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 1.4s ease, transform 1.4s ease;
}

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

/* Vela de cumpleaños (touch target generoso) */
.candle-box {
  margin: 1.5rem 0;
  padding: 1.5rem 2.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  border-radius: 16px;
  touch-action: none;
  transition: transform 0.2s ease;
}

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

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

.candle-flame {
  width: 22px;
  height: 32px;
  background: radial-gradient(ellipse at bottom, #ffffff 15%, #ffd43b 45%, #ff922b 80%, rgba(255, 146, 43, 0) 100%);
  border-radius: 50% 50% 20% 20% / 60% 60% 40% 40%;
  box-shadow: 0 0 18px #ffd43b, 0 0 32px #ff922b;
  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 6px rgba(0, 0, 0, 0.15);
}

.candle-hint {
  font-family: var(--font-sans);
  font-size: 0.9rem;
  color: #5c4228;
  margin-top: 1rem;
  letter-spacing: 0.05em;
  max-width: 320px;
  animation: pulse-soft 2.5s infinite ease-in-out;
}

.finale-group {
  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.3rem;
  font-weight: 600;
  color: #7a4609;
  letter-spacing: 0.03em;
  text-shadow: 0 1px 10px rgba(255, 230, 180, 0.8);
}

.finale-subtext {
  font-size: 1.35rem;
  font-style: italic;
  color: #4a341e;
  margin-top: 0.5rem;
  max-width: 480px;
}

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

.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(10, 11, 18, 0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  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(22, 24, 35, 0.96);
  border: 1px solid rgba(212, 175, 55, 0.28);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.7);
  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.35rem;
  line-height: 1.6;
  font-style: italic;
  font-weight: 400;
  margin-bottom: 1.8rem;
}

.secret-text .divider {
  margin: 1.3rem 0;
  color: var(--gold-accent);
  font-size: 1.1rem;
  opacity: 0.8;
}

.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(212, 175, 55, 0.1);
  border: 1px solid rgba(212, 175, 55, 0.35);
  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(212, 175, 55, 0.2);
}

/* Mensaje final de despedida */
.farewell-message {
  font-size: 1.2rem;
  line-height: 1.65;
  font-style: italic;
  text-align: left;
  border-left: 2px solid var(--gold-accent);
  padding-left: 1.2rem;
  margin-bottom: 2rem;
  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: 1rem;
}

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

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

.btn-secondary {
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  color: #f7f3ec;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  padding: 0.65rem 1.6rem;
  border-radius: 9999px;
  cursor: pointer;
  transition: background 0.2s ease;
}

.btn-secondary:active {
  background: rgba(255, 255, 255, 0.2);
}

/* --- 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 float-star {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-6px) rotate(8deg); }
}

@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: 1.85rem; }
  .typewriter-text { font-size: 2rem; }
  .phrase-text { font-size: 1.65rem; }
  .dawn-line { font-size: 1.25rem; }
  .finale-title { font-size: 1.9rem; }
  .secret-text { font-size: 1.15rem; }
}
