/* Regional map: always-visible layer panel, phone bottom drawer, 100dvh map.
   Loaded after site.css on regional-map.html only (body.rm-page). */
.rm-page .map-layout { margin: 1rem 0; }
.rm-page .map-main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 17rem;
  grid-template-areas: "toolbar toolbar" "hint hint" "status status" "map panel";
  column-gap: 0.85rem;
  align-items: start;
}
.rm-page .map-toolbar { grid-area: toolbar; }
.rm-page .map-locate-hint { grid-area: hint; }
.rm-page .map-status-banner { grid-area: status; }
.rm-page .map-frame { grid-area: map; min-width: 0; }
.rm-page .layer-panel { grid-area: panel; }
.rm-page #map { height: 70vh; min-height: 28rem; }

/* Layer panel */
.layer-panel { margin: 0; padding: 0.75rem 0.85rem; min-width: 0; }
.layer-panel-handle {
  display: flex; align-items: center; gap: 0.5rem; width: 100%;
  min-height: 44px; margin: 0 0 0.35rem; padding: 0.2rem 0;
  border: 0; background: none; font: inherit; color: var(--ink); cursor: pointer; text-align: left;
}
.layer-panel-title { font-weight: 700; font-size: 1.05rem; }
.layer-panel-more-label { margin-left: auto; font-size: 0.85rem; color: #1f5c45; text-decoration: underline; }
.layer-panel-grip { display: none; }
.layer-list { list-style: none; margin: 0; padding: 0; }
.layer-item {
  display: flex; align-items: center; gap: 0.55rem;
  min-height: 44px; padding: 0.25rem 0.35rem; border-radius: 8px; cursor: pointer;
}
.layer-item:hover { background: #eef3ee; }
.layer-item input { width: 1.25rem; height: 1.25rem; margin: 0; flex: 0 0 auto; accent-color: #1f5c45; }
.layer-item .swatch { margin: 0; }
.layer-name { font-weight: 600; flex: 1 1 auto; min-width: 0; }
.layer-count { font-size: 0.8rem; color: var(--muted); white-space: nowrap; }
.layer-option .layer-name { font-weight: 500; }
.layer-panel-more { display: none; border-top: 1px solid var(--line); margin-top: 0.4rem; padding-top: 0.4rem; }
.layer-panel.is-expanded .layer-panel-more { display: block; }
.layer-panel .map-legend { margin: 0.5rem 0; }

/* Swatches per layer */
.swatch.sw-tax { background: rgba(31, 92, 69, 0.35); border: 2px solid #1f5c45; border-radius: 3px; }
.swatch.sw-sale { background: #1e3a5f; border: 2px solid #111; border-radius: 50%; }
.swatch.sw-lodging { background: #0f766e; border: 2px solid #0b3d39; border-radius: 50%; }
.swatch.sw-lodging-hollow { background: #fff; border: 3px dashed #0f766e; border-radius: 50%; }
.swatch.sw-fbcl { border-radius: 50%; border: 2px solid #1a1f1c; background: linear-gradient(90deg, #5c3d6e 50%, #b45309 50%); }

/* Popups and tooltips: tap-friendly */
.rm-page .leaflet-popup-pane { display: block !important; }
.rm-page .leaflet-popup-content { margin: 0.75rem 0.9rem; overflow-wrap: anywhere; }
.rm-page .leaflet-popup-content .map-popup { max-width: none; }
.rm-page .leaflet-container a.leaflet-popup-close-button {
  width: 44px; height: 44px; font-size: 1.6rem; line-height: 44px; padding: 0; text-align: center;
}
.rm-page .leaflet-popup-content .map-popup .parcel-owner { padding-right: 1.6rem; }
.rm-page .map-popup a { min-height: 40px; line-height: 1.6; padding: 0.4rem 0.75rem; margin-right: 0.35rem; }
.rm-approx { margin: 0.25rem 0; padding: 0.3rem 0.5rem; border-left: 3px solid #b45309; background: #fff7ed; font-size: 0.85rem; }
.rm-terms { font-size: 0.88rem; }
.rm-tooltip { max-width: 18rem; white-space: normal; }
.rm-page .map-feature-panel { display: none !important; }

/* Full screen: keep the panel visible next to/below the map */
body.rm-page.map-user-fs .map-layout { display: block; }
body.rm-page.map-user-fs .map-main {
  display: grid; height: 100%;
  grid-template-rows: auto auto auto minmax(0, 1fr);
}
body.rm-page.map-user-fs .map-frame,
body.rm-page.map-user-fs #map { min-height: 0; height: 100%; }
body.rm-page.map-user-fs .layer-panel { overflow-y: auto; max-height: 100%; border-radius: 0; }

/* Phones: map fills the viewport (100dvh) with the panel as a bottom drawer
   beneath it, so the panel never covers the map. */
@media (max-width: 720px) {
  .rm-page .map-main {
    display: flex; flex-direction: column;
    height: 100vh; height: 100dvh;
  }
  .rm-page .map-toolbar { flex: 0 0 auto; margin: 0 0 0.4rem; }
  .rm-page .map-toolbar .map-tool-btn { flex: 1 1 auto; justify-content: center; }
  .rm-page .map-status-banner { display: none; }
  .rm-page .map-locate-hint { flex: 0 0 auto; padding: 0.6rem 0.8rem; font-size: 0.95rem; }
  .rm-page .map-frame { flex: 1 1 auto; min-height: 12rem; height: auto; border-radius: 10px 10px 0 0; }
  .rm-page #map { height: 100%; min-height: 0; }
  .rm-page .layer-panel {
    flex: 0 0 auto; max-height: 55%; overflow-y: auto; -webkit-overflow-scrolling: touch;
    border-radius: 0 0 12px 12px; border-top: 0; padding: 0.25rem 0.75rem 0.6rem;
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.08);
  }
  .layer-panel-handle { flex-wrap: wrap; justify-content: space-between; }
  .layer-panel-grip { display: block; width: 100%; height: 4px; }
  .layer-panel-grip::before { content: ""; display: block; width: 2.5rem; height: 4px; margin: 0 auto; border-radius: 2px; background: #c8c4b8; }
  .layer-list { display: grid; grid-template-columns: 1fr 1fr; gap: 0.25rem 0.5rem; }
  .layer-item { min-height: 48px; padding: 0.3rem 0.4rem; border: 1px solid var(--line); background: #fff; }
  .layer-item .layer-count { display: none; }
  .layer-name { font-size: 0.9rem; line-height: 1.2; }
  body.rm-page.map-user-fs .map-main { display: flex; }
  body.rm-page.map-user-fs .map-frame { flex: 1 1 auto; min-height: 0; }
  body.rm-page.map-user-fs .map-toolbar { margin: 0; }
}
@media (max-width: 340px) { .layer-list { grid-template-columns: 1fr; } }

/* ---- v2: compact phone layout (desktop unchanged) ---- */
.layer-legend-btn, .layer-panel-state { display: none; }
@media (max-width: 720px) {
  /* Collapsible panel: thin handle bar when collapsed */
  .rm-page .layer-panel { padding: 0 0.6rem 0.4rem; }
  .layer-panel-handle { min-height: 40px; margin: 0; padding: 0.15rem 0; flex-wrap: nowrap; }
  .layer-panel-grip { display: none; }
  .layer-panel-handle .layer-panel-more-label { display: none; }
  .layer-panel-state { display: inline; font-weight: 600; color: #1f5c45; font-size: 0.9rem; }
  .layer-panel-title { font-size: 0.98rem; }
  .layer-panel.is-collapsed .layer-list,
  .layer-panel.is-collapsed .layer-legend-btn,
  .layer-panel.is-collapsed .layer-panel-more { display: none !important; }
  .rm-page .layer-panel.is-collapsed { padding-bottom: 0; overflow: hidden; }
  /* Compact chips when expanded */
  .layer-list { display: flex; flex-wrap: wrap; gap: 0.35rem; }
  .layer-item { min-height: 40px; padding: 0.2rem 0.6rem 0.2rem 0.45rem; border-radius: 999px; gap: 0.35rem; }
  .layer-item input { width: 1.1rem; height: 1.1rem; }
  .layer-item .swatch { width: 0.95rem; height: 0.95rem; flex-basis: 0.95rem; }
  .layer-name { font-size: 0.85rem; white-space: nowrap; }
  .layer-legend-btn {
    display: inline-block; margin: 0.35rem 0 0; padding: 0.3rem 0; min-height: 36px;
    border: 0; background: none; font: inherit; font-size: 0.85rem; color: #1f5c45; text-decoration: underline; cursor: pointer;
  }

  /* Compact popups */
  .rm-page .leaflet-popup-content { margin: 0.45rem 0.6rem; font-size: 0.82rem; line-height: 1.3; }
  .rm-page .leaflet-popup-content p { margin: 0.15rem 0; }
  .rm-page .leaflet-popup-content .map-popup .parcel-owner { font-size: 0.9rem; padding-right: 1.9rem; }
  .rm-page .leaflet-popup-content .map-popup .sources { font-size: 0.78rem; }
  .rm-page .leaflet-container a.leaflet-popup-close-button { width: 36px; height: 36px; line-height: 36px; font-size: 1.35rem; }
  .rm-summary { font-size: 0.82rem; }
  .rm-more summary { min-height: 32px; line-height: 32px; font-weight: 600; color: #1f5c45; cursor: pointer; }
  .rm-page .map-popup a { min-height: 32px; line-height: 1.4; padding: 0.3rem 0.55rem; font-size: 0.8rem; }
  .rm-page .map-popup a.rm-tel { background: none; color: #1f5c45 !important; padding: 0.2rem 0; text-decoration: underline; min-height: 0; margin: 0; }
  .rm-approx { font-size: 0.78rem; padding: 0.2rem 0.4rem; }

  /* Fullscreen: no banner; Exit + My location become small icon buttons over the map corner */
  body.rm-page.map-user-fs .map-fs-banner { display: none !important; }
  body.rm-page.map-user-fs .map-main { position: relative; }
  body.rm-page.map-user-fs .map-toolbar {
    position: absolute; top: 0.5rem; right: 0.5rem; z-index: 1100;
    display: flex; flex-direction: column; gap: 0.4rem;
    margin: 0; padding: 0; background: none; border: 0; box-shadow: none;
  }
  body.rm-page.map-user-fs .map-toolbar .map-tool-btn {
    flex: 0 0 auto; width: 44px; height: 44px; min-height: 44px; padding: 0; justify-content: center;
    border-radius: 8px; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
  }
  body.rm-page.map-user-fs .map-tool-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  body.rm-page.map-user-fs .map-locate-hint { position: absolute; left: 0.5rem; right: 3.6rem; bottom: 3.5rem; z-index: 1100; }
  body.rm-page.map-user-fs .map-frame { border-radius: 0; }
}
.rm-page .layer-panel { align-self: stretch; }
