/* ---------- Fuentes ---------- */
@font-face {
  font-family: "Hollyhock";
  src: url("../fuentes/hollyhock.woff2") format("woff2");
  font-display: swap;
}
/* Cuando tengas "Cake Italic C": pon el archivo en sitio/fuentes/cake-italic-c.woff2 y descomenta:
@font-face {
  font-family: "Cake Italic C";
  src: url("../fuentes/cake-italic-c.woff2") format("woff2");
  font-display: swap;
}
*/

:root {
  --blanco: #FFFFFF;
  --marfil: #FFFCF7;
  --crema: #FBF6EE;
  --vino: #4B0002;
  --granate: #530407;
  --rojo: #5A0B0A;
  --tinta-clara: #FFF6EE;

  --f-titulo: "Hollyhock", "Great Vibes", "Parisienne", cursive;
  --f-frase: "Cake Italic C", "Cormorant Garamond", Georgia, serif;
  --f-cuerpo: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  --gutter: 20px;
  --radio: 18px;
  --sombra: 0 14px 34px -14px rgba(75, 0, 2, .35), 0 3px 10px -4px rgba(75, 0, 2, .18);
  --ease: cubic-bezier(.22, .8, .24, 1);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
html.bloqueado { overflow: hidden; }
body {
  margin: 0;
  background: var(--blanco);
  color: var(--vino);
  font-family: var(--f-cuerpo);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}
img, video { display: block; max-width: 100%; }
button { font: inherit; color: inherit; cursor: pointer; }

#fondo {
  position: fixed; inset: 0; z-index: -1;
  background: var(--blanco);
}

.app {
  max-width: 480px;
  margin: 0 auto;
  padding: 0 var(--gutter);
}

/* Temas por sección: el JS asigna según el color de fondo en ese punto */
.tema-claro { color: var(--vino); }
.tema-oscuro { color: var(--tinta-clara); }

/* ---------- Tipografía ---------- */
.titulo {
  font-family: var(--f-titulo);
  font-weight: 400;
  line-height: 1.05;
  margin: 0;
  overflow-wrap: break-word;
}
.frase {
  font-family: var(--f-frase);
  font-style: italic;
  font-weight: 400;
  line-height: 1.4;
  margin: 0;
  text-wrap: balance;
}
.titulo { text-wrap: balance; }

/* ---------- Portada ---------- */
.portada {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center;
  position: relative;
  padding: 10dvh 0 14dvh;
}
.portada .ornamento { font-size: 1.1rem; letter-spacing: .6em; opacity: .55; margin-bottom: 1.6rem; }
.portada .titulo { font-size: clamp(4rem, 25vw, 7.5rem); }
.portada .frase { font-size: clamp(1.15rem, 5.2vw, 1.45rem); margin-top: 1.1rem; max-width: 18em; opacity: .85; }
.portada .titulo, .portada .frase, .portada .ornamento { animation: entrar 1.6s var(--ease) both; }
.portada .frase { animation-delay: .5s; }
.portada .ornamento { animation-delay: .2s; }

.deslizar {
  position: absolute; bottom: max(28px, env(safe-area-inset-bottom)); left: 0; right: 0;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  font-family: var(--f-frase); font-style: italic; font-size: 1rem; opacity: .7;
  animation: entrar 1.4s 1.4s var(--ease) both;
}
.deslizar svg { width: 22px; height: 22px; animation: flotar 2.2s ease-in-out infinite; }

@keyframes entrar { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }
@keyframes flotar { 0%, 100% { transform: translateY(0); opacity: .6; } 50% { transform: translateY(8px); opacity: 1; } }

/* ---------- Frases intermedias ---------- */
.intermedia {
  min-height: 78vh;
  min-height: 78dvh;
  display: flex; align-items: center; justify-content: center;
  text-align: center;
  padding: 12dvh 6px;
}
.intermedia .frase { font-size: clamp(1.55rem, 7.4vw, 2.15rem); }
.intermedia .linea {
  display: block;
  opacity: 0; transform: translateY(14px);
  transition: opacity 1.1s var(--ease), transform 1.1s var(--ease);
}
.intermedia .linea.destacada { font-family: var(--f-titulo); font-style: normal; font-size: 1.7em; margin-top: .25em; }
.intermedia.visible .linea { opacity: 1; transform: none; }

