/* ==========================================================================
   Lucas & Camila — Invitación digital
   ========================================================================== */
:root {
  --paper: #f9f5f2;          /* fondo exacto del diseño de Canva */
  --paper-deep: #efe8e1;     /* fondo exterior en pantallas grandes */
  --ink: #3c2f2f;
  --mauve: #664c4c;          /* color de los números de la cuenta regresiva */
  --gold: #b8955a;
  --col: min(100vw, 480px);  /* ancho de la columna de la invitación */
  --u: calc(var(--col) / 3875); /* 1 px del diseño original en pantalla */
  --ease-soft: cubic-bezier(.22, .61, .36, 1);
  --ease-silk: cubic-bezier(.65, .05, .36, 1);
}

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  background: var(--paper);
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font-family: "Cormorant Garamond", Georgia, "Times New Roman", serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
  overflow-x: hidden;
}

body.is-locked { overflow: hidden; height: 100%; }
html.is-locked { overflow: hidden; height: 100%; }

img { display: block; max-width: none; -webkit-user-select: none; user-select: none; -webkit-user-drag: none; }
picture { display: block; }
button { font: inherit; color: inherit; }

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

/* ==========================================================================
   SOBRE
   ========================================================================== */
.intro {
  position: fixed;
  top: 0; right: 0; bottom: 0; left: 0;
  z-index: 50;
  height: 100vh;
  height: 100dvh;
  background: var(--paper);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  touch-action: none;
  transition: opacity .9s var(--ease-soft);
}
.intro.is-gone { opacity: 0; pointer-events: none; }
.intro.is-loaded .intro__stage { opacity: 1; transform: none; }

.intro__stage {
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 1.2s var(--ease-soft), transform 1.4s var(--ease-soft);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(14px, 3.2vh, 28px);
  padding-top: 4vh;
}

.envelope {
  position: relative;
  width: min(84vw, calc(70vh * .7054), 420px);
  height: 0;
  padding-top: calc(min(84vw, calc(70vh * .7054), 420px) * 1.41758);
  transition: transform 1.2s var(--ease-silk), opacity 1s var(--ease-soft);
  will-change: transform;
}
@supports (height: 100dvh) {
  .envelope {
    width: min(84vw, calc(70dvh * .7054), 420px);
    padding-top: calc(min(84vw, calc(70dvh * .7054), 420px) * 1.41758);
  }
}

.envelope > * { position: absolute; }

