/* Travel heatmap — стили в духе лендинга: тёмный терминал, пиксельная графика. */

:root {
  --bg: #0b0b0b;
  --panel: rgba(13, 13, 14, 0.92);
  --fg: #e8e6e3;
  --dim: #8a8783;
  --edge: #2a2a2c;
  --violet: #a78bfa;
  --violet-strong: #7c3aed;
  --blue: #93c5fd;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
  --pixel: 'Handjet', var(--mono);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--mono);
  overscroll-behavior: none; /* карта на весь экран: без pull-to-refresh при драге */
}

#map { position: fixed; inset: 0; background: var(--bg); }

.dim { opacity: 0.55; }

/* ── бренд-ссылка на главную ─────────────────── */
#brand {
  position: absolute;
  top: 14px;
  left: 14px;
  z-index: 600;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 12px;
  background: var(--panel);
  border: 1px solid var(--edge);
  color: var(--fg);
  text-decoration: none;
  font-size: 14px;
  line-height: 1.2;
}
#brand:hover { border-color: var(--fg); }
.brand__host { color: var(--violet); }
#brand .dim { font-size: 12px; }

/* ── панель управления ───────────────────────── */
#panel {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 600;
  width: 320px;
  max-width: calc(100vw - 28px);
  max-height: calc(100vh - 28px);
  overflow-y: auto;
  padding: 16px;
  background: var(--panel);
  border: 1px solid var(--edge);
}

.panel__bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 12px;
}

.panel__title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-family: var(--pixel);
  font-size: 24px;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1;
}
.panel__title svg { width: 20px; height: 20px; fill: var(--violet); flex: none; }

/* тумблер панели: виден только на телефоне, на десктопе панель раскрыта */
#panel-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  margin: -12px -8px -12px auto; /* тап-зона 44px при компактной строке заголовка */
  background: transparent;
  border: 0;
  color: var(--dim);
  cursor: pointer;
}
#panel-toggle svg { width: 16px; height: 16px; fill: currentColor; transition: transform 0.15s steps(2, end); }

.status { margin: 0 0 12px; font-size: 12.5px; color: var(--dim); }

.stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 14px;
}
.stat {
  border: 1px solid var(--edge);
  padding: 6px 10px;
}
.stat b {
  display: block;
  font-size: 20px;
  font-weight: 700;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}
.stat span { font-size: 11px; color: var(--dim); }

.label { font-size: 11px; color: var(--dim); margin-bottom: 6px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--fg);
  background: transparent;
  border: 1px solid var(--violet-strong);
  cursor: pointer;
  transition: background-color 0.12s steps(2, end), color 0.12s steps(2, end);
}
.chip svg { width: 14px; height: 14px; fill: currentColor; }
.chip i { font-style: normal; opacity: 0.55; font-variant-numeric: tabular-nums; }
.chip[aria-pressed="false"] { border-color: var(--edge); color: var(--dim); background: transparent; }
.chip[aria-pressed="true"]:hover { background: var(--violet-strong); color: #fff; }

/* ── переключатели ───────────────────────────── */
.tog {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 0;
  font-size: 13px;
  cursor: pointer;
  user-select: none;
}
.tog input { position: absolute; opacity: 0; }
.tog i {
  position: relative;
  width: 34px;
  height: 18px;
  border: 1px solid var(--edge);
  background: transparent;
  transition: border-color 0.12s steps(2, end);
  flex: none;
}
.tog i::before {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 12px;
  height: 12px;
  background: var(--dim);
  transition: transform 0.12s steps(2, end), background-color 0.12s steps(2, end);
}
.tog input:checked + i { border-color: var(--violet-strong); }
.tog input:checked + i::before { transform: translateX(16px); background: var(--violet); }
.tog input:focus-visible + i { outline: 2px solid var(--violet); outline-offset: 2px; }

/* ── кнопки ──────────────────────────────────── */
.btns { display: grid; gap: 8px; margin-top: 12px; }
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 12px;
  font-family: var(--mono);
  font-size: 13px;
  color: var(--fg);
  background: transparent;
  border: 1px solid var(--fg);
  cursor: pointer;
  transition: background-color 0.12s steps(2, end), color 0.12s steps(2, end);
}
.btn svg { width: 14px; height: 14px; fill: currentColor; }
.btn:hover { background: var(--fg); color: var(--bg); }
.btn.ghost { border-color: var(--edge); color: var(--dim); }
.btn.ghost:hover { border-color: var(--fg); background: transparent; color: var(--fg); }
.btn[disabled] { opacity: 0.5; cursor: wait; }

.msg { margin-top: 10px; font-size: 12px; color: var(--dim); }

/* ── leaflet-тюнинг ──────────────────────────── */
.leaflet-container { background: var(--bg); font-family: var(--mono); }
.leaflet-control-attribution {
  background: rgba(11, 11, 11, 0.8) !important;
  color: var(--dim) !important;
  font-size: 10px !important;
}
.leaflet-control-attribution a { color: var(--dim) !important; }
.leaflet-tooltip {
  font-family: var(--mono);
  font-size: 11px;
  background: var(--panel);
  border: 1px solid var(--edge);
  color: var(--fg);
  box-shadow: none;
}
.leaflet-tooltip-top:before { border-top-color: var(--edge); }

@media (max-width: 640px) {
  #brand { top: 8px; left: 8px; padding: 6px 10px; }

  /* панель — bottom sheet: свёрнута в строку заголовка, разворачивается тапом */
  #panel {
    top: auto;
    bottom: 0;
    right: 0;
    left: 0;
    width: auto;
    max-height: min(76vh, 620px);
    max-height: min(76dvh, 620px);
    padding: 10px 12px calc(12px + env(safe-area-inset-bottom));
    border-bottom: 0;
    border-right: 0;
    border-left: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 1100; /* выше leaflet-контролов (1000), чтобы атрибуция не липла поверх */
  }
  .panel__bar { margin-bottom: 0; flex: none; }
  #panel-toggle { display: inline-flex; }
  #panel.collapsed #panel-toggle svg { transform: rotate(180deg); }
  #panel-body {
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    margin-top: 12px;
  }
  #panel.collapsed #panel-body { display: none; }
  #panel.collapsed { padding-bottom: calc(10px + env(safe-area-inset-bottom)); }

  /* листалки не нужны (пинч) и они перекрывают бренд; атрибуцию убираем от панели */
  .leaflet-control-zoom { display: none; }
  .leaflet-bottom.leaflet-right { top: 8px; right: 8px; bottom: auto; left: auto; }

  /* крупные тапы: чипы, тумблеры, кнопки */
  .chip { padding: 7px 12px; }
  .tog { padding: 10px 0; }
  .tog i { width: 38px; height: 20px; }
  .tog input:checked + i::before { transform: translateX(18px); }
  .btn { padding: 12px; }
  .msg { margin-top: 12px; }
}
