/*
 * Ravar Municipality — mobile viewport integrity patch
 * Scope: public frontend only. No backend/database/admin changes.
 * Goal: vertical-only page flow on phones; no off-canvas geometry outside viewport.
 */
@media (max-width: 680px) {
    html,
    body {
        width: 100%;
        max-width: 100%;
        min-width: 0 !important;
        overflow-x: hidden !important;
        overscroll-behavior-x: none;
        touch-action: pan-y pinch-zoom;
    }

    @supports (overflow: clip) {
        html,
        body {
            overflow-x: clip !important;
        }
    }

    body,
    main,
    header,
    footer,
    section,
    nav {
        max-width: 100%;
    }

    img,
    picture,
    video,
    iframe,
    canvas,
    svg:not(.ui-sprite) {
        max-width: 100%;
    }

    .container {
        width: calc(100% - 28px) !important;
        max-width: calc(100% - 28px) !important;
        margin-inline: auto;
    }

    /* Flex/grid children must be allowed to shrink inside the phone viewport. */
    .brand-row > *,
    .nav-shell > *,
    .service-bento > *,
    .intro-layout > *,
    .mayor-layout > *,
    .news-editorial-grid > *,
    .project-cinema-grid > *,
    .city-facts-grid > *,
    .quick-access-grid > *,
    .kpi-grid > *,
    .footer-grid > * {
        min-width: 0 !important;
        max-width: 100%;
    }

    /* Closed mobile navigation must not physically live outside the viewport. */
    .nav-layer {
        display: none !important;
        top: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        left: auto !important;
        width: min(390px, 88vw) !important;
        max-width: 88vw !important;
        transform: none !important;
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
    }

    .nav-layer.is-open {
        display: block !important;
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
    }

    /* Horizontal entrance transforms can create a wider visual viewport on iOS/WebView. */
    [data-reveal],
    [data-reveal="left"],
    [data-reveal="right"] {
        transform: none !important;
    }

    /* Decorative shapes with negative coordinates are desktop-only. */
    .hero-orbit,
    .projects-orb,
    .footer-aura {
        display: none !important;
    }

    .visual-story::before,
    .service-supercard::before,
    .quick-access::after,
    .quick-stat::before,
    .city-facts-section::before,
    .city-facts-section::after {
        display: none !important;
    }

    .intro-image-frame {
        left: 0 !important;
    }

    .intro-float-card {
        right: 0 !important;
        left: auto !important;
        width: auto;
        max-width: calc(100% - 12px);
        min-width: 0 !important;
    }

    .intro-watermark {
        left: 0 !important;
    }

    /* The desktop one-line mayor title is intentionally allowed to wrap on phones. */
    .mayor-copy h2#mayor-title {
        width: 100% !important;
        max-width: 100% !important;
        white-space: normal !important;
        overflow-wrap: anywhere;
        word-break: normal;
    }

    /* Reset conflicting logical/physical inset declarations from the widget styles. */
    .local-tools {
        inset: auto !important;
        top: auto !important;
        right: 10px !important;
        bottom: 88px !important;
        left: auto !important;
        width: 54px !important;
        max-width: 54px !important;
        transform: none !important;
    }

    .local-tools-tabs {
        width: 54px !important;
        max-width: 54px !important;
    }

    .local-tool-tab,
    .local-tool-tab:hover,
    .local-tool-tab:focus-visible,
    .local-tool-tab[aria-expanded="true"] {
        width: 44px !important;
        min-width: 44px !important;
        max-width: 44px !important;
        transform: none !important;
    }

    .local-tools-panel {
        inset: auto !important;
        right: 0 !important;
        bottom: 112px !important;
        left: auto !important;
        width: min(340px, calc(100vw - 28px)) !important;
        max-width: calc(100vw - 28px) !important;
    }

    .mobile-dock {
        right: 10px !important;
        left: 10px !important;
        width: auto !important;
        max-width: calc(100% - 20px) !important;
    }

    .home-slider,
    .home-slider-track,
    .home-slide,
    .home-slide-link,
    .home-slide picture,
    .cinematic-hero,
    .hero-stage,
    .hero-service-rail {
        max-width: 100% !important;
    }

    .home-slide img,
    .home-slide.is-active img {
        max-width: 100% !important;
    }

    /* Long labels/URLs may wrap instead of expanding a card. */
    .service-supercard,
    .news-editorial-card,
    .project-cinema-card,
    .quick-access,
    .city-fact-card,
    .footer-grid,
    .footer-contact-section,
    .page-content {
        overflow-wrap: anywhere;
    }
}

@media (max-width: 380px) {
    .container {
        width: calc(100% - 20px) !important;
        max-width: calc(100% - 20px) !important;
    }

    .brand-row {
        gap: 8px;
    }

    .brand {
        gap: 9px;
    }

    .brand-mark {
        width: 50px;
        height: 50px;
        flex: 0 0 50px;
    }

    .brand img {
        width: 46px;
        height: 46px;
    }

    .brand-copy strong {
        font-size: 16px !important;
    }
}
