/* HattiesburgLife map: full-screen MapLibre map with a bottom sheet (phones) / side panel (desktop). */
body.page-map { overflow: hidden; overscroll-behavior: none; }
body.page-map .site-foot { display: none; }
body.page-map main { min-height: 0; }

.mapapp { position: fixed; left: 0; right: 0; top: var(--head-h, 107px); bottom: calc(var(--tabbar) + env(safe-area-inset-bottom)); --peek: 150px; --panel-w: 384px; }
.mapapp__map { position: absolute; inset: 0; background: var(--surface-2); }
.mapapp__loading { position: absolute; left: 50%; top: 40%; transform: translate(-50%, -50%); padding: 10px 16px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); font-weight: 600; font-size: .9rem; box-shadow: var(--shadow); z-index: 2; }
.mapapp__loading[hidden] { display: none; }

/* ---------- Sheet / panel ---------- */
.msheet {
  position: absolute; z-index: 5; left: 0; right: 0; bottom: 0; height: calc(100% - 10px);
  display: flex; flex-direction: column; background: var(--surface); color: var(--ink);
  border-radius: 20px 20px 0 0; box-shadow: 0 -6px 30px rgba(10, 20, 15, .16);
  transform: translateY(var(--sheet-y, calc(100% - var(--peek))));
  transition: transform .32s cubic-bezier(.2, .8, .2, 1);
  will-change: transform; touch-action: none;
}
.mapapp[data-sheet="half"] .msheet { --sheet-y: 46%; }
.mapapp[data-sheet="full"] .msheet { --sheet-y: 0px; }
.msheet.dragging { transition: none; }
.msheet__grab { flex: none; display: grid; place-items: center; height: 34px; width: 100%; border: 0; background: none; cursor: grab; padding: 0; touch-action: none; }
.msheet__grab span { width: 44px; height: 5px; border-radius: 9px; background: var(--line-2); }
.msheet__head { flex: none; padding: 0 14px 10px; display: grid; gap: 10px; }
.msheet__body { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 4px max(14px, env(safe-area-inset-right)) calc(var(--hide, 0px) + 24px + env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left)); -webkit-overflow-scrolling: touch; touch-action: pan-y; }
.msheet__head { padding-left: max(14px, env(safe-area-inset-left)); padding-right: max(14px, env(safe-area-inset-right)); }
.mapapp[data-sheet="peek"] .msheet__body { visibility: hidden; }

@media (min-width: 900px) {
  .mapapp { --peek: 0px; }
  .msheet { left: 12px; right: auto; top: 12px; bottom: 12px; height: auto; width: var(--panel-w); border-radius: 18px; transform: none !important; box-shadow: var(--shadow-lg); border: 1px solid var(--line); }
  .msheet__grab { display: none; }
  .msheet__head { padding-top: 14px; }
  .mapapp[data-sheet] .msheet__body { visibility: visible; }
}
@media (prefers-reduced-motion: reduce) { .msheet { transition: none; } }