/* ---------- Momentos ---------- */
.momento { padding: 6dvh 0 10dvh; }
.momento-cabecera { text-align: center; margin-bottom: 2.6rem; }
.momento-etiqueta {
  font-family: var(--f-cuerpo); font-size: .72rem; letter-spacing: .28em; text-transform: uppercase;
  opacity: .6; margin-bottom: .8rem;
}
.momento .titulo { font-size: clamp(2.9rem, 15vw, 4.4rem); }
.momento-cabecera .frase { font-size: clamp(1.15rem, 5vw, 1.35rem); margin: 1rem auto 0; max-width: 21em; opacity: .9; }

.bloque { margin: 0 0 3.2rem; }
.nota {
  font-family: var(--f-frase); font-style: italic; font-size: 1.05rem;
  text-align: center; opacity: .75; margin: .9rem 0 0;
}

/* Revelado al entrar en pantalla */
.revelar { opacity: 0; transform: translateY(28px); transition: opacity 1s var(--ease), transform 1s var(--ease); }
.revelar.visible { opacity: 1; transform: none; }

/* ---------- Foto con carga progresiva ---------- */
.foto {
  position: relative; overflow: hidden;
  border-radius: 12px;
  background: #EFE6DD;
  padding: 0; border: 0; width: 100%;
  display: block;
  aspect-ratio: var(--ar, 3 / 4);
}
.foto::before {
  content: ""; position: absolute; inset: -12px;
  background: var(--lq) center / cover no-repeat;
  filter: blur(12px);
  transition: opacity .6s;
}
.foto img {
  position: relative;
  width: 100%; height: 100%; object-fit: cover;
  opacity: 0; transition: opacity .8s ease;
}
.foto.cargada img { opacity: 1; }
.foto.cargada::before { opacity: 0; }
.foto:focus-visible { outline: 3px solid currentColor; outline-offset: 3px; }

/* Grande */
.l-grande .foto { border-radius: var(--radio); box-shadow: var(--sombra); }

/* Polaroid */
.l-polaroid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px;
  padding: 8px 4px 20px;
}
.polaroid {
  background: #FFFFFF;
  padding: 8px 8px 30px;
  box-shadow: 0 10px 24px -10px rgba(40, 0, 2, .45);
  border-radius: 3px;
  transform: rotate(var(--rot, 0deg)) translateY(var(--dy, 0));
  transition: transform .5s var(--ease);
}
.polaroid .foto { aspect-ratio: 4 / 5; border-radius: 1px; }
.l-polaroid.n3 > :nth-child(3) { grid-column: 1 / -1; width: 58%; justify-self: center; margin-top: 4px; }
.l-polaroid > :nth-child(1) { --rot: -4deg; }
.l-polaroid > :nth-child(2) { --rot: 3.5deg; --dy: 26px; }
.l-polaroid > :nth-child(3) { --rot: -1.5deg; }
.l-polaroid.n4 > :nth-child(3) { --rot: 2.5deg; --dy: 4px; }
.l-polaroid.n4 > :nth-child(4) { --rot: -3.5deg; --dy: 28px; }
.l-polaroid .nota { grid-column: 1 / -1; margin-top: 2rem; }

/* Carrusel */
.l-carrusel { margin-left: calc(var(--gutter) * -1); margin-right: calc(var(--gutter) * -1); }
.carrusel {
  display: flex; gap: 12px;
  overflow-x: auto; overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory;
  padding: 6px 11% 18px;
  scrollbar-width: none;
}
.carrusel::-webkit-scrollbar { display: none; }
.carrusel > * { flex: 0 0 78%; scroll-snap-align: center; }
.carrusel .foto { aspect-ratio: 3 / 4; border-radius: 16px; box-shadow: var(--sombra); }
.puntos { display: flex; justify-content: center; gap: 7px; }
.puntos span { width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .25; transition: opacity .3s, transform .3s; }
.puntos span.activo { opacity: .85; transform: scale(1.3); }

/* Dúo */
.l-duo { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding-bottom: 36px; }
.l-duo .foto { aspect-ratio: 3 / 4; border-radius: 14px; box-shadow: var(--sombra); }
.l-duo > :nth-child(2) { transform: translateY(36px); }

