/**
 * Advanced Animations CSS
 * IT Allies Neuro Theme
 * 
 * Provides CSS classes for:
 * - Scroll Animations
 * - Counter Animations
 * - Parallax Effects
 * - Page Transitions
 * - Reveal Animations
 */

/* ============================================
   1. SCROLL ANIMATIONS BASE
   ============================================ */

/* Disable animations initially */
[data-animate]:not(.is-animated),
.animate-on-scroll:not(.is-animated),
.fade-in:not(.is-animated),
.fade-in-up:not(.is-animated),
.fade-in-down:not(.is-animated),
.fade-in-left:not(.is-animated),
.fade-in-right:not(.is-animated),
.scale-in:not(.is-animated),
.rotate-in:not(.is-animated) {
    opacity: 0;
}


/* ============================================
   2. FADE ANIMATIONS
   ============================================ */

/* Fade In */
.fade-in {
    animation: fadeIn 0.8s ease-out forwards;
}

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

/* Fade In Up */
.fade-in-up {
    animation: fadeInUp 0.8s ease-out forwards;
}

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

/* Fade In Down */
.fade-in-down {
    animation: fadeInDown 0.8s ease-out forwards;
}

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

/* Fade In Left */
.fade-in-left {
    animation: fadeInLeft 0.8s ease-out forwards;
}

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

/* Fade In Right */
.fade-in-right {
    animation: fadeInRight 0.8s ease-out forwards;
}

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


/* ============================================
   3. SCALE ANIMATIONS
   ============================================ */

/* Scale In */
.scale-in {
    animation: scaleIn 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

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

/* Scale In Bounce */
.scale-in-bounce {
    animation: scaleInBounce 0.8s cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards;
}

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


/* ============================================
   4. ROTATE ANIMATIONS
   ============================================ */

/* Rotate In */
.rotate-in {
    animation: rotateIn 0.8s ease-out forwards;
}

@keyframes rotateIn {
    from {
        opacity: 0;
        transform: rotate(-180deg) scale(0.8);
    }
    to {
        opacity: 1;
        transform: rotate(0) scale(1);
    }
}


/* ============================================
   5. SLIDE ANIMATIONS
   ============================================ */

/* Slide In Up */
.slide-in-up {
    animation: slideInUp 0.6s ease-out forwards;
}

@keyframes slideInUp {
    from {
        transform: translateY(100%);
    }
    to {
        transform: translateY(0);
    }
}

/* Slide In Down */
.slide-in-down {
    animation: slideInDown 0.6s ease-out forwards;
}

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


/* ============================================
   6. COUNTER ANIMATIONS
   ============================================ */

.counter,
.stat-number,
[data-counter] {
    font-variant-numeric: tabular-nums;
    transition: transform 0.3s ease;
}

.counter.is-counted,
.stat-number.is-counted {
    animation: counterPulse 0.4s ease-out;
}

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


/* ============================================
   7. PARALLAX EFFECTS
   ============================================ */

.parallax,
.parallax-bg,
[data-parallax] {
    will-change: transform;
    transition: transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* Parallax container should have overflow hidden */
.parallax-container {
    overflow: hidden;
    position: relative;
}

/* Background parallax */
.parallax-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 120%;
    object-fit: cover;
    z-index: -1;
}


/* ============================================
   8. PAGE TRANSITIONS
   ============================================ */

/* Transition Overlay */
.page-transition-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, 
        rgba(99, 102, 241, 0.95) 0%, 
        rgba(139, 92, 246, 0.95) 50%,
        rgba(236, 72, 153, 0.95) 100%
    );
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.page-transition-overlay.is-active {
    opacity: 1;
    pointer-events: all;
}

/* Loader Animation */
.page-transition-loader {
    display: flex;
    gap: 12px;
}

.loader-circle {
    width: 16px;
    height: 16px;
    background: white;
    border-radius: 50%;
    animation: loaderPulse 1.4s ease-in-out infinite;
}

.loader-circle:nth-child(2) {
    animation-delay: 0.2s;
}

