/* ============================================
   MAGIC IMAGE Group - Animations
   Smooth & Modern Animations
   ============================================ */

/* Fade Animations */
.animate-fade-in {
    animation: fadeIn 1s ease forwards;
}

.animate-fade-up {
    opacity: 0;
    transform: translateY(30px);
    animation: fadeUp 1s ease forwards;
}

.animate-fade-up.delay-1 {
    animation-delay: 0.2s;
}

.animate-fade-up.delay-2 {
    animation-delay: 0.4s;
}

.animate-fade-up.delay-3 {
    animation-delay: 0.6s;
}

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

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

/* Scroll Trigger Animations */
.animate-on-scroll {
    opacity: 0;
    transform: translateY(40px);
    transition: all 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    transition-delay: var(--delay, 0s);
}

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

/* Scale Animation */
.animate-scale {
    opacity: 0;
    transform: scale(0.9);
    transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

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

/* Slide Animations */
.slide-left {
    opacity: 0;
    transform: translateX(-50px);
    transition: all 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

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

.slide-right {
    opacity: 0;
    transform: translateX(50px);
    transition: all 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

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

/* Stagger Animation for Lists */
.stagger-item {
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.5s ease;
}

.stagger-item.animated {
    opacity: 1;
    transform: translateY(0);
}

/* Hover Effects */
.hover-lift {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.hover-lift:hover {
    transform: translateY(-10px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}

.hover-glow {
    transition: box-shadow 0.3s ease;
}

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

.hover-scale {
    transition: transform 0.3s ease;
}

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

/* Gradient Animation */
.gradient-animate {
    background: linear-gradient(-45deg, #6366f1, #ec4899, #f59e0b, #10b981);
    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%; }
}

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

.text-reveal span {
    display: inline-block;
    transform: translateY(100%);
    animation: textReveal 0.8s ease forwards;
}

@keyframes textReveal {
    to {
        transform: translateY(0);
    }
}

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

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

@keyframes blink-caret {
    from, to { border-color: transparent; }
    50% { border-color: var(--primary); }
}

/* Floating Animation */
.float {
    animation: floatAnimation 6s ease-in-out infinite;
}

@keyframes floatAnimation {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-20px);
    }
}

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

@keyframes pulseAnimation {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.05);
        opacity: 0.8;
    }
}

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

@keyframes glowPulse {
    0%, 100% {
        box-shadow: 0 0 5px var(--primary), 0 0 10px var(--primary), 0 0 15px var(--primary);
    }
    50% {
        box-shadow: 0 0 10px var(--primary), 0 0 20px var(--primary), 0 0 30px var(--primary);
    }
}

/* Rotate Animation */
.rotate {
    animation: rotate360 20s linear infinite;
}

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

/* Shimmer Effect */
.shimmer {
    position: relative;
    overflow: hidden;
}

.shimmer::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.1),
        transparent
    );
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    100% {
        left: 100%;
    }
}

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

@keyframes bounceAnimation {
    0%, 20%, 50%, 80%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-30px);
    }
    60% {
        transform: translateY(-15px);
    }
}

/* Wave Animation */
.wave {
    animation: waveAnimation 3s ease-in-out infinite;
}

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

/* Counter Animation */
.counter-animation {
    display: inline-block;
}

/* Progress Bar Animation */
.progress-fill {
    width: 0;
    transition: width 1.5s ease-in-out;
}

.progress-fill.animated {
    width: var(--progress, 100%);
}

/* Card Flip */
.flip-card {
    perspective: 1000px;
}

.flip-card-inner {
    transition: transform 0.8s;
    transform-style: preserve-3d;
}

.flip-card:hover .flip-card-inner {
    transform: rotateY(180deg);
}

.flip-card-front, .flip-card-back {
    backface-visibility: hidden;
}

.flip-card-back {
    transform: rotateY(180deg);
}

/* Morphing Shape */
.morph {
    animation: morphShape 10s ease-in-out infinite;
}

@keyframes morphShape {
    0%, 100% {
        border-radius: 60% 40% 30% 70% / 60% 30% 70% 40%;
    }
    50% {
        border-radius: 30% 60% 70% 40% / 50% 60% 30% 60%;
    }
}

