/* ========================================
   Platillo Volante — Animaciones y Transiciones
   ======================================== */

/* ---- Scroll reveals ---- */
.reveal {
    opacity: 0;
    transform: translateY(24px);
    transition: opacity 0.6s ease, transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.reveal.visible {
    opacity: 1;
    transform: translateY(0);
}

.reveal-delay-1 { transition-delay: 100ms; }
.reveal-delay-2 { transition-delay: 200ms; }
.reveal-delay-3 { transition-delay: 300ms; }
.reveal-delay-4 { transition-delay: 400ms; }

/* Stagger children */
.stagger-children > .reveal:nth-child(1) { transition-delay: 0ms; }
.stagger-children > .reveal:nth-child(2) { transition-delay: 80ms; }
.stagger-children > .reveal:nth-child(3) { transition-delay: 160ms; }
.stagger-children > .reveal:nth-child(4) { transition-delay: 240ms; }
.stagger-children > .reveal:nth-child(5) { transition-delay: 320ms; }
.stagger-children > .reveal:nth-child(6) { transition-delay: 400ms; }
.stagger-children > .reveal:nth-child(7) { transition-delay: 480ms; }
.stagger-children > .reveal:nth-child(8) { transition-delay: 560ms; }
.stagger-children > .reveal:nth-child(9) { transition-delay: 640ms; }

/* ---- Card hover lift ---- */
.hover-lift {
    transition: transform var(--transition-base), box-shadow var(--transition-base);
}

.hover-lift:hover {
    transform: translateY(-6px);
    box-shadow: var(--shadow-card-hover);
}

/* ---- Keyframes ---- */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

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

@keyframes scaleIn {
    from { opacity: 0; transform: scale(0.95); }
    to   { opacity: 1; transform: scale(1); }
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50%      { transform: scale(1.05); }
}

@keyframes toastIn {
    from { opacity: 0; transform: translateX(100%); }
    to   { opacity: 1; transform: translateX(0); }
}

@keyframes toastOut {
    from { opacity: 1; transform: translateX(0); }
    to   { opacity: 0; transform: translateX(100%); }
}

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

@keyframes shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

@keyframes badgeBounce {
    0%, 100% { transform: scale(1); }
    50%      { transform: scale(1.3); }
}

@keyframes pulseRing {
    0%   { box-shadow: 0 0 0 0 rgba(254, 101, 32, 0.4); }
    70%  { box-shadow: 0 0 0 10px rgba(254, 101, 32, 0); }
    100% { box-shadow: 0 0 0 0 rgba(254, 101, 32, 0); }
}

/* ========================================
   "Como funciona" — Truck delivery animation

   Timeline (total ~2.8s):
   - 0.0s: Truck appears at paso 1, starts moving
   - 0.3s: Paso 1 icon pops in (truck reveals it)
   - 1.0s: Truck reaches paso 2
   - 1.1s: Paso 2 icon pops in
   - 1.8s: Truck reaches paso 3
   - 1.9s: Paso 3 icon pops in
   - 2.4s: Truck fades out (it IS paso 3's icon now)
   ======================================== */

/* Track line connecting the 3 steps */
.pasos-track {
    position: absolute;
    top: 44px;
    left: 16.66%;
    right: 16.66%;
    height: 2px;
    background: var(--pv-border);
    z-index: 0;
    border-radius: 1px;
}

.pasos-track-fill {
    height: 100%;
    width: 0%;
    background: var(--pv-naranja);
    border-radius: 1px;
    transition: none;
}

/* Traveling truck */
.truck-traveler {
    position: absolute;
    top: 28px;
    left: 16.66%;
    transform: translateX(-50%);
    z-index: 2;
    color: var(--pv-naranja);
    opacity: 0;
    pointer-events: none;
}

/* Paso icons start hidden before animation */
.pasos-grid .paso .paso-icon {
    opacity: 0;
    transform: scale(0.3);
    transition: none;
}

/* Text starts hidden too */
.pasos-grid .paso h3,
.pasos-grid .paso p {
    opacity: 0;
    transform: translateY(10px);
    transition: none;
}

/* ---- ANIMATED STATE (class added by JS) ---- */

/* Truck travels left to right */
.pasos-grid.animate .truck-traveler {
    animation: truckTravel 2.4s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

/* Track fills as truck moves */
.pasos-grid.animate .pasos-track-fill {
    animation: trackFill 2.2s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

/* Paso 1: icon appears at 0.3s */
.pasos-grid.animate .paso:nth-child(3) .paso-icon {
    animation: iconPop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) 0.3s forwards;
}
.pasos-grid.animate .paso:nth-child(3) h3,
.pasos-grid.animate .paso:nth-child(3) p {
    animation: textReveal 0.4s ease 0.5s forwards;
}

/* Paso 2: icon appears at 1.1s */
.pasos-grid.animate .paso:nth-child(4) .paso-icon {
    animation: iconPop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) 1.1s forwards;
}
.pasos-grid.animate .paso:nth-child(4) h3,
.pasos-grid.animate .paso:nth-child(4) p {
    animation: textReveal 0.4s ease 1.3s forwards;
}

/* Paso 3: icon appears at 1.9s */
.pasos-grid.animate .paso:nth-child(5) .paso-icon {
    animation: iconPop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) 1.9s forwards;
}
.pasos-grid.animate .paso:nth-child(5) h3,
.pasos-grid.animate .paso:nth-child(5) p {
    animation: textReveal 0.4s ease 2.1s forwards;
}

