/* =========================================================================
   Invitación Daniela & Patricia — misma experiencia que la invitación Atelier
   (precarga → sobre que flota → solapa 3D → carta sube → tarjeta en cascada →
   aparición al hacer scroll), con el diseño de esta boda. + vaivén de flores.
   ========================================================================= */
:root {
  --ink: #40052e;
  --cream: #f2ece2;
  --serif: 'Cormorant Garamond', 'Cormorant', Georgia, 'Times New Roman', serif;
  --ease-out: cubic-bezier(.16, 1, .3, 1);
  --ease-flap: cubic-bezier(.34, 1.06, .5, 1);
  --hinge: 40.276%;                 /* bisagra de la solapa en el lienzo del sobre */
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: #e4dbce;
  color: var(--ink);
  font-family: var(--serif);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
img { max-width: 100%; display: block; }

/* fondo de papel detrás de todo — deriva lenta (46 s) + parallax con el mouse */
body::before {
  content: ""; position: fixed; inset: -10%; z-index: -2;
  background: #e4dbce url(../assets/papel.webp) center / 1106px auto repeat;
  background-position: calc(50% + var(--bgx, 0px)) calc(50% + var(--bgy, 0px));
  filter: brightness(.93) saturate(.92);
  transform: scale(1.1);
  animation: silkdrift 46s ease-in-out infinite alternate;
  will-change: transform;
}
@keyframes silkdrift {
  0%   { transform: scale(1.1) translate3d(0, 0, 0); }
  100% { transform: scale(1.16) translate3d(-2%, -1.6%, 0) rotate(.4deg); }
}
body::after {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background: radial-gradient(130% 100% at 50% 40%, transparent 30%, rgba(64, 5, 46, .16) 100%);
}

.sr {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ============================ PRECARGA ============================ */
.preloader { display: none; }
.js .preloader {
  position: fixed; inset: 0; z-index: 1000;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px;
  background: var(--cream);
  transition: opacity .6s ease, visibility .6s ease;
}
.preloader.is-done { opacity: 0; visibility: hidden; }
.preloader__mark { width: 76px; height: 76px; }
.preloader__bar { width: 120px; height: 2px; background: rgba(64, 5, 46, .12); overflow: hidden; border-radius: 2px; }
.preloader__bar span { display: block; height: 100%; width: 40%; background: var(--ink); animation: load 1.1s ease-in-out infinite; }
@keyframes load { 0% { transform: translateX(-120%); } 100% { transform: translateX(320%); } }

/* ============================ PORTADA · SOBRE ============================ */
.hero { display: none; }
.js .hero {
  position: fixed; inset: 0; z-index: 900;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  transition: opacity .6s ease, visibility .6s ease;
}
.hero.is-gone { opacity: 0; visibility: hidden; pointer-events: none; }
.stage-sobre {
  perspective: 1400px;
  display: flex; flex-direction: column; align-items: center; gap: 30px;
  /* el lienzo reserva arriba el espacio de la solapa abierta: subir para centrar el sobre cerrado */
  margin-top: calc(min(86vw, 420px) * -0.30);
}
.sobre {
  appearance: none; border: 0; background: none; padding: 0; margin: 0; cursor: pointer;
  position: relative; display: block;
  width: min(86vw, 420px);
  aspect-ratio: 2124 / 1738;
  perspective: 1100px;
  animation: float 4s ease-in-out infinite;
  -webkit-tap-highlight-color: transparent;
}
.sobre:focus-visible { outline: 2px solid var(--ink); outline-offset: 14px; border-radius: 8px; }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-9px); } }

