/* =========================================================
   KAÏ Parfum — animaciones
   Todo lo que se mueve está aquí. Para ajustar:
   - velocidad general  → --anim-dur
   - curva de movimiento → --anim-ease
   - distancia de entrada → --anim-dist
   Varias animaciones usan variables que escribe js/animaciones.js
   (--sy: scroll, --rx/--ry: inclinación de las tarjetas).
   Si el usuario activó "reducir movimiento" en su sistema,
   todo se desactiva al final de este archivo.

   Referencias: intro, cortina de fotos, parallax y títulos de
   Casa Güell; palabras con máscara, barra de progreso y contadores
   de Kórpo; stickers girados (Slush).
   ========================================================= */
:root {
  --anim-dur: .7s;
  --anim-ease: cubic-bezier(.22, 1, .36, 1);
  --anim-dist: 24px;
  --anim-bounce: cubic-bezier(.34, 1.56, .64, 1);
}

/* Lo que entra desde los lados no debe crear scroll horizontal (clip no rompe position: sticky) */
main { overflow-x: clip; }

/* ---------- 0. Intro con el logo (la crea js/animaciones.js) ---------- */
/* Una vez por visita. Mientras está, el hero espera en pausa. */
.intro-on .hero-copy > *,
.intro-on .hero h1 .w > span,
.intro-on .stage .bottles img,
.intro-on .stage .st { animation-play-state: paused; }
.intro-on body { overflow: hidden; }

.intro {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  background: #13204b;
  overflow: hidden;
  cursor: pointer;
  transition: opacity .7s ease, visibility .7s;
}
.intro.fuera { opacity: 0; visibility: hidden; }
.intro .i-blob {
  position: absolute;
  width: 380px;
  aspect-ratio: 1;
  left: 50%;
  top: 50%;
  margin: -240px 0 0 -220px;
  border-radius: 42% 58% 63% 37% / 45% 41% 59% 55%;
  background: rgba(92, 74, 222, .35);
  filter: blur(70px);
  opacity: 0;
  animation: fundido 1.4s ease .1s forwards, forma 9s ease-in-out infinite alternate;
}
.intro .i-blob + .i-blob { width: 300px; margin: -80px 0 0 -40px; background: rgba(40, 70, 170, .45); animation-duration: 1.4s, 11s; animation-delay: .35s, -4s; }
/* El logo aparece desenfocado y se enfoca; luego un destello lo recorre siguiendo su forma */
.intro .i-logo { position: relative; width: min(56vw, 240px); transition: transform .7s var(--anim-ease); }
.intro .i-logo img { width: 100%; height: auto; animation: logo-in 1.3s cubic-bezier(.34, 1.3, .5, 1) .25s both; }
.intro .i-brillo {
  position: absolute;
  inset: 0;
  -webkit-mask: url("../img/logo-kai.png") center / contain no-repeat;
  mask: url("../img/logo-kai.png") center / contain no-repeat;
  background: linear-gradient(105deg, transparent 38%, rgba(255, 255, 255, .85) 50%, transparent 62%) no-repeat;
  background-size: 250% 100%;
  background-position: 150% 0;
  animation: brillo-logo 1.1s ease-in-out 1.45s forwards;
}
.intro.fuera .i-logo { transform: translateY(-24px) scale(.92); }
.intro .i-skip { position: absolute; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); font-size: 11px; letter-spacing: .2em; text-transform: uppercase; color: rgba(255, 255, 255, .45); opacity: 0; animation: fundido .6s ease 1s forwards; }

/* ---------- 1. Entrada del hero ---------- */
.hero-copy > * {
  animation: subir var(--anim-dur) var(--anim-ease) both;
}
.hero-copy > :nth-child(1) { animation-delay: .05s; }
.hero-copy > :nth-child(2) { animation-delay: .15s; }
.hero-copy > :nth-child(3) { animation-delay: .28s; }
.hero-copy > :nth-child(4) { animation-delay: .4s; }
.hero-copy > :nth-child(5) { animation-delay: .52s; }

