:root {
  --letra-titulo: "Marcellus", serif;
  --suave: #4E6470;
  --linea: #DCE7EA;
  --sombra: rgba(31, 51, 64, .14);
  --mar: #7CC4C5;
}

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

#escena { position: relative; height: 100vh; height: 100svh; overflow: hidden; background: #FFFFFF; }

/* Cada capa es el cuadro del arte (720 × 1290) centrado y recortado como `cover`: lo de adentro se acomoda en % del arte. */
.lienzo { position: absolute; left: 50%; top: 50%; width: max(100%, 55.81vh); width: max(100%, 55.81svh); aspect-ratio: 720 / 1290; margin-left: calc(max(100%, 55.81svh) / -2); margin-top: calc(max(100%, 55.81svh) * -.8959); will-change: transform; pointer-events: none; }
.lienzo > img { position: absolute; left: 0; width: 100%; }
#p-fondo > img { top: 0; height: 100%; }
#p-fondo { transform-origin: 50% 44%; }
#p-arco { transform-origin: 50% 52%; }
#p-foto { transform-origin: 50% 55%; }
#p-arena { transform-origin: 50% 80%; }
#p-palmas { transform-origin: 50% 70%; }
#p-palmas > img { top: 0; height: 100%; }
#p-flores { transform-origin: 50% 100%; }
#p-flores > img { bottom: -11%; left: -4%; width: 108%; }

/* Cielo: el sol se pone detrás del horizonte (44.2 % del arte). */
#cielo { position: absolute; left: 0; right: 0; top: 0; height: 44.2%; overflow: hidden; }
#sol { position: absolute; left: 58%; top: 40%; width: 27%; aspect-ratio: 1; border-radius: 50%; background: radial-gradient(closest-side, #FFE3BC 0, #FFDDB2 52%, rgba(255, 212, 170, .55) 72%, rgba(255, 205, 165, 0) 100%); }
#calido { position: absolute; inset: 0; background: linear-gradient(to bottom, rgba(255, 214, 190, 0) 10%, rgba(250, 186, 156, .42) 80%, rgba(246, 170, 140, .55)); opacity: 0; }
#reflejo { position: absolute; left: 64.5%; width: 10%; top: 44.4%; height: 13%; background: repeating-linear-gradient(to bottom, rgba(255, 226, 190, .95) 0 2px, rgba(255, 226, 190, 0) 2px 7px); -webkit-mask: linear-gradient(to bottom, #000, transparent); mask: linear-gradient(to bottom, #000, transparent); opacity: 0; }
#mojado { position: absolute; left: 0; right: 0; top: 63.5%; bottom: 0; background: linear-gradient(to bottom, rgba(96, 150, 156, .34), rgba(110, 160, 165, .14) 45%, rgba(110, 160, 165, 0)); opacity: 0; }

/* Olas que se mueven: trazos blancos que corren sobre el mar y la espuma que sube y baja en la orilla. */
.olas { position: absolute; left: 0; right: 0; background-repeat: repeat-x; animation: corre 9s linear infinite; opacity: .7; }
#olas-lejos { top: 45.6%; height: 7%; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='40' fill='none' stroke='%23fff' stroke-linecap='round'%3E%3Cpath d='M8 9q8-4 16 0t16 0' stroke-width='1.4'/%3E%3Cpath d='M92 21q7-3 14 0t14 0' stroke-width='1.2'/%3E%3Cpath d='M40 33q9-4 18 0t18 0' stroke-width='1.6'/%3E%3C/svg%3E"); background-size: 160px 40px; }
#olas-cerca { top: 52.5%; height: 9.5%; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='60' fill='none' stroke='%23fff' stroke-linecap='round'%3E%3Cpath d='M10 14q12-6 24 0t24 0t24 0' stroke-width='2'/%3E%3Cpath d='M120 36q11-5 22 0t22 0' stroke-width='1.8'/%3E%3Cpath d='M30 52q10-5 20 0t20 0' stroke-width='2.2'/%3E%3C/svg%3E"); background-size: 220px 60px; animation-duration: 6s; animation-direction: reverse; opacity: .8; }
@keyframes corre { to { background-position-x: -440px; } }
#orilla { position: absolute; left: -2%; width: 104%; top: 62.6%; height: 3%; fill: rgba(255, 255, 255, .9); animation: lamer 4.6s ease-in-out infinite alternate; transform-origin: 50% 0; }
@keyframes lamer { from { transform: translateY(-40%) scaleY(.7); opacity: .7; } to { transform: translateY(45%) scaleY(1.15); opacity: 1; } }

