/* =========================================================
   Invitación digital · Sobre animado
   ========================================================= */

@font-face {
  font-family: "Great Vibes";
  src: url("../assets/fonts/GreatVibes-Regular.ttf") format("truetype");
  font-display: swap;
}

:root {
  --oro-1: #7d5a1c;
  --oro-2: #b8862e;
  --oro-3: #e6c77a;
  --oro-4: #f6e7b4;
  --ease-elegante: cubic-bezier(.65, 0, .25, 1);
  --ease-suave: cubic-bezier(.22, .61, .36, 1);
  --alto: 100vh;
}
@supports (height: 100dvh) {
  :root { --alto: 100dvh; }
}

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

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #fff;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: "Great Vibes", cursive;
  overscroll-behavior: none;
}

img { user-select: none; -webkit-user-drag: none; }

/* ---------- Invitación (contenedor; las secciones están en invitacion.css) ---------- */
#invitacion {
  position: fixed;
  inset: 0;
  z-index: 1;
  background: #fff;
  opacity: 0;
  visibility: hidden;
  transition: opacity 2.2s var(--ease-suave), visibility 0s linear 2.2s;
}
#invitacion.visible {
  opacity: 1;
  visibility: visible;
  transition: opacity 2.2s var(--ease-suave), visibility 0s;
}

/* ---------- Escena / sobre ---------- */
#escena {
  position: fixed;
  inset: 0;
  z-index: 2;
  overflow: hidden;
  background: #fff url("../assets/img/web/papel.webp") center / 600px repeat;
  transition: background-color 1.4s ease;
}
/* Al abrir, el fondo pasa a blanco puro */
#escena.abriendo { background-image: none; background-color: #fff; }
#escena.oculta { display: none; }

/* El sobre siempre ocupa el 100% del alto; en pantallas angostas se recortan los laterales */
#sobre {
  position: absolute;
  top: 0;
  left: 50%;
  height: var(--alto);
  aspect-ratio: 2400 / 1792;
  transform: translateX(-50%);
}

.capa {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
}

/* Capas del sobre abierto: ocultas hasta ingresar */
.capa-abajo, .capa-solapa { opacity: 0; will-change: transform, opacity; }
.capa-solapa { z-index: 2; transform-origin: 50% 0; }
.capa-abajo  { z-index: 1; }
.capa-completo { z-index: 3; opacity: 0; }

/* ---------- Dije (botón) — posicionado exactamente sobre el sello de la solapa ---------- */
#dije {
  position: absolute;
  z-index: 4;
  left: 44.583%;
  top: 57.868%;
  width: 10.958%;
  aspect-ratio: 339 / 418;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  opacity: 0;
  border-radius: 50%;
  outline-offset: 6px;
}
#dije img { width: 100%; height: 100%; display: block; }
#dije:disabled { cursor: default; }
#dije:focus-visible { outline: 2px solid var(--oro-2); }

#dije.listo { animation: latido 3.2s ease-in-out infinite; }
#dije.listo:hover { animation-play-state: paused; transform: scale(1.04); transition: transform .4s var(--ease-suave); }

@keyframes latido {
  0%, 100% { transform: scale(1);    filter: drop-shadow(0 2px 4px rgba(120, 85, 20, .25)); }
  50%      { transform: scale(1.035); filter: drop-shadow(0 0 14px rgba(230, 190, 100, .85)); }
}

