/* Recuerdos del Corazón — estilos de la página-regalo (pensado primero para celular).
   Los colores y letras salen de la paleta elegida (temas.js) y se aplican como variables. */

:root {
  --rosado: #ff7395;          /* color principal */
  --dorado: #c6a15b;          /* color de acento */
  --crema: #fff8f5;           /* fondo */
  --tarjeta: #ffffff;         /* fondo de tarjetas */
  --texto: #4a3a40;
  --blanco: #ffffff;
  --rosado-claro: color-mix(in srgb, var(--rosado) 16%, var(--tarjeta));
  --rosado-oscuro: color-mix(in srgb, var(--rosado) 82%, #000);
  --dorado-claro: color-mix(in srgb, var(--dorado) 35%, #fff);
  --texto-suave: color-mix(in srgb, var(--texto) 65%, var(--crema));
  --sombra: 0 10px 30px color-mix(in srgb, var(--rosado) 18%, transparent);
  --radio: 22px;
  --letra-titulo: 'Dancing Script', cursive;
  --letra: 'Poppins', system-ui, -apple-system, sans-serif;
}

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

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

body {
  font-family: var(--letra);
  color: var(--texto);
  background-color: var(--crema);
  line-height: 1.6;
  overflow-x: hidden;
}

body.bloqueado { overflow: hidden; height: 100vh; }

/* Fondos decorativos */
body.fondo-corazones {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='64' height='64'%3E%3Cpath d='M32 44 C20 35 18 27 24 23 C28 20 31 23 32 25 C33 23 36 20 40 23 C46 27 44 35 32 44Z' fill='%23ff7395' fill-opacity='.09'/%3E%3C/svg%3E");
}
body.fondo-estrellas {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='72' height='72'%3E%3Cpath d='M18 10l2 6 6 2-6 2-2 6-2-6-6-2 6-2z M54 44l1.5 4.5 4.5 1.5-4.5 1.5-1.5 4.5-1.5-4.5-4.5-1.5 4.5-1.5z' fill='%23c6a15b' fill-opacity='.22'/%3E%3C/svg%3E");
}
body.fondo-confeti {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='90' height='90'%3E%3Crect x='10' y='12' width='8' height='4' rx='2' transform='rotate(25 14 14)' fill='%23ff7395' fill-opacity='.18'/%3E%3Crect x='60' y='30' width='8' height='4' rx='2' transform='rotate(-30 64 32)' fill='%23c6a15b' fill-opacity='.25'/%3E%3Ccircle cx='35' cy='70' r='3' fill='%23ff7395' fill-opacity='.15'/%3E%3C/svg%3E");
}
body.fondo-puntos {
  background-image: radial-gradient(color-mix(in srgb, var(--rosado) 14%, transparent) 1.5px, transparent 2px);
  background-size: 22px 22px;
}

img { display: block; max-width: 100%; }

button { font: inherit; cursor: pointer; border: 0; background: none; color: inherit; }

.contenedor { width: 100%; max-width: 520px; margin: 0 auto; padding: 0 20px; }

/* ---------- Portada (pantalla de abrir) ---------- */

.portada {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 28px;
  padding: 24px;
  text-align: center;
  background:
    radial-gradient(circle at 20% 15%, rgba(255, 255, 255, 0.35) 0 2px, transparent 3px) 0 0 / 46px 46px,
    radial-gradient(circle at 70% 60%, rgba(255, 255, 255, 0.25) 0 1.5px, transparent 2.5px) 0 0 / 64px 64px,
    linear-gradient(160deg, color-mix(in srgb, var(--rosado) 80%, #fff) 0%, var(--rosado) 45%, var(--rosado-oscuro) 100%);
  color: var(--blanco);
  transition: opacity 0.7s ease, visibility 0.7s ease;
}

.portada.oculta { opacity: 0; visibility: hidden; }

.portada .logo { width: 132px; opacity: 0.95; filter: brightness(0) invert(1); }

.portada .para { font-size: 15px; letter-spacing: 0.18em; text-transform: uppercase; opacity: 0.9; }

.portada .nombre {
  font-family: var(--letra-titulo);
  font-size: clamp(40px, 12vw, 62px);
  line-height: 1.1;
  text-shadow: 0 3px 14px rgba(0, 0, 0, 0.18);
}

.portada .pista { font-size: 15px; opacity: 0.95; animation: latido 1.6s ease-in-out infinite; }

.abrible {
  position: relative;
  width: 190px;
  height: 190px;
  -webkit-tap-highlight-color: transparent;
}

/* Regalo con lazo */
.regalo { animation: menearse 2.4s ease-in-out infinite; }
.regalo .caja {
  position: absolute; left: 10px; right: 10px; bottom: 0; height: 130px; border-radius: 10px;
  background: linear-gradient(180deg, #fff 0%, #f7eef1 100%);
  box-shadow: 0 18px 30px rgba(0, 0, 0, 0.22);
}
.regalo .tapa {
  position: absolute; left: 0; right: 0; top: 34px; height: 40px; border-radius: 10px;
  background: linear-gradient(180deg, #fff 0%, #f1e4e8 100%);
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.18);
  transition: transform 0.8s cubic-bezier(0.2, 0.9, 0.3, 1.2), opacity 0.8s ease;
  z-index: 2;
}
.regalo .caja::before, .regalo .tapa::before {
  content: ''; position: absolute; top: 0; bottom: 0; left: 50%; width: 26px; transform: translateX(-50%);
  background: linear-gradient(90deg, color-mix(in srgb, var(--dorado) 80%, #000), var(--dorado) 40%, var(--dorado-claro) 60%, var(--dorado));
}
.regalo .lazo { position: absolute; left: 50%; top: -30px; width: 0; height: 0; }
.regalo .lazo::before, .regalo .lazo::after {
  content: ''; position: absolute; top: 0; width: 52px; height: 36px;
  border: 9px solid var(--dorado); border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
}
.regalo .lazo::before { right: 2px; transform: rotate(-18deg); }
.regalo .lazo::after { left: 2px; transform: rotate(18deg); }
.regalo.abierto { animation: none; }
.regalo.abierto .tapa { transform: translateY(-160px) rotate(-24deg); opacity: 0; }

.abrible .brillo {
  position: absolute; left: 50%; bottom: 60px; width: 20px; height: 20px; border-radius: 50%;
  background: radial-gradient(circle, #fff 0%, #ffe9b8 40%, transparent 70%);
  transform: translateX(-50%) scale(0); transition: transform 0.7s ease; z-index: 1;
}
.abrible.abierto .brillo { transform: translateX(-50%) scale(16); }

/* Sobre con carta */
.sobre { animation: flotar 3s ease-in-out infinite; }
.sobre .cuerpo {
  position: absolute; left: 0; right: 0; bottom: 20px; height: 120px; border-radius: 8px;
  background: #fff; box-shadow: 0 18px 30px rgba(0, 0, 0, 0.22); overflow: hidden; z-index: 3;
}
.sobre .cuerpo::before {
  content: ''; position: absolute; inset: 0;
  background:
    linear-gradient(32deg, transparent 49.5%, #f1e4e8 50%) left / 50% 100% no-repeat,
    linear-gradient(-32deg, transparent 49.5%, #f1e4e8 50%) right / 50% 100% no-repeat;
}
.sobre .solapa {
  position: absolute; left: 0; right: 0; bottom: 80px; height: 60px; z-index: 4;
  background: #f7eef1; clip-path: polygon(0 0, 100% 0, 50% 100%);
  transform-origin: top; transform: scaleY(-1) translateY(-60px);
  transition: transform 0.6s ease;
}
.sobre .sello {
  position: absolute; left: 50%; bottom: 66px; width: 34px; height: 34px; margin-left: -17px; z-index: 5;
  border-radius: 50%; background: var(--dorado); box-shadow: 0 2px 6px rgba(0,0,0,.25);
  display: grid; place-items: center; color: #fff; font-size: 16px; transition: opacity 0.3s ease;
}
.sobre .hoja {
  position: absolute; left: 14px; right: 14px; bottom: 30px; height: 100px; border-radius: 6px;
  background: #fffdf8; z-index: 2; transition: transform 0.8s ease 0.4s;
  box-shadow: 0 2px 6px rgba(0,0,0,.08);
}
.sobre .hoja::before {
  content: '♥'; position: absolute; top: 12px; left: 0; right: 0; text-align: center; color: var(--rosado); font-size: 22px;
}
.sobre.abierto { animation: none; }
.sobre.abierto .solapa { transform: scaleY(1) translateY(-60px); z-index: 1; }
.sobre.abierto .sello { opacity: 0; }
.sobre.abierto .hoja { transform: translateY(-90px); }

/* Corazón que late */
.corazon-portada { display: grid; place-items: center; }
.corazon-portada .forma {
  width: 120px; height: 120px; background: #fff; transform: rotate(-45deg);
  position: relative; animation: latir 1.1s ease-in-out infinite;
  box-shadow: 0 18px 30px rgba(0, 0, 0, 0.2);
}
.corazon-portada .forma::before, .corazon-portada .forma::after {
  content: ''; position: absolute; width: 120px; height: 120px; border-radius: 50%; background: #fff;
}
.corazon-portada .forma::before { top: -60px; left: 0; }
.corazon-portada .forma::after { left: 60px; top: 0; }
.corazon-portada .inicial {
  position: absolute; inset: 0; display: grid; place-items: center; z-index: 2;
  font-family: var(--letra-titulo); font-size: 48px; color: var(--rosado);
}
.corazon-portada.abierto .forma { animation: estallar 0.7s ease forwards; }
.corazon-portada.abierto .inicial { opacity: 0; transition: opacity 0.3s; }

/* Cofre del tesoro */
.cofre { animation: menearse 2.6s ease-in-out infinite; }
.cofre .base {
  position: absolute; left: 10px; right: 10px; bottom: 0; height: 100px; border-radius: 8px 8px 14px 14px;
  background: linear-gradient(180deg, #a86b3c, #7a4a26); box-shadow: 0 18px 30px rgba(0,0,0,.25);
  border: 5px solid var(--dorado);
}
.cofre .base::after {
  content: ''; position: absolute; left: 50%; top: -6px; width: 26px; height: 30px; margin-left: -13px;
  background: var(--dorado); border-radius: 4px;
}
.cofre .tapa-cofre {
  position: absolute; left: 10px; right: 10px; bottom: 96px; height: 60px; border-radius: 60px 60px 6px 6px;
  background: linear-gradient(180deg, #b77744, #8a5530); border: 5px solid var(--dorado); z-index: 2;
  transform-origin: bottom; transition: transform 0.8s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}
.cofre.abierto { animation: none; }
.cofre.abierto .tapa-cofre { transform: rotateX(75deg) translateY(-20px); }

/* Globo */
.globo .esfera {
  position: absolute; left: 35px; top: 0; width: 120px; height: 145px; border-radius: 50% 50% 48% 48%;
  background: radial-gradient(circle at 35% 30%, #fff 0 8px, color-mix(in srgb, var(--rosado) 70%, #fff) 9px, var(--rosado) 70%);
  box-shadow: 0 18px 30px rgba(0,0,0,.2); animation: flotar 2.4s ease-in-out infinite;
}
.globo .hilo { position: absolute; left: 94px; top: 145px; width: 2px; height: 45px; background: rgba(255,255,255,.8); }
.globo.abierto .esfera { animation: estallar 0.4s ease forwards; }
.globo.abierto .hilo { opacity: 0; transition: opacity .3s; }

@keyframes menearse {
  0%, 70%, 100% { transform: rotate(0); }
  75% { transform: rotate(-6deg); }
  80% { transform: rotate(6deg); }
  85% { transform: rotate(-4deg); }
  90% { transform: rotate(3deg); }
}
@keyframes flotar { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }
@keyframes latido { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.06); } }
@keyframes latir {
  0%, 100% { transform: rotate(-45deg) scale(1); }
  30% { transform: rotate(-45deg) scale(1.12); }
  50% { transform: rotate(-45deg) scale(0.98); }
}
@keyframes estallar { to { transform: rotate(-45deg) scale(2.4); opacity: 0; } }

/* ---------- Inicio (después de abrir) ---------- */

.inicio {
  min-height: 88vh;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 60px 20px 40px;
  background: radial-gradient(circle at 50% 0%, var(--rosado-claro) 0%, transparent 70%);
}
.inicio .logo { width: 110px; margin-bottom: 28px; }
.inicio h1 { font-family: var(--letra-titulo); font-size: clamp(44px, 13vw, 70px); line-height: 1.08; color: var(--rosado); }
.inicio .nombre-grande { font-family: var(--letra-titulo); font-size: clamp(38px, 11vw, 58px); color: var(--dorado); margin-top: 4px; }
.inicio p { margin-top: 18px; font-size: 17px; color: var(--texto-suave); max-width: 340px; }
.inicio .de { margin-top: 10px; font-size: 14px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--dorado); }

.flecha-abajo {
  margin-top: 44px; width: 44px; height: 44px; border-radius: 50%;
  border: 2px solid var(--rosado); color: var(--rosado); text-decoration: none;
  display: grid; place-items: center; font-size: 20px; animation: rebote 1.8s ease-in-out infinite;
}
@keyframes rebote { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(8px); } }

/* ---------- Secciones ---------- */

.seccion { padding: 48px 0; }
.seccion h2 {
  font-family: var(--letra-titulo); font-size: 40px; line-height: 1.15;
  color: var(--rosado); text-align: center; margin-bottom: 22px;
}
.adorno { display: block; text-align: center; color: var(--dorado); letter-spacing: 0.4em; font-size: 13px; margin-bottom: 6px; }
.tarjeta { background: var(--tarjeta); border-radius: var(--radio); box-shadow: var(--sombra); padding: 24px; }

.aparecer { opacity: 0; transform: translateY(28px); transition: opacity 0.8s ease, transform 0.8s ease; }
.aparecer.visible { opacity: 1; transform: none; }
.sin-animaciones .aparecer { opacity: 1; transform: none; transition: none; }

/* ---------- Música ---------- */

.musica { display: flex; flex-direction: column; gap: 14px; }
.musica .cabecera { display: flex; align-items: center; gap: 14px; }
.musica .disco {
  flex: none; width: 56px; height: 56px; border-radius: 50%;
  background: radial-gradient(circle, #fff 0 5px, var(--rosado) 6px 11px, #2b2226 12px 100%);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}
.musica.sonando .disco { animation: girar 3s linear infinite; }
@keyframes girar { to { transform: rotate(360deg); } }
.musica .info { flex: 1; min-width: 0; }
.musica .info strong { display: block; font-size: 16px; }
.musica .info span { font-size: 14px; color: var(--texto-suave); }
.musica .reproductor { position: relative; width: 100%; aspect-ratio: 16 / 9; border-radius: 14px; overflow: hidden; background: #000; }
.musica .reproductor.spotify { aspect-ratio: auto; height: 152px; background: transparent; }
.musica .reproductor iframe, .musica .reproductor > div { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.musica .reproductor.spotify iframe { position: static; height: 152px; }

.boton {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 22px; border-radius: 999px; background: var(--rosado); color: var(--blanco);
  font-weight: 600; font-size: 15px; text-decoration: none;
  box-shadow: 0 6px 16px color-mix(in srgb, var(--rosado) 40%, transparent); transition: transform 0.15s ease;
}
.boton:active { transform: scale(0.96); }

.boton-musica {
  position: fixed; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom)); z-index: 40;
  width: 52px; height: 52px; border-radius: 50%; background: var(--tarjeta); color: var(--rosado);
  font-size: 22px; box-shadow: 0 6px 20px color-mix(in srgb, var(--rosado) 35%, transparent);
  display: grid; place-items: center; opacity: 0; transform: scale(0.6); pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
}
.boton-musica.visible { opacity: 1; transform: none; pointer-events: auto; }
.boton-musica.sonando { animation: latido 1.2s ease-in-out infinite; }

/* ---------- Galería ---------- */

.galeria {
  display: flex; gap: 14px; overflow-x: auto; scroll-snap-type: x mandatory;
  padding: 6px 20px 18px; margin: 0 -20px; scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.galeria::-webkit-scrollbar { display: none; }
.galeria figure {
  flex: 0 0 82%; scroll-snap-align: center; background: var(--tarjeta);
  border-radius: var(--radio); box-shadow: var(--sombra); padding: 10px 10px 14px;
}
.galeria .medio { width: 100%; aspect-ratio: 4 / 5; border-radius: 16px; overflow: hidden; background: var(--rosado-claro); }
.galeria .medio img, .galeria .medio video { width: 100%; height: 100%; object-fit: cover; }
.galeria .medio.vacio {
  display: grid; place-items: center; text-align: center; padding: 24px; color: var(--rosado-oscuro);
  border: 2px dashed var(--rosado);
  background: repeating-linear-gradient(135deg, var(--tarjeta) 0 14px, var(--rosado-claro) 14px 28px);
}
.galeria .medio.vacio span { font-size: 54px; display: block; }
.galeria figcaption { text-align: center; font-family: var(--letra-titulo); font-size: 24px; margin-top: 8px; }
.puntos { display: flex; justify-content: center; gap: 8px; }
.puntos span { width: 8px; height: 8px; border-radius: 999px; background: var(--rosado-claro); transition: width 0.3s ease, background 0.3s ease; }
.puntos span.activo { width: 22px; background: var(--rosado); }

/* ---------- Carta ---------- */

.carta {
  position: relative; padding: 34px 26px 30px;
  background:
    repeating-linear-gradient(180deg, transparent 0 31px, color-mix(in srgb, var(--rosado) 12%, transparent) 31px 32px),
    var(--tarjeta);
  border-top: 6px solid var(--dorado);
}
.carta::before { content: '💌'; position: absolute; top: -24px; left: 50%; transform: translateX(-50%); font-size: 34px; }
.carta .texto { white-space: pre-line; font-size: 16.5px; line-height: 32px; min-height: 160px; }
.carta .texto.escribiendo::after { content: '|'; color: var(--rosado); animation: parpadeo 0.8s steps(1) infinite; }
@keyframes parpadeo { 50% { opacity: 0; } }
.carta .firma {
  margin-top: 18px; text-align: right; font-family: var(--letra-titulo); font-size: 28px;
  color: var(--rosado); opacity: 0; transition: opacity 0.8s ease;
}
.carta .firma.visible { opacity: 1; }
.carta .saltar { display: block; margin: 14px auto 0; font-size: 13px; color: var(--texto-suave); text-decoration: underline; }

/* ---------- Contador ---------- */

.contador { text-align: center; }
.contador .etiqueta { font-size: 15px; color: var(--texto-suave); margin-bottom: 14px; }
.contador .numeros { display: grid; grid-template-columns: 1.5fr 1fr 1fr 1fr; gap: 8px; }
.contador .casilla { background: linear-gradient(160deg, var(--rosado), var(--rosado-oscuro)); color: #fff; border-radius: 16px; padding: 12px 4px 10px; }
.contador .casilla:first-child { background: linear-gradient(160deg, var(--dorado-claro), var(--dorado)); }
.contador .casilla b { display: block; font-size: clamp(20px, 6.5vw, 30px); font-weight: 600; line-height: 1.1; font-variant-numeric: tabular-nums; }
.contador .casilla small { font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; opacity: 0.9; }
.contador .pie { margin-top: 14px; font-size: 14px; color: var(--texto-suave); }

/* ---------- Raspa y gana ---------- */

.raspa { text-align: center; }
.raspa .instruccion { font-size: 14px; color: var(--texto-suave); margin-bottom: 14px; }
.raspa .zona { position: relative; width: 100%; aspect-ratio: 5 / 3; border-radius: 18px; overflow: hidden; user-select: none; -webkit-user-select: none; }
.raspa .premio {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; padding: 20px; background: linear-gradient(160deg, var(--rosado-claro), var(--tarjeta));
  border: 2px dashed var(--rosado); border-radius: 18px;
}
.raspa .premio strong { font-size: 19px; line-height: 1.35; color: var(--rosado-oscuro); }
.raspa .premio span { font-size: 14px; color: var(--texto-suave); }
.raspa canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: grab; transition: opacity 0.8s ease; }
.raspa canvas.listo { opacity: 0; pointer-events: none; }

/* ---------- Pie ---------- */

.pie-pagina {
  padding: 50px 20px calc(90px + env(safe-area-inset-bottom)); text-align: center;
  background: linear-gradient(180deg, transparent, var(--rosado-claro));
}
.pie-pagina .logo { width: 96px; margin: 0 auto 8px; }
.pie-pagina .submarca { font-family: var(--letra-titulo); font-size: 20px; color: var(--rosado); margin-bottom: 8px; }
.pie-pagina p { font-size: 13px; color: var(--texto-suave); }
.pie-pagina a { color: var(--rosado-oscuro); font-weight: 600; text-decoration: none; }

/* ---------- Mensajes (recuerdo no encontrado, preparándose, PIN) ---------- */

.aviso-pagina {
  min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; gap: 14px; padding: 24px;
}
.aviso-pagina h1 { font-family: var(--letra-titulo); font-size: 44px; color: var(--rosado); }
.aviso-pagina p { color: var(--texto-suave); max-width: 320px; }

/* ---------- Confeti ---------- */

.confeti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 60; }

/* Vista previa dentro del editor: sin pantalla completa fija */
.modo-vista .boton-musica { bottom: 16px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition-duration: 0.01ms !important; }
  .aparecer { opacity: 1; transform: none; }
}
