/* A section keeps its design width; unused columns do not reserve panel space. */
#mega-menu-wrap-main-menu #mega-menu-main-menu .ap-menu-empty {
    display: none !important;
}

.ap-legacy-content [id] {
    scroll-margin-top: calc(var(--ap-header-height, 120px) + 16px);
}

@media only screen and (max-width: 820px) {
    /* A blurred sticky header becomes a containing block for the fixed drawer. */
    html.mega-menu-main-menu-off-canvas-open #masthead {
        -webkit-backdrop-filter: none !important;
        backdrop-filter: none !important;
    }

    /* The plugin's hidden drawer at left:-300px adds 300px of scroll range in RTL. */
    body.rtl #mega-menu-wrap-main-menu #mega-menu-main-menu {
        left: 0 !important;
        right: auto !important;
        transform: none !important;
    }

    /* Keep Elementor's clipped, one-pixel breakpoint detector inside the viewport. */
    body.rtl #elementor-device-mode {
        left: 1px !important;
        right: auto !important;
    }
}

@media only screen and (min-width: 821px) {
    #mega-menu-wrap-main-menu #mega-menu-main-menu > li.ap-adaptive-menu > ul.mega-sub-menu {
        width: var(--ap-menu-width) !important;
        max-width: calc(100vw - 32px) !important;
        left: var(--ap-menu-left, 0px) !important;
        right: auto !important;
        box-sizing: border-box !important;
    }

    #mega-menu-wrap-main-menu #mega-menu-main-menu > li.ap-adaptive-menu > ul > li.mega-menu-row > ul.mega-sub-menu {
        display: grid !important;
        grid-template-columns: repeat(var(--ap-menu-columns), minmax(0, 1fr));
        gap: 16px;
        direction: ltr;
    }

    #mega-menu-wrap-main-menu #mega-menu-main-menu > li.ap-adaptive-menu > ul > li.mega-menu-row > ul > li.mega-menu-column {
        float: none !important;
        width: 100% !important;
        min-width: 0;
        direction: rtl;
    }
}