.envelope__inside {
  top: 0; right: 0; bottom: 0; left: 0;
  border-radius: 2px;
  background:
    radial-gradient(120% 60% at 50% 0%, rgba(255,255,255,.35), rgba(255,255,255,0) 60%),
    linear-gradient(180deg, #ddd2bf 0%, #e6dccb 45%, #e9e0d0 100%);
  box-shadow:
    inset 0 10px 24px rgba(90, 70, 45, .18),
    0 22px 40px -8px rgba(80, 60, 40, .22),
    0 3px 8px rgba(80, 60, 40, .10);
  z-index: 1;
}

.envelope__card {
  left: 7%;
  width: 86%;
  top: 33%;
  height: 63%;
  z-index: 2;
  background: var(--paper);
  border-radius: 2px;
  box-shadow: 0 1px 2px rgba(60, 45, 30, .12), 0 8px 24px rgba(60, 45, 30, .10);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  transform: translate3d(0, 0, 0);
  transition: transform 1.3s var(--ease-silk);
}
.envelope__card picture { width: 36%; margin-top: 13%; transition: opacity .8s var(--ease-soft), transform 1.2s var(--ease-silk); }
.envelope__card img { width: 100%; height: auto; }

.envelope__closed { top: 0; right: 0; bottom: 0; left: 0; z-index: 7; pointer-events: none; }
.envelope__closed img { width: 100%; height: 100%; }
.intro.is-opening .envelope__closed { display: none; }
.envelope__pocket { top: 0; right: 0; bottom: 0; left: 0; z-index: 3; }
.envelope__pocket img { width: 100%; height: 100%; }

.envelope__flap {
  left: 0; top: 0;
  width: 100%;
  height: 51.047%;
  z-index: 4;
  transform-origin: 50% 0;
  -webkit-transform-style: preserve-3d;
  transform-style: preserve-3d;
  transform: perspective(1400px) rotateX(0deg);
  transition: transform 1.15s var(--ease-silk);
}
.flap__front, .flap__back {
  position: absolute;
  top: 0; right: 0; bottom: 0; left: 0;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}
.flap__front img { width: 100%; height: 100%; }
.flap__back {
  transform: rotateY(180deg);
  background: linear-gradient(0deg, #f3eee6 0%, #ebe4d8 70%, #e2d9ca 100%);
  -webkit-mask: url("../assets/img/env-flap.webp") center / 100% 100% no-repeat;
  mask: url("../assets/img/env-flap.webp") center / 100% 100% no-repeat;
}

.envelope__seal {
  left: 42.115%;
  top: 42.733%;
  width: 15.412%;
  height: 11.047%;
  z-index: 8;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  border-radius: 50%;
  -webkit-appearance: none;
  appearance: none;
  transition: transform .7s var(--ease-soft), opacity .6s var(--ease-soft), filter .6s;
}
.envelope__seal::after {           /* área táctil generosa */
  content: "";
  position: absolute;
  top: -45%; right: -45%; bottom: -45%; left: -45%;
  border-radius: 50%;
}
.envelope__seal img { position: relative; width: 100%; height: 100%; filter: drop-shadow(0 3px 4px rgba(70, 45, 10, .35)); }
.envelope__seal:focus { outline: none; }
.envelope__seal:focus-visible { outline: 1px solid var(--gold); outline-offset: 6px; }

.seal__glow {
  position: absolute;
  top: -38%; right: -38%; bottom: -38%; left: -38%;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(255, 226, 160, .55), rgba(255, 226, 160, 0));
  animation: sealGlow 2.8s ease-in-out infinite;
  pointer-events: none;
}
@keyframes sealGlow {
  0%, 100% { opacity: .25; transform: scale(.85); }
  50%      { opacity: .9;  transform: scale(1.05); }
}
.envelope__seal picture { animation: sealBreath 2.8s ease-in-out infinite; }
@keyframes sealBreath {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.035); }
}

.intro__hint {
  margin: 0;
  font-size: 13px;
  letter-spacing: .32em;
  text-transform: uppercase;
  color: rgba(60, 47, 47, .72);
  font-weight: 500;
  animation: hintPulse 2.8s ease-in-out infinite;
  transition: opacity .5s;
}
@keyframes hintPulse { 0%, 100% { opacity: .45; } 50% { opacity: 1; } }

/* --- secuencia de apertura --- */
.intro.is-opening .intro__hint { opacity: 0 !important; animation: none; }
.intro.is-opening .seal__glow,
.intro.is-opening .envelope__seal picture { animation: none; }
.intro.is-opening .envelope__seal {
  transform: translateY(8%) scale(.6) rotate(-14deg);
  opacity: 0;
  filter: blur(1px);
  pointer-events: none;
}
.intro.flap-open .envelope__flap { transform: perspective(1400px) rotateX(180deg); }
.intro.flap-behind .envelope__flap { z-index: 1; }
.intro.flap-behind .envelope__inside { z-index: 0; }
.intro.card-up .envelope { transform: translate3d(0, 26%, 0); }
.intro.card-up .envelope__card { transform: translate3d(0, -106%, 0); }
.intro.env-away .envelope { transform: translate3d(0, 75vh, 0); opacity: 0; transition-duration: 1.1s, .9s; transition-timing-function: cubic-bezier(.55, 0, .75, .3), ease; }

/* tarjeta que se expande hasta ocupar la pantalla */
.card-fly {
  position: fixed;
  z-index: 60;
  background: var(--paper);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 2px;
  box-shadow: 0 8px 30px rgba(60, 45, 30, .12);
  transition:
    top 1.15s var(--ease-silk), left 1.15s var(--ease-silk),
    width 1.15s var(--ease-silk), height 1.15s var(--ease-silk),
    box-shadow 1.15s var(--ease-silk), border-radius 1.15s, opacity .9s var(--ease-soft);
  pointer-events: none;
}
.card-fly picture { position: absolute; transition: transform 1.15s var(--ease-silk), opacity .9s var(--ease-soft); }
.card-fly img { width: 100%; height: auto; }
.card-fly.is-full { box-shadow: 0 0 0 rgba(0,0,0,0); border-radius: 0; }
.card-fly.is-fading { opacity: 0; }

