/* map.css — the Map tab (#/map). Tokens from app.css; MapLibre's own CSS is
 * loaded by map.js with the library, only when the tab opens. */

/* The map fills the viewport under the sticky header (--bt-hdr is its live
 * height, set by assistant.js), like the Assistant page: no page scroll, no footer. */
html:has(body.on-map), body.on-map { overflow: hidden; }
body.on-map .ftr { display: none; }
.map-page { position: relative; height: calc(100dvh - var(--bt-hdr, var(--hdr-h))); }
/* .map-page > keeps this ahead of maplibre-gl.css, which loads later and sets .maplibregl-map to position: relative */
.map-page > .map-canvas { position: absolute; inset: 0; background: #eef1f4; }
/* MapLibre's corner controls: the bottom-right ones clear the assistant launcher */
.map-page .maplibregl-ctrl-bottom-right { right: 88px; }
.map-msg { position: absolute; inset: 0; display: grid; place-items: center; padding: 24px; text-align: center; font-size: 14px; color: var(--ink-2); }

/* the panel: summary, stats, layer toggles, view, legend */
.map-panel { position: absolute; z-index: 2; top: 16px; left: 16px; width: 340px; max-height: calc(100% - 128px); overflow-y: auto; overscroll-behavior: contain; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-2); }
/* the panel scrolls, not its body; the summary bar stays pinned at the top while it does */
.map-panel > summary { position: sticky; top: 0; z-index: 1; background: var(--surface); list-style: none; cursor: pointer; display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 18px; }
.map-panel > summary::-webkit-details-marker { display: none; }
.map-panel[open] > summary { border-bottom: 1px solid var(--line); }
.map-panel summary b { display: block; font-size: 16px; color: var(--ink); margin-top: 2px; }
.map-panel summary .ic { width: 18px; height: 18px; color: var(--ink-3); transition: transform .3s var(--ease); flex: none; }
.map-panel[open] summary .ic { transform: rotate(180deg); }
.map-panel-body { padding: 12px 18px 16px; }
.map-sub { margin: 0 0 12px; font-size: 12.5px; color: var(--ink-2); }
.map-stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.map-stats div { border: 1px solid var(--line); border-top: 3px solid var(--gold-500); border-radius: 10px; padding: 9px 12px; }
.map-stats b { display: block; font-size: 22px; font-weight: 800; line-height: 1.1; color: var(--ink); font-variant-numeric: tabular-nums; }
.map-stats span { font-size: 11px; color: var(--ink-3); }
.map-wx { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 12px; font-size: 12.5px; color: var(--ink-2); }
.map-panel .drawer-h { margin: 16px 0 8px; }
.map-layers { display: flex; flex-direction: column; gap: 9px; }
.map-toggle { display: flex; gap: 10px; align-items: flex-start; font-size: 13px; font-weight: 600; color: var(--ink); cursor: pointer; }
.map-toggle input { accent-color: var(--navy-700); width: 16px; height: 16px; margin: 1px 0 0; flex: none; }
.map-toggle small { display: block; font-size: 11.5px; font-weight: 400; color: var(--ink-3); }
.map-views { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 14px; }
.map-basemap-hint { margin: 6px 0 0; font-size: 11.5px; color: var(--ink-3); }
.map-page .map-legend { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 7px 10px; font-size: 12px; color: var(--ink-2); }
.map-page .map-legend li { display: flex; align-items: center; gap: 7px; }
.map-views button { padding: 7px 12px; border: 1px solid var(--line); border-radius: 7px; background: #fff; color: var(--navy-700); font-size: 12px; font-weight: 600; }
.map-views button.active { background: var(--navy-700); border-color: var(--navy-700); color: #fff; }
.map-panel .drawer-h { text-transform: uppercase; letter-spacing: .12em; font-size: 10px; }
.bt-pop button { display: block; border: 0; background: transparent; color: var(--navy-700); font-weight: 600; padding: 6px 0 0; }
.map-note { margin: 14px 0 0; font-size: 11.5px; line-height: 1.5; color: var(--ink-3); }

/* legend marks: the same colors the layers use */
.mk { width: 11px; height: 11px; border-radius: 50%; border: 1.5px solid #fff; box-shadow: 0 0 0 1px rgba(13, 43, 73, .18); flex: none; }
.mk.ok { background: var(--ok); } .mk.warn { background: var(--warn); } .mk.crit { background: var(--crit); }
.mk.blue { background: var(--blue-500); } .mk.navy { background: var(--navy-700); }
.mk.ship { border: 2px solid var(--navy-700); box-shadow: none; }
.mk.wh { width: 14px; height: 14px; background: var(--navy-700); border: 3px solid var(--gold-500); box-shadow: none; }
.mk.zone { width: 16px; height: 11px; border-radius: 3px; border: 1.5px dashed currentColor; box-shadow: none; }
.mk.zone.crit { color: var(--crit); background: var(--crit-bg); } .mk.zone.warn { color: var(--warn); background: var(--warn-bg); }

/* Operating-area navigation stays visible below the scrolling panel. */
.map-area-switch { position: absolute; z-index: 3; bottom: 18px; left: 16px; width: 340px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: #fff; box-shadow: var(--shadow-2); display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.map-area-switch > span { grid-column: 1 / -1; font-size: 9px; font-weight: 700; letter-spacing: .15em; text-transform: uppercase; color: var(--ink-3); }
.map-area-switch a { text-align: center; border: 1px solid var(--line); border-radius: 7px; padding: 9px; font-size: 12px; font-weight: 800; letter-spacing: .08em; color: var(--navy-700); }
.map-area-switch a.active { background: var(--navy-700); border-color: var(--navy-700); color: #fff; box-shadow: inset 0 -3px var(--gold-500); }
.map-area-switch a:focus-visible, .map-roster button:focus-visible { outline: 2px solid var(--gold-500); outline-offset: 2px; }
.map-roster { margin-bottom: 16px; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.map-roster button { display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; padding: 10px 12px; border: 0; background: #fff; text-align: left; color: var(--navy-700); }
.map-roster button + button { border-top: 1px solid var(--line); }
.map-roster button:hover { background: var(--blue-100); }
.map-roster strong { font-size: 12px; display: block; }
.map-roster small { font-size: 10px; color: var(--ink-3); display: block; margin-top: 2px; }
.map-panel .drawer-h > span { float: right; text-transform: none; letter-spacing: 0; color: var(--ink-3); font-weight: 400; }
.map-data-note { margin-top: 12px; padding: 10px 12px; border-left: 3px solid var(--gold-500); background: #fffbf0; color: var(--ink-2); font-size: 11px; line-height: 1.5; }
.map-data-note strong { display: block; color: var(--navy-700); }
.map-sources { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 12px; font-size: 11px; color: var(--ink-3); }
.map-sources summary { cursor: pointer; font-weight: 600; color: var(--navy-700); }
.map-sources a { display: block; padding: 6px 0; color: var(--navy-700); }
.map-sources small { display: block; color: var(--ink-3); }
.mk.representative { background: #8393a2; border: 2px solid var(--gold-500); }
.mk.dependency { width: 18px; height: 3px; border: 0; border-radius: 0; background: #cf8700; }
.map-inspector { position: absolute; z-index: 4; right: 16px; top: 16px; width: 340px; max-height: calc(100% - 110px); overflow-y: auto; padding: 16px; border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-2); background: #fff; font-size: 12px; line-height: 1.5; color: var(--ink-2); }
.map-inspector[hidden] { display: none; }
.map-inspector > b { padding-right: 22px; }
.map-inspector .map-inspector-close { position: absolute; right: 8px; top: 5px; padding: 4px 8px; font-size: 22px; line-height: 1; }
.map-inspector .map-node-metrics b { font-size: 20px; }
.map-inspector .map-labor > strong { font-size: 12px; }
.map-node-tag { color: #9b6900; background: #fff5dc; font-size: 10px; padding: 3px 7px; border-radius: 4px; display: inline-block; }
.bt-pop p { margin: 7px 0; }
.map-posture { display: block; color: var(--navy-700); font-size: 12px; }
.map-posture small { font-weight: 400; color: var(--ink-3); }
.map-node-metrics { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 12px 0; margin-top: 8px; border-block: 1px solid var(--line); }
.map-node-metrics span { font-size: 10px; }
.map-node-metrics b { font-size: 20px; margin: 0; }
.map-labor { padding: 10px 0; font-size: 11px; }
.map-labor > strong { display: block; margin-bottom: 5px; color: var(--navy-700); }
.map-labor > div { display: flex; justify-content: space-between; gap: 20px; padding: 2px 0; }
.map-node-source { border-top: 1px solid var(--line); padding-top: 10px; margin-top: 10px; font-size: 10px; }
.map-node-source > strong, .map-node-source > span, .map-node-source > small { display: block; }
.map-node-source a { display: block; font-size: 10px; }
.map-page .maplibregl-ctrl-attrib { max-width: max(180px, calc(100vw - 480px)); }

/* popups (MapLibre's markup, our look) */
.bt-pop .maplibregl-popup-content { border-radius: 10px; padding: 12px 16px 12px 14px; box-shadow: var(--shadow-2); font-family: inherit; font-size: 12.5px; line-height: 1.5; color: var(--ink-2); }
.bt-pop .maplibregl-popup-close-button { font-size: 18px; width: 26px; height: 26px; color: var(--ink-3); }
.bt-pop .maplibregl-popup-close-button:focus { outline: none; }
.bt-pop .maplibregl-popup-close-button:focus-visible { outline: 2px solid var(--gold-500); border-radius: 6px; }
.bt-pop b { display: block; padding-right: 16px; margin-bottom: 2px; font-size: 13.5px; color: var(--ink); }
.bt-pop .pill { margin: 5px 6px 3px 0; }
.bt-pop a { display: inline-block; margin-top: 6px; font-weight: 600; color: var(--navy-700); }
.bt-pop a:hover { text-decoration: underline; }
.bt-pop em { display: block; margin-top: 4px; font-size: 11px; color: var(--ink-3); }

/* phones: the panel folds to its summary bar at the top (map.js starts it folded) */
@media (max-width: 1100px) {
  .map-inspector { top: auto; bottom: 108px; right: 12px; width: min(340px, calc(100% - 24px)); max-height: 48%; }
}
@media (max-width: 720px) {
  .map-panel { top: 10px; left: 10px; right: 10px; width: auto; max-height: 62%; }
  .map-area-switch { bottom: 14px; left: 10px; width: min(240px, calc(100% - 105px)); }
  .map-area-switch a { font-size: 11px; padding: 8px; }
  .map-page .maplibregl-ctrl-attrib { max-width: 180px; }
  .map-page .maplibregl-ctrl-bottom-right { bottom: 108px; right: 10px; }
}