.sobre > span { position: absolute; inset: 0; background-position: center; background-size: contain; background-repeat: no-repeat; }
.sobre-cuerpo { background-image: url(../assets/sobre-cuerpo.webp); z-index: 1; }
.sobre-tapa   { background-image: url(../assets/sobre-tapa.webp);   z-index: 2; }
.sobre-front  { background-image: url(../assets/sobre-front.webp);  z-index: 3; }
.sobre-sombra { background-image: url(../assets/sobre-sombra.webp); z-index: 3; }
.sobre-solapa { background-image: url(../assets/sobre-solapa.webp); z-index: 4; transform-origin: 50% var(--hinge); }
.sobre > .sobre-sello {
  inset: auto; left: 43.192%; top: 63.142%; width: 17.193%; aspect-ratio: 1;
  background-image: url(../assets/sobre-sello.webp); z-index: 5;
  transform-origin: 50% -108.82%;          /* gira sobre la misma bisagra que la solapa */
}
/* la carta: detrás del bolsillo, sube por la boca */
.sobre > .sobre-boca { inset: auto; left: 0; right: 0; top: -60%; bottom: 0; z-index: 2; overflow: hidden; pointer-events: none; }
.sobre-carta {
  position: absolute; left: 14%; right: 14%; top: 100%; height: 37.5%;   /* 60 % del lienzo */
  background: var(--cream) url(../assets/carta-preview.webp) top / 100% auto no-repeat;
  border-radius: 6px;
  box-shadow: 0 -10px 30px rgba(64, 5, 46, .16);
}
/* brillo diagonal que cruza el papel, recortado a la silueta del sobre */
.sobre-sheen {
  z-index: 6; pointer-events: none; mix-blend-mode: soft-light;
  -webkit-mask: url(../assets/sobre-mask.png) center / contain no-repeat;
          mask: url(../assets/sobre-mask.png) center / contain no-repeat;
  background: linear-gradient(112deg, transparent 34%, rgba(255, 255, 255, .12) 46%,
              rgba(255, 255, 255, .34) 50%, rgba(255, 255, 255, .12) 54%, transparent 66%) no-repeat;
  background-size: 260% 100%;
  animation: sheen 7.5s ease-in-out infinite;
  transition: opacity .3s ease;
}
@keyframes sheen { 0% { background-position: 165% 0; } 55%, 100% { background-position: -65% 0; } }

/* indicación "Toca el sobre para abrir" */
.hint { display: flex; flex-direction: column; align-items: center; gap: 10px; transition: opacity .3s ease; }
.hint p { margin: 0; color: var(--ink); font-weight: 500; text-align: center; }
.hint__fecha { font-size: clamp(17px, 4.8vw, 24px); letter-spacing: .38em; padding-left: .38em; }
.hint__txt { display: flex; align-items: center; gap: 10px; font-size: clamp(14px, 3.8vw, 17px); letter-spacing: .14em; }
.hint__pulse { width: 7px; height: 7px; border-radius: 50%; background: var(--ink); animation: pulse 2s ease-out infinite; }
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(64, 5, 46, .45); }
  70%  { box-shadow: 0 0 0 14px rgba(64, 5, 46, 0); }
  100% { box-shadow: 0 0 0 0 rgba(64, 5, 46, 0); }
}
.hint.is-hidden { opacity: 0; pointer-events: none; }

/* ---------- secuencia de apertura (tiempos de Atelier) ---------- */
.js .sobre.is-open { animation: sobre-react 1.1s var(--ease-out) .1s; }
.js .sobre.is-open .sobre-solapa { animation: flap 1s var(--ease-flap) .1s forwards; will-change: transform, filter; }
.js .sobre.is-open .sobre-sello  { animation: sello 1s var(--ease-flap) .1s forwards; }
.js .sobre.is-tucked .sobre-solapa { z-index: 0; }     /* JS: pasa detrás del cuerpo al cruzar la vertical */
.js .sobre.is-open .sobre-tapa,
.js .sobre.is-open .sobre-sombra { opacity: 0; transition: opacity .35s ease .1s; }
.js .sobre.is-open .sobre-sheen { opacity: 0; }
@keyframes flap {
  0%   { transform: translateY(0) rotateX(0); filter: brightness(1); }
  32%  { filter: brightness(1.06); }
  50%  { filter: brightness(.95); }
  100% { transform: translateY(1.5px) rotateX(-172deg); filter: brightness(.9); }   /* +1.5px: tapa la línea fina en la bisagra (fix de Atelier) */
}
@keyframes sello {
  0%   { transform: rotateX(0); opacity: 1; }
  30%  { opacity: 1; }
  45%  { opacity: 0; }
  100% { transform: rotateX(-172deg); opacity: 0; }
}
@keyframes sobre-react {
  0%   { transform: none; }
  28%  { transform: rotateX(5deg) scale(1.012); }
  62%  { transform: rotateX(-1.6deg); }
  100% { transform: none; }
}
.js .sobre.is-open .sobre-carta { animation: carta .8s var(--ease-out) .82s forwards; will-change: transform; }
@keyframes carta { from { transform: translateY(0); } to { transform: translateY(-130%); } }

