/*
|--------------------------------------------------------------------------
| LatamPOS · Animaciones de la página "Elige tu sistema"
|--------------------------------------------------------------------------
| Todo el movimiento de la página está en este archivo:
|   1. Variables (velocidades, curvas y retrasos generales)
|   2. Keyframes reutilizables
|   3. Entrada de la página (header, columnas, tarjetas, footer, decoración)
|   4. Vitrina: transición entre diapositivas, texto y barra de progreso
|   5. Escenas: una sección por característica (01 a 06)
|   6. Movimiento reducido (accesibilidad)
|
| Las escenas solo se animan cuando su <article> tiene la clase .is-playing
| (la agrega select-showcase.js), así que se reproducen de nuevo en cada
| vuelta. "--i" es el orden de cada elemento dentro de un grupo escalonado.
*/

/* ═════════ 1. Variables ═════════ */
:root {
    --anim-ease: cubic-bezier(0.22, 1, 0.36, 1);       /* salida suave */
    --anim-ease-back: cubic-bezier(0.34, 1.56, 0.64, 1); /* pequeño rebote */
    --anim-slide: 0.7s;     /* cambio entre diapositivas */
    --anim-stagger: 0.12s;  /* separación entre elementos escalonados */
}

/* ═════════ 2. Keyframes ═════════ */
@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes fadeDown {
    from { opacity: 0; transform: translateY(-16px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes fadeUp {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes fadeRight {
    from { opacity: 0; transform: translateX(-30px); }
    to   { opacity: 1; transform: translateX(0); }
}

@keyframes fadeLeft {
    from { opacity: 0; transform: translateX(30px); }
    to   { opacity: 1; transform: translateX(0); }
}

@keyframes fadeInScale {
    from { opacity: 0; transform: scale(0.8); }
    to   { opacity: 1; transform: scale(1); }
}

@keyframes riseIn {
    from { opacity: 0; transform: translateY(22px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes slideInRight {
    from { opacity: 0; transform: translateX(24px); }
    to   { opacity: 1; transform: translateX(0); }
}

@keyframes slideInLeft {
    from { opacity: 0; transform: translateX(-16px); }
    to   { opacity: 1; transform: translateX(0); }
}

@keyframes popIn {
    0%   { opacity: 0; transform: scale(0.4); }
    70%  { opacity: 1; transform: scale(1.08); }
    100% { opacity: 1; transform: scale(1); }
}

@keyframes stampIn {
    0%   { opacity: 0; transform: scale(2.2) rotate(-25deg); }
    60%  { opacity: 1; transform: scale(0.9) rotate(4deg); }
    100% { opacity: 1; transform: scale(1) rotate(0); }
}

@keyframes growX {
    from { transform: scaleX(0); }
    to   { transform: scaleX(1); }
}

@keyframes growY {
    from { transform: scaleY(0); }
    to   { transform: scaleY(1); }
}

@keyframes drawLine {
    from { stroke-dasharray: 1; stroke-dashoffset: 1; }
    to   { stroke-dasharray: 1; stroke-dashoffset: 0; }
}

@keyframes dashFlow {
    to { stroke-dashoffset: -20; }
}

@keyframes bubbleIn {
    0%   { opacity: 0; transform: translateY(10px) scale(0.92); }
    100% { opacity: 1; transform: translateY(0) scale(1); }
}

/* Aparece, se queda "escribiendo" y desaparece */
@keyframes typingLife {
    0%   { opacity: 0; transform: scale(0.8); }
    15%  { opacity: 1; transform: scale(1); }
    85%  { opacity: 1; transform: scale(1); }
    100% { opacity: 0; transform: scale(0.8); }
}

@keyframes typingDot {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
    30%           { transform: translateY(-4px); opacity: 1; }
}

@keyframes toastIn {
    from { opacity: 0; transform: translateY(18px) scale(0.95); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes ripple {
    from { opacity: 0.9; transform: scale(0.6); }
    to   { opacity: 0;   transform: scale(1.5); }
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-6px); }
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes statusPulse {
    0%   { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.55); }
    100% { box-shadow: 0 0 0 9px rgba(34, 197, 94, 0); }
}

@keyframes fillBar {
    from { transform: scaleX(0); }
    to   { transform: scaleX(1); }
}

@keyframes decoFloat {
    0%, 100% { transform: translate(0, 0); }
    50%      { transform: translate(20px, -15px); }
}

@keyframes decoSpin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.3; }
}

/* ═════════ 3. Entrada de la página ═════════ */
.deco--blob1 { animation: decoFloat 14s ease-in-out infinite; }
.deco--blob2 { animation: decoFloat 11s ease-in-out infinite reverse; }
.deco--dots  { animation: fadeInScale 1s ease-out 0.6s both; }
.deco--ring  { animation: decoSpin 20s linear infinite, fadeInScale 1s ease-out 1s both; }

.select-header         { animation: fadeDown 0.6s ease-out both; }
.select-header__badge i { animation: pulse 2s ease-in-out infinite; }
.select-left           { animation: fadeRight 0.8s ease-out 0.15s both; }
.select-right          { animation: fadeLeft 0.8s ease-out 0.3s both; }
.select-card--restaurant { animation: fadeLeft 0.6s ease-out 0.4s both; }
.select-card--product    { animation: fadeLeft 0.6s ease-out 0.55s both; }
.select-footer         { animation: fadeUp 0.7s ease-out 0.7s both; }

/* Hover de las tarjetas de sistema */
.select-card               { transition: all 0.45s cubic-bezier(0.25, 0.46, 0.45, 0.94); }
.select-card::before       { transition: height 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94); }
.select-card__icon-wrap    { transition: all 0.4s ease; }
.select-card__icon-wrap i  { transition: transform 0.4s ease; }
.select-card__arrow        { transition: all 0.4s ease; }
.select-footer__text a     { transition: color 0.3s; }

@media (max-width: 700px) {
    .select-left  { animation: fadeUp 0.7s ease-out 0.1s both; }
    .select-right { animation: fadeUp 0.7s ease-out 0.25s both; }
}

/* ═════════ 4. Vitrina ═════════ */

/* Cambio entre diapositivas: la que entra sube y la que sale se desvanece hacia arriba */
.feature {
    opacity: 0;
    transform: translateY(14px) scale(0.985);
    transition:
        opacity var(--anim-slide) var(--anim-ease),
        transform var(--anim-slide) var(--anim-ease),
        visibility 0s linear var(--anim-slide);
}

.feature.is-active {
    opacity: 1;
    transform: none;
    transition-delay: 0s;
}

.feature.is-leaving {
    transform: translateY(-10px) scale(0.985);
}

/* Texto de la característica */
.is-playing .feature__icon  { animation: popIn 0.6s var(--anim-ease-back) 0.3s both; }
.is-playing .feature__title { animation: fadeUp 0.6s var(--anim-ease) 0.4s both; }
.is-playing .feature__desc  { animation: fadeUp 0.6s var(--anim-ease) 0.5s both; }

/* Barra de progreso: su duración la define select-showcase.js con --showcase-interval */
.showcase__bar.is-active::after {
    animation: fillBar var(--showcase-interval, 6.5s) linear both;
}

.showcase.is-paused .showcase__bar.is-active::after {
    animation-play-state: paused;
}

.showcase__bar { transition: background 0.3s; }

/* ═════════ 5. Escenas ═════════ */

/* ── 01 · Facturación electrónica ── */
.is-playing .mock-doc        { animation: riseIn 0.6s var(--anim-ease) 0.2s both; }
.is-playing .mock-doc__line  { animation: growX 0.5s var(--anim-ease) calc(0.45s + var(--i) * var(--anim-stagger)) both; }
.is-playing .mock-doc__total { animation: fadeIn 0.4s ease 0.85s both; }
.is-playing .mock-steps li   { animation: slideInRight 0.45s var(--anim-ease) calc(1s + var(--i) * 0.45s) both; }
.is-playing .mock-doc__seal  { animation: stampIn 0.55s var(--anim-ease) 2.5s both; }

/* ── 02 · WhatsApp con IA ── */
.is-playing .mock-chat          { animation: riseIn 0.6s var(--anim-ease) 0.2s both; }
.is-playing .bubble--q1         { animation: bubbleIn 0.4s var(--anim-ease) 0.8s both; }
.is-playing .bubble--typing     { animation: typingLife 1.4s ease 1.3s both; }
.is-playing .bubble--typing span { animation: typingDot 1s ease-in-out infinite; }
.is-playing .bubble--typing span:nth-child(2) { animation-delay: 0.15s; }
.is-playing .bubble--typing span:nth-child(3) { animation-delay: 0.3s; }
.is-playing .bubble--a1         { animation: bubbleIn 0.45s var(--anim-ease) 2.7s both; }
.is-playing .bubble--q2         { animation: bubbleIn 0.4s var(--anim-ease) 4s both; }

/* Fuera de la animación la burbuja "escribiendo..." queda oculta */
.bubble--typing { opacity: 0; }

/* ── 03 · Inventario ── */
.is-playing .mock-table     { animation: riseIn 0.6s var(--anim-ease) 0.2s both; }
.is-playing .mock-row       { animation: slideInLeft 0.45s var(--anim-ease) calc(0.45s + var(--i) * var(--anim-stagger)) both; }
.is-playing .mock-row__bar i { animation: growX 0.9s var(--anim-ease) calc(0.7s + var(--i) * var(--anim-stagger)) both; }
.is-playing .mock-toast     { animation: toastIn 0.5s var(--anim-ease-back) 2.2s both; }
.is-playing .mock-toast i   { animation: spin 1.2s linear 2.4s infinite; }

/* ── 04 · Reportes ── */
.is-playing .mock-report          { animation: riseIn 0.6s var(--anim-ease) 0.2s both; }
.is-playing .mock-chart__bars span { animation: growY 0.7s var(--anim-ease) calc(0.5s + var(--i) * 0.08s) both; }
.is-playing .mock-chart__line path { animation: drawLine 1.4s ease-in-out 1.1s both; }
.is-playing .mock-report__trend   { animation: popIn 0.45s var(--anim-ease-back) 1.9s both; }

/* ── 05 · Nube ── */
.is-playing .cloud-links path   { animation: fadeIn 0.5s ease calc(0.6s + var(--i) * 0.15s) both, dashFlow 1.2s linear infinite; }
.is-playing .cloud-hub__core    { animation: popIn 0.6s var(--anim-ease-back) 0.2s both, float 4s ease-in-out 1s infinite; }
.is-playing .cloud-hub__ring    { animation: ripple 2.8s ease-out 0.4s infinite both; }
.is-playing .cloud-hub__ring--2 { animation-delay: 1.8s; }
.is-playing .cloud-hub__shield  { animation: popIn 0.45s var(--anim-ease-back) 1.2s both; }
.is-playing .cloud-device       { animation: popIn 0.5s var(--anim-ease-back) calc(0.6s + var(--i) * 0.15s) both; }
.is-playing .cloud-chip         { animation: fadeUp 0.5s var(--anim-ease) 1.5s both; }

/* ── 06 · Soporte ── */
.is-playing .mock-agent         { animation: riseIn 0.6s var(--anim-ease) 0.2s both; }
.is-playing .mock-agent__orbit  { animation: spin 2.4s linear infinite; }
.is-playing .mock-agent__status { animation: statusPulse 1.8s ease-out 0.8s infinite; }
.is-playing .mock-agent__badge  { animation: popIn 0.45s var(--anim-ease-back) 0.7s both; }
.is-playing .mock-perks li      { animation: fadeUp 0.45s var(--anim-ease) calc(0.7s + var(--i) * var(--anim-stagger)) both; }

/* ═════════ 6. Movimiento reducido ═════════ */
@media (prefers-reduced-motion: reduce) {
    .deco,
    .select-header,
    .select-header__badge i,
    .select-left,
    .select-right,
    .select-card,
    .select-footer,
    .feature,
    .feature * {
        animation: none !important;
    }

    .feature {
        transform: none !important;
        transition-duration: 0.3s, 0s, 0s;
    }

    .bubble--typing {
        display: none;
    }
}
