/**
 * AIFA Football Academy - Animations
 * Version: 1.0
 *
 * Table of Contents:
 * 1. Keyframe Animations
 * 2. Scroll Reveal Animations
 * 3. Hover Animations
 * 4. Loading Animations
 * 5. Special Effects
 */

/* ==========================================================================
   1. KEYFRAME ANIMATIONS
   ========================================================================== */

/* Fade Animations */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

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

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

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

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

/* Scale Animations */
@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes scaleOut {
    from {
        opacity: 1;
        transform: scale(1);
    }
    to {
        opacity: 0;
        transform: scale(0.9);
    }
}

@keyframes scaleBounce {
    0% {
        opacity: 0;
        transform: scale(0.3);
    }
    50% {
        opacity: 1;
        transform: scale(1.05);
    }
    70% {
        transform: scale(0.9);
    }
    100% {
        transform: scale(1);
    }
}

/* Slide Animations */
@keyframes slideInUp {
    from {
        transform: translateY(100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes slideInDown {
    from {
        transform: translateY(-100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

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

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

/* Rotate Animations */
@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

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

/* Bounce Animations */
@keyframes bounce {
    0%, 20%, 53%, 100% {
        animation-timing-function: cubic-bezier(0.215, 0.61, 0.355, 1);
        transform: translateY(0);
    }
    40%, 43% {
        animation-timing-function: cubic-bezier(0.755, 0.05, 0.855, 0.06);
        transform: translateY(-20px);
    }
    70% {
        animation-timing-function: cubic-bezier(0.755, 0.05, 0.855, 0.06);
        transform: translateY(-10px);
    }
    80% {
        transform: translateY(0);
    }
    90% {
        transform: translateY(-4px);
    }
}

@keyframes bounceIn {
    0% {
        opacity: 0;
        transform: scale(0.3);
    }
    50% {
        transform: scale(1.05);
    }
    70% {
        transform: scale(0.9);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

/* Pulse Animations */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.8;
        transform: scale(1.05);
    }
}

@keyframes pulseGlow {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.7);
    }
    50% {
        box-shadow: 0 0 0 15px rgba(59, 130, 246, 0);
    }
}

@keyframes pulseRing {
    0% {
        transform: scale(0.8);
        opacity: 1;
    }
    100% {
        transform: scale(1.5);
        opacity: 0;
    }
}

/* Shake Animations */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}

@keyframes wiggle {
    0%, 100% { transform: rotate(0deg); }
    25% { transform: rotate(-5deg); }
    75% { transform: rotate(5deg); }
}

/* Float Animation */
@keyframes float {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}

@keyframes floatRotate {
    0%, 100% {
        transform: translateY(0) rotate(0deg);
    }
    50% {
        transform: translateY(-15px) rotate(5deg);
    }
}

/* Gradient Animation */
@keyframes gradientMove {
    0%, 100% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
}

@keyframes gradientFlow {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

/* Text Reveal Animation */
@keyframes textReveal {
    from {
        transform: translateY(110%);
    }
    to {
        transform: translateY(0);
    }
}

@keyframes textRevealClip {
    from {
        clip-path: inset(0 100% 0 0);
    }
    to {
        clip-path: inset(0 0 0 0);
    }
}

/* Marquee Animation */
@keyframes marquee {
    0% { transform: translateX(0); }
    100% { transform: translateX(-50%); }
}

@keyframes marqueeReverse {
    0% { transform: translateX(-50%); }
    100% { transform: translateX(0); }
}

/* Particle Animation */
@keyframes floatParticle {
    0% {
        transform: translateY(100vh) rotate(0deg);
        opacity: 0;
    }
    10% {
        opacity: 0.5;
    }
    90% {
        opacity: 0.5;
    }
    100% {
        transform: translateY(-100vh) rotate(720deg);
        opacity: 0;
    }
}

/* Orb Animation */
@keyframes orbFloat {
    0%, 100% {
        transform: translate(0, 0) scale(1);
    }
    33% {
        transform: translate(30px, -30px) scale(1.1);
    }
    66% {
        transform: translate(-20px, 20px) scale(0.9);
    }
}

@keyframes orbPulse {
    0%, 100% {
        opacity: 0.3;
        transform: scale(1);
    }
    50% {
        opacity: 0.5;
        transform: scale(1.1);
    }
}

/* Ken Burns Effect */
@keyframes kenBurnsZoomIn {
    0% {
        transform: scale(1);
    }
    100% {
        transform: scale(1.1);
    }
}

@keyframes kenBurnsZoomOut {
    0% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
    }
}

@keyframes kenBurnsPan {
    0% {
        transform: scale(1.2) translateX(-5%);
    }
    100% {
        transform: scale(1.2) translateX(5%);
    }
}

/* Preloader Animations */
@keyframes preloaderOut {
    0% {
        clip-path: inset(0 0 0 0);
    }
    100% {
        clip-path: inset(0 0 100% 0);
    }
}

@keyframes loadLine {
    0% {
        width: 0%;
    }
    100% {
        width: 100%;
    }
}

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

/* Counter Animation */
@keyframes countUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Scroll Indicator */
@keyframes scrollMouse {
    0%, 100% {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
    50% {
        opacity: 0.3;
        transform: translateX(-50%) translateY(12px);
    }
}

/* Glitch Effect */
@keyframes glitch {
    0% {
        transform: translate(0);
    }
    20% {
        transform: translate(-2px, 2px);
    }
    40% {
        transform: translate(-2px, -2px);
    }
    60% {
        transform: translate(2px, 2px);
    }
    80% {
        transform: translate(2px, -2px);
    }
    100% {
        transform: translate(0);
    }
}

@keyframes glitchSkew {
    0% {
        transform: skew(0deg);
    }
    20% {
        transform: skew(2deg);
    }
    40% {
        transform: skew(-2deg);
    }
    60% {
        transform: skew(1deg);
    }
    80% {
        transform: skew(-1deg);
    }
    100% {
        transform: skew(0deg);
    }
}

/* Grid Pulse */
@keyframes gridPulse {
    0%, 100% {
        opacity: 0.3;
    }
    50% {
        opacity: 0.6;
    }
}

/* Ripple Effect */
@keyframes ripple {
    0% {
        transform: scale(0);
        opacity: 1;
    }
    100% {
        transform: scale(4);
        opacity: 0;
    }
}

/* Shimmer Effect */
@keyframes shimmer {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* Typing Effect */
@keyframes typing {
    from {
        width: 0;
    }
    to {
        width: 100%;
    }
}

@keyframes blink {
    0%, 100% {
        border-color: transparent;
    }
    50% {
        border-color: var(--primary);
    }
}

/* ==========================================================================
   2. SCROLL REVEAL ANIMATIONS
   ========================================================================== */

/* Base scroll animation states */
.animate-on-scroll {
    opacity: 0;
    transform: translateY(40px);
    transition: all 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.animate-on-scroll.animated {
    opacity: 1;
    transform: translateY(0);
}

/* Animate from left */
.animate-left {
    opacity: 0;
    transform: translateX(-40px);
    transition: all 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.animate-left.animated {
    opacity: 1;
    transform: translateX(0);
}

/* Animate from right */
.animate-right {
    opacity: 0;
    transform: translateX(40px);
    transition: all 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.animate-right.animated {
    opacity: 1;
    transform: translateX(0);
}

/* Animate scale */
.animate-scale {
    opacity: 0;
    transform: scale(0.85);
    transition: all 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.animate-scale.animated {
    opacity: 1;
    transform: scale(1);
}

/* Animate fade */
.animate-fade {
    opacity: 0;
    transition: opacity 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.animate-fade.animated {
    opacity: 1;
}

/* Staggered children animation */
.stagger-children > * {
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.stagger-children.animated > *:nth-child(1) { transition-delay: 0.1s; }
.stagger-children.animated > *:nth-child(2) { transition-delay: 0.2s; }
.stagger-children.animated > *:nth-child(3) { transition-delay: 0.3s; }
.stagger-children.animated > *:nth-child(4) { transition-delay: 0.4s; }
.stagger-children.animated > *:nth-child(5) { transition-delay: 0.5s; }
.stagger-children.animated > *:nth-child(6) { transition-delay: 0.6s; }
.stagger-children.animated > *:nth-child(7) { transition-delay: 0.7s; }
.stagger-children.animated > *:nth-child(8) { transition-delay: 0.8s; }

.stagger-children.animated > * {
    opacity: 1;
    transform: translateY(0);
}

/* ==========================================================================
   3. HOVER ANIMATIONS
   ========================================================================== */

/* Lift on hover */
.hover-lift {
    transition: transform var(--transition-normal) var(--ease-bounce);
}

.hover-lift:hover {
    transform: translateY(-5px);
}

/* Scale on hover */
.hover-scale {
    transition: transform var(--transition-normal) var(--ease-bounce);
}

.hover-scale:hover {
    transform: scale(1.05);
}

/* Glow on hover */
.hover-glow {
    transition: box-shadow var(--transition-normal);
}

.hover-glow:hover {
    box-shadow: var(--shadow-glow-lg);
}

/* Shine effect on hover */
.hover-shine {
    position: relative;
    overflow: hidden;
}

.hover-shine::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.2),
        transparent
    );
    transition: left 0.5s;
}

.hover-shine:hover::before {
    left: 100%;
}

/* Underline animation on hover */
.hover-underline {
    position: relative;
}

.hover-underline::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--primary);
    transition: width var(--transition-normal);
}

.hover-underline:hover::after {
    width: 100%;
}

/* Color shift on hover */
.hover-primary:hover {
    color: var(--primary);
}

/* Image zoom on hover */
.hover-zoom {
    overflow: hidden;
}

.hover-zoom img {
    transition: transform var(--transition-slow);
}

.hover-zoom:hover img {
    transform: scale(1.1);
}

/* Tilt effect (requires JS for full effect) */
.hover-tilt {
    transform-style: preserve-3d;
    transition: transform var(--transition-normal);
}

.hover-tilt:hover {
    transform: perspective(1000px) rotateX(5deg) rotateY(5deg);
}

/* ==========================================================================
   4. LOADING ANIMATIONS
   ========================================================================== */

/* Spinner */
.spin {
    animation: spin 1s linear infinite;
}

.spin-slow {
    animation: spin 2s linear infinite;
}

.spin-fast {
    animation: spin 0.5s linear infinite;
}

/* Pulse */
.pulse {
    animation: pulse 2s ease-in-out infinite;
}

/* Bounce */
.bounce {
    animation: bounce 2s infinite;
}

/* Float */
.float {
    animation: float 3s ease-in-out infinite;
}

/* Shimmer */
.shimmer {
    background: linear-gradient(
        90deg,
        var(--glass) 25%,
        var(--glass-white-10) 50%,
        var(--glass) 75%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

/* ==========================================================================
   5. SPECIAL EFFECTS
   ========================================================================== */

/* Gradient text animation */
.gradient-text-animated {
    background: linear-gradient(135deg, var(--primary), var(--primary-light), #fff, var(--primary));
    background-size: 300% 300%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: gradientMove 4s ease infinite;
}

/* Glitch text effect */
.glitch-text {
    position: relative;
}

.glitch-text::before,
.glitch-text::after {
    content: attr(data-text);
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.glitch-text::before {
    left: 2px;
    text-shadow: -2px 0 var(--error);
    clip: rect(24px, 550px, 90px, 0);
    animation: glitch 2s infinite linear alternate-reverse;
}

.glitch-text::after {
    left: -2px;
    text-shadow: -2px 0 var(--info);
    clip: rect(85px, 550px, 140px, 0);
    animation: glitch 2s infinite linear alternate-reverse;
    animation-delay: -1s;
}

/* Typing effect container */
.typing-text {
    overflow: hidden;
    border-right: 2px solid var(--primary);
    white-space: nowrap;
    animation: typing 3.5s steps(40, end), blink 0.75s step-end infinite;
}

/* Magnetic button effect (requires JS) */
.magnetic-btn {
    transition: transform var(--transition-fast);
}

/* Ripple effect container */
.ripple-effect {
    position: relative;
    overflow: hidden;
}

.ripple-effect .ripple,
.btn .ripple {
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: scale(0);
    animation: ripple 0.6s linear;
    pointer-events: none;
}

.btn-primary .ripple {
    background: rgba(0, 0, 0, 0.15);
}

/* Parallax container */
.parallax {
    transform-style: preserve-3d;
}

.parallax-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

/* Particles container */
.particles-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    pointer-events: none;
}

.particle {
    position: absolute;
    width: 4px;
    height: 4px;
    background: var(--primary);
    border-radius: 50%;
    opacity: 0.5;
    animation: floatParticle 15s infinite linear;
}

/* Glowing orbs */
.orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    animation: orbFloat 8s ease-in-out infinite;
}

.orb-primary {
    background: rgba(59, 130, 246, 0.15);
}

.orb-secondary {
    background: rgba(240, 201, 41, 0.1);
}

/* Scroll progress bar */
.scroll-progress {
    position: fixed;
    top: 0;
    left: 0;
    width: 0%;
    height: 3px;
    background: linear-gradient(90deg, var(--primary), var(--primary-light));
    z-index: var(--z-max);
    transition: width 0.1s;
}

/* Hero content reveal */
.hero-reveal {
    overflow: hidden;
}

.hero-reveal .line {
    display: block;
    overflow: hidden;
}

.hero-reveal .line-inner {
    display: block;
    transform: translateY(110%);
    animation: textReveal 1.2s cubic-bezier(0.77, 0, 0.175, 1) forwards;
}

.hero-reveal .line:nth-child(1) .line-inner { animation-delay: 0.3s; }
.hero-reveal .line:nth-child(2) .line-inner { animation-delay: 0.45s; }
.hero-reveal .line:nth-child(3) .line-inner { animation-delay: 0.6s; }

/* Marquee infinite scroll */
.marquee-wrapper {
    overflow: hidden;
}

.marquee-track {
    display: flex;
    animation: marquee 25s linear infinite;
}

.marquee-track:hover {
    animation-play-state: paused;
}

.marquee-content {
    display: flex;
    flex-shrink: 0;
}

/* Image gallery auto scroll */
.gallery-scroll {
    display: flex;
    gap: var(--space-6);
    animation: marquee 40s linear infinite;
}

.gallery-scroll:hover {
    animation-play-state: paused;
}

/* WhatsApp pulse animation */
.whatsapp-pulse {
    animation: pulseGlow 2s ease-in-out infinite;
}

/* Card hover overlay reveal */
.card-overlay-reveal {
    position: relative;
    overflow: hidden;
}

.card-overlay-reveal .overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, var(--darker));
    transform: translateY(100%);
    transition: transform var(--transition-normal);
}

.card-overlay-reveal:hover .overlay {
    transform: translateY(0);
}

/* Image grayscale to color */
.grayscale-hover img {
    filter: grayscale(100%);
    transition: filter var(--transition-slow);
}

.grayscale-hover:hover img {
    filter: grayscale(0%);
}

/* Delay utilities */
.delay-100 { animation-delay: 0.1s; }
.delay-200 { animation-delay: 0.2s; }
.delay-300 { animation-delay: 0.3s; }
.delay-400 { animation-delay: 0.4s; }
.delay-500 { animation-delay: 0.5s; }
.delay-600 { animation-delay: 0.6s; }
.delay-700 { animation-delay: 0.7s; }
.delay-800 { animation-delay: 0.8s; }
.delay-900 { animation-delay: 0.9s; }
.delay-1000 { animation-delay: 1s; }

/* Duration utilities */
.duration-fast { animation-duration: 0.3s; }
.duration-normal { animation-duration: 0.5s; }
.duration-slow { animation-duration: 0.8s; }
.duration-slower { animation-duration: 1.2s; }

/* Animation fill mode */
.fill-forwards { animation-fill-mode: forwards; }
.fill-backwards { animation-fill-mode: backwards; }
.fill-both { animation-fill-mode: both; }

/* Reduce motion for accessibility */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ==========================================================================
   MOBILE FALLBACK - Ensure elements are visible without JS animation trigger
   ========================================================================== */
@media (max-width: 768px) {
    /* Make animated elements visible on mobile without requiring JS trigger */
    .animate-on-scroll,
    .animate-left,
    .animate-right,
    .animate-scale,
    .animate-fade {
        opacity: 1 !important;
        transform: none !important;
    }

    .stagger-children > * {
        opacity: 1 !important;
        transform: none !important;
    }

    /* Ensure hero slides are visible on mobile */
    .hero-slide {
        opacity: 1 !important;
        visibility: visible !important;
    }

    .hero-slide:not(:first-child) {
        opacity: 0 !important;
        visibility: hidden !important;
    }

    .hero-slide:first-child,
    .hero-slide.active {
        opacity: 1 !important;
        visibility: visible !important;
    }

    /* Ensure hero content is visible */
    .hero-content,
    .hero-badge,
    .hero-title,
    .hero-description,
    .hero-buttons {
        opacity: 1 !important;
        visibility: visible !important;
        transform: none !important;
    }

    /* Hero reveal animations - make visible */
    .hero-reveal,
    .hero-reveal .line,
    .hero-reveal .line-inner {
        opacity: 1 !important;
        transform: none !important;
    }

    /* Hide preloader on mobile after load - CSS fallback */
    .preloader {
        display: none !important;
    }

    /* Ensure all major sections are visible */
    .section,
    .coaches-section,
    .programs-section,
    .about-section,
    .testimonials-section,
    .cta-section,
    .facilities-section,
    .achievements-section,
    .accreditations-showcase {
        opacity: 1 !important;
        visibility: visible !important;
    }

    /* Ensure cards are visible */
    .coach-card,
    .program-card,
    .facility-home-card,
    .achievement-card,
    .accreditation-showcase-card,
    .testimonial-card {
        opacity: 1 !important;
        visibility: visible !important;
        transform: none !important;
    }
}