/* Keyframes */
@keyframes truckTravel {
    0%   { left: 16.66%; opacity: 1; }
    10%  { opacity: 1; }
    40%  { left: 50%; }
    80%  { left: 83.33%; opacity: 1; }
    95%  { left: 83.33%; opacity: 0; }
    100% { left: 83.33%; opacity: 0; }
}

@keyframes trackFill {
    0%   { width: 0%; opacity: 1; }
    40%  { width: 50%; opacity: 1; }
    85%  { width: 100%; opacity: 1; }
    100% { width: 100%; opacity: 0; }
}

/* La linea base tambien desaparece */
.pasos-grid.animate .pasos-track {
    animation: trackBaseFade 2.6s ease forwards;
}

@keyframes trackBaseFade {
    0%   { opacity: 1; }
    85%  { opacity: 1; }
    100% { opacity: 0; }
}

@keyframes iconPop {
    0%   { opacity: 0; transform: scale(0.3); }
    60%  { opacity: 1; transform: scale(1.15); }
    100% { opacity: 1; transform: scale(1); }
}

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

/* Mobile: simpler vertical animation, no truck travel */
@media (max-width: 768px) {
    .pasos-track,
    .truck-traveler {
        display: none;
    }
    .pasos-grid .paso .paso-icon,
    .pasos-grid .paso h3,
    .pasos-grid .paso p {
        opacity: 1;
        transform: none;
    }
    .pasos-grid.animate .paso:nth-child(3),
    .pasos-grid.animate .paso:nth-child(4),
    .pasos-grid.animate .paso:nth-child(5) {
        animation: fadeInUp 0.5s ease forwards;
    }
    .pasos-grid.animate .paso:nth-child(3) { animation-delay: 0s; }
    .pasos-grid.animate .paso:nth-child(4) { animation-delay: 0.15s; }
    .pasos-grid.animate .paso:nth-child(5) { animation-delay: 0.3s; }
    .pasos-grid.animate .paso:nth-child(3) .paso-icon,
    .pasos-grid.animate .paso:nth-child(4) .paso-icon,
    .pasos-grid.animate .paso:nth-child(5) .paso-icon,
    .pasos-grid.animate .paso:nth-child(3) h3,
    .pasos-grid.animate .paso:nth-child(4) h3,
    .pasos-grid.animate .paso:nth-child(5) h3,
    .pasos-grid.animate .paso:nth-child(3) p,
    .pasos-grid.animate .paso:nth-child(4) p,
    .pasos-grid.animate .paso:nth-child(5) p {
        animation: none;
        opacity: 1;
        transform: none;
    }
}

/* ---- Utility classes ---- */
.badge-bounce { animation: badgeBounce 0.3s ease; }
.btn-press:active { transform: scale(0.97); }
.img-zoom { transition: transform 0.4s ease; }
.img-zoom:hover { transform: scale(1.05); }
.anim-fade-in { animation: fadeIn 0.4s ease; }
.anim-fade-in-up { animation: fadeInUp 0.5s ease; }
.anim-scale-in { animation: scaleIn 0.2s ease; }

/* ---- Micro-interaccion: boton anadido ---- */
.btn-anadido {
    background: var(--pv-verde) !important;
    color: white !important;
    pointer-events: none;
    transition: background 300ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes flyToCart {
    0% { transform: translate(0, 0) scale(1); opacity: 1; }
    50% { transform: translate(var(--fly-x-mid), var(--fly-y-mid)) scale(0.6); opacity: 0.8; }
    100% { transform: translate(var(--fly-x), var(--fly-y)) scale(0.2); opacity: 0; }
}

/* ---- Accesibilidad: respetar prefers-reduced-motion ---- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    .reveal {
        opacity: 1;
        transform: none;
    }
    .pasos-grid .paso .paso-icon,
    .pasos-grid .paso h3,
    .pasos-grid .paso p {
        opacity: 1;
        transform: none;
    }
}
