/**
 * Enable native browser pull-to-refresh on mobile by making the document the scroll root.
 * Loaded only when includes/ulgb_native_pull_refresh_config.php has the flag enabled.
 * Scoped to app-shell pages (fixed *-wrapper layouts), max-width 1024px.
 *
 * Feed-style pages only. Video-chat browse mode is in ulgb_native_pull_refresh_video_chat.css.
 */
@media screen and (max-width: 1024px) {
    html.ulgb-native-pull-refresh-active:has(
        .browse-wrapper,
        .inbox-wrapper,
        .friendspage-wrapper,
        .userprofile-wrapper,
        .viewuserprofile-wrapper,
        .standards-wrapper
    ),
    html.ulgb-native-pull-refresh-active:has(.homepage-wrapper):not(:has(body.video-chat-page)) {
        overflow-x: hidden;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        height: auto;
    }

    html.ulgb-native-pull-refresh-active:has(
        .browse-wrapper,
        .inbox-wrapper,
        .friendspage-wrapper,
        .userprofile-wrapper,
        .viewuserprofile-wrapper,
        .standards-wrapper
    ) body:not(.ulgb-groups-home-iframe):not(.ulgb-no-native-pull-refresh),
    html.ulgb-native-pull-refresh-active:has(.homepage-wrapper):not(:has(body.video-chat-page)) body:not(.ulgb-groups-home-iframe):not(.ulgb-no-native-pull-refresh) {
        overflow: visible !important;
        min-height: 100%;
    }

    html.ulgb-native-pull-refresh-active:has(.navbar-bottom) body:not(.video-chat-page):not(.ulgb-no-native-pull-refresh) {
        padding-bottom: calc(85px + env(safe-area-inset-bottom, 0px));
    }

    html.ulgb-native-pull-refresh-active:has(.navbar) body:not(.video-chat-page):not(.ulgb-groups-home-iframe):not(.ulgb-no-native-pull-refresh) {
        padding-top: var(--ulgb-mobile-content-top, 72px);
    }

    html.ulgb-native-pull-refresh-active body:not(.video-chat-page) .homepage-wrapper,
    html.ulgb-native-pull-refresh-active .browse-wrapper,
    html.ulgb-native-pull-refresh-active .inbox-wrapper,
    html.ulgb-native-pull-refresh-active .friendspage-wrapper,
    html.ulgb-native-pull-refresh-active .userprofile-wrapper,
    html.ulgb-native-pull-refresh-active .viewuserprofile-wrapper,
    html.ulgb-native-pull-refresh-active .standards-wrapper {
        position: relative !important;
        top: auto !important;
        bottom: auto !important;
        left: auto !important;
        right: auto !important;
        inset: auto !important;
        overflow: visible !important;
        min-height: 0 !important;
        height: auto !important;
        max-height: none !important;
    }

    html.ulgb-native-pull-refresh-active body:not(.video-chat-page) .homepage-main-content,
    html.ulgb-native-pull-refresh-active body:not(.video-chat-page) .homepage-main-container,
    html.ulgb-native-pull-refresh-active body:not(.video-chat-page) .homepage-columns,
    html.ulgb-native-pull-refresh-active body:not(.video-chat-page) .homepage-column-center,
    html.ulgb-native-pull-refresh-active body:not(.video-chat-page) .homepage-post-feed-container,
    html.ulgb-native-pull-refresh-active body:not(.video-chat-page) .homepage-column-groups-body,
    html.ulgb-native-pull-refresh-active body:not(.video-chat-page) .homepage-column-notifications-body,
    html.ulgb-native-pull-refresh-active .browse-main-content,
    html.ulgb-native-pull-refresh-active .browse-main-container,
    html.ulgb-native-pull-refresh-active .browse-search-mode-shell,
    html.ulgb-native-pull-refresh-active .browse-feed-row,
    html.ulgb-native-pull-refresh-active .inbox-main-content,
    html.ulgb-native-pull-refresh-active .inbox-main-container,
    html.ulgb-native-pull-refresh-active .inbox-feed-container,
    html.ulgb-native-pull-refresh-active .inbox-list-pane .inbox-conversations-list,
    html.ulgb-native-pull-refresh-active .friendspage-main-content,
    html.ulgb-native-pull-refresh-active .friendspage-main-container,
    html.ulgb-native-pull-refresh-active .userprofile-main-content,
    html.ulgb-native-pull-refresh-active .userprofile-main-container,
    html.ulgb-native-pull-refresh-active .userprofile-post-feed-wrapper,
    html.ulgb-native-pull-refresh-active .viewuserprofile-main-content,
    html.ulgb-native-pull-refresh-active .viewuserprofile-main-container,
    html.ulgb-native-pull-refresh-active .viewuserprofile-post-feed-wrapper,
    html.ulgb-native-pull-refresh-active .standards-wrapper,
    html.ulgb-native-pull-refresh-active .standards-inner {
        overflow: visible !important;
        overscroll-behavior: auto !important;
        touch-action: auto !important;
        max-height: none !important;
        height: auto !important;
        min-height: 0 !important;
        flex: none !important;
    }

    /* Keep wizard / nested panes on their own scroll (do not chain to document). */
    html.ulgb-native-pull-refresh-active .ulgb-nested-scroll,
    html.ulgb-native-pull-refresh-active .business-ads-wizard-viewport,
    html.ulgb-native-pull-refresh-active .biz-signup-categories-scroll {
        overflow-y: auto !important;
        overscroll-behavior: contain !important;
        touch-action: pan-y !important;
    }

    /* Modals and overlays keep contained scroll. */
    html.ulgb-native-pull-refresh-active .post-comment-modal-overlay,
    html.ulgb-native-pull-refresh-active .post-comment-modal-scroll-area,
    html.ulgb-native-pull-refresh-active .groups-detail-modal-scroll-wrap,
    html.ulgb-native-pull-refresh-active .homepage-modal-overlay,
    html.ulgb-native-pull-refresh-active .ulgb-dialog-overlay,
    html.ulgb-native-pull-refresh-active .navbar-menu-overlay {
        overscroll-behavior: contain !important;
    }
}