/* ---------- Textos manuscritos ---------- */
.manuscrito {
  position: absolute;
  z-index: 5;
  left: 50%;
  transform: translateX(-50%);
  padding: 0;
  border: 0;
  background: none;
  pointer-events: none;
}
.manuscrito svg {
  width: 100%;
  height: auto;
  display: block;
  overflow: visible;
  filter: drop-shadow(0 1px 1px rgba(90, 60, 10, .30)) drop-shadow(0 0 6px rgba(255, 255, 255, .9));
}
.manuscrito path {
  fill: url(#oro);
  fill-opacity: 0;
  stroke: url(#oro);
  stroke-width: 1.1;
  stroke-linecap: round;
  stroke-linejoin: round;
}

#nombres {
  bottom: 44%;              /* justo encima del dije */
  width: min(86vw, 60vh);
}
@supports (height: 100dvh) { #nombres { width: min(86vw, 60dvh); } }

#ingresar {
  top: 78.2%;               /* justo debajo del dije */
  width: min(44vw, 22vh);
  cursor: pointer;
}
@supports (height: 100dvh) { #ingresar { width: min(44vw, 22dvh); } }
#ingresar.listo { pointer-events: auto; animation: respirar 3.2s ease-in-out infinite; }
#ingresar:focus-visible { outline: 1px solid var(--oro-2); outline-offset: 6px; border-radius: 8px; }

@keyframes respirar {
  0%, 100% { opacity: 1; }
  50%      { opacity: .72; }
}

/* Respaldo si no carga opentype: texto con degradado y barrido */
.manuscrito .respaldo {
  display: block;
  font-family: "Great Vibes", cursive;
  font-size: var(--fs, 48px);
  line-height: 1.2;
  white-space: nowrap;
  text-align: center;
  background: linear-gradient(100deg, var(--oro-1), var(--oro-2) 25%, var(--oro-4) 50%, var(--oro-2) 75%, var(--oro-1));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  clip-path: inset(0 100% 0 0);
}

/* Salida de textos al ingresar */
.manuscrito.salir {
  transition: opacity .7s ease, transform .9s var(--ease-suave);
  opacity: 0 !important;
  transform: translate(-50%, -14px);
  animation: none;
  pointer-events: none;
}

/* ---------- Botón de música ---------- */
#btn-musica {
  position: fixed;
  z-index: 10;
  right: max(18px, env(safe-area-inset-right));
  bottom: max(18px, env(safe-area-inset-bottom));
  width: 54px;
  height: 54px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  display: grid;
  place-items: center;
  color: var(--oro-1);
  background: radial-gradient(circle at 30% 25%, #fffdf6, #f3e6c4 70%, #e2cb8f);
  box-shadow: 0 6px 18px rgba(90, 60, 10, .25), inset 0 0 0 1px rgba(184, 134, 46, .55);
  opacity: 0;
  transform: scale(.6);
  pointer-events: none;
  transition: opacity .8s ease, transform .8s var(--ease-suave), filter .4s ease, box-shadow .4s ease;
}
#btn-musica.visible { opacity: 1; transform: scale(1); pointer-events: auto; }
#btn-musica:hover { box-shadow: 0 8px 22px rgba(90, 60, 10, .32), inset 0 0 0 1px rgba(184, 134, 46, .8); }
#btn-musica:focus-visible { outline: 2px solid var(--oro-2); outline-offset: 3px; }

#btn-musica .anillo {
  position: absolute; inset: 0; width: 100%; height: 100%;
  fill: none; stroke: var(--oro-2); stroke-width: 1.5; stroke-dasharray: 4 6; stroke-linecap: round;
  animation: girar 8s linear infinite;
}
#btn-musica .icono { width: 22px; height: 22px; position: relative; top: -3px; }
#btn-musica .nota { fill: currentColor; }
#btn-musica .tachado { stroke: currentColor; stroke-width: 2; stroke-linecap: round; opacity: 0; transition: opacity .3s ease; }

#btn-musica .barras {
  position: absolute; bottom: 11px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 2px; align-items: flex-end; height: 7px;
}
#btn-musica .barras i {
  width: 2px; height: 100%; background: var(--oro-2); border-radius: 1px;
  animation: barra 1s ease-in-out infinite; transform-origin: bottom;
}
#btn-musica .barras i:nth-child(2) { animation-delay: -.35s; }
#btn-musica .barras i:nth-child(3) { animation-delay: -.7s; }

/* Estado pausado */
#btn-musica.pausado { filter: grayscale(.65); color: #8d7a58; }
#btn-musica.pausado .anillo { animation-play-state: paused; stroke-dasharray: none; opacity: .45; }
#btn-musica.pausado .tachado { opacity: 1; }
#btn-musica.pausado .barras i { animation: none; transform: scaleY(.25); }

@keyframes girar { to { transform: rotate(360deg); } }
@keyframes barra { 0%, 100% { transform: scaleY(.3); } 50% { transform: scaleY(1); } }

@media (prefers-reduced-motion: reduce) {
  #dije.listo, #ingresar.listo, #btn-musica .anillo, #btn-musica .barras i { animation: none; }
}

/* ---------- Partículas de ambiente ---------- */
.capa-particulas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 5;            /* sobre la invitación, bajo el botón de música */
  pointer-events: none;
}

/* ---------- Acceso privado (sin la clave en el enlace) ---------- */
#privado { display: none; }
html.sin-acceso body > *:not(#privado) { display: none !important; }
html.sin-acceso #privado {
  position: fixed;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 14px;
  padding: 24px;
  text-align: center;
  background: #141210;
  color: #efe6d2;
}
#privado img { border-radius: 18px; box-shadow: 0 0 30px rgba(217, 185, 104, .25); }
.privado-titulo { margin: 8px 0 0; font: 400 clamp(34px, 9vw, 52px) / 1.1 "Great Vibes", cursive; color: #e2c27a; }
.privado-texto  { margin: 0; max-width: 34ch; font: 400 17px / 1.6 Georgia, "Times New Roman", serif; color: rgba(239, 230, 210, .85); }
.privado-firma  { margin: 18px 0 0; font: 500 10px / 1 system-ui, sans-serif; letter-spacing: .2em; line-height: 1.8; text-transform: uppercase; color: rgba(226, 194, 122, .6); }
