/* MapMid 3.1 layout hardening: loaded after styles.css */
html, body { width: 100%; height: 100%; }
body { overflow: hidden; }

.app-shell {
  width: 100%;
  height: 100dvh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.appbar {
  flex: 0 0 52px;
  height: 52px;
}

.banner-stack {
  flex: 0 0 auto;
  width: 100%;
}

.banner-stack:empty { display: none; }

.main-layout {
  flex: 1 1 auto;
  width: 100%;
  height: auto;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(360px, 44%) minmax(0, 56%);
  overflow: hidden;
}

.planner-pane,
.map-pane {
  min-width: 0;
  min-height: 0;
  height: 100%;
}

.planner-pane {
  overflow: hidden;
}

.planner-scroll {
  height: 100%;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.map-pane {
  position: relative;
  display: flex;
  padding: 8px;
  overflow: hidden;
}

.map-card {
  position: relative;
  flex: 1 1 auto;
  width: 100%;
  height: 100%;
  min-height: 320px;
  overflow: hidden;
  isolation: isolate;
}

#map {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  min-width: 100%;
  min-height: 100%;
  z-index: 1;
}

#map.leaflet-container { display: block; }
.leaflet-map-pane,
.leaflet-tile-pane,
.leaflet-overlay-pane,
.leaflet-marker-pane { z-index: auto; }

.map-offline {
  position: absolute;
  inset: 0;
  z-index: 800;
  display: grid;
  place-items: center;
  padding: 24px;
  text-align: center;
  background:
    linear-gradient(rgba(88,166,255,.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(88,166,255,.05) 1px, transparent 1px),
    #0c1118;
  background-size: 32px 32px;
}

.map-offline[hidden] { display: none !important; }
.map-offline > div { max-width: 360px; display: grid; gap: 6px; }
.map-offline strong { font-size: 13px; color: var(--text); }
.map-offline span { color: var(--secondary); font-size: 10px; line-height: 1.5; }

.map-top-controls,
.map-status,
.map-legend,
.pick-banner { pointer-events: auto; }

@media (max-width: 839px) {
  .app-shell { min-height: 100dvh; }
  .appbar { flex-basis: 48px; height: 48px; }

  .main-layout {
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
  }

  .map-pane {
    order: 0;
    flex: 0 0 210px;
    width: 100%;
    height: 210px;
    min-height: 210px;
    padding: 5px 8px 0;
  }

  .map-pane.expanded {
    flex-basis: min(42dvh, 360px);
    height: min(42dvh, 360px);
    min-height: 280px;
  }

  .map-card {
    width: 100%;
    height: 100%;
    min-height: 0;
  }

  .planner-pane {
    order: 1;
    flex: 1 1 auto;
    height: auto;
    min-height: 0;
  }
}

@media (max-width: 560px) {
  .map-pane {
    flex-basis: 196px;
    height: 196px;
    min-height: 196px;
  }

  .map-pane.expanded {
    flex-basis: min(44dvh, 340px);
    height: min(44dvh, 340px);
    min-height: 270px;
  }
}

@media (max-height: 560px) and (min-width: 840px) {
  .map-card { min-height: 220px; }
}