/* Título del hero: cada palabra sube desde detrás de una máscara */
.hero h1.split { animation: none; }
.split .w { display: inline-block; overflow: hidden; vertical-align: top; padding: 0 .08em .1em; margin: 0 -.08em -.1em; }
.split .w > span { display: inline-block; }
.hero h1.split .w > span { animation: palabra 1s var(--anim-ease) both; animation-delay: calc(.15s + var(--i) * .07s); }

/* Al bajar, el texto del hero sube más lento y se desvanece (parallax) */
.hero-copy { translate: 0 calc(var(--sy, 0) * 110px); opacity: calc(1 - var(--sy, 0) * 1.3); }

/* ---------- 2. Botellas del hero: collage de stickers ---------- */
/* Idea tomada de los DESIGN.md: cada foto es un sticker con borde blanco
   que se "pega" de un golpe, un poco girado (Slush), sobre manchas de color
   desplazadas detrás (Calendly). Después se mecen apenas, por turnos. */
.stage .bottles img {
  border: 4px solid #fff;
  outline: 1.5px solid rgba(255, 255, 255, .25);
  outline-offset: 3px;
  rotate: var(--rot, 0deg);
  transform-origin: 50% 0;
  animation:
    pegar .75s cubic-bezier(.3, 1.5, .5, 1) both,
    mecer 7s ease-in-out infinite;
}
.stage .bottles img:nth-child(1) { --rot: -6deg; animation-delay: .30s, 1.5s; }
.stage .bottles img:nth-child(2) { --rot: 4deg;  animation-delay: .45s, 2.6s; }
.stage .bottles img:nth-child(3) { --rot: -3deg; animation-delay: .60s, 3.7s; }
.stage .bottles img:nth-child(4) { --rot: 5deg;  animation-delay: .75s, 4.8s; }
.stage .bottles img:nth-child(5) { --rot: -4deg; animation-delay: .90s, 5.9s; }
.stage .bottles img:nth-child(6) { --rot: 7deg;  animation-delay: 1.05s, 7s; }

