/*
 * Modern Animations CSS
 * Advanced animation library for modern components
 * Version: 1.0.0
 */

/* ===================================
   Intersection Observer Animations
=================================== */

/* Base Animation Classes */
[data-animate] {
    opacity: 0;
    will-change: transform, opacity;
}

[data-animate].animated {
    opacity: 1;
}

/* Fade Animations */
[data-animate="fade-in"] {
    transition: opacity 0.6s ease;
}

[data-animate="fade-in"].animated {
    opacity: 1;
}

[data-animate="fade-in-up"] {
    transform: translateY(30px);
    transition: all 0.6s ease;
}

[data-animate="fade-in-up"].animated {
    opacity: 1;
    transform: translateY(0);
}

[data-animate="fade-in-down"] {
    transform: translateY(-30px);
    transition: all 0.6s ease;
}

[data-animate="fade-in-down"].animated {
    opacity: 1;
    transform: translateY(0);
}

[data-animate="fade-in-left"] {
    transform: translateX(-30px);
    transition: all 0.6s ease;
}

[data-animate="fade-in-left"].animated {
    opacity: 1;
    transform: translateX(0);
}

[data-animate="fade-in-right"] {
    transform: translateX(30px);
    transition: all 0.6s ease;
}

[data-animate="fade-in-right"].animated {
    opacity: 1;
    transform: translateX(0);
}

/* Scale Animations */
[data-animate="scale-in"] {
    transform: scale(0.8);
    transition: all 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

[data-animate="scale-in"].animated {
    opacity: 1;
    transform: scale(1);
}

[data-animate="scale-in-bounce"] {
    transform: scale(0.3);
    transition: all 0.8s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

[data-animate="scale-in-bounce"].animated {
    opacity: 1;
    transform: scale(1);
}

/* Slide Animations */
[data-animate="slide-up"] {
    transform: translateY(50px);
    transition: all 0.6s ease;
}

[data-animate="slide-up"].animated {
    opacity: 1;
    transform: translateY(0);
}

[data-animate="slide-down"] {
    transform: translateY(-50px);
    transition: all 0.6s ease;
}

[data-animate="slide-down"].animated {
    opacity: 1;
    transform: translateY(0);
}

[data-animate="slide-left"] {
    transform: translateX(50px);
    transition: all 0.6s ease;
}

[data-animate="slide-left"].animated {
    opacity: 1;
    transform: translateX(0);
}

[data-animate="slide-right"] {
    transform: translateX(-50px);
    transition: all 0.6s ease;
}

[data-animate="slide-right"].animated {
    opacity: 1;
    transform: translateX(0);
}

/* Rotation Animations */
[data-animate="rotate-in"] {
    transform: rotate(-180deg);
    transition: all 0.6s ease;
}

[data-animate="rotate-in"].animated {
    opacity: 1;
    transform: rotate(0deg);
}

/* Flip Animations */
[data-animate="flip-in"] {
    transform: perspective(400px) rotateY(90deg);
    transition: all 0.6s ease;
}

[data-animate="flip-in"].animated {
    opacity: 1;
    transform: perspective(400px) rotateY(0deg);
}

/* Stagger Animations */
[data-animate="stagger-in"] .modern-grid-item,
[data-animate="stagger-in"] .glass-card,
[data-animate="stagger-in"] .sidebar-widget {
    opacity: 0;
    transform: translateY(30px);
    transition: all 0.6s ease;
}

[data-animate="stagger-in"].animated .modern-grid-item:nth-child(1),
[data-animate="stagger-in"].animated .glass-card:nth-child(1),
[data-animate="stagger-in"].animated .sidebar-widget:nth-child(1) {
    transition-delay: 0.1s;
    opacity: 1;
    transform: translateY(0);
}

[data-animate="stagger-in"].animated .modern-grid-item:nth-child(2),
[data-animate="stagger-in"].animated .glass-card:nth-child(2),
[data-animate="stagger-in"].animated .sidebar-widget:nth-child(2) {
    transition-delay: 0.2s;
    opacity: 1;
    transform: translateY(0);
}

[data-animate="stagger-in"].animated .modern-grid-item:nth-child(3),
[data-animate="stagger-in"].animated .glass-card:nth-child(3),
[data-animate="stagger-in"].animated .sidebar-widget:nth-child(3) {
    transition-delay: 0.3s;
    opacity: 1;
    transform: translateY(0);
}

[data-animate="stagger-in"].animated .modern-grid-item:nth-child(n+4),
[data-animate="stagger-in"].animated .glass-card:nth-child(n+4),
[data-animate="stagger-in"].animated .sidebar-widget:nth-child(n+4) {
    transition-delay: 0.4s;
    opacity: 1;
    transform: translateY(0);
}

/* ===================================
   Continuous Animations
=================================== */

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

.animate-float {
    animation: modernFloat 3s ease-in-out infinite;
}

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

.animate-pulse {
    animation: modernPulse 2s ease-in-out infinite;
}

/* Bounce Animation */
@keyframes modernBounce {
    0%, 20%, 50%, 80%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-10px);
    }
    60% {
        transform: translateY(-5px);
    }
}

.animate-bounce {
    animation: modernBounce 2s infinite;
}

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

.animate-shake {
    animation: modernShake 0.8s ease-in-out;
}

