/* The map explorer (/housing/map/explore): the map is the page. It fills the screen under the site header
   (--fg-map-top, measured by map-explorer.mjs); full screen hides the header and the map starts at the top.
   The toolbar, legend, popup and pin card come from the shared map files (/assets/fg); this file places the page. */
.mx { margin: 0; padding: 0; color: var(--gw-ink, #1f1f1f); font-family: var(--gw-font, Figtree, system-ui, sans-serif); }
.mx [hidden] { display: none !important; }
.mx-title { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

html.mx-page, html.mx-page body { height: 100%; overflow: hidden; overscroll-behavior: none; }
html.mx-page body { background: #f2efe9; }
html.mx-page .mx-map.mx-map { position: fixed; inset: var(--fg-map-top, 0px) 0 0 0; z-index: 1; height: auto; margin: 0; border: 0; border-radius: 0; background: #f2efe9; }
.mx-map .fg-map-canvas { position: absolute; inset: 0; }
.mx-map:focus-visible { outline: 2px solid var(--gw-ink, #1f1f1f); outline-offset: -2px; }
/* MapLibre's attribution moves left of the side panel while it is open. */
.mx .mx-map.fgm .maplibregl-ctrl-bottom-right { right: var(--mx-side-w, 0px); }

/* Full screen: the Fullscreen API on <html>, or the html.mx-full fallback where the API is missing (iPhone Safari). */
html:is(.mx-full, :fullscreen) { --fg-map-top: 0px !important; }
html:is(.mx-full, :fullscreen) :is(.gw-ds3-mast, header.gw-masthead) { display: none !important; }
html:fullscreen body { background: #f2efe9; }

/* The toolbar floats over the top of the map; only its own controls take clicks. */
.mx-toolbar { position: absolute; z-index: 6; top: 0; left: 0; right: 0; pointer-events: none; }
.mx-toolbar > * { pointer-events: auto; }

/* Side panel: "More about this spot" and Compare. A white card on the right, under the toolbar, full map height. */
.mx-side {
  position: fixed; z-index: 8; top: calc(var(--fg-map-top, 0px) + 72px); right: 12px; bottom: 12px;
  box-sizing: border-box; width: 360px; max-width: calc(100vw - 24px); overflow-y: auto; overscroll-behavior: contain;
  background: #fff; border-radius: 16px; box-shadow: 0 1px 2px rgb(0 0 0 / .16), 0 8px 28px rgb(0 0 0 / .18);
  color: var(--gw-ink, #1f1f1f); font: 400 15px/1.45 var(--gw-font, Figtree, system-ui, sans-serif);
}
.mx-side-bar {
  position: sticky; top: 0; z-index: 1; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  min-height: 56px; padding: 6px 6px 6px 16px; background: #fff; border-bottom: 1px solid #e4e4e2;
}
.mx-side-bar h2 { margin: 0; font: 700 16px/1.25 var(--gw-font, Figtree, system-ui, sans-serif); }
.mx-side-bar h2:focus { outline: none; }
.mx-side-bar h2:focus-visible { outline: 2px solid currentColor; outline-offset: 3px; }
.mx-side-close {
  display: grid; place-items: center; flex: none; width: 44px; height: 44px; margin: 0; padding: 0;
  border: 0; border-radius: 999px; background: transparent; color: inherit; cursor: pointer;
}
.mx-side-close:hover { background: #f2f2f0; }
.mx-side-close:focus-visible { outline: 2px solid currentColor; outline-offset: -2px; }
.mx-side-body, .mx-side > :not(.mx-side-bar) { padding: 12px 16px 16px; }
.mx-side-body:empty { display: none; }

/* No map: the browser can't draw it, or JavaScript is off. */
.mx-fallback { box-sizing: border-box; max-width: 600px; margin: 48px auto; padding: 0 16px; font-size: 17px; line-height: 1.5; }
.mx-fallback a { color: inherit; font-weight: 650; text-underline-offset: .18em; }

/* Phones: the side panel is a sheet from the bottom, over the legend; the map stays above it. */
@media (max-width: 760px) {
  .mx-side { top: auto; left: 0; right: 0; bottom: 0; width: auto; max-width: none; max-height: min(72dvh, calc(100dvh - var(--fg-map-top, 0px) - 72px));
    border-radius: 16px 16px 0 0; padding-bottom: env(safe-area-inset-bottom, 0px); box-shadow: 0 -4px 20px rgb(0 0 0 / .16); }
  /* The attribution sits just above the card at the bottom of the map (the hint or the legend row), measured by
     map-explorer.mjs as --mx-attrib-b. */
  .mx .mx-map.fgm .maplibregl-ctrl-bottom-right { right: 0; bottom: var(--mx-attrib-b, 0px); }
}
@keyframes mx-side-in { from { opacity: 0; transform: translateX(12px); } }
@keyframes mx-sheet-in { from { opacity: 0; transform: translateY(24px); } }
@media (prefers-reduced-motion: no-preference) {
  .mx-side:not([hidden]) { animation: mx-side-in .18s ease-out; }
}
@media (prefers-reduced-motion: no-preference) and (max-width: 760px) {
  .mx-side:not([hidden]) { animation-name: mx-sheet-in; }
}

/* Zoom in, zoom out and reset view: one stacked card bottom right, above the attribution, left of an open side panel.
   Phones pinch, so the card is desktop only. */
.mx-zoom {
  position: absolute; z-index: 5; right: calc(12px + var(--mx-side-w, 0px)); bottom: 28px; display: flex; flex-direction: column;
  overflow: hidden; border-radius: 12px; background: #fff; box-shadow: 0 1px 2px rgb(0 0 0 / .16), 0 2px 8px rgb(0 0 0 / .12);
}
.mx-zoom button {
  display: grid; place-items: center; width: 44px; height: 44px; margin: 0; padding: 0; border: 0; border-radius: 0;
  background: #fff; color: var(--gw-ink, #1f1f1f); cursor: pointer;
}
.mx-zoom button + button { border-top: 1px solid #e4e4e2; }
.mx-zoom button:hover { background: #f6f6f4; }
.mx-zoom button:focus-visible { outline: 2px solid var(--gw-ink, #1f1f1f); outline-offset: -3px; }
@media (max-width: 760px) { .mx-zoom { display: none; } }
/* No layer on, phones: the hint is one short line (map-explorer.mjs), balanced if it ever wraps. */
.mx .fg-map-hint { text-wrap: balance; }

/* Narrow desktops with the side panel open: the zoom card would meet the legend card, so it steps aside; the
   map still pinches and wheels. */
@media (max-width: 1099px) { html.mx-side-open .mx-zoom { display: none; } }