/* ==========================================================================
   PÁGINAS
   ========================================================================== */
.book {
  position: relative;
  width: var(--col);
  margin: 0 auto;
  background: var(--paper);
  visibility: hidden;
}
.book.is-ready { visibility: visible; }

.page {
  position: relative;
  width: 100%;
  height: 0;
  padding-top: 140.955%;        /* 5462 / 3875 — proporción exacta del diseño */
  overflow: hidden;
  background: var(--paper);
}

.piece {
  position: absolute;
  overflow: hidden;
  opacity: 0;
  transform: translate3d(0, calc(var(--u) * 90), 0);
  transition:
    opacity 1.2s var(--ease-soft) var(--d, 0ms),
    transform 1.5s var(--ease-soft) var(--d, 0ms);
}
.piece > picture { position: absolute; top: 0; right: 0; bottom: 0; left: 0; }
.piece > img, .piece > picture > img {
  position: absolute;
  height: auto;
}
.piece.a-fade  { transform: none; }
.piece.a-left  { transform: translate3d(calc(var(--u) * -160), 0, 0); }
.piece.a-photo { transform: translate3d(0, calc(var(--u) * 60), 0); }
.piece.a-photo .ph { transform: scale(1.07); transition: transform 2.4s var(--ease-soft) var(--d, 0ms); }
.piece.a-wipe  { opacity: 1; transform: none; }
/* el recorte se aplica al hijo: IntersectionObserver ignora elementos totalmente recortados */
.piece.a-wipe > picture {
  -webkit-clip-path: inset(0 0 100% 0);
  clip-path: inset(0 0 100% 0);
  transition: -webkit-clip-path 2s var(--ease-silk) var(--d, 0ms), clip-path 2s var(--ease-silk) var(--d, 0ms);
}

.piece.in { opacity: 1; transform: none; }
.piece.in .ph { transform: none; }
.piece.a-wipe.in > picture { -webkit-clip-path: inset(0 0 0 0); clip-path: inset(0 0 0 0); }

/* ---------- cuenta regresiva ---------- */
.countdown { position: absolute; top: 0; right: 0; bottom: 0; left: 0; pointer-events: none; }
.cd-num, .cd-sep, .cd-lbl {
  position: absolute;
  font-family: Arimo, Arial, "Helvetica Neue", Helvetica, sans-serif;
  font-weight: 400;
  color: var(--mauve);
  line-height: 1;
  white-space: nowrap;
  transform: translateX(-50%);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}
