/**
 * Android Chrome text-inflation / overflow fixes.
 * Applied only when <html class="is-android"> (set early in theme init).
 * iPhone / iOS Safari is intentionally untouched.
 */

html.is-android {
    -webkit-text-size-adjust: 100%;
    -moz-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

html.is-android,
html.is-android body {
    max-width: 100%;
    overflow-x: hidden;
}

/* Cabinet + public mobile: keep chrome inside the screen */
@media (max-width: 820px) {
    html.is-android .app,
    html.is-android .topbar,
    html.is-android .header,
    html.is-android .content,
    html.is-android .cab-news-embed,
    html.is-android .main-content,
    html.is-android .container {
        max-width: 100%;
        box-sizing: border-box;
    }

    html.is-android .topbar {
        padding-left: max(12px, env(safe-area-inset-left, 0px));
        padding-right: max(12px, env(safe-area-inset-right, 0px));
        gap: 10px;
        width: 100%;
        box-sizing: border-box;
    }

    html.is-android .topbar .search {
        min-width: 0;
        flex: 1 1 auto;
        max-width: none;
    }

    html.is-android .topbar .search input {
        min-width: 0;
        width: 100%;
    }

    /* News embed: stop masonry / cards from blowing past viewport */
    html.is-android .cab-news-embed,
    html.is-android .cab-news-embed * {
        -webkit-text-size-adjust: 100%;
        text-size-adjust: 100%;
    }

    html.is-android .cab-news-embed img,
    html.is-android .cab-news-embed video,
    html.is-android .news-media,
    html.is-android .slider-media {
        max-width: 100%;
        height: auto;
    }

    html.is-android #new-news-container {
        width: 100%;
        max-width: 100%;
        padding-left: 12px;
        padding-right: 12px;
        box-sizing: border-box;
    }

    html.is-android .news-item {
        max-width: 100%;
        box-sizing: border-box;
    }

    /*
     * Video / Shorts only: phantom horizontal scroll + clipped topbar after bell.
     * Causes: CSS columns, inline-block cards, native <video controls> min-width,
     * and off-screen share bottom-sheets with translateY still in overflow calc.
     * Pinch-zoom-out "fixes" it — classic slight overflow past the layout viewport.
     */
    html.is-android .main.is-shorts,
    html.is-android .main.is-shorts .content,
    html.is-android .main.is-shorts .content-news,
    html.is-android .cab-shorts-embed {
        max-width: 100%;
        min-width: 0;
        overflow-x: clip;
        box-sizing: border-box;
    }

    html.is-android .main.is-shorts .topbar {
        overflow: hidden;
        max-width: 100%;
    }

    html.is-android .main.is-shorts .top-actions {
        flex-shrink: 0;
    }

    html.is-android .main.is-shorts .content-news {
        padding-left: 12px !important;
        padding-right: 12px !important;
    }

    html.is-android .cab-shorts-embed #new-news-container {
        column-count: 1 !important;
        column-gap: 0 !important;
        display: block !important;
        width: 100% !important;
        max-width: 100% !important;
        padding-left: 0 !important;
        padding-right: 0 !important;
        overflow-x: hidden;
        box-sizing: border-box;
    }

    html.is-android .cab-shorts-embed .news-item,
    html.is-android .cab-shorts-embed .shorts-card {
        display: block !important;
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        overflow: hidden;
        box-sizing: border-box;
    }

    html.is-android .cab-shorts-embed .news-video-wrap,
    html.is-android .cab-shorts-embed .shorts-grid-video,
    html.is-android .cab-shorts-embed video,
    html.is-android .cab-shorts-embed .news-media.video {
        max-width: 100% !important;
        width: 100% !important;
        min-width: 0 !important;
        box-sizing: border-box;
    }

    /* Closed share sheets must not participate in layout/overflow */
    html.is-android .cab-shorts-embed .share-menu {
        display: none !important;
    }

    html.is-android .cab-shorts-embed .social-share.active .share-menu {
        display: block !important;
        left: 10% !important;
        right: 10% !important;
        width: auto !important;
        max-width: 80% !important;
        box-sizing: border-box;
    }
}
