/**
 * Cloud Network Visualization Styles
 * Enhanced professional cloud animation for enterprise applications
 */

/* Animation Container - with scroll performance optimizations */
.hero-animation-container {
    position: absolute;
    top: 50%;
    right: calc(5% + 50px);
    transform: translateY(-50%) translateX(50px);
    width: 500px;
    height: 400px;
    overflow: visible;
    z-index: 1;
    background: transparent;
    border: none;
    outline: none;
    box-shadow: none;
    pointer-events: none;
    will-change: transform; /* Performance optimization */
    /* Prevent flickering during scrolling */
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    -webkit-transform-style: preserve-3d;
    transform-style: preserve-3d;
    -webkit-perspective: 1000;
    perspective: 1000;
    contain: layout paint style;
}

/* Cloud SVG */
.animated-cloud {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
    will-change: transform; /* Performance optimization */
}

/* Cloud Particles */
.cloud-particle {
    position: absolute;
    background: radial-gradient(
        circle at center,
        rgba(235, 245, 255, 0.9) 0%,
        rgba(200, 230, 255, 0.6) 40%,
        rgba(180, 220, 255, 0.25) 70%,
        rgba(160, 210, 255, 0) 100%
    );
    border-radius: 50%;
    z-index: 1;
    will-change: transform, opacity; /* Performance optimization */
}

/* Dark Mode Adjustments */
.dark-mode .cloud-particle {
    background: radial-gradient(
        circle at center,
        rgba(255, 255, 255, 0.85) 0%,
        rgba(173, 216, 255, 0.45) 40%,
        rgba(173, 216, 255, 0.18) 70%,
        rgba(173, 216, 255, 0) 100%
    );
}

/* Animations */
@keyframes cloudFloat {
    0%, 100% { transform: translate(0, 0) scale(1); }
    25% { transform: translate(5px, -5px) scale(1.03); }
    50% { transform: translate(0, 3px) scale(0.97); }
    75% { transform: translate(-5px, -2px) scale(1.01); }
}

@keyframes particleFade {
    0%, 100% { opacity: 0.15; transform: scale(0.9); }
    50% { opacity: 0.6; transform: scale(1.1); }
}

/* Apply animations */
.animated-cloud {
    animation: cloudFloat 12s ease-in-out infinite;
}

/* Animation pause during scroll - added via JS */
.scroll-active .animated-cloud,
.scroll-active .cloud-particle,
.scroll-active canvas.cloud-canvas {
    animation-play-state: paused !important;
}

/* Canvas-specific styling with improved performance */
canvas.cloud-canvas {
    position: absolute;
    top: -10%;
    left: -10%;
    width: 120%;
    height: 120%;
    border-radius: 0;
    display: block;
    /* Add hardware acceleration */
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    will-change: transform;
    image-rendering: auto;
}

/* Responsive Adjustments */
@media (max-width: 1200px) {
    .hero-animation-container {
        width: 400px;
        height: 320px;
        right: calc(3% + 50px);
    }
}

@media (max-width: 992px) {
    .hero-animation-container {
        width: 350px;
        height: 280px;
        right: calc(2% + 50px);
        opacity: 0.85;
    }
}

