/*
 * Global News Alert — mobile platform finish
 *
 * This stylesheet intentionally sits after app.css and the public module
 * stylesheets. It focuses on navigation accessibility, reliable touch
 * interaction, safe wrapping and small-screen overflow without changing the
 * established desktop theme.
 */

html {
    overflow-x: clip;
}

body {
    min-width: 0;
    overflow-wrap: anywhere;
}

img,
svg,
video,
canvas,
iframe {
    max-width: 100%;
}

.header-navigation-panel {
    display: flex;
    align-items: center;
    gap: 30px;
}

.mobile-navigation-heading,
.mobile-menu-close,
.mobile-menu-backdrop {
    display: none;
}

.mobile-menu-button {
    width: 46px;
    height: 46px;
    flex: 0 0 46px;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 5px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.035);
    -webkit-tap-highlight-color: transparent;
}

.mobile-menu-button > span {
    width: 21px;
    height: 2px;
    border-radius: 999px;
    background: var(--text);
    transition:
        transform 180ms ease,
        opacity 180ms ease;
}

.mobile-menu-button.is-open > span:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}

.mobile-menu-button.is-open > span:nth-child(2) {
    opacity: 0;
}

.mobile-menu-button.is-open > span:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}

.mobile-menu-button:focus-visible,
.mobile-menu-close:focus-visible,
.main-navigation a:focus-visible,
.header-actions a:focus-visible,
.header-actions button:focus-visible {
    outline: 3px solid rgba(255, 48, 79, 0.42);
    outline-offset: 3px;
}