/* ============================ TARJETA ============================ */
.tarjeta-wrap {
  min-height: 100vh; min-height: 100svh;
  display: flex; align-items: flex-start; justify-content: center;
  padding: 48px 20px;
}
.tarjeta {
  position: relative;
  width: min(92vw, 430px);
  border-radius: 14px;
  overflow: hidden;
  isolation: isolate;
  background: var(--cream);
  border: 1px solid rgba(64, 5, 46, .08);
  box-shadow: 0 34px 82px rgba(64, 30, 40, .26), 0 6px 18px rgba(64, 30, 40, .08);
}
@media (min-width: 1024px) { .tarjeta { width: min(620px, 78vh); } }
.js .tarjeta { opacity: 0; transform: translateY(36px) scale(.97); will-change: transform, opacity; }
.js .tarjeta.is-in { opacity: 1; transform: none; transition: opacity .9s var(--ease-out), transform .9s var(--ease-out); }
.js .tarjeta.tilt {
  transition: transform .3s ease;
  transform: perspective(1100px) rotateX(var(--tiltX, 0deg)) rotateY(var(--tiltY, 0deg));
  transform-origin: 50% var(--tiltOY, 50%);
}

/* cascada de la portada al abrir (retardos de Atelier, definidos por capa en --rd) */
.js .tarjeta:not(.is-in) .reveal { opacity: 0; }
.js .tarjeta.is-in .reveal { animation: rise .7s var(--ease-out) var(--rd, 0s) both; }
@keyframes rise { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }

/* resto: aparece al entrar en pantalla, escalonado (--rd) */
.js .reveal-up {
  opacity: 0; transform: translateY(32px);
  transition: opacity .85s var(--ease-out) var(--rd, 0s), transform .85s var(--ease-out) var(--rd, 0s);
}
.js .reveal-up.in { opacity: 1; transform: none; }

/* ---------- pantallas del diseño (unidades = 1/1080 del ancho) ---------- */
.stage {
  position: relative; width: 100%; overflow: hidden;
  container-type: inline-size;
  --u: calc(100cqw / 1080);
}
@supports not (width: 1cqw) { .stage { --u: calc(min(92vw, 430px) / 1080); } }
.bg { position: absolute; inset: 0; overflow: hidden; }
.bgp { position: absolute; max-width: none; display: block; }
.L { position: absolute; margin: 0; }
.L > img { display: block; width: 100%; height: 100%; }

/* flores: único movimiento continuo dentro de la invitación (además del botón de asistencia) */
.L[data-a="flor"] > img {
  transform-origin: var(--o, 50% 100%);
  animation: sway 7s ease-in-out var(--d, 0s) infinite alternate;
}
.L[data-a="flor-sol"] > img { animation: sun 9s ease-in-out var(--d, 0s) infinite alternate; }
@keyframes sway { from { transform: rotate(-1.8deg); } to { transform: rotate(1.8deg); } }
@keyframes sun  { from { transform: rotate(-6deg); } to { transform: rotate(6deg); } }

