/* Shared LittleTrak map HUD styles */
:root {
  --bg: #e8eef5;
  --panel: rgba(255, 255, 255, 0.92);
  --ink: #152033;
  --muted: #5a6a82;
  --accent: #2f6fed;
  --dot: #34c759;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink);
  font-family: "SF Pro Display", "Segoe UI", system-ui, sans-serif; }
#map { position: absolute; inset: 0; }
.leaflet-top.leaflet-left { top: auto; bottom: 24px; }

.hud {
  position: absolute; z-index: 1000; left: 16px; top: 16px;
  width: min(360px, calc(100vw - 32px));
  background: var(--panel); backdrop-filter: blur(14px);
  border: 1px solid rgba(20,40,80,0.08);
  border-radius: 16px; padding: 14px 16px 12px;
  box-shadow: 0 12px 40px rgba(20,40,80,0.12);
  transition: width .2s ease, padding .2s ease;
}
.hud-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 10px; margin-bottom: 10px;
}
.hud-head-text { min-width: 0; flex: 1; }
.hud h1 { margin: 0 0 2px; font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
.hud .sub { color: var(--muted); font-size: 12px; margin: 0; }
.hud .sub.live-status {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  min-height: 22px;
}
.hud:not(.collapsed) .sub { margin-bottom: 0; }
.seen-label { color: var(--muted); }
.seen-badge {
  display: inline-flex; align-items: center; gap: 6px;
  border: 0; border-radius: 999px; padding: 2px 10px 2px 8px;
  font-size: 11px; font-weight: 700; letter-spacing: 0.01em;
  background: rgba(20,40,80,0.06); color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.seen-badge.now {
  background: rgba(52, 199, 89, 0.16); color: #1b7a35;
  box-shadow: 0 0 0 0 rgba(52, 199, 89, 0.55);
  animation: seen-glow 1.6s ease-out infinite;
}
.seen-badge .pulse {
  width: 7px; height: 7px; border-radius: 50%;
  background: #34c759;
  box-shadow: 0 0 0 0 rgba(52, 199, 89, 0.7);
  animation: seen-pulse 1.6s ease-out infinite;
}
@keyframes seen-glow {
  0% { box-shadow: 0 0 0 0 rgba(52, 199, 89, 0.45); }
  70% { box-shadow: 0 0 0 10px rgba(52, 199, 89, 0); }
  100% { box-shadow: 0 0 0 0 rgba(52, 199, 89, 0); }
}
@keyframes seen-pulse {
  0% { box-shadow: 0 0 0 0 rgba(52, 199, 89, 0.65); }
  70% { box-shadow: 0 0 0 8px rgba(52, 199, 89, 0); }
  100% { box-shadow: 0 0 0 0 rgba(52, 199, 89, 0); }
}
.hud.collapsed .live-chip {
  display: inline-flex; width: 8px; height: 8px; border-radius: 50%;
  background: #34c759; margin-left: 8px; vertical-align: middle;
  box-shadow: 0 0 0 0 rgba(52, 199, 89, 0.7);
  animation: seen-pulse 1.6s ease-out infinite;
}
.hud.collapsed .live-chip.off { display: none; }
.nav { display: flex; gap: 10px; margin-bottom: 8px; font-size: 12px; }
.nav a { color: var(--accent); text-decoration: none; font-weight: 600; }
.nav a.active { color: var(--ink); }

.device-pick { margin: 6px 0 8px; }
.device-pick select {
  width: 100%;
  background: rgba(20,40,80,0.05);
  color: var(--ink);
  border: 1px solid rgba(20,40,80,0.12);
  border-radius: 8px;
  padding: 6px 8px;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.transport {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  margin-bottom: 10px;
}
.transport .history-scrub {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.history-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}
.history-head .lbl { font-size: 12px; color: var(--muted); }
.history-head .times {
  display: flex; gap: 6px; font-size: 11px;
  color: var(--muted); font-variant-numeric: tabular-nums;
}
.history-head .sep { opacity: 0.5; }
.history-slider {
  width: 100%;
  accent-color: var(--accent);
  cursor: pointer;
  display: block;
}

button.icon.recenter {
  background: var(--accent);
  box-shadow: 0 4px 14px rgba(47,111,237,0.28);
  flex-shrink: 0;
}
button.icon.recenter svg {
  width: 18px; height: 18px;
  /* Filled paper-plane / near_me style */
  fill: currentColor; stroke: none;
}
button.icon.recenter.is-idle,
button.icon.recenter:disabled {
  background: rgba(20,40,80,0.18);
  color: rgba(255,255,255,0.9);
  box-shadow: none;
  opacity: 1;
  cursor: default;
  transform: none;
  filter: none;
}
button.icon.recenter:not(.is-idle):not(:disabled):hover {
  filter: brightness(1.08);
  transform: scale(1.04);
}

button.hud-toggle {
  width: 28px; height: 28px; border: 0; border-radius: 8px;
  background: rgba(20,40,80,0.06); color: var(--ink); cursor: pointer;
  display: grid; place-items: center; flex-shrink: 0; padding: 0;
}
button.hud-toggle:hover { background: rgba(20,40,80,0.1); }
button.hud-toggle svg {
  width: 14px; height: 14px; fill: none; stroke: currentColor;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
  transition: transform .2s ease;
}
.hud.collapsed {
  /* Keep full width so collapse doesn't jump the layout. */
  padding: 10px 16px;
}
.hud.collapsed .hud-head { margin-bottom: 0; align-items: center; }
.hud.collapsed .nav,
.hud.collapsed .hud-body,
.hud.collapsed .sub,
.hud.collapsed .device-pick { display: none; }
.hud.collapsed button.hud-toggle svg { transform: rotate(180deg); }

button.icon {
  width: 40px; height: 40px; border: 0; border-radius: 50%;
  background: var(--accent); color: #fff; cursor: pointer;
  display: grid; place-items: center; flex-shrink: 0;
  box-shadow: 0 4px 14px rgba(47,111,237,0.28);
  transition: transform .15s ease, filter .15s, background .15s ease;
}
button.icon:hover { filter: brightness(1.08); transform: scale(1.04); }
button.icon:disabled { opacity: 0.45; cursor: default; transform: none; }
button.icon svg { width: 18px; height: 18px; fill: currentColor; }
button.secondary {
  border: 1px solid rgba(20,40,80,0.14); background: rgba(20,40,80,0.05);
  color: var(--ink); border-radius: 8px; padding: 6px 10px; font-size: 12px;
  font-weight: 600; cursor: pointer;
}
button.secondary:hover { background: rgba(20,40,80,0.08); }

.scrub { flex: 1; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.scrub input[type=range],
.ctrl input[type=range].slider-blue,
.ctrl input[type=range] {
  flex: 1; min-width: 0; width: 100%; accent-color: var(--accent); cursor: pointer;
}
.times { display: flex; justify-content: space-between; font-size: 11px;
  color: var(--muted); font-variant-numeric: tabular-nums; width: 100%; }

.stats {
  display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px;
  margin: 10px 0 8px;
}
.stat {
  background: rgba(20,40,80,0.04); border-radius: 10px; padding: 8px 10px;
}
.stat .k { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.stat .v { font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; margin-top: 2px; }

.opts {
  display: flex; flex-direction: column; gap: 0; margin-top: 2px;
  border-top: 1px solid rgba(20,40,80,0.08); padding-top: 10px;
}
.ctrl {
  display: grid;
  grid-template-columns: 108px 1fr;
  gap: 8px 12px;
  align-items: center;
  min-height: 28px;
}
.ctrl + .ctrl { margin-top: 6px; }
.ctrl .lbl { font-size: 12px; color: var(--muted); line-height: 1.2;
  display: flex; align-items: baseline; justify-content: space-between; gap: 6px; }
.ctrl .lbl .inline-val {
  font-size: 12px; font-weight: 600; color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.ctrl .fld { display: flex; align-items: center; gap: 10px; min-width: 0; }
.ctrl .fld > input[type=range] { width: 100%; }
.ctrl .fld.checks {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 12px;
}
.ctrl label.check {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--ink); cursor: pointer; user-select: none;
}
.ctrl select, .ctrl input[type=datetime-local] {
  background: rgba(20,40,80,0.05); color: var(--ink);
  border: 1px solid rgba(20,40,80,0.12); border-radius: 8px;
  padding: 4px 8px; font-size: 12px; width: 100%;
}
.ctrl input[type=checkbox] { accent-color: var(--accent); margin: 0; }
.ctrl .val {
  width: 48px; flex-shrink: 0;
  font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums;
  text-align: right; color: var(--ink);
}
.hint {
  font-size: 11px; color: var(--muted); line-height: 1.35;
  margin: 8px 0 0;
}

button.toggle-btn {
  border: 1px solid rgba(20,40,80,0.14);
  background: rgba(20,40,80,0.05);
  color: var(--muted);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  justify-self: start;
}
button.toggle-btn.on,
button.toggle-btn[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

button.debug-toggle {
  margin-top: 8px;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border: 0;
  border-radius: 8px;
  background: rgba(20,40,80,0.06);
  color: var(--ink);
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
button.debug-toggle svg {
  width: 14px; height: 14px; fill: none; stroke: currentColor;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
  transition: transform .2s ease;
}
button.debug-toggle.open svg { transform: rotate(180deg); }

.debug-panel {
  display: none;
  margin-top: 8px;
  padding: 8px;
  border-radius: 10px;
  background: rgba(20,40,80,0.04);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: var(--muted);
  overflow-x: auto;
}
.debug-panel.on { display: block; }
.dbg-dev { margin-bottom: 6px; color: var(--ink); }
.dbg-row {
  display: grid;
  grid-template-columns: 9ch 9.2ch 8.6ch 5.2ch 5.2ch 4.6ch 4.6ch;
  gap: 6px;
  line-height: 1.55;
}
.dbg-row.head { color: var(--ink); font-weight: 600; }
.dbg-row span { text-align: right; }
.dbg-row span:first-child { text-align: left; }
.dbg-empty { color: var(--muted); padding: 4px 0; }

.dot-icon {
  position: absolute; left: 50%; top: 50%;
  width: 16px; height: 16px; margin: -8px 0 0 -8px;
  border-radius: 50%; background: #34c759;
  border: 2px solid #fff;
  box-shadow: 0 0 0 0 rgba(52, 199, 89, 0.7);
  animation: seen-pulse 1.6s ease-out infinite;
  pointer-events: none;
}
.marker-wrap { position: relative; width: 32px; height: 32px; }
.heading-cone {
  position: absolute; left: 50%; top: 50%;
  width: 0; height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-bottom: 14px solid #248a3d;
  transform: translate(-50%, -100%) rotate(0deg);
  transform-origin: 50% 100%;
  pointer-events: none;
}
.heading-cone.hidden { display: none; }
.dot-icon.hidden { display: none; }