/* ---------- Search ---------- */
.msearch { position: relative; }
.msearch svg { position: absolute; left: 14px; top: 13px; width: 19px; height: 19px; color: var(--muted); pointer-events: none; }
.msearch input { width: 100%; height: 46px; border-radius: 14px; border: 1px solid var(--line-2); background: var(--bg); color: var(--ink); padding: 0 14px 0 42px; font: inherit; font-size: 16px; /* 16px stops iOS zoom-on-focus */ }
.msearch input:focus { outline: 2px solid var(--focus); outline-offset: 1px; }
.msearch__results { list-style: none; margin: 0 0 12px; padding: 0; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.msearch__results[hidden] { display: none; }
.msearch__results li + li { border-top: 1px solid var(--line); }
.msearch__results li[aria-selected="true"] button { background: var(--surface-2); }
.msearch__results button { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 52px; padding: 8px 14px; background: var(--surface); border: 0; text-align: left; font: inherit; color: var(--ink); cursor: pointer; }
.msearch__results button:hover, .msearch__results button[aria-selected="true"] { background: var(--surface-2); }
.msearch__results small { display: block; color: var(--muted); font-size: .8rem; }
.msearch__results .empty { padding: 14px; color: var(--muted); font-size: .92rem; }

/* ---------- Views (presets) ---------- */
.mviews { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; margin: 0 -14px; padding: 0 14px 2px; scroll-padding: 0 14px; }
.mviews::-webkit-scrollbar { display: none; }
.mviews button { flex: none; display: inline-flex; align-items: center; gap: 6px; height: 44px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--line-2); background: var(--surface); color: var(--ink-2); font: 600 .86rem/1 var(--font); cursor: pointer; white-space: nowrap; }
.mviews button svg { width: 14px; height: 14px; display: none; }
.mviews button[aria-pressed="true"] { border-color: var(--brand); color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand); }
.mviews button[aria-pressed="true"] svg { display: inline; }
@media (min-width: 900px) { .mviews { flex-wrap: wrap; overflow: visible; margin: 0; padding: 0; } }

