/* ============================================================
   LIVEMAP — живая карта поставок (Leaflet + кастомные оверлеи)
   ============================================================ */

.livemap {
  padding: clamp(64px, 8vw, 120px) 0;
  background: linear-gradient(180deg, var(--bg) 0%, var(--bg-3) 100%);
  position: relative;
  overflow: hidden;
}

.livemap::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(900px 500px at 80% 0%, rgba(47, 58, 74, 0.05), transparent 70%),
    radial-gradient(700px 400px at 20% 100%, rgba(200, 168, 110, 0.06), transparent 70%);
  pointer-events: none;
}

.livemap .wrap { position: relative; z-index: 1; }

.livemap .sec-head { max-width: 760px; margin-bottom: 32px; }

.lm-sub-row {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  margin-top: 14px;
  font-size: 13px; color: var(--ink-2);
  font-weight: 500; letter-spacing: 0.02em;
}
.lm-live-dot {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 5px 12px 5px 10px;
  border-radius: 999px;
  background: rgba(47, 58, 74, 0.08);
  color: var(--accent);
  font-weight: 600; font-size: 12px;
  letter-spacing: 0.04em; text-transform: uppercase;
}
.lm-live-dot::before {
  content: "";
  width: 8px; height: 8px; border-radius: 50%;
  background: #5dd96a;
  box-shadow: 0 0 0 0 rgba(93, 217, 106, 0.6);
  animation: lm-pulse 1.8s ease-out infinite;
}
@keyframes lm-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(93, 217, 106, 0.55); }
  70%  { box-shadow: 0 0 0 12px rgba(93, 217, 106, 0); }
  100% { box-shadow: 0 0 0 0 rgba(93, 217, 106, 0); }
}

/* === Stats row === */
.livemap-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  margin-bottom: 28px;
}
.livemap-stat {
  background: var(--bg-2);
  padding: 22px 22px 18px;
  display: flex; flex-direction: column; gap: 6px;
}
.lm-num {
  font-family: 'Inter', sans-serif;
  font-size: clamp(28px, 3.2vw, 40px);
  font-weight: 700;
  line-height: 1; letter-spacing: -0.02em;
  color: var(--ink);
  display: flex; align-items: baseline; gap: 6px;
}
.lm-num .lm-unit {
  font-size: 14px; font-weight: 500;
  color: var(--ink-2);
  letter-spacing: 0;
}
.lm-num.lm-tg { color: var(--accent); }
.lm-l {
  font-size: 13px; color: var(--ink-2);
  letter-spacing: 0.02em;
}
@media (max-width: 720px) {
  .livemap-stats { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 380px) {
  .livemap-stats { grid-template-columns: 1fr; }
}

/* === Map frame === */
.livemap-frame {
  position: relative;
  border: 1px solid var(--line-strong);
  border-radius: 18px;
  overflow: hidden;
  background: var(--bg-2);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.6) inset,
    0 24px 48px -28px rgba(31, 24, 12, 0.18);
}

.livemap-canvas {
  width: 100%;
  height: clamp(420px, 56vh, 620px);
  background: #e9e3d5;
}

/* Стилизуем тайлы Carto под палитру беж+графит */
.livemap-canvas .leaflet-tile-pane {
  filter:
    saturate(0.35)
    sepia(0.18)
    contrast(0.92)
    brightness(1.02);
  mix-blend-mode: multiply;
  opacity: 0.85;
}

.livemap-canvas .leaflet-container {
  background: #e9e3d5 !important;
  font-family: 'Inter', sans-serif;
  outline: none;
}

/* Убираем мокроту контролов и атрибуции — оставим только тонкую подпись */
.livemap-canvas .leaflet-control-zoom,
.livemap-canvas .leaflet-control-attribution a { display: none !important; }
.livemap-canvas .leaflet-control-attribution {
  background: transparent !important;
  color: rgba(31, 24, 12, 0.35) !important;
  font-size: 10px !important;
  padding: 2px 6px !important;
  letter-spacing: 0.02em;
}

/* === Кастомные маркеры === */
.lm-marker-moscow {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid #fffdf9;
  box-shadow:
    0 0 0 2px var(--accent),
    0 6px 14px rgba(47, 58, 74, 0.4);
  position: relative;
}
.lm-marker-moscow::after {
  content: "";
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  opacity: 0.6;
  animation: lm-ring 2.4s ease-out infinite;
}
@keyframes lm-ring {
  0%   { transform: scale(0.6); opacity: 0.6; }
  100% { transform: scale(2.2); opacity: 0; }
}

.lm-marker-origin {
  width: 12px; height: 12px;
  border-radius: 50%;
  background: #fffdf9;
  border: 2px solid var(--accent);
  box-shadow: 0 4px 10px rgba(31, 24, 12, 0.18);
}

.lm-marker-car {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #fffdf9;
  box-shadow:
    0 0 0 4px rgba(47, 58, 74, 0.16),
    0 4px 12px rgba(31, 24, 12, 0.25);
  display: grid; place-items: center;
  color: #fffdf9;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.lm-marker-car:hover {
  transform: scale(1.15);
  box-shadow:
    0 0 0 6px rgba(47, 58, 74, 0.22),
    0 6px 16px rgba(31, 24, 12, 0.32);
}
.lm-marker-car svg { width: 16px; height: 16px; fill: currentColor; }

/* Маркер авто — статичный, без движения */
.lm-marker-car .lm-prog-ring {
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 2px solid rgba(47, 58, 74, 0.18);
  pointer-events: none;
}

