:root {
  --letra-titulo: "Marcellus", serif;
  --letra-firma: "Parisienne", cursive;
  --suave: #6F6380;
  --linea: #E7E0EE;
  --sombra: rgba(58, 48, 72, .14);
}

body.cerrado { overflow: hidden; height: 100vh; height: 100svh; }

/* ---------- Jardín ---------- */
#escena { position: relative; height: 100vh; height: 100svh; overflow: hidden; background: #FFFFFF; }
.capa { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; will-change: transform; }
#b-fondo { transform-origin: 50% 64%; }
#b-arco { transform-origin: 50% 46%; }
#b-flores { transform-origin: 50% 88%; }
#luz { position: absolute; left: -30%; right: -30%; top: 22%; height: 60%; background: radial-gradient(closest-side, rgba(255, 236, 196, .95), rgba(255, 222, 170, .45) 45%, rgba(255, 214, 160, 0)); opacity: 0; pointer-events: none; mix-blend-mode: screen; }
#vuelo { position: absolute; inset: 0; z-index: 6; pointer-events: none; overflow: hidden; }
#vuelo .mariposa { opacity: 0; }
#vuelo .cerca { width: 118px; --aleteo: .3s; filter: blur(.6px); }
/* Antes de abrir, el jardín se ve borroso y más cerca detrás del capelo. */
body.cerrado #b-fondo { transform: scale(1.12); filter: blur(6px); }
body.cerrado #b-arco { transform: scale(1.3); opacity: 0; }
body.cerrado #b-flores { transform: scale(1.45); opacity: 0; }
body.cerrado #medallon { opacity: 0; }

/* ---------- Mariposas: cada ala es la mitad de la acuarela y gira sobre el cuerpo ---------- */
.mariposa { position: absolute; left: 0; top: 0; width: 54px; aspect-ratio: 220 / 160; display: flex; perspective: 240px; pointer-events: none; will-change: transform; }
.mariposa i { flex: 1 1 50%; height: 100%; background-repeat: no-repeat; background-size: 200% 100%; animation: ala-izq var(--aleteo, .24s) ease-in-out infinite alternate; will-change: transform; }
.mariposa i:first-child { background-position: 0 0; transform-origin: 100% 50%; }
.mariposa i:last-child { background-position: 100% 0; transform-origin: 0 50%; animation-name: ala-der; }
.m1 i { background-image: url(mariposa1.webp); }
.m2 i { background-image: url(mariposa2.webp); }
.m3 i { background-image: url(mariposa3.webp); }
.m4 i { background-image: url(mariposa4.webp); }
@keyframes ala-izq { from { transform: rotateY(6deg); } to { transform: rotateY(74deg); } }
@keyframes ala-der { from { transform: rotateY(-6deg); } to { transform: rotateY(-74deg); } }