@media (max-width: 1120px) {
    body.mobile-navigation-open {
        overflow: hidden;
        overscroll-behavior: none;
    }

    .site-header {
        isolation: isolate;
    }

    .header-container {
        min-height: 70px;
        gap: 14px;
    }

    .brand {
        min-width: 0;
    }

    .brand-copy {
        min-width: 0;
    }

    .brand-copy strong {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .mobile-menu-button {
        display: flex;
        position: relative;
        z-index: 1003;
    }

    .header-navigation-panel {
        position: fixed;
        z-index: 1002;
        top: 0;
        right: 0;
        bottom: 0;
        height: 100vh;
        height: 100dvh;
        max-height: 100dvh;
        width: min(88vw, 380px);
        display: flex;
        flex-direction: column;
        align-items: stretch;
        gap: 0;
        padding:
            max(18px, env(safe-area-inset-top))
            18px
            max(22px, env(safe-area-inset-bottom));
        border-left: 1px solid var(--border);
        background:
            radial-gradient(
                circle at 100% 0,
                rgba(255, 48, 79, 0.13),
                transparent 34%
            ),
            #0d1118;
        box-shadow: -28px 0 70px rgba(0, 0, 0, 0.52);
        overflow-y: auto;
        overscroll-behavior: contain;
        transform: translateX(105%);
        visibility: hidden;
        transition:
            transform 220ms ease,
            visibility 220ms ease;
    }

    /*
     * The opener lives in the page header while the close control lives in
     * the drawer. Hide the opener while the drawer is open so the two buttons
     * cannot occupy the same top-right position.
     */
    body.mobile-navigation-open .mobile-menu-button {
        visibility: hidden;
        opacity: 0;
        pointer-events: none;
    }

    .header-navigation-panel.is-open {
        transform: translateX(0);
        visibility: visible;
    }

    .mobile-navigation-heading {
        min-height: 54px;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 18px;
        padding-bottom: 16px;
        border-bottom: 1px solid var(--border);
    }

    .mobile-navigation-heading div {
        min-width: 0;
        display: flex;
        flex-direction: column;
    }

    .mobile-navigation-heading strong {
        font-size: 18px;
    }

    .mobile-navigation-heading span {
        color: var(--muted);
        font-size: 11px;
    }

    .mobile-menu-close {
        position: relative;
        width: 44px;
        height: 44px;
        flex: 0 0 44px;
        display: grid;
        place-items: center;
        border: 1px solid var(--border);
        border-radius: 12px;
        background: rgba(255, 255, 255, 0.04);
        color: var(--text);
        font-size: 0;
        line-height: 1;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
    }

    .mobile-menu-close::before,
    .mobile-menu-close::after {
        content: "";
        position: absolute;
        top: 50%;
        left: 50%;
        width: 19px;
        height: 2px;
        border-radius: 999px;
        background: currentColor;
        transform-origin: center;
    }

    .mobile-menu-close::before {
        transform: translate(-50%, -50%) rotate(45deg);
    }

    .mobile-menu-close::after {
        transform: translate(-50%, -50%) rotate(-45deg);
    }

    .main-navigation,
    .header-actions {
        display: flex;
    }

    .main-navigation,
    .main-navigation.open {
        position: static;
        inset: auto;
        width: 100%;
        flex: 0 0 auto;
        display: flex;
        flex-direction: column;
        align-items: stretch;
        gap: 4px;
        margin: 14px 0;
        padding: 0;
        border: 0;
        border-radius: 0;
        background: transparent;
        box-shadow: none;
    }

    .main-navigation a {
        min-height: 48px;
        display: flex;
        align-items: center;
        padding: 10px 13px;
        border-radius: 11px;
        color: #c7cdd8;
        font-size: 14px;
    }

    .main-navigation a:hover,
    .main-navigation a.active {
        background: rgba(255, 48, 79, 0.1);
        color: var(--text);
    }

    .main-navigation a.active {
        box-shadow: inset 3px 0 0 var(--red);
    }

    .header-actions {
        width: 100%;
        flex: 0 0 auto;
        display: grid;
        grid-template-columns: 1fr;
        gap: 9px;
        margin-top: auto;
        padding-top: 16px;
        border-top: 1px solid var(--border);
    }

    .header-actions .search-button,
    .header-actions .alert-button,
    .header-actions .notification-header-link {
        width: 100%;
        min-height: 48px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        margin: 0;
        padding: 11px 15px;
        border: 1px solid var(--border);
        border-radius: 11px;
        text-align: center;
        font-size: 14px;
        font-weight: 800;
    }

    .header-actions .notification-header-link {
        position: relative;
        background: rgba(255, 255, 255, 0.035);
    }

    .header-actions .notification-header-link > span {
        min-width: 22px;
        height: 22px;
        display: inline-grid;
        place-items: center;
        padding: 0 5px;
        border-radius: 999px;
        background: var(--red);
        color: #fff;
        font-size: 10px;
    }

    .header-actions .mobile-login-button {
        background: rgba(255, 255, 255, 0.045);
    }

    .header-actions .mobile-signup-button,
    .header-actions .alert-button {
        border-color: transparent;
        background:
            linear-gradient(
                145deg,
                var(--red),
                var(--red-dark)
            );
        box-shadow: 0 14px 30px rgba(255, 48, 79, 0.18);
        color: #fff;
    }

    .mobile-menu-backdrop {
        position: fixed;
        z-index: 1001;
        inset: 0;
        width: 100%;
        height: 100%;
        display: block;
        border: 0;
        background: rgba(0, 0, 0, 0.7);
        backdrop-filter: blur(3px);
    }

    .mobile-menu-backdrop[hidden] {
        display: none;
    }

    /*
     * General public-page safeguards for narrow viewports.
     */
    main,
    section,
    article,
    aside,
    form,
    fieldset {
        min-width: 0;
    }

    input,
    select,
    textarea,
    button {
        max-width: 100%;
    }

    input:not([type="checkbox"]):not([type="radio"]),
    select,
    textarea {
        width: 100%;
        min-height: 46px;
        font-size: 16px;
    }

    table {
        max-width: 100%;
    }

    .table-responsive,
    .table-scroll,
    .responsive-table {
        max-width: 100%;
        overflow-x: auto;
        overscroll-behavior-inline: contain;
        -webkit-overflow-scrolling: touch;
    }
}

@media (max-width: 700px) {
    .page-container,
    .header-container,
    .footer-container,
    .footer-bottom {
        width: min(100% - 24px, 1180px);
    }

    .brand {
        gap: 9px;
    }

    .brand-icon {
        width: 39px;
        height: 39px;
        flex: 0 0 39px;
        border-radius: 11px;
    }

    .brand-copy strong {
        font-size: 14px;
    }

    .mobile-menu-button {
        width: 44px;
        height: 44px;
        flex-basis: 44px;
    }

    .hero-content h1,
    .public-story-main > h1,
    .dashboard-heading h1 {
        font-size: clamp(34px, 11vw, 48px);
        line-height: 1.04;
        letter-spacing: -1.8px;
    }

    .hero-actions,
    .public-story-actions,
    .dashboard-heading {
        width: 100%;
    }

    .hero-actions > a,
    .hero-actions > button,
    .public-story-actions > a,
    .public-story-actions > button {
        min-height: 48px;
    }
}

@media (max-width: 440px) {
    .header-navigation-panel {
        width: 100%;
        border-left: 0;
    }

    .brand-copy strong {
        max-width: 164px;
    }

    .brand-copy small {
        display: none;
    }

    .hero-actions {
        display: grid;
        grid-template-columns: 1fr;
    }

    .hero-actions > * {
        width: 100%;
    }
}

@media (prefers-reduced-motion: reduce) {
    .header-navigation-panel,
    .mobile-menu-button > span {
        transition: none;
    }
}
