/* MitaBase Pro — a product of ETMITA · https://etmita.com
   Copyright © ETMITA. All rights reserved. */
/*
 * public/map.css — Live-Karte v3 (2026-08-23). Token-native (.mt-scope,
 * overview-tokens.css); the page module is src/features/map/map.page.ts
 * → public/js/pages/map.js. Pins glide (the module tweens positions);
 * this sheet only paints them. Dark mode: same tiles, CSS-filtered —
 * no second tile source, no third-party call added by a theme.
 */

.lm3 { display: flex; flex-direction: column; flex: 1; min-height: 0; gap: 10px; padding: 12px 14px 14px; }

/* ── top strip: counts · filters · search · realtime badge ───────── */
.lm3-top { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.lm3-counts { display: inline-flex; gap: 10px; align-items: center; }
.lm3-cnt {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--font-mono), monospace; font-size: .86rem; font-weight: 600; color: var(--text-primary);
}
.lm3-cnt i { width: 9px; height: 9px; border-radius: 999px; background: var(--text-muted); }
.lm3-cnt.is-live i { background: var(--status-valid); box-shadow: 0 0 0 3px var(--status-valid-soft); }
.lm3-cnt.is-idle i { background: var(--status-expiring); }
.lm3-cnt.is-parkt i { background: var(--text-muted); }
.lm3-chips { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.lm3-chip {
  height: 30px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--border-subtle);
  background: transparent; color: var(--text-secondary); font: inherit; font-size: .76rem; font-weight: 600; cursor: pointer;
  transition: background .12s, color .12s, border-color .12s;
}
.lm3-chip:hover { background: var(--surface-inset); color: var(--text-primary); }
.lm3-chip.is-on { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.lm3-search {
  display: inline-flex; align-items: center; gap: 8px; height: 34px; padding: 0 12px; min-width: 200px;
  border-radius: 999px; border: 1px solid var(--border-subtle); background: var(--surface-card); color: var(--text-muted);
  margin-inline-start: auto;
}
.lm3-search input { border: 0; background: transparent; color: var(--text-primary); font: inherit; font-size: .82rem; outline: none; width: 160px; }
.lm3-sse {
  display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 11px; border-radius: 999px;
  border: 1px solid var(--border-subtle); background: var(--surface-card); color: var(--text-muted);
  font-size: .72rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
}
.lm3-sse i { width: 8px; height: 8px; border-radius: 999px; background: var(--text-muted); }
.lm3-sse.is-on { color: var(--accent); border-color: var(--accent-fill-solid); }
.lm3-sse.is-on i { background: var(--accent-fill-solid); box-shadow: 0 0 0 3px var(--accent-soft); }

/* ── body: side panel + map ──────────────────────────────────────── */
.lm3-body { display: flex; gap: 12px; flex: 1; min-height: 0; }
.lm3-side {
  flex: 0 0 300px; min-width: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 6px;
  padding: 4px; scrollbar-width: thin;
}
.lm3-row {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; text-align: start;
  border-radius: 14px; border: 1px solid var(--border-subtle); background: var(--surface-card); color: var(--text-primary);
  font: inherit; cursor: pointer; transition: border-color .12s, transform .12s var(--mt-ease-out);
  min-height: 56px;
}
.lm3-row:hover { border-color: var(--border-strong); transform: translateY(-1px); }
.lm3-row.is-sel { border-color: var(--accent-fill-solid); box-shadow: 0 0 0 3px var(--accent-soft); }
.lm3-row.is-parkt { opacity: .72; }
.lm3-row-av { position: relative; flex: 0 0 auto; display: inline-flex; }
.lm3-row-av .mt-av, .lm3-row-av .lm3-avfall { border-radius: 999px; }
.lm3-avfall { display: inline-flex; align-items: center; justify-content: center; border-radius: 999px; background: var(--surface-inset); color: var(--text-secondary); font-size: .72rem; font-weight: 700; }
.lm3-row-veh { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: 10px; background: var(--surface-inset); color: var(--text-secondary); }
.lm3-row-veh.is-big { width: 44px; height: 44px; border-radius: 12px; }
.lm3-dot { position: absolute; inset-inline-end: -2px; inset-block-end: -2px; width: 11px; height: 11px; border-radius: 999px; border: 2px solid var(--surface-card); background: var(--text-muted); }
.lm3-dot.is-live { background: var(--status-valid); }
.lm3-dot.is-idle { background: var(--status-expiring); }
.lm3-row-txt { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.lm3-row-txt > b { font-size: .88rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lm3-row-sub { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.lm3-plate {
  display: inline-flex; padding: 1px 6px; border-radius: 6px; border: 1px solid var(--border-default);
  background: var(--surface-inset); font-family: var(--font-mono), monospace; font-size: .68rem; font-weight: 600; color: var(--text-secondary);
}
.lm3-src { font-size: .64rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--text-muted); }
.lm3-src.is-app { color: var(--status-info); }
.lm3-src.is-gps { color: var(--mt-purple, #8538f0); }
.lm3-far { font-size: .64rem; font-weight: 700; color: var(--status-expiring); }
.lm3-row-ride { display: inline-flex; align-items: center; gap: 5px; font-size: .74rem; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lm3-row-age { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; flex: 0 0 auto; font-size: .7rem; color: var(--text-muted); }
.lm3-kmh { font-family: var(--font-mono), monospace; font-size: .84rem; color: var(--status-valid); }
.lm3-kmh::after { content: " km/h"; font-size: .6rem; color: var(--text-muted); }
.lm3-empty { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 40px 16px; text-align: center; color: var(--text-muted); }
.lm3-empty-ic { display: inline-flex; width: 52px; height: 52px; border-radius: 16px; background: var(--surface-inset); align-items: center; justify-content: center; }
.lm3-empty b { color: var(--text-primary); font-size: .95rem; }
.lm3-empty span { font-size: .8rem; max-width: 32ch; line-height: 1.5; }

/* ── the map ─────────────────────────────────────────────────────── */
/* isolation: Leaflet's internal z-indexes (panes up to ~1000) must stay
   INSIDE the map box — without a stacking context they float above the
   navbar's dropdowns (operator report, 2026-08-23). */
.lm3-maphost { position: relative; flex: 1; min-width: 0; border-radius: 18px; overflow: hidden; border: 1px solid var(--border-subtle); isolation: isolate; z-index: 0; }
/* two classes on purpose: maplibre-gl.css sets .maplibregl-map { position: relative } and loads later */
.lm3-maphost .lm3-map { position: absolute; inset: 0; z-index: 1; background: var(--surface-inset); }
.lm3-recenter {
  position: absolute; z-index: 800; inset-block-end: 16px; inset-inline-start: 50%; transform: translateX(-50%);
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 16px; border-radius: 999px;
  border: 1px solid var(--border-default); background: var(--surface-card); color: var(--text-primary);
  font: inherit; font-size: .8rem; font-weight: 600; cursor: pointer; box-shadow: var(--shadow-md);
}
.lm3-recenter.hidden { display: none !important; }
.lm3-legend {
  position: absolute; z-index: 800; inset-block-start: 12px; inset-inline-end: 12px;
  display: inline-flex; gap: 10px; padding: 6px 12px; border-radius: 999px;
  border: 1px solid var(--border-subtle); background: var(--surface-card); color: var(--text-secondary); font-size: .7rem; font-weight: 600;
}
.lm3-legend span { display: inline-flex; align-items: center; gap: 5px; }
.lm3-legend i { width: 8px; height: 8px; border-radius: 999px; }
.lm3-legend .is-live { background: var(--status-valid); }
.lm3-legend .is-idle { background: var(--status-expiring); }
.lm3-legend .is-parkt { background: var(--text-muted); }

/* ── pins (our own DOM handed to a MapLibre Marker) ─────────────── */
.lm3-pin-wrap { width: 52px; height: 64px; background: none; border: none; cursor: pointer; }
.lm3-pin-wrap.lm3-hide { display: none !important; }
.lm3-pin { position: relative; width: 52px; height: 64px; display: flex; flex-direction: column; align-items: center; cursor: pointer; }
.lm3-pin-ring {
  position: absolute; top: 2px; left: 50%; transform: translateX(-50%);
  width: 42px; height: 42px; border-radius: 999px; border: 3px solid var(--text-muted); background: var(--surface-card);
  box-shadow: 0 4px 12px rgba(0, 0, 0, .28);
}
.lm3-pin.is-live .lm3-pin-ring { border-color: var(--status-valid); }
.lm3-pin.is-idle .lm3-pin-ring { border-color: var(--status-expiring); }
.lm3-pin.is-sel .lm3-pin-ring { box-shadow: 0 0 0 4px var(--accent-soft), 0 4px 12px rgba(0, 0, 0, .28); border-color: var(--accent-fill-solid); }
.lm3-pin .mt-av, .lm3-pin .lm3-avfall { position: absolute; top: 6px; left: 50%; transform: translateX(-50%); border-radius: 999px; }
.lm3-pin-veh { position: absolute; top: 8px; left: 50%; transform: translateX(-50%); display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: 999px; color: var(--text-primary); }
.lm3-pin.is-live.is-gps .lm3-pin-veh, .lm3-pin.is-live .lm3-pin-veh { color: var(--status-valid); }
.lm3-pin-h { position: absolute; top: -12px; left: 50%; margin-left: -6px; color: var(--status-valid); transition: transform .2s linear; }
.lm3-pin-speed {
  position: absolute; top: 0; inset-inline-end: -4px;
  min-width: 20px; padding: 1px 4px; border-radius: 999px; background: var(--status-valid); color: var(--text-on-status);
  font-family: var(--font-mono), monospace; font-size: .62rem; font-weight: 700; text-align: center;
}
.lm3-pin-tag {
  position: absolute; top: 48px; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 0;
  padding: 2px 8px; border-radius: 8px; background: var(--surface-card); border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-sm); white-space: nowrap;
}
.lm3-pin-tag b { font-size: .68rem; font-weight: 700; color: var(--text-primary); }
.lm3-pin-tag i { font-style: normal; font-family: var(--font-mono), monospace; font-size: .58rem; color: var(--text-muted); }
.lm3-pin.is-parkt { opacity: .68; }

/* The trail and the route lines are MapLibre line layers, painted from
   the same tokens (--accent-fill-solid · --mb-ink · --mb-lime ·
   --mb-meter-amber · --mb-danger) by map.page.ts paintTheme() — the
   canvas cannot read a stylesheet. */
.lm3-nav { display: inline-flex; align-items: center; flex-wrap: wrap; gap: 3px 5px; font-family: var(--font-mono), monospace; font-size: .72rem; line-height: 1.35; color: var(--text-primary); }
.lm3-nav.is-sheet { font-size: .84rem; }
.lm3-nav.is-arrived { color: var(--mb-lime-text); font-weight: 700; }
.lm3-nav-traffic { color: var(--mb-warn); font-weight: 700; }
.lm3-sheet-nav { margin-top: 4px; }

/* ── phone sheet ─────────────────────────────────────────────────── */
.lm3-sheet {
  position: fixed; z-index: 100050; inset-inline: 0; inset-block-end: 0;
  border-radius: 20px 20px 0 0; border: 1px solid var(--border-default); border-bottom: 0;
  background: var(--surface-card); color: var(--text-body); box-shadow: var(--shadow-lg);
  padding: 8px 16px calc(14px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 10px;
  animation: lm3Up .22s var(--mt-ease-out) backwards;
}
.lm3-sheet.hidden { display: none !important; }
@keyframes lm3Up { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.lm3-sheet-grab { width: 44px; height: 4px; border-radius: 999px; background: var(--border-default); margin: 2px auto 0; }
.lm3-sheet-head { display: flex; align-items: center; gap: 12px; }
.lm3-sheet-id { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.lm3-sheet-id b { font-size: 1rem; font-weight: 600; color: var(--text-primary); }
.lm3-sheet-id > span { display: inline-flex; gap: 6px; align-items: center; }
.lm3-iconbtn {
  display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px;
  border-radius: 10px; border: 1px solid var(--border-subtle); background: var(--surface-inset); color: var(--text-secondary); cursor: pointer;
}
.lm3-sheet-state { display: flex; align-items: center; gap: 8px; font-size: .84rem; color: var(--text-secondary); }
.lm3-sheet-state.is-live > span:first-child { color: var(--status-valid); font-weight: 700; }
.lm3-sheet-state.is-idle > span:first-child { color: var(--status-expiring); font-weight: 700; }
.lm3-sheet-ride { display: inline-flex; align-items: center; gap: 6px; font-size: .84rem; color: var(--text-primary); }
.lm3-sheet-actions { display: flex; gap: 8px; }
.lm3-sheet-btn {
  flex: 1 1 0; display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 44px;
  border-radius: 12px; border: 1px solid var(--border-subtle); background: var(--surface-inset); color: var(--text-primary);
  font: inherit; font-size: .82rem; font-weight: 600; text-decoration: none; cursor: pointer;
}
.lm3-sheet-btn.is-call { background: var(--accent-fill); color: var(--accent-contrast); border-color: transparent; }
.lm3-sheet-btn.is-off { opacity: .55; cursor: default; }

/* ── MapLibre chrome, token-dressed ──────────────────────────────── */
.lm3-map .maplibregl-ctrl-group { background: var(--surface-card); border: 1px solid var(--border-subtle); box-shadow: none; border-radius: 10px; overflow: hidden; }
.lm3-map .maplibregl-ctrl-group button {
  width: 40px !important; height: 40px !important;
  background: var(--surface-card); color: var(--text-primary); border-color: var(--border-subtle);
}
.lm3-map .maplibregl-ctrl-group button + button { border-top: 1px solid var(--border-subtle); }
body.dark .lm3-map .maplibregl-ctrl-zoom-in .maplibregl-ctrl-icon,
body.dark .lm3-map .maplibregl-ctrl-zoom-out .maplibregl-ctrl-icon { filter: invert(1); }
/* the attribution OpenStreetMap's licence asks for — visible in both themes, never compacted away */
.lm3-map .maplibregl-ctrl-attrib { background: color-mix(in srgb, var(--surface-card) 80%, transparent); color: var(--text-muted); font-size: 10px; border-radius: 6px 0 0 0; }
.lm3-map .maplibregl-ctrl-attrib a { color: var(--text-secondary); }
.lm3-map .maplibregl-canvas { outline: none; }

/* ── phone layout: horizontal strip + big targets ────────────────── */
@media (max-width: 767px) {
  .lm3 { padding: 8px 8px 0; gap: 8px; }
  .lm3-top { gap: 8px; }
  .lm3-search { min-width: 0; flex: 1 1 auto; order: 5; }
  .lm3-search input { width: 100%; }
  .lm3-body { flex-direction: column; }
  .lm3-side { flex: 0 0 auto; flex-direction: row; overflow-x: auto; overflow-y: hidden; padding: 2px; gap: 8px; }
  .lm3-row { flex: 0 0 auto; min-width: 150px; }
  .lm3-row-ride { display: none; }
  .lm3-pin-tag { display: none; }
  .lm3-pin.is-sel .lm3-pin-tag { display: none; }
  .lm3-maphost { min-height: 52vh; }
  .lm3-map .maplibregl-ctrl-group button { width: 44px !important; height: 44px !important; }
  .lm3-legend { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .lm3-sheet { animation: none; }
  .lm3-pin-h { transition: none; }
  .lm3-row { transition: none; }
}
