/* ========================================================================
   ABAN — MOBILE LAYOUT OVERRIDES
   Applies only to phone-class viewports (<= 575.98px).
   This intentionally preserves the mobile layout approved after the
   2026-09-29 flood-warning update. Future phone-only edits belong here.
   ======================================================================== */

/* Two roomy columns; complete button labels. */
.action-buttons {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 8px !important;
    overflow: visible !important;
    padding-bottom: 0 !important;
}

.action-buttons .custom-btn {
    min-width: 0 !important;
    width: 100% !important;
    min-height: 54px !important;
    height: auto !important;
    padding: 8px 9px !important;
    gap: 6px !important;
    white-space: normal !important;
    overflow: visible !important;
    font-size: .78rem !important;
    line-height: 1.3 !important;
}

.action-buttons .custom-btn i {
    width: 28px !important;
    height: 28px !important;
    flex: 0 0 28px !important;
    font-size: .92rem !important;
}

.action-buttons .custom-btn span,
.action-buttons #customPointBtn span,
.action-buttons #floodAreaBtn span {
    display: block !important;
    min-width: 0 !important;
    max-width: none !important;
    white-space: normal !important;
    overflow: visible !important;
    text-overflow: clip !important;
    overflow-wrap: anywhere !important;
    line-height: 1.3 !important;
    text-align: center !important;
}

.action-buttons #customPointBtn {
    grid-column: 1 / -1 !important;
    min-width: 0 !important;
}

/* Approved phone map-control arrangement:
   row 1 = zoom + search, row 2 = basemap selector. */
.leaflet-top.leaflet-left .leaflet-control-zoom {
    margin-top: 8px !important;
    margin-left: 8px !important;
}

.map-stage > .aban-map-search,
.aban-map-search,
.leaflet-container .aban-map-search-floating,
.leaflet-container .aban-map-search-right-of-zoom,
.leaflet-container .aban-map-search-dynamic-v3,
.leaflet-container .aban-map-left-row .aban-map-search-v4 {
    position: absolute !important;
    top: 8px !important;
    left: 54px !important;
    right: 8px !important;
    width: auto !important;
    min-width: 0 !important;
    max-width: none !important;
    margin: 0 !important;
    box-sizing: border-box !important;
    z-index: 1002 !important;
}

.aban-map-search-form { min-height: 40px !important; }
.aban-map-search-input {
    height: 40px !important;
    padding: 6px 9px !important;
    font-size: .76rem !important;
}
.aban-map-search-button {
    flex: 0 0 40px !important;
    width: 40px !important;
}

.leaflet-top.leaflet-right .leaflet-control-layers,
.leaflet-control-layers {
    margin-top: 58px !important;
    margin-right: 8px !important;
    min-width: 0 !important;
    width: auto !important;
    max-width: min(180px, calc(100vw - 20px)) !important;
    font-size: .76rem !important;
    clear: both !important;
}

.leaflet-control-layers-expanded {
    width: min(178px, calc(100vw - 20px)) !important;
    min-width: 0 !important;
    max-width: min(178px, calc(100vw - 20px)) !important;
    padding: 6px 7px 7px !important;
}

.leaflet-control-layers-base label,
.leaflet-control-layers label {
    font-size: .76rem !important;
    line-height: 1.35 !important;
    margin-bottom: 1px !important;
}

.aban-basemap-text {
    font-size: .76rem !important;
    line-height: 1.35 !important;
}

/* Keep approved compact legend dimensions. */
.aban-map-legend {
    min-width: 126px !important;
    max-width: 154px !important;
    margin-right: 8px !important;
    margin-bottom: 8px !important;
}

.aban-map-legend-toggle {
    min-height: 30px !important;
    padding: 4px 7px !important;
    font-size: .70rem !important;
}

.aban-map-legend-body {
    max-height: 34vh !important;
    padding: 6px 7px 7px !important;
    font-size: .68rem !important;
}

@media (max-width: 390px) {
    .action-buttons .custom-btn {
        font-size: .74rem !important;
        padding-inline: 7px !important;
    }
    .aban-map-search-input { font-size: .72rem !important; }
    .leaflet-control-layers-expanded {
        width: 164px !important;
        max-width: 164px !important;
    }
}


/* Desktop-only layers label stays hidden on phones. */
.aban-layer-control-title { display: none !important; }


/* ========================================================================
   2026-09-29 final phone polish
   The top map controls own the first ~100px of the map; the popup starts
   below them and ends above the compact legend/help controls. Its body is
   vertically scrollable, preventing every phone-size overlap seen before.
   ======================================================================== */
.aban-map-forecast-popup,
.aban-map-forecast-popup.dock-left,
.aban-map-forecast-popup.dock-right {
    top: 108px !important;
    left: max(6px, env(safe-area-inset-left)) !important;
    right: max(6px, env(safe-area-inset-right)) !important;
    bottom: max(48px, calc(env(safe-area-inset-bottom) + 42px)) !important;
    width: auto !important;
    height: auto !important;
    max-width: none !important;
    max-height: none !important;
    transform: translateY(7px) scale(.995) !important;
}

.aban-map-forecast-popup.is-open {
    transform: translateY(0) scale(1) !important;
}

.aban-map-forecast-popup-content {
    min-height: 0 !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    -webkit-overflow-scrolling: touch !important;
    overscroll-behavior-y: contain !important;
    touch-action: pan-y !important;
}

/* On very short phone viewports keep a usable but still non-overlapping
   corridor. The vertical scroll handles the reduced sheet height. */
@media (max-height: 600px) {
    .aban-map-forecast-popup,
    .aban-map-forecast-popup.dock-left,
    .aban-map-forecast-popup.dock-right {
        top: 104px !important;
        bottom: max(44px, calc(env(safe-area-inset-bottom) + 38px)) !important;
    }
}

/* Center the generated custom-point result exactly beneath the action area.
   Bootstrap .row negative gutters previously shifted this result slightly to
   the right on phones. */
#customPointData {
    --bs-gutter-x: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    margin-left: auto !important;
    margin-right: auto !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
    justify-content: center !important;
}

#customPointData > .col-12 {
    width: 100% !important;
    max-width: 100% !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
    margin-left: auto !important;
    margin-right: auto !important;
}

#customPointData .alert {
    width: calc(100% - 12px) !important;
    max-width: calc(100% - 12px) !important;
    margin-left: auto !important;
    margin-right: auto !important;
}

/* ABAN v1.7.0: grouped raster/vector catalogue on phones. */
.leaflet-top.leaflet-right .leaflet-control-layers,
.leaflet-control-layers {
    max-width: min(235px, calc(100vw - 20px)) !important;
}
.leaflet-control-layers-expanded {
    width: min(232px, calc(100vw - 20px)) !important;
    max-width: min(232px, calc(100vw - 20px)) !important;
}
.leaflet-control-layers-list { max-height: 58vh !important; }
.aban-layer-section-header { padding: 5px 6px !important; font-size: .72rem !important; }
.aban-layer-section-icon, .aban-vector-icon-wrap { width: 22px !important; height: 22px !important; min-width: 22px !important; }
.aban-vector-text { font-size: .73rem !important; }


/* Hide routing analysis controls on phone-size screens. JavaScript also
   disables these options because Safari/iOS may ignore display:none on option. */
#floodLayerSelect option[value="stream_network"],
#floodLayerSelect option[value="dominant_flow"],
#routingAnimationControls { display: none !important; }
