/* Optimized Parallax Animation Styles */

/* Base parallax classes - NO transitions to avoid conflicts with JS */
.parallax,
.parallax-slow,
.parallax-medium,
.parallax-fast,
.parallax-text {
    /* Removed transition to prevent conflicts with JavaScript transforms */
    will-change: transform;
    /* GPU acceleration */
    transform: translate3d(0, 0, 0);
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    perspective: 1000px;
    -webkit-perspective: 1000px;
}

/* Parallax active state - handled by JavaScript */
.parallax-active {
    /* JavaScript handles transforms */
}

/* Fade in on scroll - separate from parallax transforms */
.fade-in-on-scroll {
    opacity: 0;
    transform: translate3d(0, 30px, 0);
    transition: opacity 0.6s cubic-bezier(0.4, 0, 0.2, 1), 
                transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: opacity, transform;
    position: relative; /* Ensure proper stacking context */
    z-index: 1; /* Ensure content is above background elements */
}

.fade-in-on-scroll.fade-in-visible {
    opacity: 1;
    transform: translate3d(0, 0, 0);
    will-change: auto;
}

/* Scale on scroll - uses IntersectionObserver, no transition needed */
.scale-on-scroll {
    transform: scale3d(0.8, 0.8, 1);
    will-change: transform;
}

/* Rotate on scroll - handled by JavaScript */
.rotate-on-scroll {
    will-change: transform;
    transform: rotate3d(0, 0, 1, 0deg);
}

/* Parallax for images */
.parallax-image {
    overflow: hidden;
    position: relative;
}

.parallax-image img {
    transform: scale3d(1.1, 1.1, 1);
    will-change: transform;
    backface-visibility: hidden;
}

/* Parallax for sections - container only, no transforms */
.parallax-section {
    position: relative;
    overflow: visible; /* Changed from hidden to prevent clipping */
    z-index: 1; /* Ensure sections are above background but below navigation */
}

/* Parallax cards - separate from parallax transforms, only hover effect */
.parallax-card {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), 
                box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: transform, box-shadow;
}

.parallax-card:hover {
    transform: translate3d(0, -5px, 0);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
}

/* Stagger animation for multiple items */
.fade-in-stagger {
    opacity: 0;
    transform: translate3d(0, 30px, 0);
    transition: opacity 0.6s cubic-bezier(0.4, 0, 0.2, 1), 
                transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: opacity, transform;
}

.fade-in-stagger.fade-in-visible {
    opacity: 1;
    transform: translate3d(0, 0, 0);
    will-change: auto;
}

.fade-in-stagger:nth-child(1) { transition-delay: 0.1s; }
.fade-in-stagger:nth-child(2) { transition-delay: 0.2s; }
.fade-in-stagger:nth-child(3) { transition-delay: 0.3s; }
.fade-in-stagger:nth-child(4) { transition-delay: 0.4s; }
.fade-in-stagger:nth-child(5) { transition-delay: 0.5s; }
.fade-in-stagger:nth-child(6) { transition-delay: 0.6s; }

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

/* Performance optimizations - ensure GPU acceleration */
.parallax,
.parallax-slow,
.parallax-medium,
.parallax-fast,
.parallax-text {
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    perspective: 1000px;
    -webkit-perspective: 1000px;
}

/* Parallax active - JavaScript controls transform, but keep GPU hints */
.parallax-active {
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    /* Don't set transform here - JavaScript handles it */
}

/* Disable parallax on mobile for better performance and UX */
@media (max-width: 768px) {
    .parallax,
    .parallax-slow,
    .parallax-medium,
    .parallax-fast,
    .parallax-text {
        transform: translate3d(0, 0, 0) !important;
        will-change: auto !important;
    }
    
    .parallax-image img {
        transform: scale3d(1, 1, 1) !important;
    }
    
    .parallax-card:hover {
        transform: translate3d(0, 0, 0) !important;
    }
    
    /* Keep fade-in animations on mobile */
    .fade-in-on-scroll {
        /* Fade-in still works on mobile */
    }
}

/* Desktop-specific improvements for scaling and spacing */
@media (min-width: 769px) {
    /* Reduce section padding on desktop for tighter spacing */
    .section[style*="padding-top: 2rem"] {
        padding-top: 2rem !important;
    }
    
    /* Improve container scaling on large screens */
    .container {
        max-width: min(1280px, 90vw);
    }
    
    .container.is-small {
        max-width: min(1000px, 85vw);
    }
    
    /* Reduce parallax effect intensity on desktop */
    .parallax-text {
        transform: translate3d(0, 0, 0) !important;
    }
    
    /* Better icon sizing on desktop */
    .icon.is-medium {
        width: 2rem;
        height: 2rem;
    }
}

/* Prefers reduced motion - comprehensive disable */
@media (prefers-reduced-motion: reduce) {
    .parallax,
    .parallax-slow,
    .parallax-medium,
    .parallax-fast,
    .parallax-text,
    .parallax-active,
    .scale-on-scroll,
    .rotate-on-scroll {
        transform: translate3d(0, 0, 0) !important;
        transition: none !important;
        animation: none !important;
        will-change: auto !important;
    }
    
    .fade-in-on-scroll {
        opacity: 1 !important;
        transform: translate3d(0, 0, 0) !important;
        transition: none !important;
    }
    
    .parallax-image img {
        transform: scale3d(1, 1, 1) !important;
    }
    
    .parallax-card:hover {
        transform: translate3d(0, 0, 0) !important;
    }
    
    html {
        scroll-behavior: auto;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .parallax,
    .parallax-slow,
    .parallax-medium,
    .parallax-fast,
    .parallax-text {
        transform: translate3d(0, 0, 0) !important;
    }
}

/* Ensure navigation overlay doesn't interfere when closed */
.w-nav-overlay[style*="display: none"] {
    display: none !important;
    pointer-events: none !important;
    opacity: 0 !important;
    visibility: hidden !important;
}

/* Ensure navigation overlay only appears when menu is open */
.w-nav.w--open .w-nav-overlay {
    pointer-events: auto;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* Ensure menu is visible when open */
.w-nav.w--open .w-nav-menu,
.w-nav-overlay .w-nav-menu,
.w-nav-overlay [data-nav-menu-open] {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    z-index: 1002 !important;
}

/* Ensure content sections are properly stacked */
section.parallax-section {
    z-index: 1;
    position: relative;
}

/* Ensure navbar is always on top */
.navbar {
    z-index: 1000;
    position: relative;
}

/* Ensure body content is visible and not blocked */
body {
    position: relative;
    z-index: 0;
}

/* Ensure main content is above background but below navigation */
body > section,
body > div:not(.navbar):not(.w-nav-overlay) {
    position: relative;
    z-index: 1;
}

/* Fix for elements that should be visible on initial load */
.fade-in-on-scroll:first-child,
section:first-of-type .fade-in-on-scroll {
    /* Elements at the top of the page should be visible immediately if in viewport */
}

/* Ensure navigation menu is visible when overlay is open */
.w-nav.w--open .w-nav-overlay {
    z-index: 1001 !important;
}

.w-nav.w--open .w-nav-menu {
    z-index: 1002 !important;
    position: relative;
}

