/* Animation Styles for MagisTV Premium Theme - Mobile Optimized */

/* Performance First Approach */
.animate-on-scroll,
.hover-lift,
.hover-scale,
.hover-rotate,
.btn-animate,
.glow-effect {
    will-change: transform, opacity;
    backface-visibility: hidden;
    transform: translateZ(0);
}

/* Scroll Animations - Mobile Optimized */
.animate-on-scroll {
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.animate-on-scroll.animated {
    opacity: 1;
    transform: translateY(0);
}

/* Counter Animation - Lighter for Mobile */
@keyframes countUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.counter-animate {
    animation: countUp 0.4s ease-out;
}

/* Loading Animation - Mobile Friendly */
.loading-spinner {
    display: inline-block;
    width: 30px;
    height: 30px;
    border: 3px solid rgba(37, 99, 235, 0.2);
    border-radius: 50%;
    border-top-color: var(--primary);
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Hover Animations - Mobile Safe */
.hover-lift {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.hover-lift:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
}

.hover-scale {
    transition: transform 0.2s ease;
}

.hover-scale:hover {
    transform: scale(1.03);
}

.hover-rotate {
    transition: transform 0.3s ease;
}

.hover-rotate:hover {
    transform: rotate(3deg);
}

/* Button Animations - Performance Optimized */
.btn-animate {
    position: relative;
    overflow: hidden;
    transform: translateZ(0);
}

.btn-animate::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    transition: left 0.6s;
}

.btn-animate:hover::before {
    left: 100%;
}

/* Typing Animation - Mobile Optimized */
.typing-animation {
    overflow: hidden;
    border-right: 2px solid var(--primary);
    white-space: nowrap;
    margin: 0 auto;
    animation: typing 2.5s steps(30, end), blink-caret 0.8s step-end infinite;
}

@keyframes typing {
    from {
        width: 0;
    }
    to {
        width: 100%;
    }
}

@keyframes blink-caret {
    from, to {
        border-color: transparent;
    }
    50% {
        border-color: var(--primary);
    }
}

/* Stagger Animation - Mobile Friendly */
.stagger-animation > * {
    opacity: 0;
    transform: translateY(20px);
    animation: staggerFadeIn 0.4s ease-out forwards;
}

.stagger-animation > *:nth-child(1) { animation-delay: 0.05s; }
.stagger-animation > *:nth-child(2) { animation-delay: 0.1s; }
.stagger-animation > *:nth-child(3) { animation-delay: 0.15s; }
.stagger-animation > *:nth-child(4) { animation-delay: 0.2s; }
.stagger-animation > *:nth-child(5) { animation-delay: 0.25s; }
.stagger-animation > *:nth-child(6) { animation-delay: 0.3s; }

@keyframes staggerFadeIn {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Floating Animation - Lighter for Mobile */
.float-animation {
    animation: float 4s ease-in-out infinite;
}

@keyframes float {
    0%, 100% {
        transform: translateY(0px);
    }
    50% {
        transform: translateY(-10px);
    }
}

/* Progress Bar Animation */
.progress-bar {
    width: 100%;
    height: 3px;
    background: rgba(37, 99, 235, 0.1);
    border-radius: 2px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--gradient);
    border-radius: 2px;
    transform: translateX(-100%);
    transition: transform 0.8s cubic-bezier(0.65, 0, 0.35, 1);
}

.progress-fill.animate {
    transform: translateX(0);
}

/* Slide In Animations - Mobile Optimized */
.slide-in-left {
    animation: slideInLeft 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.slide-in-right {
    animation: slideInRight 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.slide-in-up {
    animation: slideInUp 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.slide-in-down {
    animation: slideInDown 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-50px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(50px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(50px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideInDown {
    from {
        opacity: 0;
        transform: translateY(-50px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Zoom Animations - Performance Optimized */
.zoom-in {
    animation: zoomIn 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

@keyframes zoomIn {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Text Animations - Mobile Friendly */
.text-focus-in {
    animation: textFocusIn 0.8s cubic-bezier(0.55, 0.085, 0.68, 0.53) both;
}

@keyframes textFocusIn {
    0% {
        filter: blur(8px);
        opacity: 0;
    }
    100% {
        filter: blur(0px);
        opacity: 1;
    }
}

/* Loading Dots - Mobile Optimized */
.loading-dots {
    display: inline-block;
}

.loading-dots::after {
    content: '';
    animation: loadingDots 1.2s infinite;
}

@keyframes loadingDots {
    0%, 20% {
        content: '';
    }
    40% {
        content: '.';
    }
    60% {
        content: '..';
    }
    80%, 100% {
        content: '...';
    }
}

/* ========== MOBILE SPECIFIC OPTIMIZATIONS ========== */

/* Mobile Devices - Reduced Animations */
@media (max-width: 768px) {
    /* Reduce animation distances and durations */
    .animate-on-scroll {
        transform: translateY(15px);
        transition: all 0.3s ease-out;
    }
    
    .float-animation {
        animation: floatMobile 3s ease-in-out infinite;
    }
    
    @keyframes floatMobile {
        0%, 100% {
            transform: translateY(0px);
        }
        50% {
            transform: translateY(-5px);
        }
    }
    
    /* Disable heavy animations on mobile */
    .glow-effect::before,
    .particle,
    .morph-button,
    .hover-rotate {
        display: none;
    }
    
    /* Simplify hover effects for touch */
    .hover-lift:hover,
    .hover-scale:hover {
        transform: none;
    }
    
    /* Faster stagger animations */
    .stagger-animation > * {
        animation-duration: 0.3s;
        transform: translateY(10px);
    }
    
    .stagger-animation > *:nth-child(1) { animation-delay: 0.03s; }
    .stagger-animation > *:nth-child(2) { animation-delay: 0.06s; }
    .stagger-animation > *:nth-child(3) { animation-delay: 0.09s; }
    .stagger-animation > *:nth-child(4) { animation-delay: 0.12s; }
    .stagger-animation > *:nth-child(5) { animation-delay: 0.15s; }
    .stagger-animation > *:nth-child(6) { animation-delay: 0.18s; }
    
    /* Optimize loading spinner for mobile */
    .loading-spinner {
        width: 25px;
        height: 25px;
        border-width: 2px;
        animation-duration: 0.6s;
    }
    
    /* Reduce typing animation time */
    .typing-animation {
        animation: typingMobile 1.5s steps(20, end), blink-caret 0.8s step-end infinite;
    }
    
    @keyframes typingMobile {
        from {
            width: 0;
        }
        to {
            width: 100%;
        }
    }
}

/* Small Mobile Devices - Further Optimization */
@media (max-width: 480px) {
    /* Minimal animations for low-end devices */
    .animate-on-scroll {
        transition: opacity 0.3s ease;
        transform: none;
    }
    
    .animate-on-scroll.animated {
        transform: none;
    }
    
    /* Disable all non-essential animations */
    .float-animation,
    .btn-animate::before,
    .stagger-animation > * {
        animation: none !important;
        opacity: 1 !important;
        transform: none !important;
    }
    
    /* Keep only essential animations */
    .loading-spinner,
    .progress-fill.animate,
    .typing-animation {
        animation-duration: 0.5s;
    }
}

/* Touch Device Optimizations */
@media (hover: none) and (pointer: coarse) {
    /* Remove hover effects for touch devices */
    .hover-lift:hover,
    .hover-scale:hover,
    .hover-rotate:hover,
    .btn-animate:hover::before,
    .glow-effect:hover::before {
        transform: none;
        opacity: 1;
    }
    
    /* Add active states for touch feedback */
    .btn-animate:active {
        transform: scale(0.98);
    }
    
    .hover-lift:active,
    .hover-scale:active {
        transform: scale(0.98);
    }
}

/* Performance Optimizations for Low-end Devices */
@media (max-width: 1024px) {
    /* Reduce particle effects */
    .particle {
        display: none;
    }
    
    /* Simplify gradient animations */
    .gradient-animation {
        animation: gradientShiftMobile 20s ease infinite;
    }
    
    @keyframes gradientShiftMobile {
        0%, 100% {
            background-position: 0% 50%;
        }
        50% {
            background-position: 100% 50%;
        }
    }
}

/* Battery Saving Mode */
@media (prefers-reduced-data: reduce) {
    .float-animation,
    .gradient-animation,
    .particle,
    .typing-animation,
    .loading-dots::after {
        animation: none !important;
    }
    
    .animate-on-scroll {
        transition: opacity 0.3s ease !important;
        transform: none !important;
    }
}

/* High Performance Devices Enhancement */
@media (min-width: 1025px) and (min-resolution: 120dpi) {
    /* Enable enhanced animations for high-end devices */
    .parallax-element {
        transform: translateZ(0);
        will-change: transform;
    }
}

/* Print Styles - Remove All Animations */
@media print {
    *,
    *::before,
    *::after {
        animation: none !important;
        transition: none !important;
    }
    
    .animate-on-scroll,
    .loading-spinner,
    .float-animation {
        opacity: 1 !important;
        transform: none !important;
        animation: none !important;
    }
}

/* ========== ACCESSIBILITY IMPROVEMENTS ========== */

/* 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;
        scroll-behavior: auto !important;
    }
    
    .animate-on-scroll {
        transition: opacity 0.3s ease !important;
        transform: none !important;
    }
    
    .animate-on-scroll.animated {
        transform: none !important;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .loading-spinner {
        border-color: currentColor;
        border-top-color: CanvasText;
    }
    
    .progress-fill {
        background: CanvasText;
    }
}

/* Dark mode animation adjustments */
@media (prefers-color-scheme: dark) {
    .btn-animate::before {
        background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.05), transparent);
    }
}

/* ========== PERFORMANCE ENHANCEMENTS ========== */

/* Hardware Acceleration */
.gpu-accelerated {
    transform: translateZ(0);
    backface-visibility: hidden;
    perspective: 1000px;
}

/* Optimize transition properties */
.optimized-transition {
    transition-property: transform, opacity;
    transition-duration: 0.3s;
    transition-timing-function: cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* Critical animations only */
.critical-animation {
    animation-duration: 0.4s;
    animation-fill-mode: both;
    animation-timing-function: cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* Non-critical animations (can be disabled) */
.non-critical-animation {
    animation-duration: 0.6s;
}

/* Animation performance classes */
.performance-optimized {
    will-change: transform, opacity;
    transform: translateZ(0);
}