/* ============================================
   TRACKPRO - MODERN ANIMATIONS
   Professional scroll-triggered animations,
   counters, hover effects, and text animations
   ============================================ */

/* ============================================
   BASE ANIMATION VARIABLES
   ============================================ */
:root {
    --animation-duration: 0.8s;
    --animation-duration-fast: 0.4s;
    --animation-duration-slow: 1.2s;
    --animation-easing: cubic-bezier(0.4, 0, 0.2, 1);
    --animation-easing-bounce: cubic-bezier(0.68, -0.55, 0.265, 1.55);
    --animation-easing-smooth: cubic-bezier(0.25, 0.46, 0.45, 0.94);
    --stagger-delay: 0.1s;
}

/* ============================================
   SCROLL-TRIGGERED ANIMATIONS - BASE STATES
   Elements start hidden and animate in
   ============================================ */

/* Fade Up Animation */
[data-animate="fade-up"] {
    opacity: 0;
    transform: translateY(40px);
    transition: opacity var(--animation-duration) var(--animation-easing),
                transform var(--animation-duration) var(--animation-easing);
}

[data-animate="fade-up"].animated {
    opacity: 1;
    transform: translateY(0);
}

/* Fade Down Animation */
[data-animate="fade-down"] {
    opacity: 0;
    transform: translateY(-40px);
    transition: opacity var(--animation-duration) var(--animation-easing),
                transform var(--animation-duration) var(--animation-easing);
}

[data-animate="fade-down"].animated {
    opacity: 1;
    transform: translateY(0);
}

/* Fade Left Animation */
[data-animate="fade-left"] {
    opacity: 0;
    transform: translateX(40px);
    transition: opacity var(--animation-duration) var(--animation-easing),
                transform var(--animation-duration) var(--animation-easing);
}

[data-animate="fade-left"].animated {
    opacity: 1;
    transform: translateX(0);
}

/* Fade Right Animation */
[data-animate="fade-right"] {
    opacity: 0;
    transform: translateX(-40px);
    transition: opacity var(--animation-duration) var(--animation-easing),
                transform var(--animation-duration) var(--animation-easing);
}

[data-animate="fade-right"].animated {
    opacity: 1;
    transform: translateX(0);
}

/* Fade In Animation */
[data-animate="fade-in"] {
    opacity: 0;
    transition: opacity var(--animation-duration) var(--animation-easing);
}

[data-animate="fade-in"].animated {
    opacity: 1;
}

/* Zoom In Animation */
[data-animate="zoom-in"] {
    opacity: 0;
    transform: scale(0.8);
    transition: opacity var(--animation-duration) var(--animation-easing),
                transform var(--animation-duration) var(--animation-easing-bounce);
}

[data-animate="zoom-in"].animated {
    opacity: 1;
    transform: scale(1);
}

/* Zoom Out Animation */
[data-animate="zoom-out"] {
    opacity: 0;
    transform: scale(1.2);
    transition: opacity var(--animation-duration) var(--animation-easing),
                transform var(--animation-duration) var(--animation-easing);
}

[data-animate="zoom-out"].animated {
    opacity: 1;
    transform: scale(1);
}

/* Flip Up Animation */
[data-animate="flip-up"] {
    opacity: 0;
    transform: perspective(1000px) rotateX(45deg);
    transition: opacity var(--animation-duration) var(--animation-easing),
                transform var(--animation-duration) var(--animation-easing);
}

[data-animate="flip-up"].animated {
    opacity: 1;
    transform: perspective(1000px) rotateX(0);
}

/* Slide Up Animation */
[data-animate="slide-up"] {
    opacity: 0;
    transform: translateY(100px);
    transition: opacity var(--animation-duration-slow) var(--animation-easing),
                transform var(--animation-duration-slow) var(--animation-easing);
}

[data-animate="slide-up"].animated {
    opacity: 1;
    transform: translateY(0);
}

/* Scale Up Animation */
[data-animate="scale-up"] {
    opacity: 0;
    transform: scale(0.5);
    transition: opacity var(--animation-duration) var(--animation-easing-bounce),
                transform var(--animation-duration) var(--animation-easing-bounce);
}

[data-animate="scale-up"].animated {
    opacity: 1;
    transform: scale(1);
}