/* Manchas magenta y cian desplazadas detrás del collage */
.stage .mancha {
  position: absolute;
  width: 42%;
  aspect-ratio: 1;
  border-radius: 42% 58% 63% 37% / 45% 41% 59% 55%;
  filter: blur(6px);
  opacity: .9;
  animation: fundido 1s ease .2s both, forma 12s ease-in-out infinite alternate;
}
.stage .m1 { background: #e55cff; top: 0; left: 2%; }
.stage .m2 { background: #0099ff; bottom: -4%; right: 0; width: 36%; animation-delay: .35s, -6s; }

/* Stickers decorativos: estrella que gira y sello de envío */
.stage .st {
  position: absolute;
  z-index: 2;
  display: grid;
  place-items: center;
  border: 2px solid #13204b;
  animation: pegar .6s cubic-bezier(.3, 1.5, .5, 1) 1.3s both;
}
.stage .st-estrella { top: -4%; right: 8%; width: 54px; height: 54px; border-radius: 50%; background: #ffd731; color: #13204b; font-size: 26px; --rot: 0deg; }
.stage .st-estrella { animation: pegar .6s cubic-bezier(.3, 1.5, .5, 1) 1.3s both, girar 9s linear 2s infinite; }
.stage .st-envio {
  bottom: -2%;
  left: 4%;
  width: 86px;
  height: 86px;
  border-radius: 50%;
  background: #ff6a0d;
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.15;
  text-align: center;
  text-transform: uppercase;
  --rot: -12deg;
  rotate: var(--rot);
  animation-delay: 1.45s;
}

/* Brillo naranja que "respira" detrás de las botellas */
.stage .glow { animation: respirar 6s ease-in-out infinite; }

/* Contadores del hero */
.facts b { transition: color .3s; }

/* ---------- 3. Aparición al hacer scroll ---------- */
/* js/animaciones.js agrega .reveal y luego .visible al entrar en pantalla */
.reveal {
  opacity: 0;
  translate: 0 var(--anim-dist);
  transition:
    opacity var(--anim-dur) var(--anim-ease),
    translate var(--anim-dur) var(--anim-ease),
    rotate var(--anim-dur) var(--anim-ease);
  transition-delay: calc(var(--i, 0) * 70ms);
}
.reveal.visible { opacity: 1; translate: 0 0; rotate: 0deg; }

/* Guía rápida: entran de los lados, giradas como stickers, y se acomodan */
.tip.reveal:nth-child(odd)  { translate: -40px 20px; rotate: -4deg; }
.tip.reveal:nth-child(even) { translate: 40px 20px; rotate: 4deg; }
.tip.reveal.visible { translate: 0 0; rotate: 0deg; }

/* Títulos de sección: el eyebrow se cierra y el título sube palabra por palabra */
.sh .eyebrow { transition: letter-spacing 1.2s var(--anim-ease), opacity 1s ease; }
.sh.reveal { translate: none; opacity: 1; }
.sh.reveal:not(.visible) .eyebrow { letter-spacing: .5em; opacity: 0; }
.sh h2.split .w > span { translate: 0 105%; transition: translate .9s var(--anim-ease); transition-delay: calc(.1s + var(--i) * 60ms); }
.sh.visible h2.split .w > span { translate: 0 0; }
/* línea naranja que se dibuja bajo el título */
.sh h2 { position: relative; padding-bottom: 10px; }
.sh h2::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  height: 3px;
  width: 56px;
  border-radius: 3px;
  background: var(--orange);
  transform-origin: 0 50%;
  transition: transform 1s var(--anim-ease) .45s;
}
.sh.reveal:not(.visible) h2::after { transform: scaleX(0); }

/* Familias: el ícono aparece como un sticker que rebota */
.fam .ic { display: inline-block; transition: transform .5s var(--anim-bounce); }
.fam.reveal .ic { transform: scale(0) rotate(-30deg); transition-delay: calc(var(--i, 0) * 70ms + .25s); }
.fam.reveal.visible .ic { transform: none; }

/* ---------- 4. Tarjetas de producto ---------- */
/* Cortina: la foto se descubre de abajo hacia arriba y el frasco se acerca */
.card.reveal .ph { clip-path: inset(100% 0 0 0); transition: clip-path 1.1s cubic-bezier(.65, 0, .25, 1); transition-delay: calc(var(--i, 0) * 70ms + .1s); }
.card.reveal.visible .ph { clip-path: inset(0); }
.card.reveal:not(.visible) .ph img { scale: 1.3; }

/* Sticker de la familia en la esquina de la foto */
.card .ph::before {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #fff;
  border: 1.5px solid #13204b;
  font-size: 17px;
  rotate: 10deg;
  transition: scale .45s var(--anim-bounce) .55s, rotate .45s var(--anim-bounce);
}
.card[data-fam="dulce"] .ph::before    { content: "🍮"; }
.card[data-fam="fresco"] .ph::before   { content: "🌊"; }
.card[data-fam="frutal"] .ph::before   { content: "🍓"; }
.card[data-fam="tropical"] .ph::before { content: "🥥"; }
.card[data-fam="intenso"] .ph::before  { content: "🌙"; }
.card.reveal:not(.visible) .ph::before { scale: 0; }

/* Destello que cruza la foto al pasar el mouse */
.card .ph::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  background: linear-gradient(105deg, transparent 38%, rgba(255, 255, 255, .65) 50%, transparent 62%);
  translate: -120% 0;
  pointer-events: none;
}

.card, .fam, .tip {
  transition: transform .45s var(--anim-ease), box-shadow .45s var(--anim-ease), border-color .2s;
}
.card .ph img { transition: scale .9s var(--anim-ease), translate .45s var(--anim-ease); }
@media (hover: hover) {
  /* Inclinación 3D hacia el mouse (--rx/--ry los pone js/animaciones.js) */
  .card:hover {
    transform: perspective(900px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)) translateY(-6px);
    box-shadow: 0 24px 44px rgba(19, 32, 75, .14);
  }
  .card:hover .ph img { scale: 1.08; translate: calc(var(--tx, 0) * 10px) calc(var(--ty, 0) * 10px); }
  .card:hover .ph::after { translate: 120% 0; transition: translate .9s ease-in-out; }
  .card:hover .ph::before { rotate: -12deg; }
  .fam:hover { transform: translateY(-4px); }
  .fam:hover .ic { transform: scale(1.25) rotate(-10deg); }
  .tip:hover { transform: translateY(-4px) rotate(-1deg); }
}
.add, .btn, .wabtn, .bagbtn, .dd-btn { transition: transform .2s var(--anim-ease), translate .35s var(--anim-ease), filter .2s, background-color .2s, color .2s; }
.add:active, .btn:active, .dd-btn:active { transform: scale(.97); }
@media (hover: hover) {
  .btn:hover, .wabtn:hover { transform: translateY(-2px); }
}

