/* ==========================================================
   Madaure Mobile Scroll Guard v1.5.4
   Astra + Elementor + LiteSpeed safe mobile scrolling
   ----------------------------------------------------------
   Goal: keep the document as the only vertical scroll owner.
   Horizontal overflow is clipped only at html/body level.
   Do NOT create nested vertical scroll containers on Elementor
   root wrappers. Astra may intentionally lock body while its
   off-canvas menu is actually open; JS releases stale locks
   after the drawer is closed.
   ========================================================== */

@media (max-width: 1024px) {
    html {
        width: 100% !important;
        max-width: 100% !important;
        height: auto !important;
        min-height: 100% !important;
        overflow-x: hidden !important;
        overflow-y: auto !important;
        -webkit-text-size-adjust: 100%;
        scroll-behavior: auto !important;
    }

    body {
        width: 100% !important;
        max-width: 100% !important;
        min-height: 100% !important;
        height: auto !important;
        overflow-x: hidden !important;
        overscroll-behavior-y: auto !important;
        -webkit-overflow-scrolling: touch;
    }

    /*
     * The site's global responsive CSS previously applies
     * overflow-x: clip to these root wrappers. On mobile Safari
     * this can interact badly with transformed/sticky Elementor
     * sections. Let the document own scrolling instead.
     */
    body .site,
    body .site-content,
    body .site-main,
    body .elementor,
    body.elementor-page,
    body .elementor-page {
        overflow: visible !important;
        max-width: 100% !important;
        min-width: 0 !important;
    }

    /* Normal page state: always allow vertical pan. */
    body:not(.ast-main-header-nav-open):not(.dialog-prevent-scroll):not(.e-scroll-lock) {
        overflow-y: visible !important;
        position: static !important;
        top: auto !important;
        left: auto !important;
        right: auto !important;
        touch-action: manipulation !important;
    }

    /* Keep common fixed helpers from creating viewport-wide touch traps. */
    .joinchat,
    .ht-ctc-chat,
    .qlwapp,
    #whatsapp-chat,
    .cky-btn-revisit-wrapper {
        touch-action: manipulation !important;
    }
}

@media (max-width: 767px) {
    html,
    body {
        max-width: 100vw !important;
    }

    /* Prevent accidental horizontal drag from hijacking vertical swipes. */
    body main,
    body #page,
    body .site,
    body .site-content,
    body .site-main {
        max-width: 100vw !important;
        min-width: 0 !important;
    }
}


/* ==========================================================
   v1.5.5 — Targeted fix for the 3 cards below:
   "محتوى غني و متنوع"
   ========================================================== */
@media (max-width: 1024px) {
    .mac-rich-content-scroll-safe,
    .mac-rich-content-scroll-safe > *,
    .mac-rich-content-scroll-safe .elementor-element,
    .mac-rich-content-scroll-safe .elementor-widget,
    .mac-rich-content-scroll-safe .elementor-widget-container,
    .mac-rich-content-scroll-safe a,
    .mac-rich-content-scroll-safe .swiper,
    .mac-rich-content-scroll-safe .swiper-wrapper,
    .mac-rich-content-scroll-safe .swiper-slide {
        touch-action: manipulation !important;
        overscroll-behavior-y: auto !important;
    }

    /* Do not let a nested card become its own vertical scroll surface. */
    .mac-rich-content-scroll-safe,
    .mac-rich-content-scroll-safe .elementor-widget-container,
    .mac-rich-content-scroll-safe .e-con,
    .mac-rich-content-scroll-safe .elementor-column,
    .mac-rich-content-scroll-safe .elementor-widget-wrap {
        overflow-y: visible !important;
        -webkit-overflow-scrolling: auto !important;
    }

    /* Decorative overlays must never trap a swipe. */
    .mac-rich-content-scroll-safe .elementor-background-overlay,
    .mac-rich-content-scroll-safe .elementor-motion-effects-layer,
    .mac-rich-content-scroll-safe .elementor-motion-effects-container {
        touch-action: manipulation !important;
    }
}


/* ==========================================================
   v1.5.6 — Preserve horizontal swipe for the 4 rich cards
   ----------------------------------------------------------
   The previous mobile scroll guard used pan-y on the body and
   on the rich-content section. touch-action is intersected
   across ancestors, so that unintentionally disabled pan-x on
   .features-scroll. This exception restores native two-axis
   gesture negotiation: horizontal drag scrolls the 4 cards,
   vertical drag scrolls the page.
   ========================================================== */
@media (max-width: 1024px) {
    body:not(.ast-main-header-nav-open):not(.dialog-prevent-scroll):not(.e-scroll-lock) {
        touch-action: manipulation !important;
    }

    .mac-rich-content-scroll-safe .features-scroll {
        overflow-x: auto !important;
        overflow-y: hidden !important;
        -webkit-overflow-scrolling: touch !important;
        touch-action: pan-x pan-y pinch-zoom !important;
        overscroll-behavior-x: contain !important;
        overscroll-behavior-y: auto !important;
        scroll-snap-type: x proximity !important;
        scroll-behavior: auto !important;
        cursor: grab;
    }

    .mac-rich-content-scroll-safe .feature-card,
    .mac-rich-content-scroll-safe .feature-card * {
        touch-action: manipulation !important;
    }

    .mac-rich-content-scroll-safe .feature-image {
        pointer-events: none !important;
        -webkit-user-drag: none !important;
        user-select: none !important;
    }
}