/* === Подписи городов === */
.livemap-canvas .leaflet-tooltip.lm-tooltip {
  background: var(--ink);
  color: #fffdf9;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 4px 9px;
  box-shadow: 0 6px 14px -8px rgba(31, 24, 12, 0.4);
}
.livemap-canvas .leaflet-tooltip.lm-tooltip::before {
  border-right-color: var(--ink);
}
.livemap-canvas .leaflet-tooltip.lm-tooltip-moscow {
  background: var(--accent);
  border-color: var(--accent);
  color: #fffdf9;
}
.livemap-canvas .leaflet-tooltip.lm-tooltip-moscow::before {
  border-right-color: var(--accent);
}
.livemap-canvas .leaflet-tooltip.lm-tooltip-origin {
  background: rgba(255, 253, 249, 0.95);
  color: var(--ink);
  border: 1px solid var(--line);
  font-size: 10px;
  text-transform: none;
  letter-spacing: 0;
  padding: 3px 7px;
}
.livemap-canvas .leaflet-tooltip.lm-tooltip-origin::before {
  border-top-color: rgba(255, 253, 249, 0.95);
}
@media (max-width: 720px) {
  .livemap-canvas .leaflet-tooltip.lm-tooltip-origin {
    display: none;
  }
}

/* === Попап === */
.livemap-canvas .leaflet-popup-content-wrapper {
  background: var(--ink);
  color: #fffdf9;
  border-radius: 10px;
  padding: 14px 16px;
  box-shadow: 0 16px 40px -16px rgba(31, 24, 12, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.08);
}
.livemap-canvas .leaflet-popup-content {
  margin: 0;
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  line-height: 1.45;
  width: 240px !important;
}
.livemap-canvas .leaflet-popup-tip { background: var(--ink); }
.livemap-canvas .leaflet-popup-close-button { color: rgba(255, 255, 255, 0.5) !important; }

.lm-pop {
  display: flex; flex-direction: column; gap: 10px;
}
.lm-pop-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.lm-pop-brand {
  font-size: 14px; font-weight: 700; letter-spacing: -0.01em;
  color: #fffdf9;
}
.lm-pop-route {
  font-size: 11px; font-weight: 500;
  padding: 3px 8px;
  border-radius: 6px;
  background: rgba(200, 168, 110, 0.15);
  color: #d4b878;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.lm-pop-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px 14px;
}
.lm-pop-cell {
  display: flex; flex-direction: column; gap: 2px;
}
.lm-pop-cell .lm-pop-l {
  font-size: 10px; letter-spacing: 0.06em;
  color: rgba(255, 255, 255, 0.45);
  text-transform: uppercase;
}
.lm-pop-cell .lm-pop-v {
  font-size: 13px; font-weight: 600;
  color: #fffdf9;
}

.lm-pop-bar {
  height: 4px; border-radius: 2px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
}
.lm-pop-bar > i {
  display: block; height: 100%;
  background: linear-gradient(90deg, #c8a86e, #d4b878);
  border-radius: 2px;
}

/* === Legend === */
.livemap-legend {
  position: absolute;
  top: 16px; left: 16px;
  background: rgba(255, 253, 249, 0.94);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  display: flex; flex-direction: column; gap: 6px;
  font-size: 12px;
  color: var(--ink);
  z-index: 401;
  box-shadow: 0 8px 24px -12px rgba(31, 24, 12, 0.18);
}
.lm-legend-title {
  font-size: 10px; font-weight: 600;
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--ink-2);
  margin-bottom: 4px;
}
.lm-legend-line {
  display: flex; align-items: center; gap: 8px;
  font-weight: 500;
}
.lm-legend-line .lm-l-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}
.lm-legend-line .lm-l-name { font-weight: 600; }
.lm-legend-line .lm-l-meta { color: var(--ink-2); font-weight: 400; font-size: 11px; }

/* === Bottom bar with route summary === */
.livemap-routes {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-top: 18px;
}
.lm-route-card {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
  display: flex; flex-direction: column; gap: 4px;
  transition: border-color 0.2s ease, transform 0.2s ease;
}
.lm-route-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}
.lm-route-flag {
  display: flex; align-items: center; gap: 8px;
  font-size: 18px;
}
.lm-route-flag span {
  font-size: 13px; font-weight: 600; color: var(--ink);
  letter-spacing: 0.02em;
}
.lm-route-stat {
  display: flex; align-items: baseline; gap: 6px;
  margin-top: 4px;
}
.lm-route-stat b {
  font-size: 18px; font-weight: 700; color: var(--accent);
  letter-spacing: -0.01em;
}
.lm-route-stat span {
  font-size: 12px; color: var(--ink-2);
}
.lm-route-card .lm-route-meta {
  font-size: 11px; color: var(--ink-3);
  letter-spacing: 0.02em;
  margin-top: 2px;
}

@media (max-width: 900px) {
  .livemap-routes { grid-template-columns: repeat(2, 1fr); }
  .lm-legend-title { display: none; }
  .livemap-legend { padding: 8px 10px; }
}
@media (max-width: 720px) {
  .livemap-legend { display: none; }
}
@media (max-width: 480px) {
  .livemap-routes { grid-template-columns: 1fr; }
  .livemap-canvas { height: 380px; }
  .lm-pop-grid { grid-template-columns: 1fr; }
  .livemap-canvas .leaflet-popup-content { width: 200px !important; }
}

@media (prefers-reduced-motion: reduce) {
  .lm-marker-moscow::after,
  .lm-live-dot::before,
  .lm-marker-car .lm-prog-ring { animation: none; }
}