/* ---------- 5. Agregar al pedido ---------- */
/* Botón de la bolsa "salta" */
.bagbtn.bump { animation: saltar .55s var(--anim-ease); }
.bagbtn.bump .n { animation: girar-num .55s var(--anim-ease); }
/* Botón "Agregar" confirma */
.add.pop { animation: confirmar .4s var(--anim-ease); }
/* Foto que vuela hacia la bolsa (la crea js/animaciones.js) */
.vuelo {
  position: fixed;
  z-index: 80; /* encima de la ficha */
  pointer-events: none;
  border-radius: 12px;
  background: #fff;
  object-fit: contain;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .25);
}

/* ---------- 5b. Ficha del perfume ---------- */
/* La caja sale desde la tarjeta tocada y se acerca hacia la pantalla (eso lo hace
   js/animaciones.js). Aquí: el fondo se oscurece y los datos entran uno tras otro. */
.ficha:not([hidden]) .ficha-fondo { animation: fundido .45s ease both; }
.ficha.sale .ficha-fondo { animation: fundido .4s ease reverse both; }
.ficha:not([hidden]) .ficha-foto img { animation: acercar .9s var(--anim-ease) .1s both; }
.ficha:not([hidden]) .ficha-info > * { animation: subir .6s var(--anim-ease) both; }
.ficha:not([hidden]) .ficha-info > :nth-child(1) { animation-delay: .18s; }
.ficha:not([hidden]) .ficha-info > :nth-child(2) { animation-delay: .24s; }
.ficha:not([hidden]) .ficha-info > :nth-child(3) { animation-delay: .32s; }
.ficha:not([hidden]) .ficha-info > :nth-child(5) { animation-delay: .46s; }
.ficha:not([hidden]) .ficha-info > :nth-child(6) { animation-delay: .54s; }
/* Las 3 palabras del aroma se pegan como stickers, una por una */
.ficha:not([hidden]) .ficha-info > .aroma { animation: none; }
.ficha:not([hidden]) .aroma li { animation: pegar .55s cubic-bezier(.3, 1.5, .5, 1) both; animation-delay: calc(.36s + var(--i, 0) * 90ms); }
.ficha .x { transition: rotate .35s var(--anim-bounce), background-color .2s; }
@media (hover: hover) { .ficha .x:hover { rotate: 90deg; } }

/* ---------- 6. Panel del pedido y aviso ---------- */
.scrim:not([hidden]) { animation: fundido .3s ease both; }
.drawer:not([hidden]) { animation: deslizar .45s var(--anim-ease) both; }
.drawer:not([hidden]) .it { animation: subir .4s var(--anim-ease) both; }
.toast.show { animation: aviso .4s var(--anim-ease) both; }

/* ---------- 7. Barra superior ---------- */
.top { transition: box-shadow .3s; }
.top.scrolled { box-shadow: 0 10px 30px rgba(5, 9, 25, .25); }

/* ---------- 8. Pie de página: el logo se descubre ---------- */
footer.anim .brand-logo { clip-path: inset(100% 0 0 0); scale: .9; transition: clip-path 1.2s cubic-bezier(.65, 0, .25, 1), scale 1.2s var(--anim-ease); }
footer.anim.visible .brand-logo { clip-path: inset(0); scale: 1; }