/* Rotate In Animation */
[data-animate="rotate-in"] {
    opacity: 0;
    transform: rotate(-10deg) scale(0.9);
    transition: opacity var(--animation-duration) var(--animation-easing),
                transform var(--animation-duration) var(--animation-easing);
}

[data-animate="rotate-in"].animated {
    opacity: 1;
    transform: rotate(0) scale(1);
}

/* ============================================
   STAGGER DELAYS FOR GRID ITEMS
   ============================================ */
[data-animate-stagger] > *:nth-child(1) { transition-delay: calc(var(--stagger-delay) * 1); }
[data-animate-stagger] > *:nth-child(2) { transition-delay: calc(var(--stagger-delay) * 2); }
[data-animate-stagger] > *:nth-child(3) { transition-delay: calc(var(--stagger-delay) * 3); }
[data-animate-stagger] > *:nth-child(4) { transition-delay: calc(var(--stagger-delay) * 4); }
[data-animate-stagger] > *:nth-child(5) { transition-delay: calc(var(--stagger-delay) * 5); }
[data-animate-stagger] > *:nth-child(6) { transition-delay: calc(var(--stagger-delay) * 6); }
[data-animate-stagger] > *:nth-child(7) { transition-delay: calc(var(--stagger-delay) * 7); }
[data-animate-stagger] > *:nth-child(8) { transition-delay: calc(var(--stagger-delay) * 8); }
[data-animate-stagger] > *:nth-child(9) { transition-delay: calc(var(--stagger-delay) * 9); }
[data-animate-stagger] > *:nth-child(10) { transition-delay: calc(var(--stagger-delay) * 10); }
[data-animate-stagger] > *:nth-child(11) { transition-delay: calc(var(--stagger-delay) * 11); }
[data-animate-stagger] > *:nth-child(12) { transition-delay: calc(var(--stagger-delay) * 12); }

/* Stagger children with fade-up */
[data-animate-stagger="fade-up"] > * {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity var(--animation-duration) var(--animation-easing),
                transform var(--animation-duration) var(--animation-easing);
}

[data-animate-stagger="fade-up"].animated > * {
    opacity: 1;
    transform: translateY(0);
}

/* Stagger children with zoom-in */
[data-animate-stagger="zoom-in"] > * {
    opacity: 0;
    transform: scale(0.8);
    transition: opacity var(--animation-duration) var(--animation-easing),
                transform var(--animation-duration) var(--animation-easing-bounce);
}

[data-animate-stagger="zoom-in"].animated > * {
    opacity: 1;
    transform: scale(1);
}

/* Stagger children with fade-in */
[data-animate-stagger="fade-in"] > * {
    opacity: 0;
    transition: opacity var(--animation-duration) var(--animation-easing);
}

[data-animate-stagger="fade-in"].animated > * {
    opacity: 1;
}

/* ============================================
   COUNTER ANIMATION STYLES
   ============================================ */
[data-counter] {
    display: inline-block;
}

.counter-animated {
    animation: counterPulse 0.3s var(--animation-easing);
}

@keyframes counterPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

/* ============================================
   TEXT ANIMATIONS
   ============================================ */

/* Typewriter Effect */
.typewriter {
    overflow: hidden;
    border-right: 3px solid var(--primary-purple);
    white-space: nowrap;
    animation: typewriter 3s steps(40) 1s forwards,
               blinkCursor 0.75s step-end infinite;
}

@keyframes typewriter {
    from { width: 0; }
    to { width: 100%; }
}

@keyframes blinkCursor {
    from, to { border-color: transparent; }
    50% { border-color: var(--primary-purple); }
}

/* Text Reveal Animation */
[data-animate="text-reveal"] {
    position: relative;
    overflow: hidden;
}

[data-animate="text-reveal"]::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--primary-purple);
    transform: translateX(-101%);
    transition: transform 0.6s var(--animation-easing);
}

[data-animate="text-reveal"].animated::after {
    transform: translateX(101%);
}

/* Gradient Text Shimmer */
.text-shimmer {
    background: linear-gradient(
        90deg,
        var(--gray-900) 0%,
        var(--primary-purple) 25%,
        var(--primary-orange) 50%,
        var(--primary-purple) 75%,
        var(--gray-900) 100%
    );
    background-size: 200% auto;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: textShimmer 3s linear infinite;
}