.cd-num, .cd-sep { font-size: calc(var(--u) * 300); }
.cd-lbl { font-size: calc(var(--u) * 78); color: #694f50; }
.cd-sprig { position: absolute; height: auto; pointer-events: none; }

/* ---------- zonas interactivas sobre el diseño ---------- */
.hot {
  position: absolute;
  z-index: 5;
  display: block;
  border-radius: calc(var(--u) * 120);
  border: 1px solid rgba(102, 76, 76, .32);
  background: rgba(255, 255, 255, 0);
  color: inherit;
  text-decoration: none;
  cursor: pointer;
  padding: 0;
  -webkit-appearance: none;
  appearance: none;
  opacity: 0;
  transition: opacity 1s var(--ease-soft) .6s, background-color .25s, border-color .25s, transform .25s var(--ease-soft);
  overflow: visible;
}
.hot.in { opacity: 1; }
.hot::before {                      /* área táctil mínima 44px */
  content: "";
  position: absolute;
  top: -10px; right: -6px; bottom: -10px; left: -6px;
}
.hot::after {                       /* destello sutil que invita a tocar */
  content: "";
  position: absolute;
  top: 0; right: 0; bottom: 0; left: 0;
  border-radius: inherit;
  background: linear-gradient(100deg, rgba(255,255,255,0) 30%, rgba(184,149,90,.16) 50%, rgba(255,255,255,0) 70%);
  background-size: 250% 100%;
  background-position: 120% 0;
  animation: shine 5.5s ease-in-out infinite 2s;
  pointer-events: none;
}
@keyframes shine {
  0%, 62%   { background-position: 120% 0; }
  100%      { background-position: -120% 0; }
}
.hot:active { background: rgba(184, 149, 90, .08); transform: scale(.985); }
.hot:focus { outline: none; }
.hot:focus-visible { outline: 1px solid var(--gold); outline-offset: 3px; }

.hot__badge {
  position: absolute;
  top: 50%;
  left: 0;
  width: calc(var(--u) * 190);
  height: calc(var(--u) * 190);
  min-width: 20px; min-height: 20px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: var(--mauve);
  color: #fbf8f5;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(60, 40, 40, .25);
}
.hot__badge svg { width: 56%; height: 56%; }

/* ==========================================================================
   MÚSICA
   ========================================================================== */
.music {
  position: fixed;
  z-index: 40;
  right: max(16px, calc((100vw - var(--col)) / 2 + 16px));
  bottom: calc(18px + env(safe-area-inset-bottom, 0px));
  width: 44px; height: 44px;
  border-radius: 50%;
  border: 1px solid rgba(102, 76, 76, .28);
  background: rgba(249, 245, 242, .82);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  box-shadow: 0 4px 14px rgba(60, 45, 30, .12);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity .8s var(--ease-soft), transform .8s var(--ease-soft);
  -webkit-appearance: none;
  appearance: none;
  padding: 0;
}
.music[hidden] { display: none; }
.music.is-visible { opacity: 1; transform: none; }
.music:focus { outline: none; }
.music:focus-visible { outline: 1px solid var(--gold); outline-offset: 3px; }
.music__bars { display: flex; align-items: flex-end; gap: 3px; height: 16px; }
.music__bars i {
  display: block;
  width: 2px;
  height: 100%;
  background: var(--mauve);
  border-radius: 1px;
  transform-origin: bottom;
  transform: scaleY(.3);
}
.music.is-playing .music__bars i { animation: eq 1.1s ease-in-out infinite; }
.music.is-playing .music__bars i:nth-child(2) { animation-delay: -.35s; animation-duration: .95s; }
.music.is-playing .music__bars i:nth-child(3) { animation-delay: -.7s;  animation-duration: 1.25s; }
.music.is-playing .music__bars i:nth-child(4) { animation-delay: -.2s;  animation-duration: 1.05s; }
@keyframes eq { 0%, 100% { transform: scaleY(.25); } 50% { transform: scaleY(1); } }

/* ==========================================================================
   AVISO (toast)
   ========================================================================== */
.toast {
  position: fixed;
  z-index: 70;
  left: 50%;
  bottom: calc(80px + env(safe-area-inset-bottom, 0px));
  transform: translate(-50%, 10px);
  padding: 10px 20px;
  border-radius: 999px;
  background: rgba(60, 47, 47, .92);
  color: #fbf8f5;
  font-size: 16px;
  letter-spacing: .06em;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity .45s var(--ease-soft), transform .45s var(--ease-soft);
  box-shadow: 0 8px 24px rgba(40, 30, 30, .22);
}
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }

/* ==========================================================================
   PANTALLAS GRANDES
   ========================================================================== */
@media (min-width: 560px) {
  html, body { background: var(--paper-deep); }
  body {
    background:
      radial-gradient(90% 60% at 50% 0%, #f6f1ec 0%, rgba(246,241,236,0) 70%),
      var(--paper-deep);
    background-attachment: fixed;
  }
  .book {
    margin: 40px auto 64px;
    box-shadow: 0 30px 80px rgba(70, 50, 30, .14), 0 2px 8px rgba(70, 50, 30, .06);
  }
}

.noscript-page { width: 100%; height: auto; }

/* ==========================================================================
   MOVIMIENTO REDUCIDO
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  .seal__glow, .envelope__seal picture, .intro__hint, .hot::after { animation: none; }
  .piece, .piece .ph { transition-duration: .6s !important; transform: none !important; }
  .piece.a-wipe > picture { -webkit-clip-path: none; clip-path: none; }
  .piece.a-wipe { opacity: 0; }
  .piece.a-wipe.in { opacity: 1; }
}
.card-fly__mono img { width: 100%; height: auto; }