/* ---------- 9. Menús desplegables (Marca y Ordenar) ---------- */
.dd-chev { transition: rotate .35s var(--anim-bounce); }
.dd.op .dd-chev { rotate: 180deg; }
.dd.op .dd-menu { animation: menu-abre .32s var(--anim-ease) both; transform-origin: top right; }
#ddMarca.op .dd-menu { transform-origin: top left; }
.dd.op .dd-menu [role="option"] { animation: subir .35s var(--anim-ease) both; animation-delay: calc(min(var(--i, 0), 10) * 25ms); }
.dd-menu [role="option"] { transition: background-color .2s, padding-left .25s var(--anim-ease), color .2s; }
.dd-menu [role="option"]:hover { padding-left: 18px; }
.dd-menu [role="option"]::after { transition: opacity .2s; }
.dd-menu [role="option"][aria-selected="true"]::after { animation: confirmar .45s var(--anim-bounce); }
.dd-v { display: inline-block; }
.dd.on .dd-btn { animation: confirmar .4s var(--anim-bounce); }

/* ---------- Keyframes ---------- */
@keyframes subir    { from { opacity: 0; translate: 0 var(--anim-dist); } to { opacity: 1; translate: 0 0; } }
@keyframes palabra  { from { translate: 0 105%; } to { translate: 0 0; } }
@keyframes respirar { 0%, 100% { opacity: .75; scale: 1; } 50% { opacity: 1; scale: 1.08; } }
@keyframes forma {
  0%   { border-radius: 42% 58% 63% 37% / 45% 41% 59% 55%; transform: translate(0, 0) rotate(0) scale(1); }
  100% { border-radius: 62% 38% 35% 65% / 55% 62% 38% 45%; transform: translate(34px, -24px) rotate(45deg) scale(1.12); }
}
@keyframes saltar   { 0% { scale: 1; } 30% { scale: 1.18; } 60% { scale: .94; } 100% { scale: 1; } }
@keyframes girar-num { 0% { rotate: 0deg; } 40% { rotate: -14deg; } 100% { rotate: 0deg; } }
@keyframes confirmar { 0% { scale: 1; } 40% { scale: 1.12; } 100% { scale: 1; } }
@keyframes fundido  { from { opacity: 0; } to { opacity: 1; } }
@keyframes deslizar { from { translate: 100% 0; } to { translate: 0 0; } }
@keyframes aviso    { from { opacity: 0; translate: -50% 16px; } to { opacity: 1; translate: -50% 0; } }
@keyframes pegar    { 0% { opacity: 0; scale: 1.6; rotate: calc(var(--rot, 0deg) - 18deg); } 60% { opacity: 1; } 100% { opacity: 1; scale: 1; rotate: var(--rot, 0deg); } }
@keyframes mecer    { 0%, 14%, 100% { translate: 0 0; rotate: var(--rot, 0deg); } 5% { translate: 0 -6px; rotate: calc(var(--rot, 0deg) * -0.6); } 10% { translate: 0 0; rotate: calc(var(--rot, 0deg) * 1.15); } }
@keyframes logo-in  { from { opacity: 0; scale: .7; filter: blur(16px); } to { opacity: 1; scale: 1; filter: none; } }
@keyframes brillo-logo { to { background-position: -50% 0; } }
@keyframes menu-abre { from { opacity: 0; transform: translateY(-8px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes girar    { to { rotate: 360deg; } }
@keyframes acercar  { from { opacity: 0; scale: .7; translate: 0 30px; } to { opacity: 1; scale: 1; translate: 0 0; } }

/* ---------- Accesibilidad: reducir movimiento ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    animation-delay: 0s !important;
    transition-duration: .01ms !important;
    transition-delay: 0s !important;
    scroll-behavior: auto !important;
  }
  .reveal, .tip.reveal { opacity: 1; translate: none; rotate: none; }
  .card.reveal .ph { clip-path: none; }
  .hero-copy { translate: none; opacity: 1; }
  .stage .bottles img, .stage .st { rotate: var(--rot, 0deg); }
  footer.anim .brand-logo { clip-path: none; scale: 1; }
  .intro { display: none; }
}