/* Gaviotas lejanas */
#gaviotas { position: absolute; left: 0; right: 0; top: 9%; height: 22%; pointer-events: none; }
.gaviota { position: absolute; left: 0; width: 26px; animation: cruza linear infinite; color: #4A5A66; }
.gaviota svg { display: block; width: 100%; overflow: visible; }
.gaviota path { transform-origin: 50% 70%; transform-box: fill-box; animation: aleteo .9s ease-in-out infinite alternate; }
@keyframes cruza { from { transform: translateX(calc(var(--ancho) + 30px)); } to { transform: translateX(-60px); } }
@keyframes aleteo { to { transform: scaleY(-.35); } }

/* Arco con telas */
#arco, #telas { position: absolute; left: 13%; width: 74%; top: 24%; }
#telas { aspect-ratio: 896 / 1200; overflow: visible; }

/* Polaroid colgada del arco */
#polaroid { position: absolute; left: 29%; width: 42%; top: 41.2%; background: #FFFFFF; padding: 5.5% 5.5% 0; box-shadow: 0 10px 22px rgba(31, 51, 64, .26), 0 1px 3px rgba(31, 51, 64, .18); transform-origin: 50% -16%; container-type: inline-size; }
#polaroid .cordel { position: absolute; left: 50%; bottom: 100%; width: 1px; height: 4.4em; font-size: 1cqw; background: #8A7356; transform: translateX(-.5px); }
#polaroid .cordel::before { content: ""; position: absolute; left: -2.5px; bottom: -3px; width: 6px; height: 6px; border-radius: 50%; background: #B9A27E; }
#polaroid .marco { position: relative; aspect-ratio: 1 / 1.06; overflow: hidden; background: #EEF3F4; }
.retrato, .retrato img { width: 100%; height: 100%; }
.retrato img { object-fit: cover; }
.atardecer { display: none; position: absolute; inset: 0; background:
  linear-gradient(to bottom, #CFE8F1 0, #F3EEEA 40%, #FBE0CB 58%, #F6CDB0 62%, #8FD0CC 62.2%, #6DBDBB 80%, #F0DDBA 80.4%, #F6E9D2 100%); }
.marco:has([data-seccion="retrato"][hidden]) .atardecer { display: block; }
.atardecer::after { content: ""; position: absolute; left: 0; right: 0; top: 64%; height: 14%; background: repeating-linear-gradient(to bottom, rgba(255, 255, 255, .55) 0 1px, transparent 1px 7px); }
.atardecer .sol-chico { position: absolute; left: 50%; top: 62%; width: 34%; aspect-ratio: 2 / 1; transform: translate(-50%, -100%); border-radius: 999px 999px 0 0; background: radial-gradient(circle at 50% 100%, #FBD2A6 0 58%, rgba(251, 200, 160, .45) 64%, rgba(251, 200, 160, 0) 72%); }
.atardecer img { position: absolute; right: 8%; bottom: 3%; width: 30%; transform: rotate(-14deg); filter: drop-shadow(0 2px 2px rgba(120, 90, 60, .25)); }
#polaroid .pie { font-family: "Allura", cursive; font-size: 15cqw; line-height: 1; text-align: center; padding: .14em 0 .2em; color: var(--tinta); min-height: 1.3em; }

/* Los nombres escritos en la arena: letra hundida con grano. */
.arena { position: absolute; left: 50%; width: min(82%, calc(var(--ancho) * .9)); transform: translateX(-50%); top: 70.8%; text-align: center; color: #6F5233;
  font-family: var(--nombres-letra, "Allura", cursive); font-weight: var(--nombres-peso, 400); font-style: var(--nombres-estilo, normal); text-transform: var(--nombres-mayus, none); letter-spacing: var(--nombres-espacio, normal);
  font-size: min(3.3rem, 5.6svh, calc(var(--ancho) * 2.15 / (var(--letras) * var(--nombres-ancho, 1)))); line-height: .95; overflow-wrap: anywhere;
  text-shadow: 0 1.5px 0 rgba(255, 251, 242, .9), 0 -1px 1px rgba(84, 58, 30, .45), 0 0 10px rgba(255, 246, 228, .8);
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='90' height='90'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='1.1' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1.6 1.75'/%3E%3C/filter%3E%3Crect width='90' height='90' filter='url(%23g)'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='90' height='90'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='1.1' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1.6 1.75'/%3E%3C/filter%3E%3Crect width='90' height='90' filter='url(%23g)'/%3E%3C/svg%3E"); }
.arena .linea { display: block; }
.arena .palabra { display: inline-block; white-space: nowrap; }
.arena .l { display: inline-block; }
.arena .y { font-size: .55em; line-height: 1.1; }

/* 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; z-index: 3; }
.velo { display: inline-block; padding: 1.1rem 1.6rem; background: radial-gradient(closest-side, rgba(255, 255, 255, .93), rgba(255, 255, 255, .72) 60%, rgba(255, 255, 255, 0)); }
#t1 { top: 8.5%; opacity: 0; }
#t1 .ornato { font-family: "Marcellus", serif; font-size: 1.45rem; letter-spacing: .16em; text-transform: uppercase; color: var(--tinta); display: block; line-height: 1.2; }
#t1 p { font-size: 1.3rem; font-style: italic; color: var(--suave); }
#t2 { top: 13%; opacity: 0; }
#t2 .nombre { font-family: var(--nombres-letra, "Allura", cursive); font-size: min(4.4rem, calc(var(--ancho) * 2.2 / (var(--letras) * var(--nombres-ancho, 1)))); line-height: .95; 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.6rem; color: var(--acento); }
#t3 { top: 52%; opacity: 0; }
#t3 .fecha { font-family: "Marcellus", serif; font-size: 1.3rem; letter-spacing: .08em; display: block; }
#t3 p { font-style: italic; font-size: 1.2rem; color: var(--suave); }
#desliza { position: absolute; z-index: 3; bottom: calc(1.4rem + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); font-size: .95rem; font-style: italic; display: flex; flex-direction: column; align-items: center; gap: .2rem; opacity: 0; text-shadow: 0 0 8px #fff, 0 0 14px #fff; }
#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: postal de lino sobre la arena ---------- */
#portada { position: absolute; inset: 0; z-index: 5; display: grid; place-items: center; background: #F4E6CC; }
#portada .arena-fondo { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
#postal { position: relative; width: min(84%, 20rem); text-align: center; padding: 2.6rem 1.4rem 1.4rem; transform: rotate(-1.2deg); animation: aparece .7s ease-out backwards;
  background-color: #FFFFFF;
  background-image: repeating-linear-gradient(0deg, rgba(31, 51, 64, .03) 0 1px, transparent 1px 3px), repeating-linear-gradient(90deg, rgba(31, 51, 64, .025) 0 1px, transparent 1px 4px);
  box-shadow: 0 1px 2px rgba(80, 60, 30, .18), 0 16px 34px rgba(80, 60, 30, .28); }
@keyframes aparece { from { opacity: 0; } }
#postal::before { content: ""; position: absolute; inset: 7px; border: 1px solid rgba(31, 51, 64, .16); pointer-events: none; }
.estampilla { position: absolute; top: .8rem; right: .8rem; width: 54px; height: 64px; padding: 5px; background: #FFFFFF; outline: 3px dotted #FFFFFF; outline-offset: -1px; box-shadow: 0 1px 3px rgba(31, 51, 64, .3); transform: rotate(4deg); }
.estampilla img { width: 100%; height: 100%; object-fit: contain; background: linear-gradient(#DDF0F0, #F6EEE4); padding: 4px; }
.matasellos { position: absolute; top: 1.2rem; right: 2.4rem; width: 96px; color: rgba(31, 51, 64, .32); transform: rotate(-8deg); }
#postal .para { position: relative; font-family: "Marcellus", serif; font-size: .78rem; letter-spacing: .22em; text-transform: uppercase; color: var(--acento); text-align: left; padding-right: 4.2rem; }
#postal .para span { display: block; font-family: "Cormorant Garamond", serif; text-transform: none; letter-spacing: 0; font-size: 1.3rem; font-style: italic; color: var(--tinta); line-height: 1.2; margin-top: .15rem; }
#postal .pases { text-align: left; font-size: .95rem; color: var(--suave); }
#postal .nombre { font-family: var(--nombres-letra, "Allura", cursive); font-size: min(3rem, calc(var(--ancho) * 1.05 / (var(--letras) * var(--nombres-ancho, 1)))); overflow-wrap: anywhere; line-height: 1.1; margin: 1.1rem 0 .1rem; font-weight: var(--nombres-peso, 400); font-style: var(--nombres-estilo, normal); text-transform: var(--nombres-mayus, none); letter-spacing: var(--nombres-espacio, normal); }
#postal .nombre b { font-weight: 400; color: var(--acento); font-size: .7em; }
#postal .sub { font-style: italic; color: var(--suave); }
#abrir { margin-top: 1.3rem; width: 100%; padding: .85rem 1rem; border: 0; background: var(--tinta); color: #fff; font-family: "Marcellus", serif; font-size: .85rem; letter-spacing: .2em; text-transform: uppercase; cursor: pointer; }
#abrir:focus-visible { outline: 2px solid var(--acento); outline-offset: 3px; }

/* La ola de la apertura: la espuma arriba y el mar lleno debajo. */
#ola { position: absolute; left: -6%; right: -6%; top: 0; height: 122%; z-index: 6; pointer-events: none; visibility: hidden; background: linear-gradient(transparent 30%, var(--mar) 30%); }
#ola img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 0; }

#musica { position: fixed; z-index: 20; right: max(1rem, calc(50vw - var(--col) / 2 + 1rem)); top: calc(1rem + env(safe-area-inset-top)); width: 44px; height: 44px; border-radius: 50%; border: 1px solid rgba(31, 51, 64, .2); background: rgba(255, 255, 255, .9); 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) {
  .olas, #orilla, .gaviota, .gaviota path, #desliza i, #musica .barras i, #postal { animation: none; }
  #gaviotas { display: none; }
}