/* Parallax Layer */
.parallax-layer {
    will-change: transform;
    transition: transform 0.1s linear;
}

/* Blur In Animation */
.blur-in {
    filter: blur(20px);
    opacity: 0;
    transition: filter 1s ease, opacity 1s ease;
}

.blur-in.animated {
    filter: blur(0);
    opacity: 1;
}

/* Split Text Animation */
.split-text .char {
    display: inline-block;
    opacity: 0;
    transform: translateY(50px) rotateX(-90deg);
    animation: splitTextReveal 0.8s ease forwards;
}

@keyframes splitTextReveal {
    to {
        opacity: 1;
        transform: translateY(0) rotateX(0);
    }
}

/* Magnetic Button Effect */
.magnetic {
    position: relative;
    transition: transform 0.3s ease;
}

/* Border Animation */
.border-animate {
    position: relative;
    overflow: hidden;
}

.border-animate::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 2px solid transparent;
    border-radius: inherit;
    animation: borderRotate 4s linear infinite;
}

@keyframes borderRotate {
    0% {
        border-color: var(--primary);
        border-width: 2px 0 0 0;
    }
    25% {
        border-color: var(--primary);
        border-width: 0 2px 0 0;
    }
    50% {
        border-color: var(--secondary);
        border-width: 0 0 2px 0;
    }
    75% {
        border-color: var(--secondary);
        border-width: 0 0 0 2px;
    }
    100% {
        border-color: var(--primary);
        border-width: 2px 0 0 0;
    }
}

/* Neon Glow */
.neon-glow {
    text-shadow: 
        0 0 5px var(--primary),
        0 0 10px var(--primary),
        0 0 20px var(--primary),
        0 0 40px var(--primary);
    animation: neonFlicker 2s ease-in-out infinite alternate;
}

@keyframes neonFlicker {
    0%, 19%, 21%, 23%, 25%, 54%, 56%, 100% {
        text-shadow: 
            0 0 5px var(--primary),
            0 0 10px var(--primary),
            0 0 20px var(--primary),
            0 0 40px var(--primary);
    }
    20%, 24%, 55% {
        text-shadow: none;
    }
}

/* 3D Tilt Effect */
.tilt-3d {
    transition: transform 0.3s ease;
    transform-style: preserve-3d;
}

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

/* Line Draw Animation */
.line-draw {
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
    animation: lineDraw 3s ease forwards;
}

@keyframes lineDraw {
    to {
        stroke-dashoffset: 0;
    }
}

/* Ripple Effect */
.ripple {
    position: relative;
    overflow: hidden;
}

.ripple::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.ripple:active::after {
    width: 300px;
    height: 300px;
}

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

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

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

/* Elastic Animation */
.elastic {
    animation: elastic 1s ease;
}

@keyframes elastic {
    0% { transform: scale(1); }
    30% { transform: scale(1.25); }
    40% { transform: scale(0.75); }
    50% { transform: scale(1.15); }
    65% { transform: scale(0.95); }
    75% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

/* Fade In Up Stagger */
.fade-in-up-stagger > * {
    opacity: 0;
    transform: translateY(30px);
}

.fade-in-up-stagger.animated > *:nth-child(1) { animation: fadeUp 0.6s ease 0.1s forwards; }
.fade-in-up-stagger.animated > *:nth-child(2) { animation: fadeUp 0.6s ease 0.2s forwards; }
.fade-in-up-stagger.animated > *:nth-child(3) { animation: fadeUp 0.6s ease 0.3s forwards; }
.fade-in-up-stagger.animated > *:nth-child(4) { animation: fadeUp 0.6s ease 0.4s forwards; }
.fade-in-up-stagger.animated > *:nth-child(5) { animation: fadeUp 0.6s ease 0.5s forwards; }
.fade-in-up-stagger.animated > *:nth-child(6) { animation: fadeUp 0.6s ease 0.6s forwards; }

/* Smooth Scrolling Enhancement */
html {
    scroll-behavior: smooth;
}

/* Reduced Motion */
@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;
    }
}

/* Performance Optimization */
.will-change-transform {
    will-change: transform;
}

.will-change-opacity {
    will-change: opacity;
}

/* GPU Acceleration */
.gpu-accelerate {
    transform: translateZ(0);
    backface-visibility: hidden;
}
