/* ============================================================
   All City Motor — Scroll Animation System
   Mobile-first fly-in animations with IntersectionObserver
   ============================================================ */

/* --- Base hidden state for all animated elements --- */
.fly-left,
.fly-right,
.fly-up,
.fly-down,
.fade-in,
.scale-in {
    opacity: 0;
    will-change: transform, opacity;
    transition: opacity 0.7s cubic-bezier(0.16, 1, 0.3, 1),
                transform 0.7s cubic-bezier(0.16, 1, 0.3, 1);
}

/* --- Directional starting positions --- */
.fly-left {
    transform: translateX(-60px);
}

.fly-right {
    transform: translateX(60px);
}

.fly-up {
    transform: translateY(40px);
}

.fly-down {
    transform: translateY(-40px);
}

.scale-in {
    transform: scale(0.92);
}

/* --- Active/visible state (applied by IntersectionObserver) --- */
.fly-left.visible,
.fly-right.visible,
.fly-up.visible,
.fly-down.visible,
.fade-in.visible,
.scale-in.visible {
    opacity: 1;
    transform: translate(0, 0) scale(1);
}

/* --- Stagger delay utilities --- */
.delay-100 { transition-delay: 0.1s; }
.delay-200 { transition-delay: 0.2s; }
.delay-300 { transition-delay: 0.3s; }
.delay-400 { transition-delay: 0.4s; }
.delay-500 { transition-delay: 0.5s; }
.delay-600 { transition-delay: 0.6s; }
.delay-700 { transition-delay: 0.7s; }
.delay-800 { transition-delay: 0.8s; }

/* --- Counter animation (for stat numbers) --- */
.count-up {
    display: inline-block;
}

/* --- Hero parallax --- */
.parallax-hero {
    background-attachment: scroll; /* Mobile default — no parallax */
    background-size: cover;
    background-position: center;
    transition: background-position 0.1s linear;
}

@media (min-width: 1024px) {
    .parallax-hero {
        background-attachment: fixed;
    }
}

/* --- Text reveal animation --- */
.text-reveal {
    overflow: hidden;
}

.text-reveal .word {
    display: inline-block;
    opacity: 0;
    transform: translateY(100%);
    transition: opacity 0.5s ease, transform 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

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

/* Stagger each word */
.text-reveal.visible .word:nth-child(1) { transition-delay: 0s; }
.text-reveal.visible .word:nth-child(2) { transition-delay: 0.05s; }
.text-reveal.visible .word:nth-child(3) { transition-delay: 0.1s; }
.text-reveal.visible .word:nth-child(4) { transition-delay: 0.15s; }
.text-reveal.visible .word:nth-child(5) { transition-delay: 0.2s; }
.text-reveal.visible .word:nth-child(6) { transition-delay: 0.25s; }
.text-reveal.visible .word:nth-child(7) { transition-delay: 0.3s; }
.text-reveal.visible .word:nth-child(8) { transition-delay: 0.35s; }
.text-reveal.visible .word:nth-child(9) { transition-delay: 0.4s; }
.text-reveal.visible .word:nth-child(10) { transition-delay: 0.45s; }

/* --- Shimmer / glow effect for CTAs --- */
.btn-glow {
    position: relative;
    overflow: hidden;
}

.btn-glow::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(
        45deg,
        transparent 40%,
        rgba(255, 255, 255, 0.15) 50%,
        transparent 60%
    );
    transform: translateX(-100%);
    transition: transform 0.6s ease;
}

.btn-glow:hover::after {
    transform: translateX(100%);
}

/* --- Pulse animation for phone CTA --- */
@keyframes pulse-ring {
    0% {
        box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.4);
    }
    70% {
        box-shadow: 0 0 0 15px rgba(245, 158, 11, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(245, 158, 11, 0);
    }
}

.pulse-cta {
    animation: pulse-ring 2s infinite;
}

/* --- Card tilt on hover (desktop only) --- */
@media (min-width: 768px) {
    .tilt-card {
        transition: transform 0.3s ease, box-shadow 0.3s ease;
    }

    .tilt-card:hover {
        transform: translateY(-8px) rotateX(2deg);
        box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    }
}

/* --- Smooth section transitions --- */
.section-transition {
    position: relative;
}

.section-transition::before {
    content: '';
    position: absolute;
    top: -40px;
    left: 0;
    right: 0;
    height: 40px;
    background: linear-gradient(to bottom, transparent, var(--surface));
}

/* --- Reduced motion preference --- */
@media (prefers-reduced-motion: reduce) {
    .fly-left,
    .fly-right,
    .fly-up,
    .fly-down,
    .fade-in,
    .scale-in {
        opacity: 1;
        transform: none;
        transition: none;
    }

    .text-reveal .word {
        opacity: 1;
        transform: none;
        transition: none;
    }

    .parallax-hero {
        background-attachment: scroll;
    }

    .pulse-cta {
        animation: none;
    }

    .btn-glow::after {
        display: none;
    }
}