/* textos vivos */
.live {
  display: flex; align-items: center; justify-content: center;
  font-family: var(--serif); font-weight: 500;
  text-align: center; white-space: nowrap; color: var(--ink);
}
.live-16 { color: #0d0b0c; font-size: calc(39 * var(--u)); line-height: 1.24; }
.live-80 { font-size: calc(28.5 * var(--u)); line-height: 1.28; }
.live-dir { font-size: calc(29 * var(--u)); font-style: italic; letter-spacing: .01em; }
.sp-label { justify-content: flex-end; font-size: calc(21.5 * var(--u)); text-decoration: none; cursor: pointer; }
.sp-label:hover { text-decoration: underline; text-underline-offset: .2em; }

/* reproductor */
.play { padding: 0; border: 0; background: none; color: var(--ink); cursor: pointer; border-radius: 50%; -webkit-tap-highlight-color: transparent; }
.play::after { content: ""; position: absolute; inset: -60%; border-radius: 50%; }
.play svg { display: block; width: 100%; height: 100%; overflow: visible; }
.play .i-pause { display: none; }
.play[aria-pressed="true"] .i-pause { display: inline; }
.play[aria-pressed="true"] .i-play { display: none; }
.play:focus-visible, .sp-label:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
.track { background: var(--ink); border-radius: 2px; }
.knob { background: var(--ink); border-radius: 50%; }
.js .knob.reveal-up.in { transition: opacity .85s var(--ease-out), transform .85s var(--ease-out), left .5s linear; }
.knob.is-playing { box-shadow: 0 0 0 calc(7 * var(--u)) rgba(64, 5, 46, .14); }

/* enlaces sobre las píldoras del diseño */
.hit {
  position: absolute; z-index: 5; border-radius: 999px;
  -webkit-tap-highlight-color: transparent;
  transition: background-color .25s ease, transform .2s ease;
}
.hit:hover { background-color: rgba(64, 5, 46, .07); transform: translateY(-2px); }
.hit:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

/* "Confirma tu asistencia": brillo pulsante (señal de toque en celular) + zoom al pasar el mouse */
.rsvp-btn {
  display: block; z-index: 5; border-radius: 999px;
  -webkit-tap-highlight-color: transparent;
  animation: rsvp-glow 2.6s ease-in-out infinite;
}
.rsvp-btn, .js .rsvp-btn.reveal-up {
  transition: opacity .85s var(--ease-out) var(--rd, 0s), transform .85s var(--ease-out) var(--rd, 0s),
              scale .25s ease, background-color .25s ease, box-shadow .25s ease;
}
.rsvp-btn::after { content: ""; position: absolute; inset: -40% -4%; }
.rsvp-btn:hover {
  scale: 1.06; background-color: rgba(64, 5, 46, .07); animation: none;
  box-shadow: 0 0 22px rgba(64, 5, 46, .30), 0 0 52px rgba(64, 5, 46, .12);
}
.rsvp-btn:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
@keyframes rsvp-glow {
  0%, 100% { box-shadow: 0 0 0 rgba(64, 5, 46, 0); }
  50%      { box-shadow: 0 0 16px rgba(64, 5, 46, .26), 0 0 42px rgba(64, 5, 46, .10); }
}

/* contenedor del reproductor de Spotify: dentro del viewport (si no, no carga), invisible */
.sp-wrap { position: fixed; left: 0; bottom: 0; z-index: -1; width: 300px; height: 80px; overflow: hidden; opacity: 0; pointer-events: none; }

/* ============================ MOVIMIENTO REDUCIDO ============================ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
  .js .tarjeta { opacity: 1; transform: none; }
  .js .tarjeta .reveal { animation: none; opacity: 1; }
  .js .reveal-up { opacity: 1; transform: none; }
  .sobre { animation: none; }
}

/* ---------- burbujas con texto (botones reales, texto vivo centrado) ---------- */
.pill {
  display: flex; align-items: center; justify-content: center;
  border: max(1px, calc(1.8 * var(--u))) solid var(--ink);
  border-radius: 999px;
  color: var(--ink); text-decoration: none; white-space: nowrap;
  font-family: var(--serif); font-weight: 500;
  font-size: calc(var(--fs) * var(--u)); line-height: 1;
  padding-bottom: .08em;                 /* centrado óptico de Cormorant (ascendentes altos) */
  -webkit-tap-highlight-color: transparent;
}
.js a.pill.reveal-up, a.pill { cursor: pointer; transition: opacity .85s var(--ease-out) var(--rd, 0s), transform .85s var(--ease-out) var(--rd, 0s), scale .25s ease, background-color .25s ease, box-shadow .25s ease; }
a.pill::after { content: ""; position: absolute; inset: -35% -4%; }   /* área táctil más grande */
a.pill:hover { background-color: rgba(64, 5, 46, .07); scale: 1.04; }
a.pill:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
.pill-box { display: flex; flex-direction: column; align-items: stretch; }
.pill-label {
  font-family: var(--serif); font-weight: 500; color: var(--ink); text-align: center;
  font-size: calc(17 * var(--u)); line-height: 1; letter-spacing: .48em; padding-left: .48em;
  height: 22%; display: flex; align-items: flex-start; justify-content: center;
}
.pill--static { flex: 1; font-size: calc(var(--fs) * var(--u)); }