/* Mosaico */
.l-mosaico { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.l-mosaico .foto { aspect-ratio: 3 / 4; border-radius: 10px; }
.l-mosaico.n3 > :first-child { grid-row: span 2; }
.l-mosaico.n3 > :first-child .foto { aspect-ratio: auto; height: 100%; }

/* Paisaje */
.l-paisaje { display: grid; gap: 14px; }
.l-paisaje .foto { border-radius: 14px; box-shadow: var(--sombra); }
.l-paisaje > :nth-child(2) { width: 88%; justify-self: end; margin-top: -26px; }

/* Video */
.l-video video {
  width: 100%; border-radius: var(--radio); box-shadow: var(--sombra);
  background: #1a0001; aspect-ratio: var(--ar, 9 / 16); object-fit: cover;
}

/* ---------- Pregunta ---------- */
.pregunta {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center;
  padding: 8dvh 0;
}
.pregunta .titulo { font-size: clamp(3.2rem, 17vw, 5.4rem); margin-bottom: 2.4rem; }
.zona-botones {
  position: relative; width: 100%; height: 220px;
  display: flex; align-items: center; justify-content: center; gap: 18px;
}
.btn {
  border: 0; border-radius: 999px;
  padding: 14px 30px; min-width: 112px; min-height: 52px;
  font-family: var(--f-frase); font-style: italic; font-weight: 500; font-size: 1.35rem;
  transition: transform .45s var(--ease), opacity .4s, left .45s var(--ease), top .45s var(--ease), box-shadow .3s;
  touch-action: manipulation;
}
.btn-si {
  background: var(--blanco); color: var(--vino);
  box-shadow: 0 10px 30px -8px rgba(0, 0, 0, .5), 0 0 0 0 rgba(255, 255, 255, .5);
  transform: scale(var(--escala, 1));
  animation: latido 2.4s ease-in-out infinite;
  position: relative; z-index: 2;
}
.btn-no {
  background: transparent; color: var(--tinta-clara);
  border: 1.5px solid rgba(255, 246, 238, .6);
  transform: scale(var(--escala, 1));
}
.btn-no.suelto { position: absolute; margin: 0; }
.btn-no.ido { opacity: 0; pointer-events: none; }
.pista-no {
  font-family: var(--f-frase); font-style: italic; font-size: 1.05rem;
  min-height: 1.5em; margin-top: .6rem; opacity: 0; transition: opacity .6s;
}
.pista-no.visible { opacity: .8; }
@keyframes latido { 0%, 100% { box-shadow: 0 10px 30px -8px rgba(0,0,0,.5), 0 0 0 0 rgba(255,255,255,.35); } 50% { box-shadow: 0 10px 30px -8px rgba(0,0,0,.5), 0 0 0 12px rgba(255,255,255,0); } }

/* ---------- Final ---------- */
.final {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center;
  padding: 10dvh 0 14dvh;
}
.final[hidden] { display: none; }
.final .titulo { font-size: clamp(2.6rem, 13vw, 3.8rem); margin-bottom: 2rem; }
.final .polaroid { width: 78%; --rot: -2deg; margin-bottom: 2.4rem; }
.final .polaroid .foto { aspect-ratio: 3 / 4; }
.final .frase { font-size: clamp(1.2rem, 5.4vw, 1.45rem); max-width: 20em; }
.final .firma { font-family: var(--f-titulo); font-size: clamp(2.2rem, 11vw, 3rem); margin-top: 1.6rem; }

/* ---------- Lightbox ---------- */
.lightbox {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(22, 0, 2, var(--lb-alfa, 1));
  touch-action: none; user-select: none; -webkit-user-select: none;
  overflow: hidden;
}
.lightbox[hidden] { display: none; }
.lightbox.abriendo { animation: aparecer .3s ease both; }
@keyframes aparecer { from { opacity: 0; } }
.lb-pista {
  display: flex; height: 100%;
  will-change: transform;
}
.lb-pista.animada { transition: transform .35s var(--ease); }
.lb-slide {
  flex: 0 0 100vw; height: 100%;
  display: flex; align-items: center; justify-content: center;
  padding: max(56px, env(safe-area-inset-top)) 10px max(56px, env(safe-area-inset-bottom));
}
.lb-slide img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 6px; pointer-events: none; }
.lb-cerrar {
  position: absolute; top: max(12px, env(safe-area-inset-top)); right: 12px;
  width: 44px; height: 44px; border-radius: 50%; border: 0;
  background: rgba(255, 255, 255, .14); color: #fff; font-size: 1.15rem;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.lb-contador {
  position: absolute; bottom: max(18px, env(safe-area-inset-bottom)); left: 0; right: 0;
  text-align: center; color: rgba(255, 255, 255, .7);
  font-family: var(--f-frase); font-style: italic; font-size: 1rem;
}
.lb-flecha {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 46px; height: 46px; border-radius: 50%; border: 0;
  background: rgba(255, 255, 255, .12); color: #fff; font-size: 1.8rem; line-height: 1;
  display: none;
}
.lb-prev { left: 14px; } .lb-next { right: 14px; }
@media (hover: hover) and (pointer: fine) { .lb-flecha { display: block; } }

