/* Movimiento editorial: la página permanece completa y legible sin estas animaciones. */
@keyframes premium-rise {
  from { opacity: .18; transform: translateY(26px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes premium-postcard {
  from { opacity: .18; transform: translate3d(var(--postcard-entry-x, 76px), 12px, 0) rotate(-4deg) scale(.95); }
  72% { opacity: 1; transform: translate3d(-5px, -2px, 0) rotate(.6deg) scale(1.008); }
  to { opacity: 1; transform: translate3d(0, 0, 0) rotate(0) scale(1); }
}

@keyframes premium-seal {
  from { opacity: .2; transform: rotate(12deg) scale(1.22); }
  55% { opacity: 1; transform: rotate(12deg) scale(.94); }
  to { opacity: 1; transform: rotate(12deg) scale(1); }
}

@keyframes premium-modal {
  from { opacity: .65; transform: translateY(8px) scale(.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.perspective-frame {
  transition: opacity 160ms ease;
}
.perspective-frame.is-switching {
  opacity: .18;
}

/* Mantiene el diálogo en la capa superior durante la salida donde el navegador lo soporta. */
#productModal,
#cartDrawer {
  opacity: 0;
  transition: opacity 220ms ease, display 220ms ease, overlay 220ms ease;
  transition-behavior: allow-discrete;
}
#productModal[open],
#cartDrawer[open] {
  opacity: 1;
}
@starting-style {
  #productModal[open],
  #cartDrawer[open] { opacity: 0; }
}
#productModal::backdrop,
#cartDrawer::backdrop {
  background: rgb(78 18 25 / 0);
  backdrop-filter: blur(0);
  transition: background-color 220ms ease, backdrop-filter 220ms ease, display 220ms ease, overlay 220ms ease;
  transition-behavior: allow-discrete;
}
#productModal[open]::backdrop,
#cartDrawer[open]::backdrop {
  background: rgb(78 18 25 / .64);
  backdrop-filter: blur(6px);
}
@starting-style {
  #productModal[open]::backdrop,
  #cartDrawer[open]::backdrop {
    background: rgb(78 18 25 / 0);
    backdrop-filter: blur(0);
  }
}

@media (prefers-reduced-motion: no-preference) {
  .premium-hero-copy > :nth-child(1) { animation: premium-rise 550ms cubic-bezier(.22, 1, .36, 1) 70ms both; }
  .premium-hero-copy > :nth-child(2) { animation: premium-rise 720ms cubic-bezier(.22, 1, .36, 1) 140ms both; }
  .premium-hero-copy > :nth-child(3) { animation: premium-rise 580ms cubic-bezier(.22, 1, .36, 1) 340ms both; }
  .premium-hero-copy > :nth-child(4) { animation: premium-rise 580ms cubic-bezier(.22, 1, .36, 1) 400ms both; }
  .premium-hero-copy > :nth-child(5) { animation: premium-rise 580ms cubic-bezier(.22, 1, .36, 1) 520ms both; }
  .premium-hero-copy > :nth-child(6) { animation: premium-rise 580ms cubic-bezier(.22, 1, .36, 1) 610ms both; }
  .premium-hero-postcard .postage-stamp { animation: premium-postcard 930ms cubic-bezier(.22, 1, .36, 1) 170ms both; }
  .premium-hero-postcard > .wax-seal { animation: premium-seal 430ms cubic-bezier(.22, 1, .36, 1) 860ms both; }
  #productModal[open] > div { animation: premium-modal 280ms cubic-bezier(.22, 1, .36, 1) both; }
  #personalizador .wax-seal { transition: transform 260ms ease, filter 260ms ease; }
  #personalizador:focus-within .wax-seal { transform: rotate(4deg) scale(1.045); filter: brightness(1.06); }
}

@media (hover: hover) and (prefers-reduced-motion: no-preference) {
  .premium-motion-ready #catalogGrid .premium-card.is-visible:hover {
    transform: translateY(-4px);
    filter: drop-shadow(0 16px 28px rgb(107 29 38 / .14));
  }
}

/* Aparición temporal al entrar en pantalla, una sola vez por tarjeta. */
@media (prefers-reduced-motion: no-preference) {
  .premium-motion-ready #catalogGrid .premium-card {
    opacity: 0;
    transform: translateY(28px);
    transition: opacity 650ms cubic-bezier(.22, 1, .36, 1), transform 650ms cubic-bezier(.22, 1, .36, 1);
    transition-delay: var(--reveal-delay, 0ms);
  }
  .premium-motion-ready #catalogGrid .premium-card.is-visible {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: no-preference) {
  @supports ((animation-timeline: view()) and (animation-range: entry)) {
    .premium-scroll-reveal {
      animation: premium-rise linear both;
      animation-timeline: view();
      animation-range: entry 0% entry 70%;
    }
  }
}

@media (max-width: 767px) and (prefers-reduced-motion: no-preference) {
  .premium-hero-postcard { --postcard-entry-x: 42px; }
  .premium-motion-ready .premium-hero-postcard:not(.is-in-view) .postage-stamp,
  .premium-motion-ready .premium-hero-postcard:not(.is-in-view) > .wax-seal {
    animation-play-state: paused;
  }
}

@media (prefers-reduced-motion: reduce) {
  .perspective-frame { transition-duration: 80ms; }
  #productModal,
  #cartDrawer,
  #productModal::backdrop,
  #cartDrawer::backdrop { transition-duration: 100ms; }
}
