/* Map-only pages use the existing map palette and e-Ukraine typography.  */
html.only-map,
.only-map body {
    width: 100%;
    height: 100%;
    margin: 0;
    overflow: hidden;
    color-scheme: dark;
    background: #141921;
}
 
html.only-map {
    /* Measured from the supplied in-app screenshot: at a 390px CSS width,
       the banner is about 52px high and sits 20px above the WebView edge.
       Its height follows its aspect ratio; keep a separate 12px clear gap.
       Native safe-area insets are handled separately below. */
    --only-map-host-banner-height: clamp(46px, 13.2vw, 64px);
    --only-map-host-banner-bottom: 20px;
    --only-map-host-banner-gap: 12px;
    --only-map-control-size: 44px;
    --only-map-controls-gap: 12px;
    /* Some edge-to-edge WKWebViews report a zero safe-area inset. Reserve
       status-bar/notch space in that case too (CSS pixels, adjustable here). */
    --only-map-status-bar-min-height: 64px;
    --only-map-controls-top: calc(max(var(--only-map-status-bar-min-height), env(safe-area-inset-top, 0px))
        + var(--only-map-controls-gap));
    --only-map-controls-bottom: max(16px, env(safe-area-inset-bottom));
    --only-map-help-bottom-space: max(12px, env(safe-area-inset-bottom, 0px));
}

.only-map .app {
    height: 100%;
    height: 100dvh;
}

.only-map .content {
    min-height: 0;
}

.only-map .onlyMapSettings {
    position: absolute;
    z-index: 30;
    right: max(16px, env(safe-area-inset-right));
    bottom: var(--only-map-controls-bottom);
}

.only-map .onlyMapSettings__controls {
    position: absolute;
    top: -56px;
    right: 0;
    display: flex;
    flex-direction: row-reverse;
    gap: 12px;
}

.only-map .content .onlyMapSettings__panel {
    position: static;
    display: flex;
    min-width: 222px;
    padding: 18px;
    border: 1px solid #3f4246;
    border-radius: 8px;
    background: #2a2d31;
    box-shadow: 0 4px 16px rgb(0 0 0 / 18%);
}

.only-map .content .onlyMapSettings__panel .mapSheltersVisibility {
    margin: 0 0 12px;
    padding: 0 0 12px;
    border-bottom: 1px solid rgb(152 155 160 / 40%);
}

.only-map .content .onlyMapSettings__panel > :last-child {
    margin: 0;
    padding: 0;
    border: 0;
}

.only-map .onlyMapSettings__toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: var(--only-map-control-size);
    height: var(--only-map-control-size);
    padding: 0;
    border: 1px solid #3f4246;
    border-radius: 8px;
    background: #2a2d31;
    color: #c9ced6;
    cursor: pointer;
    touch-action: manipulation;
}

/* Pin all control boxes, including WebKit's native button minimum sizes.
   Keep these overrides scoped to the two map-only views. */
.only-map .onlyMapSettings .mapControlButton {
    box-sizing: border-box;
    -webkit-appearance: none;
    appearance: none;
    flex: 0 0 var(--only-map-control-size);
    width: var(--only-map-control-size);
    min-width: var(--only-map-control-size);
    max-width: var(--only-map-control-size);
    height: var(--only-map-control-size);
    min-height: var(--only-map-control-size);
    max-height: var(--only-map-control-size);
    padding: 0;
    margin: 0;
}

.only-map .onlyMapSettings__toggle:focus-visible {
    outline: 2px solid #78a2ed;
    outline-offset: 3px;
}