@keyframes textShimmer {
    0% { background-position: 0% center; }
    100% { background-position: 200% center; }
}

/* Word by Word Reveal */
.word-reveal .word {
    display: inline-block;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.4s var(--animation-easing),
                transform 0.4s var(--animation-easing);
}

.word-reveal.animated .word {
    opacity: 1;
    transform: translateY(0);
}

/* Character Split Animation */
.char-split .char {
    display: inline-block;
    opacity: 0;
    transform: translateY(100%);
    transition: opacity 0.3s var(--animation-easing),
                transform 0.3s var(--animation-easing);
}

.char-split.animated .char {
    opacity: 1;
    transform: translateY(0);
}

/* ============================================
   ENHANCED HOVER EFFECTS
   ============================================ */

/* Card Lift Effect */
.hover-lift {
    transition: transform var(--animation-duration-fast) var(--animation-easing),
                box-shadow var(--animation-duration-fast) var(--animation-easing);
}

.hover-lift:hover {
    transform: translateY(-8px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
}

/* Card Tilt Effect */
.hover-tilt {
    transition: transform var(--animation-duration-fast) var(--animation-easing);
    transform-style: preserve-3d;
}

.hover-tilt:hover {
    transform: perspective(1000px) rotateX(5deg) rotateY(-5deg) translateY(-5px);
}

/* Glow Effect */
.hover-glow {
    transition: box-shadow var(--animation-duration-fast) var(--animation-easing);
}

.hover-glow:hover {
    box-shadow: 0 0 30px rgba(77, 20, 140, 0.4);
}

/* Button Ripple Effect */
.btn-ripple {
    position: relative;
    overflow: hidden;
}

.btn-ripple::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.6s var(--animation-easing),
                height 0.6s var(--animation-easing);
}

.btn-ripple:hover::before {
    width: 300px;
    height: 300px;
}

/* Icon Bounce */
.icon-bounce {
    transition: transform var(--animation-duration-fast) var(--animation-easing-bounce);
}

.icon-bounce:hover {
    transform: scale(1.2);
}

/* Icon Rotate */
.icon-rotate {
    transition: transform var(--animation-duration-fast) var(--animation-easing);
}

.icon-rotate:hover {
    transform: rotate(15deg);
}

/* Icon Pulse */
.icon-pulse {
    animation: none;
}

.icon-pulse:hover {
    animation: iconPulse 0.6s var(--animation-easing);
}

@keyframes iconPulse {
    0% { transform: scale(1); }
    25% { transform: scale(1.2); }
    50% { transform: scale(0.95); }
    75% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

/* Image Zoom on Hover */
.img-zoom {
    overflow: hidden;
}

.img-zoom img {
    transition: transform var(--animation-duration) var(--animation-easing);
}

.img-zoom:hover img {
    transform: scale(1.1);
}

/* Border Animation */
.border-animate {
    position: relative;
}

.border-animate::before {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--primary-purple), var(--primary-orange));
    transition: width var(--animation-duration-fast) var(--animation-easing),
                left var(--animation-duration-fast) var(--animation-easing);
}

.border-animate:hover::before {
    width: 100%;
    left: 0;
}

/* ============================================
   FLOATING ANIMATIONS (Continuous)
   ============================================ */
.float {
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.float-slow {
    animation: float 5s ease-in-out infinite;
}

.float-fast {
    animation: float 2s ease-in-out infinite;
}

/* Pulse Animation */
.pulse {
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.05); opacity: 0.8; }
}

/* Rotate Animation */
.rotate-slow {
    animation: rotateSlow 20s linear infinite;
}

