/* =========================================================
   Farmacia El Ángel · animations.css
   Todas las animaciones del sitio. Solo usan transform y opacity
   (no provocan recálculos de layout) y se apagan con
   prefers-reduced-motion.
   ========================================================= */

/* ---------- Pantalla de carga ---------- */
.splash__halo { animation: halo-pulse 1.4s var(--ease) infinite; }
.splash__mark img { animation: angel-in 700ms var(--ease) both; }
.splash__name { animation: fade-up 600ms var(--ease) 150ms both; }
.splash__bar i { animation: bar-load 1s var(--ease) infinite; }

/* ---------- Entrada del hero (al quitar la pantalla de carga) ---------- */
.js .hero__copy > *, .js .hero__visual, .js .page-hero .container > * { opacity: 0; }
.js.is-ready .hero__copy > * { animation: fade-up 700ms var(--ease) both; }
.js.is-ready .hero__copy > :nth-child(2) { animation-delay: 80ms; }
.js.is-ready .hero__copy > :nth-child(3) { animation-delay: 160ms; }
.js.is-ready .hero__copy > :nth-child(4) { animation-delay: 240ms; }
.js.is-ready .hero__copy > :nth-child(5) { animation-delay: 320ms; }
.js.is-ready .hero__visual { animation: pop-in 900ms var(--ease) 150ms both; }
.js.is-ready .page-hero .container > * { animation: fade-up 600ms var(--ease) both; }
.js.is-ready .page-hero .container > :nth-child(2) { animation-delay: 70ms; }
.js.is-ready .page-hero .container > :nth-child(3) { animation-delay: 140ms; }
.js.is-ready .page-hero .container > :nth-child(4) { animation-delay: 210ms; }
.js.is-ready .page-hero .container > :nth-child(5) { animation-delay: 280ms; }

/* Mascota flotando y aureola que respira */
.hero__arch { animation: float 6s ease-in-out 1.2s infinite; }
.halo { animation: halo-glow 4s ease-in-out infinite; }
.hero__card { animation: card-in 700ms var(--ease) 700ms both; }

/* ---------- Transición entre páginas (Chrome/Edge 126+, Safari 18.2+; el resto navega normal) ----------
   El header y la barra móvil se quedan fijos; solo el contenido hace un fundido suave. */
@view-transition { navigation: auto; }
.site-header { view-transition-name: site-header; }
.mobile-bar { view-transition-name: mobile-bar; }
::view-transition-old(root) { animation: vt-out 180ms var(--ease) both; }
::view-transition-new(root) { animation: vt-in 380ms var(--ease) both; }

/* ---------- Revelado al hacer scroll (escalonado con --i que pone JS) ---------- */
.js .reveal {
  opacity: 0; transform: translate3d(0, 28px, 0) scale(.985);
  transition: opacity 800ms var(--ease-out), transform 900ms var(--ease-out);
  transition-delay: calc(var(--i, 0) * 100ms);
}
.js .reveal.is-visible { opacity: 1; transform: none; }

/* ---------- Menú ---------- */
/* Móvil: los enlaces entran escalonados al abrir */
@media (max-width: 1199px) {
  .nav__list li, .nav__cta { opacity: 0; transform: translateX(-12px); transition: opacity 260ms var(--ease), transform 360ms var(--ease-out); }
  .nav.is-open .nav__list li, .nav.is-open .nav__cta { opacity: 1; transform: none; }
  .nav.is-open .nav__list li:nth-child(2) { transition-delay: 30ms; }
  .nav.is-open .nav__list li:nth-child(3) { transition-delay: 60ms; }
  .nav.is-open .nav__list li:nth-child(4) { transition-delay: 90ms; }
  .nav.is-open .nav__list li:nth-child(5) { transition-delay: 120ms; }
  .nav.is-open .nav__list li:nth-child(6) { transition-delay: 150ms; }
  .nav.is-open .nav__list li:nth-child(7) { transition-delay: 180ms; }
  .nav.is-open .nav__cta { transition-delay: 220ms; }
}
/* Escritorio: el fondo del enlace aparece con transición (antes cambiaba de golpe) */
@media (min-width: 1200px) {
  .nav__list a { transition: background-color var(--t-fast), color var(--t-fast); }
  .nav__list a::before {
    content: ""; position: absolute; left: 50%; bottom: 6px; width: 0; height: 2px; border-radius: 2px;
    background: var(--c-aqua-600); translate: -50% 0; transition: width var(--t-med) var(--ease);
  }
  .nav__list a:hover::before { width: 1.2rem; }
  .nav__list a[aria-current="page"]::before { display: none; }
}

/* Barra móvil y botones: respuesta táctil al presionar */
.mobile-bar a { transition: transform var(--t-fast) var(--ease), background-color var(--t-fast); }
.mobile-bar a:active, .btn:active, .social a:active { transform: scale(.96); }
.bot-launcher:active { transform: scale(.94); }

/* ---------- Microinteracciones ---------- */
.btn--wa { position: relative; overflow: hidden; isolation: isolate; }
.btn--wa::after { /* destello al pasar el mouse */
  content: ""; position: absolute; inset: 0; z-index: -1;
  background: linear-gradient(110deg, transparent 30%, rgb(255 255 255 / .28) 50%, transparent 70%);
  transform: translateX(-120%);
}
.btn--wa:hover::after { transform: translateX(120%); transition: transform 700ms var(--ease); }