@media (max-width: 992px) {
    /* Native dialogs are centred in the WebView, which may extend underneath
       the iOS status bar. Pin the help below the same safe top as the controls,
       including the 64px fallback when WKWebView reports a zero inset. */
    .only-map .heatMapHelp {
        position: fixed;
        top: var(--only-map-controls-top);
        bottom: auto;
        margin: 0 auto;
        box-sizing: border-box;
        max-height: calc(100vh - var(--only-map-controls-top) - var(--only-map-help-bottom-space));
        max-height: calc(100dvh - var(--only-map-controls-top) - var(--only-map-help-bottom-space));
    }

    /* Only map-only radar dialogs reserve the native app's overlaid banner.
       Keep the existing help/Index/desktop placement unchanged. */
    .only-map .mapRadar {
        --only-map-help-bottom-space: calc(var(--only-map-host-banner-height)
            + var(--only-map-host-banner-bottom) + var(--only-map-host-banner-gap)
            + env(safe-area-inset-bottom, 0px));
    }

    .only-map .onlyMapSettings {
        position: fixed;
        top: var(--only-map-controls-top);
        bottom: auto;
        height: var(--only-map-control-size);
    }

    /* Move the scale to the same safe top row as the buttons. This selector
       also wins when MapLibre's CSS arrives after our stylesheet. */
    .only-map .maplibregl-ctrl-bottom-left {
        position: fixed;
        top: var(--only-map-controls-top);
        bottom: auto;
        left: max(16px, env(safe-area-inset-left));
        display: flex;
        align-items: center;
        height: var(--only-map-control-size);
    }

    .only-map .maplibregl-ctrl-bottom-left > .maplibregl-ctrl {
        margin: 0;
    }

    .only-map .onlyMapSettings__toggle {
        display: flex;
        margin-left: auto;
    }

    .only-map .onlyMapSettings__controls {
        top: 0;
        right: calc(100% + 8px);
        gap: 8px;
    }

    .only-map .content .onlyMapSettings__panel {
        position: absolute;
        right: 0;
        top: calc(var(--only-map-control-size) + var(--only-map-controls-gap));
        bottom: auto;
        width: max-content;
        min-width: 198px;
        padding: 14px;
        max-width: calc(100vw - 32px);
        max-height: calc(100vh - var(--only-map-controls-top) - var(--only-map-control-size)
            - var(--only-map-controls-gap) - var(--only-map-host-banner-height) - var(--only-map-host-banner-bottom) - var(--only-map-host-banner-gap)
            - env(safe-area-inset-bottom, 0px));
        max-height: calc(100dvh - var(--only-map-controls-top) - var(--only-map-control-size)
            - var(--only-map-controls-gap) - var(--only-map-host-banner-height) - var(--only-map-host-banner-bottom) - var(--only-map-host-banner-gap)
            - env(safe-area-inset-bottom, 0px));
        overflow-y: auto;
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
        transform: translateY(-8px) scale(.98);
        transform-origin: top right;
        transition: opacity 200ms ease, transform 200ms ease, visibility 200ms;
    }

    .only-map .onlyMapSettings__panel :is(.mapGridVisibility__switch, .mapGrayscaleSatelliteVisibility__switch, .mapSheltersVisibility__switch, .mapTargetsVisibility__switch, .mapDirectionVisibility__switch) {
        width: 42px;
        height: 24px;
        border-radius: 14px;
    }

    .only-map .onlyMapSettings__panel :is(.mapGridVisibility__switch, .mapGrayscaleSatelliteVisibility__switch, .mapSheltersVisibility__switch, .mapTargetsVisibility__switch, .mapDirectionVisibility__switch)::before {
        top: 2px;
        left: 2px;
        width: 18px;
        height: 18px;
    }

    .only-map .onlyMapSettings__panel .is-enabled::before {
        right: 2px;
        left: auto;
    }

    /* The visible switch is smaller; the touch target remains 44px tall. */
    .only-map .onlyMapSettings__panel :is(.mapGridVisibility__switch, .mapGrayscaleSatelliteVisibility__switch, .mapSheltersVisibility__switch, .mapTargetsVisibility__switch, .mapDirectionVisibility__switch)::after {
        inset: -10px -1px;
    }

    .only-map .onlyMapSettings.is-open .onlyMapSettings__panel {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
        transform: none;
    }

    /* The settings dropdown shares the top of the map with the sign-in controls. */
    .only-map .onlyMapSettings.is-open ~ .map .publicMapTopOverlay :is(.diiaAuthorization__button, .diiaAuthorization__status) {
        visibility: hidden;
        pointer-events: none;
    }

    .only-map .onlyMapSettings__toggle svg {
        transition: transform 200ms ease;
    }

    .only-map .onlyMapSettings.is-open .onlyMapSettings__toggle svg {
        transform: rotate(30deg);
    }
}

@media (prefers-reduced-motion: reduce) {
    .only-map .onlyMapSettings__panel,
    .only-map .onlyMapSettings__toggle svg {
        transition: none !important;
    }
}

/* Only map-only phone/WebView onboarding reserves room for the host app.
   Tune these two gaps if the app's overlaid banner changes height. Native
   safe-area insets are added, not replaced; Index/Heat/desktop stay unchanged. */
@media (max-width: 700px), (max-width: 992px) and (max-height: 600px) {
    .only-map .detailMapOnboarding {
        --only-map-onboarding-top-space: 24px;
        --only-map-onboarding-bottom-space: calc(var(--only-map-host-banner-height) + var(--only-map-host-banner-bottom) + var(--only-map-host-banner-gap));
        box-sizing: border-box;
        align-items: center;
        overflow: hidden;
        padding: calc(var(--only-map-onboarding-top-space) + env(safe-area-inset-top, 0px))
            12px calc(var(--only-map-onboarding-bottom-space) + env(safe-area-inset-bottom, 0px));
    }

    .only-map .detailMapOnboarding__panel {
        max-height: calc(100vh - var(--only-map-onboarding-top-space) - var(--only-map-onboarding-bottom-space)
            - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
        max-height: calc(100dvh - var(--only-map-onboarding-top-space) - var(--only-map-onboarding-bottom-space)
            - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
    }

    /* Sizes and spacing of the panel's content come from
       detail-map-onboarding.css, the same for Index. */
    .only-map .detailMapOnboarding__accept {
        min-height: 48px;
    }
}

@media (max-width: 992px) and (max-height: 500px) {
    /* Landscape phones: retain the title and all safety copy, skip only the
       decorative logo/subtitle so the scrollable body still has useful room. */
    .only-map .detailMapOnboarding__panel {
        padding-top: 36px;
        padding-bottom: 16px;
    }

    .only-map .detailMapOnboarding__logo,
    .only-map .detailMapOnboarding__header p {
        display: none;
    }

    .only-map .detailMapOnboarding__header {
        padding-bottom: 12px;
    }

    .only-map .detailMapOnboarding__header h2 {
        font-size: 18px;
    }
}
/* Cache refresh.                                                                   */