@keyframes rotateSlow {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Bounce Animation */
.bounce {
    animation: bounce 2s ease-in-out infinite;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    25% { transform: translateY(-5px); }
    75% { transform: translateY(5px); }
}

/* ============================================
   LOADING ANIMATIONS
   ============================================ */
.skeleton {
    background: linear-gradient(
        90deg,
        var(--gray-200) 25%,
        var(--gray-100) 50%,
        var(--gray-200) 75%
    );
    background-size: 200% 100%;
    animation: skeleton 1.5s ease-in-out infinite;
}

@keyframes skeleton {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Spinner */
.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--gray-200);
    border-top-color: var(--primary-purple);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ============================================
   PROGRESS BAR ANIMATION
   ============================================ */
.progress-animate {
    width: 0;
    transition: width 1.5s var(--animation-easing);
}

.progress-animate.animated {
    width: var(--progress-width, 100%);
}

/* Timeline Line Draw */
.timeline-draw {
    position: relative;
}

.timeline-draw::before {
    content: '';
    position: absolute;
    left: 50%;
    top: 0;
    width: 2px;
    height: 0;
    background: linear-gradient(180deg, var(--primary-purple), var(--primary-orange));
    transition: height 1.5s var(--animation-easing);
}

.timeline-draw.animated::before {
    height: 100%;
}

/* ============================================
   PARALLAX EFFECT
   ============================================ */
.parallax {
    transform: translateY(var(--parallax-offset, 0));
    transition: transform 0.1s linear;
}

/* ============================================
   BACKGROUND ANIMATIONS
   ============================================ */

/* Gradient Shift */
.bg-gradient-animate {
    background-size: 200% 200%;
    animation: gradientShift 8s ease-in-out infinite;
}

@keyframes gradientShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* Particle Float Container */
.particles-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    pointer-events: none;
}

.particle {
    position: absolute;
    width: 10px;
    height: 10px;
    background: rgba(77, 20, 140, 0.1);
    border-radius: 50%;
    animation: particleFloat 15s ease-in-out infinite;
}

@keyframes particleFloat {
    0%, 100% {
        transform: translate(0, 0) rotate(0deg);
        opacity: 0;
    }
    10% {
        opacity: 1;
    }
    90% {
        opacity: 1;
    }
    100% {
        transform: translate(100px, -500px) rotate(720deg);
        opacity: 0;
    }
}

/* ============================================
   SPECIAL ENTRANCE ANIMATIONS
   ============================================ */

/* Hero Entrance */
.hero-entrance {
    animation: heroEntrance 1s var(--animation-easing) forwards;
}

@keyframes heroEntrance {
    0% {
        opacity: 0;
        transform: translateY(30px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Badge Pop */
.badge-pop {
    animation: badgePop 0.5s var(--animation-easing-bounce) forwards;
}

@keyframes badgePop {
    0% {
        opacity: 0;
        transform: scale(0);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

/* Slide In From Bottom */
.slide-in-bottom {
    animation: slideInBottom 0.6s var(--animation-easing) forwards;
}

@keyframes slideInBottom {
    0% {
        opacity: 0;
        transform: translateY(50px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================
   ATTENTION SEEKERS
   ============================================ */

/* Shake */
.shake:hover {
    animation: shake 0.5s var(--animation-easing);
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-5px); }
    40% { transform: translateX(5px); }
    60% { transform: translateX(-5px); }
    80% { transform: translateX(5px); }
}

/* Heartbeat */
.heartbeat:hover {
    animation: heartbeat 1s var(--animation-easing);
}

@keyframes heartbeat {
    0% { transform: scale(1); }
    14% { transform: scale(1.1); }
    28% { transform: scale(1); }
    42% { transform: scale(1.1); }
    70% { transform: scale(1); }
}

/* Jello */
.jello:hover {
    animation: jello 0.9s var(--animation-easing);
}

@keyframes jello {
    0%, 100% { transform: scale3d(1, 1, 1); }
    30% { transform: scale3d(1.25, 0.75, 1); }
    40% { transform: scale3d(0.75, 1.25, 1); }
    50% { transform: scale3d(1.15, 0.85, 1); }
    65% { transform: scale3d(0.95, 1.05, 1); }
    75% { transform: scale3d(1.05, 0.95, 1); }
}

/* ============================================
   REDUCED MOTION SUPPORT
   ============================================ */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    [data-animate],
    [data-animate-stagger] > * {
        opacity: 1 !important;
        transform: none !important;
    }
}

/* ============================================
   RESPONSIVE ADJUSTMENTS
   ============================================ */
@media (max-width: 768px) {
    :root {
        --animation-duration: 0.6s;
        --animation-duration-slow: 0.8s;
    }

    [data-animate="fade-up"],
    [data-animate="fade-down"] {
        transform: translateY(20px);
    }

    [data-animate="fade-left"],
    [data-animate="fade-right"] {
        transform: translateX(20px);
    }

    .hover-lift:hover {
        transform: translateY(-4px);
    }
}