/* Bot: llama la atención hasta que se abre por primera vez (.is-seen lo apaga) */
.bot-launcher::after { /* onda que sale del botón */
  content: ""; position: absolute; inset: -3px; border-radius: inherit; border: 3px solid var(--c-aqua-400);
  opacity: 0; pointer-events: none;
}
.is-ready .bot-launcher:not(.is-seen)::after { animation: ring 2.4s var(--ease) 1.5s infinite; }
.is-ready .bot-launcher:not(.is-seen) .bot-launcher__avatar { animation: nudge 6s var(--ease) 2.5s infinite; }
/* fill "backwards": al terminar no se queda fijo el transform (si no, se anula el :hover) */
.bot-launcher.has-msg .bot-launcher__badge { animation: badge-pop 500ms cubic-bezier(.3, 1.6, .5, 1) backwards; }
.is-ready .bot-launcher.is-ping .bot-launcher__avatar { animation: ping-shake 700ms var(--ease) both; }   /* sacudida al "llegar" el mensaje */
.bot-teaser__bubble:not([hidden]), .bot-teaser__chips:not([hidden]) { animation: msg-in 380ms var(--ease-out) backwards; }
.bot-teaser__typing i { animation: typing 900ms ease-in-out infinite; }
.bot-teaser__typing i:nth-child(2) { animation-delay: 150ms; }
.bot-teaser__typing i:nth-child(3) { animation-delay: 300ms; }
.is-ready .bot-launcher { animation: launcher-in 600ms var(--ease-out) 600ms backwards; }
.bot-launcher[aria-expanded="true"] { animation: none; }
.bot-teaser:not([hidden]) { animation: teaser-in 520ms cubic-bezier(.3, 1.35, .5, 1) backwards; }
.bot-teaser.is-leaving { animation: teaser-out 220ms var(--ease) both; }

/* Chat */
.bot:not([hidden]) { animation: bot-in 280ms var(--ease) both; }
.bot__msg { animation: fade-up 300ms var(--ease) both; }
.bot__typing i { animation: typing 900ms ease-in-out infinite; }
.bot__typing i:nth-child(2) { animation-delay: 150ms; }
.bot__typing i:nth-child(3) { animation-delay: 300ms; }

/* ---------- Keyframes ---------- */
@keyframes fade-up { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }
@keyframes pop-in { from { opacity: 0; transform: translateY(24px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes card-in { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }
@keyframes halo-glow { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: .65; transform: scale(1.05); } }
@keyframes halo-pulse { 0% { transform: scale(.85); opacity: 1; } 100% { transform: scale(1.35); opacity: 0; } }
@keyframes angel-in { from { opacity: 0; transform: translateY(10px) scale(.9); } to { opacity: 1; transform: none; } }
@keyframes bar-load { from { transform: translateX(-100%); } to { transform: translateX(250%); } }
@keyframes ring { from { transform: scale(1); opacity: .9; } to { transform: scale(1.5); opacity: 0; } }
@keyframes nudge { /* saludo: se mueve ~0.6 s y descansa el resto del ciclo */
  0%, 12%, 100% { transform: none; }
  2% { transform: rotate(-10deg) scale(1.06); } 4% { transform: rotate(8deg) scale(1.06); }
  6% { transform: rotate(-6deg) scale(1.04); } 8% { transform: rotate(4deg); } 10% { transform: rotate(-2deg); }
}
@keyframes ping-shake {
  0%, 100% { transform: none; } 15% { transform: rotate(-8deg) scale(1.08); } 30% { transform: rotate(7deg) scale(1.08); }
  45% { transform: rotate(-5deg) scale(1.05); } 60% { transform: rotate(3deg); } 75% { transform: rotate(-1deg); }
}
@keyframes msg-in { from { opacity: 0; transform: translateY(8px) scale(.96); transform-origin: 0 100%; } to { opacity: 1; transform: none; } }
@keyframes badge-pop { from { opacity: 0; transform: scale(0); } to { opacity: 1; transform: none; } }
@keyframes launcher-in { from { opacity: 0; transform: translateY(20px) scale(.8); } to { opacity: 1; transform: none; } }
@keyframes teaser-in { from { opacity: 0; transform: translateY(12px) scale(.85); } to { opacity: 1; transform: none; } }
@keyframes teaser-out { to { opacity: 0; transform: translateY(8px) scale(.92); } }
@keyframes bot-in { from { opacity: 0; transform: translateY(12px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes typing { 0%, 100% { transform: translateY(0); opacity: .4; } 50% { transform: translateY(-3px); opacity: 1; } }
@keyframes pulse { from { transform: scale(1); opacity: .6; } to { transform: scale(2.6); opacity: 0; } }
@keyframes vt-out { to { opacity: 0; } }
@keyframes vt-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ---------- Reducir movimiento ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; animation-delay: 0ms !important; transition-duration: .01ms !important; transition-delay: 0ms !important; }
  .js .reveal, .js .hero__copy > *, .js .hero__visual, .js .page-hero .container > *, .nav__list li, .nav__cta { opacity: 1; transform: none; }
  ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; }
}