/* ---------- Celebración y música ---------- */
#celebracion { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 40; }
.musica {
  position: fixed; z-index: 30;
  right: 14px; bottom: max(14px, env(safe-area-inset-bottom));
  width: 42px; height: 42px; border-radius: 50%;
  border: 1px solid rgba(75, 0, 2, .18);
  background: rgba(255, 255, 255, .72);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  color: var(--vino); font-size: 1.15rem;
  box-shadow: 0 4px 14px -6px rgba(75, 0, 2, .4);
  transition: opacity .3s;
  opacity: .75;
}
.musica[aria-pressed="true"] { opacity: 1; }
.oscuro .musica { background: rgba(255, 255, 255, .14); color: #fff; border-color: rgba(255, 255, 255, .28); }
.musica[aria-pressed="true"] .musica-icono { display: inline-block; animation: flotar 1.6s ease-in-out infinite; }

/* ---------- Modo álbum ---------- */
.dijo-si { display: flex; flex-direction: column; align-items: center; gap: .4rem; margin-top: -.6rem; }
.dijo-si-texto { font-size: clamp(1.4rem, 6.4vw, 1.8rem); }
.dijo-si-fecha {
  font-family: var(--f-cuerpo); font-style: normal; font-size: .74rem;
  letter-spacing: .28em; text-transform: uppercase; opacity: .65;
}

.capitulos-btn {
  position: fixed; z-index: 30;
  left: 14px; bottom: max(14px, env(safe-area-inset-bottom));
  width: 42px; height: 42px; border-radius: 50%;
  display: grid; place-items: center; padding: 0;
  border: 1px solid rgba(75, 0, 2, .18);
  background: rgba(255, 255, 255, .72);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  color: var(--vino);
  box-shadow: 0 4px 14px -6px rgba(75, 0, 2, .4);
}
.capitulos-btn[hidden], .musica[hidden] { display: none; }
.capitulos-btn svg { width: 20px; height: 20px; }
.oscuro .capitulos-btn { background: rgba(255, 255, 255, .14); color: #fff; border-color: rgba(255, 255, 255, .28); }

.indice {
  position: fixed; inset: 0; z-index: 45;
  background: rgba(30, 0, 2, .45);
  display: flex; align-items: flex-end; justify-content: center;
  animation: aparecer .25s ease both;
}
.indice[hidden] { display: none; }
.indice-panel {
  width: 100%; max-width: 480px; max-height: 75dvh; overflow-y: auto;
  background: var(--marfil); color: var(--vino);
  border-radius: 22px 22px 0 0;
  padding: 22px 24px max(26px, env(safe-area-inset-bottom));
  animation: subir .35s var(--ease) both;
}
@keyframes subir { from { transform: translateY(40px); opacity: 0; } }
.indice-titulo { font-family: var(--f-titulo); font-size: 2.4rem; margin: 0 0 .6rem; text-align: center; }
.indice ol { list-style: none; margin: 0; padding: 0; counter-reset: cap; }
.indice li { border-top: 1px solid rgba(75, 0, 2, .1); }
.indice a {
  display: block; padding: 14px 4px; min-height: 48px;
  font-family: var(--f-frase); font-style: italic; font-size: 1.25rem;
  color: inherit; text-decoration: none;
}

/* ---------- Escritorio ---------- */
@media (min-width: 700px) {
  .app { padding: 0 28px; }
  .l-carrusel { margin-left: 0; margin-right: 0; }
}

/* ---------- Movimiento reducido ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
  .revelar, .intermedia .linea { transform: none !important; transition: opacity .4s linear !important; }
  .btn, .lb-pista.animada { transition-duration: .01ms !important; }
}