/* ---------- Layers list ---------- */
.mlayers h3 { font: 700 .74rem/1 var(--font); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 18px 0 6px; }
.mlayers h3:first-child { margin-top: 6px; }
.mlayer { display: grid; grid-template-columns: 26px minmax(0, 1fr) auto 22px; align-items: center; gap: 10px; min-height: 48px; padding: 4px 2px; border-bottom: 1px solid var(--line); cursor: pointer; }
.mlayer:last-of-type { border-bottom: 0; }
.mlayer input { width: 20px; height: 20px; margin: 0; accent-color: var(--brand); cursor: pointer; }
.mlayer__name { display: flex; align-items: center; gap: 9px; min-width: 0; font-weight: 550; font-size: .95rem; }
.mlayer__name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mlayer__name svg { flex: none; width: 20px; height: 20px; }
.mlayer__count { font-size: .8rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.mlayer__state { width: 18px; height: 18px; color: var(--muted); opacity: 0; }
.mlayer__state.spin { opacity: 1; }
.mlayer__state.spin { animation: mspin .8s linear infinite; }
.mlayer__desc { grid-column: 2 / -1; margin: -4px 0 6px; font-size: .8rem; color: var(--muted); }
.mlayer[data-error] .mlayer__count { color: var(--lead); }
@keyframes mspin { to { transform: rotate(360deg); } }
.mshade { display: grid; gap: 2px; }
.mshade label { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 2px; font-weight: 550; font-size: .95rem; border-bottom: 1px solid var(--line); cursor: pointer; }
.mshade label:last-child { border-bottom: 0; }
.mshade input { width: 20px; height: 20px; margin: 0; accent-color: var(--brand); }
.mnote { font-size: .8rem; color: var(--muted); margin-top: 10px; line-height: 1.45; }
.mnote a { color: inherit; }
.msources { margin-top: 22px; font-size: .78rem; color: var(--muted); line-height: 1.5; }
.msources summary { cursor: pointer; font-weight: 600; min-height: 44px; display: flex; align-items: center; }
.msources ul { padding-left: 18px; margin: 4px 0 0; }

/* ---------- Detail ---------- */
.mdetail { padding-top: 4px; }
.mdetail[hidden] { display: none; }
.mdetail__top { display: flex; align-items: flex-start; gap: 10px; }
.mdetail__top h2 { flex: 1; font-size: 1.3rem; line-height: 1.2; }
.mdetail__close { flex: none; width: 44px; height: 44px; margin: -8px -8px 0 0; border: 0; background: none; color: var(--muted); border-radius: 12px; cursor: pointer; display: grid; place-items: center; }
.mdetail__close:hover { background: var(--surface-2); color: var(--ink); }
.mdetail__close svg { width: 22px; height: 22px; }
.mdetail__kind { display: inline-flex; align-items: center; gap: 7px; font: 650 .74rem/1 var(--font); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
.mdetail__kind svg { width: 16px; height: 16px; }
.mdetail__sub { color: var(--muted); font-size: .9rem; margin-top: 4px; }
.mdetail dl { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 14px; margin: 14px 0 0; font-size: .92rem; }
.mdetail dt { color: var(--muted); }
.mdetail dd { margin: 0; font-weight: 550; overflow-wrap: anywhere; }
.mdetail__list { list-style: none; padding: 0; margin: 14px 0 0; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.mdetail__list li + li { border-top: 1px solid var(--line); }
.mdetail__list a { display: block; padding: 11px 14px; text-decoration: none; min-height: 48px; }
.mdetail__list a:hover { background: var(--surface-2); }
.mdetail__list b { display: block; font-weight: 600; font-size: .94rem; line-height: 1.3; }
.mdetail__list small { display: block; color: var(--muted); font-size: .8rem; margin-top: 2px; }
.mdetail__actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.mdetail__actions .btn { height: 44px; }
.mdetail__src { margin-top: 14px; font-size: .78rem; color: var(--muted); }

/* ---------- Legend ---------- */
.mlegend { position: absolute; z-index: 3; left: 10px; top: 10px; max-width: min(260px, calc(100% - 70px)); background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; box-shadow: var(--shadow); font-size: .8rem; }
.mlegend[hidden] { display: none; }
.mlegend b { display: block; font-size: .82rem; margin-bottom: 6px; }
.mlegend__ramp { display: flex; height: 10px; border-radius: 6px; overflow: hidden; }
.mlegend__ramp i { flex: 1; }
.mlegend__labels { display: flex; justify-content: space-between; margin-top: 4px; color: var(--muted); font-variant-numeric: tabular-nums; gap: 6px; }
.mlegend__na { display: flex; align-items: center; gap: 6px; margin-top: 6px; color: var(--muted); }
.mlegend__na i { width: 14px; height: 10px; border-radius: 2px; background: none; border: 1.5px dashed var(--muted); }
@media (min-width: 900px) { .mlegend { left: auto; right: 54px; top: auto; bottom: 34px; } }

/* ---------- MapLibre chrome ---------- */
.mapapp .maplibregl-ctrl-group { border-radius: 12px; box-shadow: var(--shadow); border: 1px solid var(--line); background: var(--surface); overflow: hidden; }
.mapapp .maplibregl-ctrl-group button { width: 44px; height: 44px; }
.mapapp .maplibregl-ctrl-group button + button { border-top-color: var(--line); }
.mapapp .maplibregl-ctrl-top-right { top: 0; right: env(safe-area-inset-right); }
.mapapp .mlegend { left: max(10px, env(safe-area-inset-left)); }
.mapapp .maplibregl-ctrl-bottom-right, .mapapp .maplibregl-ctrl-bottom-left { bottom: var(--peek); transition: bottom .3s; }
.mapapp .maplibregl-ctrl-attrib { font-size: 11px; }
@media (min-width: 900px) { .mapapp .maplibregl-ctrl-bottom-left { left: calc(var(--panel-w) + 24px); } }
:root[data-theme="dark"] .mapapp .maplibregl-ctrl-group button .maplibregl-ctrl-icon,
.dark-map .maplibregl-ctrl-group button .maplibregl-ctrl-icon { filter: invert(1); }
.mapapp .maplibregl-ctrl-attrib { background: color-mix(in srgb, var(--surface) 80%, transparent); color: var(--muted); }
.mapapp .maplibregl-ctrl-attrib a { color: var(--ink-2); }
.mapapp .maplibregl-canvas:focus-visible { outline: 3px solid var(--focus); outline-offset: -3px; }

/* Hover tooltip (desktop pointer only) */
.mtip { position: absolute; z-index: 4; pointer-events: none; padding: 6px 10px; border-radius: 9px; background: var(--ink); color: var(--bg); font: 600 .8rem/1.3 var(--font); max-width: 240px; transform: translate(-50%, calc(-100% - 14px)); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mtip[hidden] { display: none; }