@media (max-width: 768px) {
    /* Add more padding on top of the hero section on mobile */
    .hero {
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        width: 100% !important;
        padding: 0 !important;
        padding-top: 3rem !important;
        margin-top: 1rem !important;
    }
    
    /* Optimize mobile animation to prevent flickering */
    .hero-animation-container {
        position: static !important;
        top: auto !important;
        left: auto !important;
        right: auto !important;
        transform: none !important;
        display: block;
        width: 100% !important;
        max-width: 450px !important;
        height: 350px !important;
        margin: 4rem auto 0 !important;
        opacity: 1;
        order: 10 !important;
        /* Hardware acceleration to prevent flickering */
        -webkit-backface-visibility: hidden !important;
        backface-visibility: hidden !important;
        -webkit-perspective: 1000 !important;
        perspective: 1000 !important;
        -webkit-transform: translateZ(0) !important;
        transform: translateZ(0) !important;
        will-change: opacity !important;
        /* More aggressive containment during scroll */
        contain: strict !important;
        /* Fix for scroll performance */
        isolation: isolate !important;
    }
    
    .hero h1 {
        order: 1 !important;
        margin-top: 1rem !important;
    }
    
    .hero p {
        order: 2 !important;
    }
    
    .hero-buttons {
        order: 5 !important;
        margin-bottom: 0 !important;
        width: 100% !important;
        text-align: center !important;
    }
    
    /* Override any possible parent styles affecting order */
    .hero > .hero-animation-container {
        order: 10 !important;
    }
    
    /* Further optimize animation performance */
    .animated-cloud {
        animation-duration: 20s !important; /* Slow down animation to reduce CPU usage */
        animation-timing-function: linear !important; /* Use linear timing for smoother appearance */
        /* Hardware acceleration */
        -webkit-transform: translateZ(0) !important;
        transform: translateZ(0) !important;
        -webkit-backface-visibility: hidden !important;
        backface-visibility: hidden !important;
        will-change: transform !important;
        /* Prevent paint during scroll */
        animation-play-state: paused !important;
    }
    
    /* Stop animation during scroll in mobile - gets re-enabled after scroll stops */
    .scroll-active .animated-cloud,
    .scroll-active .cloud-particle,
    .scroll-active canvas.cloud-canvas {
        animation-play-state: paused !important;
        transition: none !important;
        -webkit-transform: translateZ(0) !important;
        transform: translateZ(0) !important;
    }
    
    /* More aggressively reduce particle count and complexity on mobile */
    .hero-animation-container.mobile-optimized .cloud-particle {
        opacity: 0.8;
        display: none !important; /* Disable particles to improve performance */
    }
    
    /* Show only every fourth particle to reduce rendering load */
    .hero-animation-container.mobile-optimized .cloud-particle:nth-child(4n) {
        display: block !important;
    }
    
    .hero-animation-container.mobile-optimized .animated-cloud {
        animation-duration: 30s !important; /* Even slower on mobile */
    }
    
    canvas.cloud-canvas {
        image-rendering: auto;
        top: -10% !important;
        left: -10% !important;
        width: 120% !important;
        height: 120% !important;
        /* Hardware acceleration for canvas elements */
        -webkit-transform: translateZ(0) !important;
        transform: translateZ(0) !important;
        -webkit-backface-visibility: hidden !important;
        backface-visibility: hidden !important;
        will-change: transform !important;
        /* Optimize rendering performance */
        image-rendering: optimizeSpeed !important; 
        /* Fixed positioning within parent to prevent layout shifts */
        position: absolute !important;
    }
    
    /* Prevent any flickering from transitions */
    .hero, .hero *, .hero-animation-container, .hero-animation-container * {
        transition: none !important; /* Disable transitions that might cause flickering */
    }
}

@media (max-width: 480px) {
    .hero-animation-container {
        height: 300px;
        max-width: 380px;
        margin: 0 auto 2rem;
    }
    
    @keyframes cloudFloat {
        0%, 100% { transform: translate(0, 0) scale(1); }
        25% { transform: translate(5px, -5px) scale(1.03); }
        50% { transform: translate(0, 3px) scale(0.97); }
        75% { transform: translate(-5px, -2px) scale(1.01); }
    }
}

/* Add style for dark mode */
.dark-mode .hero-animation-container {
    box-shadow: none;
}

/* Ensure the hero text is always on top of animation for readability */
.hero h1, 
.hero p,
.hero-buttons {
    position: relative;
    z-index: 5;
}

/* Reduced motion settings */
@media (prefers-reduced-motion: reduce) {
    .hero-animation-container {
        transform: scale(0.9);
    }
    
    .animated-cloud {
        animation: none !important;
    }
    
    .cloud-particle {
        animation: none !important;
        opacity: 0.5 !important;
    }
}

/* Loading state - shown while JS initializes */
.hero-animation-container.loading::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 80px;
    height: 80px;
    margin: -40px 0 0 -40px;
    border-radius: 50%;
    background: radial-gradient(
        circle at center,
        rgba(235, 245, 255, 0.95) 0%,
        rgba(200, 230, 255, 0.75) 30%,
        rgba(180, 220, 255, 0.4) 70%,
        rgba(160, 210, 255, 0) 100%
    );
    opacity: 0.8;
    animation: pulseOpacity 1.5s ease-in-out infinite;
}

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

.dark-mode .hero-animation-container.loading::before {
    background: radial-gradient(
        circle at center,
        rgba(255, 255, 255, 0.9) 0%,
        rgba(173, 216, 255, 0.6) 30%,
        rgba(135, 206, 235, 0.3) 70%,
        rgba(135, 206, 235, 0) 100%
    );
}

/* Improve performance on high-DPI screens */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .hero-animation-container {
        transform: none !important; /* Don't scale down on high-DPI screens */
    }
    
    /* Reduce resolution for high-DPI devices */
    canvas.cloud-canvas {
        image-rendering: optimizeSpeed !important;
    }
}

/* Apply hardware acceleration to all animation elements */
.cloud-canvas {
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    perspective: 1000px;
    will-change: transform;
} 