/* Map viewer (js/map-viewer.js). Prefix mv-. Below 1200px a full-screen overlay (100dvh, safe-area aware); from 1200px a large
   centred dialog over a backdrop. The host is a direct child of <body>; the page behind is locked with body.pp-sheet-lock. */

/* ---------- Expand control on the small maps ---------- */
.mv-wrap { position: relative; }
.mv-wrap .market-minimap { cursor: pointer; }
.mv-expand {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 800;
  width: 44px;
  height: 44px;
  min-height: 44px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
  cursor: pointer;
}
.mv-expand:hover { background: var(--surface-2); }
.mv-expand:focus-visible, .mv-close:focus-visible, .mv-ctl:focus-visible, .mv-route-row:focus-visible { outline: 3px solid var(--focus-ring); outline-offset: 2px; }

/* ---------- The viewer ---------- */
#mvHost { position: relative; z-index: 1200; }
.mv-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.55); }
.mv-dialog {
  position: fixed;
  inset: 0;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  color: var(--text);
  padding-top: env(safe-area-inset-top);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}
.mv-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 8px 6px 16px; border-bottom: 1px solid var(--border); }
.mv-title { margin: 0; font-size: 18px; line-height: 1.3; font-weight: 600; overflow-wrap: anywhere; }
.mv-title:focus { outline: none; }
.mv-close {
  flex: none;
  width: 44px;
  height: 44px;
  min-height: 44px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: var(--text);
  border: 0;
  border-radius: 10px;
  cursor: pointer;
}
.mv-close:hover { background: var(--surface-2); }
.mv-sr { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

.mv-body { flex: 1; min-height: 0; position: relative; display: flex; }
.mv-mapwrap { position: relative; flex: 1; min-width: 0; isolation: isolate; }
.mv-map { position: absolute; inset: 0; background: var(--surface-2); }

.mv-controls { position: absolute; top: 12px; right: 12px; z-index: 1000; display: flex; flex-direction: column; gap: 8px; }
.mv-ctl {
  width: 44px;
  height: 44px;
  min-height: 44px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
  cursor: pointer;
}
.mv-ctl:hover { background: var(--surface-2); }

.mv-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); border-top: 1px solid var(--border); background: var(--surface); }
.mv-loc-msg { flex: 1 1 200px; margin: 0; font-size: 13px; color: var(--text-muted); min-width: 0; }
.mv-loc-msg:empty { display: none; }
.mv-gmaps { flex: 0 0 auto; margin-left: auto; min-height: 44px; }

/* Markers: the hub markers are smaller than the entity pin and differ by shape and colour (bus stop: round, brand; landmark:
   rounded square, amber) so they never rely on colour alone. The selected hub is larger and outlined. */
.mv-hub-wrap { background: transparent; border: none; }
.mv-hub {
  box-sizing: border-box;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.45);
}
.mv-hub-stop { background: #330099; border-radius: 50%; }
.mv-hub-landmark { background: #B45309; border-radius: 6px; }
.mv-hub.is-selected { border-color: #12121C; border-width: 3px; box-shadow: 0 0 0 3px #fff, 0 2px 6px rgba(0, 0, 0, 0.5); }
.mv-hub.is-selected svg { width: 18px; height: 18px; }
.mv-popup-line { font-size: 13px; }

.mv-me-wrap { background: transparent; border: none; }
.mv-me-dot { display: block; width: 100%; height: 100%; box-sizing: border-box; background: #1a73e8; border: 3px solid #fff; border-radius: 50%; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.3), 0 1px 4px rgba(0, 0, 0, 0.4); }

/* Leaflet's popup close link is a small target; it is not the way out of the viewer (Close is). */
#mvHost .leaflet-container { font: inherit; }

/* ---------- Large dialog from 1200px ---------- */
@media (min-width: 1200px) {
  .mv-dialog {
    inset: auto;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: min(1100px, 90vw);
    height: 85vh;
    padding: 0;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.4);
  }
  .mv-foot { padding-bottom: 10px; }
}

/* ---------- Routes panel ---------- */
.mv-panel { background: var(--surface); color: var(--text); min-width: 0; }
.mv-panel-toggle {
  width: 100%;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 16px;
  background: transparent;
  color: var(--text);
  border: 0;
  border-bottom: 1px solid var(--border);
  font: inherit;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}
.mv-panel-toggle:focus-visible { outline: 3px solid var(--focus-ring); outline-offset: -3px; }
.mv-panel-chevron { flex: none; transition: transform 150ms; }
.mv-panel.is-collapsed .mv-panel-chevron { transform: rotate(180deg); }
.mv-panel.is-collapsed .mv-panel-body { display: none; }
.mv-panel-body { padding: 10px 12px 12px; overflow-y: auto; }
.mv-panel-note { margin: 0 0 8px; font-size: 13px; color: var(--text-muted); }
.mv-straight-note { margin: 10px 0 0; }
.mv-panel-status { margin: 8px 0 0; font-size: 13px; }
.mv-panel-status:empty { display: none; }
.mv-route-rows { display: flex; flex-direction: column; gap: 6px; }
.mv-route-row {
  width: 100%;
  min-height: 44px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 8px 12px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.mv-route-row[aria-pressed="true"] { border-color: var(--brand-text); background: var(--brand-tint); color: #12121C; box-shadow: inset 0 0 0 1px var(--brand-text); }
.mv-route-from { font-weight: 600; }
.mv-route-line { font-size: 13px; color: var(--text-muted); }
.mv-route-row[aria-pressed="true"] .mv-route-line { color: #3d3f55; }
.mv-route-flag { font-style: italic; }
.mv-whole, .mv-suggest { margin-top: 8px; min-height: 44px; }

/* The map's last-leg label and the starting-area marker */
.mv-line-label { background: var(--surface); color: var(--text); border: 1px solid var(--border); font-weight: 600; font-size: 12px; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3); }
.mv-line-label::before { display: none; }
.mv-origin-wrap { background: transparent; border: none; }
.mv-origin { box-sizing: border-box; width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; background: #15803D; color: #fff; border: 3px solid #fff; border-radius: 50%; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.45); }
.mv-origin svg { width: 16px; height: 16px; }

/* Phone: a bottom panel over the map that collapses so the map stays usable */
@media (max-width: 1199px) {
  .mv-panel { position: absolute; left: 0; right: 0; bottom: 0; z-index: 1100; max-height: 46%; display: flex; flex-direction: column; border-top: 1px solid var(--border); border-radius: 14px 14px 0 0; box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.25); }
  .mv-panel-body { flex: 1 1 auto; min-height: 0; }
}

/* Desktop: a side panel */
@media (min-width: 1200px) {
  .mv-panel { flex: 0 0 320px; display: flex; flex-direction: column; border-left: 1px solid var(--border); }
  .mv-panel-toggle { cursor: default; }
  .mv-panel-chevron { display: none; }
  .mv-panel.is-collapsed .mv-panel-body { display: block; }
}