/* ---------- Medallón con la foto ---------- */
#escena { --med: min(calc(var(--ancho) * .66), 33svh); --med-arriba: calc(8.5% + env(safe-area-inset-top)); }
#medallon { position: absolute; left: 0; right: 0; margin: 0 auto; top: var(--med-arriba); width: var(--med); aspect-ratio: 600 / 803; }
#medallon::before { content: ""; position: absolute; inset: -8% -14%; background: radial-gradient(closest-side, rgba(255, 255, 255, .9) 45%, rgba(255, 255, 255, .55) 70%, rgba(255, 255, 255, 0)); }
#medallon .marco { position: absolute; inset: 0; width: 100%; height: 100%; }
.ovalo { position: absolute; left: 12.4%; width: 75.6%; top: 10.2%; height: 73.8%; border-radius: 50%; overflow: hidden; background: radial-gradient(closest-side, #FFFFFF 30%, #F2ECF7 78%, #E9E0F1); box-shadow: inset 0 0 18px rgba(110, 90, 158, .18); }
.retrato { position: absolute; inset: 0; }
.retrato img { width: 100%; height: 100%; object-fit: cover; }
.sin-foto { display: none; position: absolute; inset: 0; place-items: center; align-content: center; gap: .2rem; }
.ovalo:has(.retrato[hidden]) .sin-foto { display: grid; }
.sin-foto .mariposa { position: relative; width: 70%; --aleteo: 1.5s; }
.sin-foto .mariposa i { animation-name: ala-izq-suave; animation-timing-function: cubic-bezier(.45, 0, .55, 1); }
.sin-foto .mariposa i:last-child { animation-name: ala-der-suave; }
@keyframes ala-izq-suave { from { transform: rotateY(0); } to { transform: rotateY(48deg); } }
@keyframes ala-der-suave { from { transform: rotateY(0); } to { transform: rotateY(-48deg); } }

/* ---------- Textos de la escena ---------- */
.texto-escena { position: absolute; left: 0; right: 0; text-align: center; padding: 0 1.2rem; pointer-events: none; text-shadow: 0 0 14px #fff, 0 0 26px #fff; }
.velo { display: inline-block; padding: 1rem 1.6rem; background: radial-gradient(closest-side, rgba(255, 255, 255, .94), rgba(255, 255, 255, .74) 60%, rgba(255, 255, 255, 0)); }
#t1 { top: calc(var(--med-arriba) + var(--med) * 1.34 + .4rem); opacity: 0; }
#t1 .ornato { font-family: "Marcellus", serif; font-size: .8rem; letter-spacing: .22em; text-transform: uppercase; color: var(--tinta); display: block; margin-bottom: .2rem; }
#t1 p { font-size: 1.55rem; font-style: italic; }
#t2 { top: 37%; opacity: 0; }
#t2 .nombre { font-family: var(--nombres-letra, "Parisienne", cursive); font-size: min(4.6rem, calc(var(--ancho) * 1.62 / (var(--letras) * var(--nombres-ancho, 1)))); line-height: 1.1; display: block; overflow-wrap: anywhere; font-weight: var(--nombres-peso, 400); font-style: var(--nombres-estilo, normal); text-transform: var(--nombres-mayus, none); letter-spacing: var(--nombres-espacio, normal); }
#t2 .nombre .linea { display: block; }
#t2 .nombre .palabra { display: inline-block; white-space: nowrap; }
#t2 .nombre .l { display: inline-block; }
#t2 .nombre .y { font-size: 2.8rem; color: var(--acento); }
#t2 .sub { font-family: "Marcellus", serif; font-size: .95rem; letter-spacing: .28em; text-transform: uppercase; color: var(--tinta); }
#t3 { top: 40%; opacity: 0; }
#t3 .fecha { font-family: "Marcellus", serif; font-size: 1.45rem; letter-spacing: .14em; display: block; white-space: nowrap; }
#t3 p { font-style: italic; font-size: 1.3rem; color: var(--suave); }
#desliza { position: absolute; bottom: calc(1.4rem + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); font-size: 1rem; font-style: italic; display: flex; flex-direction: column; align-items: center; gap: .2rem; opacity: 0; text-shadow: 0 0 10px #fff, 0 0 18px #fff; }
/* Movimiento reducido: sin recorrido, el nombre y la fecha quedan bajo el medallón. */
#escena.quieto { --med: min(calc(var(--ancho) * .52), 26svh); }
#escena.quieto #t1, #escena.quieto #desliza { display: none; }
#escena.quieto #t2 { top: calc(var(--med-arriba) + var(--med) * 1.34); opacity: 1; }
#escena.quieto #t3 { top: auto; bottom: calc(2.6rem + env(safe-area-inset-bottom)); opacity: 1; }
#desliza i { width: 1px; height: 28px; background: linear-gradient(var(--tinta), transparent); animation: gota 1.8s ease-in-out infinite; transform-origin: top; }
@keyframes gota { 0% { transform: scaleY(0); } 50% { transform: scaleY(1); } 100% { transform: scaleY(1); opacity: 0; } }

/* ---------- Portada: el capelo con las mariposas dentro ---------- */
#portada { position: absolute; inset: 0; z-index: 5; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: calc(4rem + env(safe-area-inset-top)) 1.5rem calc(1.5rem + env(safe-area-inset-bottom)); background: rgba(255, 255, 255, .5); }
#capelo { --alto: min(calc(100svh - 21.5rem), 30rem); position: relative; flex: none; height: max(var(--alto), 9rem); aspect-ratio: 420 / 562; }
#capelo img { position: absolute; left: 0; width: 100%; }
#cupula { top: 0; will-change: transform; }
#pedestal { top: 58%; }
#dentro { position: absolute; left: 29%; width: 42%; top: 15%; height: 42%; }
#dentro .mariposa { width: 46%; --aleteo: .5s; animation: revolotea 6s ease-in-out infinite alternate; }
#dentro .m1 { left: 4%; top: 4%; }
#dentro .m2 { left: 50%; top: 34%; animation-duration: 7.4s; animation-delay: -2s; --aleteo: .42s; }
#dentro .m3 { left: 14%; top: 62%; animation-duration: 5.2s; animation-delay: -4s; --aleteo: .56s; }
@keyframes revolotea { 0% { transform: translate(0, 0) rotate(-10deg); } 35% { transform: translate(14%, -16%) rotate(6deg); } 70% { transform: translate(-10%, 10%) rotate(-4deg); } 100% { transform: translate(8%, 18%) rotate(12deg); } }
#destello { position: absolute; left: -40%; right: -40%; top: -10%; height: 90%; background: radial-gradient(closest-side, rgba(255, 246, 220, 1), rgba(255, 228, 180, .55) 45%, rgba(255, 220, 170, 0)); opacity: 0; pointer-events: none; }

#portada .tarjeta { position: relative; flex: none; width: min(100%, 19rem); margin-top: -1.2rem; text-align: center; background: rgba(255, 255, 255, .94); padding: 1.4rem 1.3rem 1.3rem; box-shadow: 0 16px 40px rgba(58, 48, 72, .16); animation: aparece .8s ease-out backwards; }
#portada .tarjeta::before { content: ""; position: absolute; inset: 6px; border: 1px solid color-mix(in srgb, var(--acento) 35%, #FFFFFF); pointer-events: none; }
@keyframes aparece { from { opacity: 0; } }
.tarjeta .para { font-family: "Marcellus", serif; font-size: .78rem; letter-spacing: .2em; text-transform: uppercase; color: var(--acento); overflow-wrap: anywhere; }
.tarjeta .nombre { font-family: var(--nombres-letra, "Parisienne", cursive); font-size: min(2.9rem, calc(var(--ancho) * .78 / (var(--letras) * var(--nombres-ancho, 1)))); overflow-wrap: anywhere; line-height: 1.2; margin: .3rem 0 .05rem; font-weight: var(--nombres-peso, 400); font-style: var(--nombres-estilo, normal); text-transform: var(--nombres-mayus, none); letter-spacing: var(--nombres-espacio, normal); }
.tarjeta .nombre b { font-weight: 400; color: var(--acento); font-size: 2rem; }
.tarjeta .sub { font-style: italic; color: var(--suave); }
#abrir { margin-top: 1rem; width: 100%; padding: .85rem 1rem; border: 0; background: var(--tinta); color: #FFFFFF; font-family: "Marcellus", serif; font-size: .82rem; letter-spacing: .2em; text-transform: uppercase; cursor: pointer; }
#abrir:focus-visible { outline: 2px solid var(--acento); outline-offset: 3px; }

#musica { position: fixed; z-index: 20; right: max(1rem, calc(50vw - var(--col) / 2 + 1rem)); bottom: calc(1rem + env(safe-area-inset-bottom)); box-shadow: 0 6px 18px rgba(58, 48, 72, .15); width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--linea); background: rgba(255, 255, 255, .9); color: var(--tinta); display: none; place-items: center; cursor: pointer; }
#musica.ver { display: grid; }
#musica svg { width: 20px; height: 20px; }
#musica .barras { display: flex; gap: 2px; align-items: flex-end; height: 16px; }
#musica .barras i { width: 3px; background: var(--tinta); height: 30%; animation: barra 1s ease-in-out infinite; }
#musica .barras i:nth-child(2) { animation-delay: -.3s; }
#musica .barras i:nth-child(3) { animation-delay: -.6s; }
@keyframes barra { 50% { height: 100%; } }

@media (prefers-reduced-motion: reduce) {
  #escena .mariposa i, #dentro .mariposa, #desliza i, #musica .barras i, #portada .tarjeta { animation: none; }
}
