/**
 * Scroll Fix CSS
 * Fixes scrolling issues on Chrome, Elementor pages, shortcodes, and mobile
 * Version: 1.0.0
 */

/* ===== CRITICAL SCROLL FIX ===== */

/* Ensure html and body allow scrolling when menu is closed */
html:not(.sidebar-open):not(.menu-open) {
    overflow-y: auto !important;
    overflow-x: hidden !important;
    height: auto !important;
}

html:not(.sidebar-open):not(.menu-open) body:not(.menu-open) {
    overflow-y: visible !important;
    overflow-x: hidden !important;
    position: static !important;
    height: auto !important;
    min-height: 100vh;
    /* Respect dynamic header height - don't override padding-top */
}

/* Override Elementor's overscroll-behavior that can cause issues */
.elementor-kit-16,
.elementor-page,
[class*="elementor"] {
    overscroll-behavior: auto !important;
}

/* ===== MOBILE TOUCH SCROLLING FIX ===== */

/* Enable touch scrolling on all elements */
html,
body,
#page,
.site,
#content,
.site-content,
main,
.entry-content,
.elementor,
.elementor-section,
.elementor-container,
.elementor-row,
.elementor-column,
.elementor-widget-wrap,
.elraed-homepage-full,
.elraed-landing-hero,
.elraed-landing-features,
.elraed-landing-stats,
.elraed-landing-testimonials,
.elraed-courses-grid,
.elraed-courses-filter,
[class*="elraed-"] {
    touch-action: pan-y pan-x !important;
    -webkit-overflow-scrolling: touch !important;
}

/* ===== POINTER EVENTS FIX ===== */

/* Ensure content can receive pointer events */
#page,
.site,
#content,
.site-content,
main,
.entry-content,
.elementor,
.elementor-section,
.elementor-container,
[class*="elraed-"] section,
[class*="elraed-"] .container {
    pointer-events: auto !important;
}

/* ===== OVERLAY FIXES ===== */

/* Ensure overlays don't block scrolling when not active */
.sidebar-menu-wrapper:not(.is-active),
.mobile-menu-overlay:not(.active) {
    pointer-events: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
}

/* Only hide navbar-nav-wrapper on mobile when not active */
@media (max-width: 1200px) {
    .navbar-nav-wrapper:not(.active) {
        pointer-events: none !important;
        visibility: hidden !important;
        opacity: 0 !important;
    }
}

/* Reset body styles when menu is NOT open */
body:not(.menu-open) {
    overflow-y: auto !important;
    position: static !important;
}

/* ===== ELEMENTOR SPECIFIC FIXES ===== */

/* Fix for Elementor sections blocking scroll */
.elementor-section {
    position: relative !important;
    overflow: visible !important;
}

.elementor-section-wrap,
.elementor-section-content-middle,
.elementor-section-content-full {
    pointer-events: auto !important;
}

/* Fix for full-width sections */
.elementor-section-full_width {
    overflow: visible !important;
}

/* ===== SHORTCODES PAGES FIX ===== */

/* Ensure shortcode containers allow scrolling */
.elraed-landing-hero,
.elraed-landing-features,
.elraed-landing-stats,
.elraed-landing-testimonials,
.elraed-courses-grid,
.elraed-student-signup,
.elraed-student-signin,
.elraed-instructor-signup,
.elraed-instructor-signin,
.elraed-homepage-full {
    overflow: visible !important;
    position: relative !important;
}

/* Fix hero section pseudo-elements that might block scroll */
.elraed-landing-hero::before,
.elraed-landing-hero::after,
.elraed-about-hero::before,
.elraed-about-hero::after {
    pointer-events: none !important;
}

/* ===== TUTOR LMS PAGE FIXES ===== */

/* Ensure TutorLMS pages allow scrolling */
.tutor-wrap,
.tutor-page-wrap,
.tutor-dashboard,
.tutor-course-content-wrap {
    touch-action: pan-y pan-x !important;
    overflow: visible !important;
    pointer-events: auto !important;
}

/* ===== WEBKIT/CHROME SPECIFIC FIXES ===== */

/* Chrome-specific scroll fix */
@supports (-webkit-appearance: none) {
    html {
        scroll-behavior: smooth;
        overflow-y: scroll !important;
    }
    
    body:not(.menu-open) {
        overflow-y: visible !important;
        overflow-x: hidden !important;
    }
}

/* ===== RESPONSIVE SCROLL FIXES ===== */

@media screen and (max-width: 1200px) {
    html:not(.sidebar-open):not(.menu-open),
    body:not(.menu-open) {
        overflow-y: auto !important;
        position: static !important;
    }
    
    /* Ensure mobile content scrolls */
    .site-content,
    #content,
    main {
        -webkit-overflow-scrolling: touch !important;
        touch-action: pan-y !important;
    }
}

@media screen and (max-width: 768px) {
    /* Mobile-specific scroll fixes */
    html {
        -webkit-overflow-scrolling: touch !important;
        touch-action: manipulation !important;
    }
    
    body:not(.menu-open) {
        touch-action: pan-y pan-x !important;
        -webkit-overflow-scrolling: touch !important;
        overflow-y: auto !important;
        position: static !important;
    }
    
    /* Ensure all content sections can be scrolled */
    .elementor,
    .elementor-section,
    [class*="elraed-"],
    [class*="tutor-"] {
        touch-action: pan-y pan-x !important;
    }
}

/* ===== DEBUG HELPER (Remove in production) ===== */
/* Uncomment to visually debug scroll-blocking elements
body.debug-scroll-issues *[style*="position: fixed"],
body.debug-scroll-issues *[style*="overflow: hidden"] {
    outline: 3px solid red !important;
}
*/