.loader-circle:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes loaderPulse {
    0%, 80%, 100% {
        transform: scale(0.6);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}


/* ============================================
   9. STAGGER ANIMATIONS
   ============================================ */

/* Children of stagger container animate with delay */
[data-stagger] > * {
    opacity: 0;
    animation: fadeInUp 0.6s ease-out forwards;
}

/* Example: Cards in grid */
.wp-block-query [data-stagger] .wp-block-group {
    animation-fill-mode: both;
}


/* ============================================
   10. REVEAL ON SCROLL
   ============================================ */

.reveal-on-scroll {
    opacity: 0;
    transition: all 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.reveal-on-scroll.is-revealed {
    opacity: 1;
}

/* Reveal directions */
.reveal-on-scroll[data-reveal="up"]:not(.is-revealed) {
    transform: translateY(60px);
}

.reveal-on-scroll[data-reveal="down"]:not(.is-revealed) {
    transform: translateY(-60px);
}

.reveal-on-scroll[data-reveal="left"]:not(.is-revealed) {
    transform: translateX(60px);
}

.reveal-on-scroll[data-reveal="right"]:not(.is-revealed) {
    transform: translateX(-60px);
}

.reveal-on-scroll.is-revealed {
    transform: translate(0, 0);
}


/* ============================================
   11. ADVANCED ANIMATIONS
   ============================================ */

/* Bounce In */
.bounce-in {
    animation: bounceIn 0.8s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

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

/* Flip In */
.flip-in {
    animation: flipIn 0.8s ease-out;
}

@keyframes flipIn {
    from {
        opacity: 0;
        transform: perspective(400px) rotateY(90deg);
    }
    to {
        opacity: 1;
        transform: perspective(400px) rotateY(0);
    }
}

/* Zoom In */
.zoom-in {
    animation: zoomIn 0.6s ease-out;
}

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


/* ============================================
   12. HOVER ANIMATIONS (BONUS)
   ============================================ */

/* Float on Hover */
.hover-float {
    transition: transform 0.3s ease;
}

.hover-float:hover {
    transform: translateY(-8px);
}

/* Grow on Hover */
.hover-grow {
    transition: transform 0.3s ease;
}

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

/* Rotate on Hover */
.hover-rotate {
    transition: transform 0.3s ease;
}

.hover-rotate:hover {
    transform: rotate(5deg);
}

/* Glow on Hover */
.hover-glow {
    transition: box-shadow 0.3s ease;
}

.hover-glow:hover {
    box-shadow: 0 0 30px rgba(99, 102, 241, 0.6);
}


/* ============================================
   13. LOADING ANIMATIONS
   ============================================ */

/* Pulse */
.animate-pulse {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

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

/* Spin */
.animate-spin {
    animation: spin 1s linear infinite;
}

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

/* Ping */
.animate-ping {
    animation: ping 1s cubic-bezier(0, 0, 0.2, 1) infinite;
}

@keyframes ping {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    75%, 100% {
        transform: scale(2);
        opacity: 0;
    }
}

/* Bounce */
.animate-bounce {
    animation: bounce 1s infinite;
}

@keyframes bounce {
    0%, 100% {
        transform: translateY(0);
        animation-timing-function: cubic-bezier(0.8, 0, 1, 1);
    }
    50% {
        transform: translateY(-25%);
        animation-timing-function: cubic-bezier(0, 0, 0.2, 1);
    }
}


/* ============================================
   14. GRADIENT ANIMATIONS
   ============================================ */

/* Animated Gradient Background */
.gradient-animate {
    background: linear-gradient(-45deg, #6366f1, #8b5cf6, #ec4899, #6366f1);
    background-size: 400% 400%;
    animation: gradientShift 15s ease infinite;
}

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


/* ============================================
   15. TEXT ANIMATIONS
   ============================================ */

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

@keyframes typing {
    from {
        width: 0;
    }
    to {
        width: 100%;
    }
}

@keyframes blink {
    from, to {
        border-color: transparent;
    }
    50% {
        border-color: #6366f1;
    }
}

/* Gradient Text Shimmer */
.text-shimmer {
    background: linear-gradient(90deg, #6366f1, #8b5cf6, #ec4899, #6366f1);
    background-size: 200% auto;
    color: transparent;
    -webkit-background-clip: text;
    background-clip: text;
    animation: textShimmer 3s linear infinite;
}

@keyframes textShimmer {
    to {
        background-position: 200% center;
    }
}


/* ============================================
   16. PERFORMANCE OPTIMIZATIONS
   ============================================ */

/* Use GPU acceleration for animations */
.parallax,
.animate-on-scroll,
[data-parallax],
[data-animate] {
    will-change: transform, opacity;
    backface-visibility: hidden;
    perspective: 1000px;
}

/* Remove will-change after animation completes */
.is-animated {
    will-change: auto;
}


/* ============================================
   17. 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;
    }
    
    /* Disable parallax */
    .parallax,
    [data-parallax] {
        transform: none !important;
    }
    
    /* Show content immediately */
    [data-animate]:not(.is-animated),
    .animate-on-scroll:not(.is-animated),
    .fade-in:not(.is-animated),
    .reveal-on-scroll {
        opacity: 1 !important;
        transform: none !important;
    }
}


/* ============================================
   18. CUSTOM ANIMATION UTILITIES
   ============================================ */

/* Animation Delays */
.delay-100 { animation-delay: 100ms; }
.delay-200 { animation-delay: 200ms; }
.delay-300 { animation-delay: 300ms; }
.delay-400 { animation-delay: 400ms; }
.delay-500 { animation-delay: 500ms; }
.delay-1000 { animation-delay: 1000ms; }

/* Animation Durations */
.duration-300 { animation-duration: 300ms; }
.duration-500 { animation-duration: 500ms; }
.duration-700 { animation-duration: 700ms; }
.duration-1000 { animation-duration: 1000ms; }


/* ============================================
   19. WORDPRESS BLOCK SPECIFIC
   ============================================ */

/* Animate WordPress Blocks on scroll */
.wp-block-group.animate-on-scroll,
.wp-block-columns.animate-on-scroll,
.wp-block-cover.animate-on-scroll {
    opacity: 0;
    transition: opacity 0.8s ease, transform 0.8s ease;
}

.wp-block-group.animate-on-scroll.is-animated,
.wp-block-columns.animate-on-scroll.is-animated,
.wp-block-cover.animate-on-scroll.is-animated {
    opacity: 1;
}


/* ============================================
   20. PRINT STYLES
   ============================================ */

@media print {
    .page-transition-overlay,
    .parallax-bg {
        display: none !important;
    }
    
    * {
        animation: none !important;
        transition: none !important;
    }
}