/* Glow Animation */
@keyframes modernGlow {
    0%, 100% {
        box-shadow: 0 0 5px rgba(102, 126, 234, 0.3);
    }
    50% {
        box-shadow: 0 0 20px rgba(102, 126, 234, 0.6), 0 0 30px rgba(102, 126, 234, 0.4);
    }
}

.animate-glow {
    animation: modernGlow 2s ease-in-out infinite;
}

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

.animate-gradient {
    background: linear-gradient(-45deg, #667eea, #764ba2, #667eea, #764ba2);
    background-size: 400% 400%;
    animation: modernGradient 3s ease infinite;
}

/* ===================================
   Hover Animations
=================================== */

/* Hover Lift */
.hover-lift {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.hover-lift:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
}

/* Hover Scale */
.hover-scale {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

/* Hover Rotate */
.hover-rotate {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

/* Hover Tilt */
.hover-tilt {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

/* Hover Shine */
.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.4), transparent);
    transition: left 0.5s ease;
}

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

/* ===================================
   Loading Animations
=================================== */

/* Skeleton Loading */
@keyframes modernSkeleton {
    0% {
        background-position: -200px 0;
    }
    100% {
        background-position: calc(200px + 100%) 0;
    }
}

.skeleton-loading {
    background-color: #f2f2f2;
    background-image: linear-gradient(90deg, #f2f2f2, #e6e6e6, #f2f2f2);
    background-size: 200px 100%;
    background-repeat: no-repeat;
    animation: modernSkeleton 1.2s ease-in-out infinite;
}

/* Spinner Loading */
@keyframes modernSpinner {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

.spinner-loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid rgba(102, 126, 234, 0.3);
    border-radius: 50%;
    border-top-color: #667eea;
    animation: modernSpinner 0.8s linear infinite;
}

/* Dots Loading */
@keyframes modernDots {
    0%, 80%, 100% {
        transform: scale(0);
    }
    40% {
        transform: scale(1);
    }
}

.dots-loading {
    display: inline-block;
    position: relative;
    width: 64px;
    height: 20px;
}

.dots-loading div {
    position: absolute;
    top: 50%;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #667eea;
    animation-timing-function: cubic-bezier(0, 1, 1, 0);
    transform: translateY(-50%);
}

.dots-loading div:nth-child(1) {
    left: 8px;
    animation: modernDots 0.6s infinite;
    animation-delay: -0.24s;
}

.dots-loading div:nth-child(2) {
    left: 24px;
    animation: modernDots 0.6s infinite;
    animation-delay: -0.12s;
}

.dots-loading div:nth-child(3) {
    left: 40px;
    animation: modernDots 0.6s infinite;
}

/* ===================================
   Page Transition Animations
=================================== */

/* Fade Page Transition */
.page-transition-fade {
    animation: pageTransitionFade 0.5s ease-in-out;
}

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

/* Slide Page Transition */
.page-transition-slide {
    animation: pageTransitionSlide 0.5s ease-in-out;
}

@keyframes pageTransitionSlide {
    from {
        transform: translateX(100%);
    }
    to {
        transform: translateX(0);
    }
}

/* ===================================
   Morphing Animations
=================================== */

/* Button Morphing */
.btn-morph {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-morph:hover {
    border-radius: 0.5rem;
    padding: 1rem 2rem;
}

/* Card Morphing */
.card-morph {
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.card-morph:hover {
    border-radius: 2rem;
    transform: scale(1.02);
}

/* ===================================
   Parallax Effect
=================================== */

.parallax-element {
    will-change: transform;
}

/* ===================================
   Performance Optimizations
=================================== */

/* 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;
        scroll-behavior: auto !important;
    }
    
    [data-animate] {
        opacity: 1 !important;
        transform: none !important;
    }
}

/* GPU Acceleration for Better Performance */
.gpu-accelerated {
    transform: translate3d(0, 0, 0);
    backface-visibility: hidden;
    perspective: 1000px;
}

/* ===================================
   Animation Utilities
=================================== */

/* Animation Delays */
.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; }

/* Animation Durations */
.duration-fast { animation-duration: 0.15s; transition-duration: 0.15s; }
.duration-normal { animation-duration: 0.3s; transition-duration: 0.3s; }
.duration-slow { animation-duration: 0.5s; transition-duration: 0.5s; }
.duration-slower { animation-duration: 0.75s; transition-duration: 0.75s; }

/* Animation Easing */
.ease-linear { animation-timing-function: linear; transition-timing-function: linear; }
.ease-in { animation-timing-function: cubic-bezier(0.4, 0, 1, 1); transition-timing-function: cubic-bezier(0.4, 0, 1, 1); }
.ease-out { animation-timing-function: cubic-bezier(0, 0, 0.2, 1); transition-timing-function: cubic-bezier(0, 0, 0.2, 1); }
.ease-in-out { animation-timing-function: cubic-bezier(0.4, 0, 0.2, 1); transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1); }

/* ===================================
   Animation Control Classes
=================================== */

.animation-paused { animation-play-state: paused; }
.animation-running { animation-play-state: running; }

.animation-infinite { animation-iteration-count: infinite; }
.animation-once { animation-iteration-count: 1; }
.animation-twice { animation-iteration-count: 2; }