@import url('./fonts.css?v=bt-v13');

/* ============================================================
   «Медвежья тропа» — демо
   Основа: фирменный стиль портала Visit Yaroslavia (белое полотно,
   тёмный текст, фотография как герой, плоско, без теней).
   Идентичность «Медвежьей тропы» — акцентом, а не заливкой.
   ============================================================ */

:root {
  /* Полотно */
  --paper:        #FFFFFF;
  --surface:      #F7F6F4;   /* тёплый нейтральный, не серый */
  --surface-2:    #EFEDE8;
  --line:         #E8E5DF;

  /* Текст */
  --ink:          #1C1C1C;
  --ink-2:        #6B6B6B;
  --ink-3:        #9A968E;

  /* Акценты — дозированно */
  --accent:       #F3B917;   /* жёлтый: стрелка, активное, прогресс. ≤10% площади */
  --accent-deep:  #C4930F;   /* жёлтый для текста на светлом — контраст */
  --route:        #E02324;   /* ТОЛЬКО линия маршрута */
  --ok:           #1F9D4D;
  --warn:         #D97706;

  /* Геометрия */
  --r-card:  12px;
  --r-btn:   14px;
  --r-chip:  999px;
  --pad:     20px;

  /* Движение: всё до 400 мс, ничего не прыгает */
  --e-out:   cubic-bezier(.2, .8, .2, 1);
  --e-in-out:cubic-bezier(.4, 0, .2, 1);
  --t-fast:  200ms;
  --t-base:  260ms;
  --t-slow:  400ms;

  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  overscroll-behavior: none;
}

body {
  background: var(--paper);
  color: var(--ink);
  font-family: 'Golos Text', -apple-system, 'Segoe UI', system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

/* Крупные числа и заголовки экранов — единственное место Unbounded */
.display {
  font-family: 'Unbounded', 'Golos Text', sans-serif;
  font-weight: 700;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}

h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; text-wrap: balance; }
h1 { font-size: 24px; }
h2 { font-size: 19px; }
h3 { font-size: 16px; }
p  { margin: 0 0 12px; text-wrap: pretty; }
p:last-child { margin-bottom: 0; }

.muted   { color: var(--ink-2); }
.small   { font-size: 13px; line-height: 1.4; }
.tiny    { font-size: 11.5px; line-height: 1.35; }
.upper   { text-transform: uppercase; letter-spacing: .08em; font-weight: 600; font-size: 11.5px; }

/* ─── Каркас экрана ─────────────────────────────────────── */

#app {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  max-width: 520px;
  margin: 0 auto;
  background: var(--paper);
  overflow: hidden;
}

.screen {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  background: var(--paper);
}
.screen.is-active { display: flex; animation: screen-in var(--t-fast) var(--e-out); }

@keyframes screen-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

.screen__body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0 var(--pad) 24px;
}

/* ─── Верхняя панель ────────────────────────────────────── */

.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: calc(var(--safe-t) + 12px) var(--pad) 12px;
  border-bottom: 1px solid var(--line);
  background: var(--paper);
  flex-shrink: 0;
}
.topbar__title {
  font-weight: 600;
  font-size: 16px;
  letter-spacing: -0.01em;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.topbar__logo { display: flex; align-items: center; gap: 8px; flex: 1; }
.topbar__logo span { font-weight: 600; font-size: 15px; letter-spacing: -0.01em; }

/* ─── Кнопки ────────────────────────────────────────────── */

.btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: var(--r-btn);
  font: inherit;
  font-weight: 600;
  font-size: 15px;
  min-height: 52px;
  padding: 0 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  cursor: pointer;
  background: var(--ink);
  color: var(--paper);
  transition: transform 120ms var(--e-out), background var(--t-fast) var(--e-in-out);
}
.btn:active { transform: scale(.975); }
.btn--accent  { background: var(--accent); color: var(--ink); }  /* текст только тёмный */
.btn--ghost   { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn--quiet   { background: transparent; color: var(--ink-2); min-height: 44px; font-weight: 500; }
.btn--block   { width: 100%; }
.btn[disabled] { opacity: .4; pointer-events: none; }

.iconbtn {
  appearance: none; border: 0; background: transparent; cursor: pointer;
  width: 44px; height: 44px; margin: -10px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--r-chip); color: var(--ink);
  transition: background var(--t-fast) var(--e-in-out);
}
.iconbtn:active { background: var(--surface-2); }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 34px; padding: 0 14px;
  border-radius: var(--r-chip);
  border: 1px solid var(--line);
  background: var(--paper);
  font-size: 14px; font-weight: 500; color: var(--ink);
  cursor: pointer; white-space: nowrap;
  transition: background var(--t-fast) var(--e-in-out), border-color var(--t-fast) var(--e-in-out);
}
.chip.is-on { background: var(--accent); border-color: var(--accent); font-weight: 600; }

/* ─── Карточки ──────────────────────────────────────────── */

.card {
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  background: var(--paper);
  overflow: hidden;
}
.card__media { width: 100%; aspect-ratio: 16/10; object-fit: cover; display: block; background: var(--surface-2); }
.card__body  { padding: 14px 16px; }

.panel {
  background: var(--surface);
  border-radius: var(--r-card);
  padding: 14px 16px;
}

/* ─── Главный экран: стрелка ────────────────────────────── */

/* Компас с подписями занимает всё свободное место и стоит по центру */
.go-mid {
  flex: 1;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 10px; min-height: 0; padding: 8px 0;
}

.compass {
  position: relative;
  width: 208px; height: 208px;
  flex-shrink: 0;
}
.compass__ring { position: absolute; inset: 0; transform: rotate(-90deg); }
.compass__ring circle { fill: none; stroke-width: 5; stroke-linecap: round; }
.compass__track { stroke: var(--surface-2); }
.compass__fill  { stroke: var(--accent); transition: stroke-dashoffset var(--t-slow) var(--e-out); }

.compass__arrow {
  position: absolute; inset: 26px;
  display: flex; align-items: center; justify-content: center;
  /* пружинный доворот — стрелка не дёргается */
  transition: transform 320ms var(--e-out);
  will-change: transform;
}

.hero {
  display: flex; flex-direction: column; align-items: center;
  gap: 2px; padding: 4px var(--pad) 0; text-align: center;
}
.hero__dist { font-size: 58px; line-height: 1.05; }
.hero__to   { font-size: 19px; font-weight: 600; }
.hero__meta { font-size: 13.5px; color: var(--ink-2); }
.hero__lead { font-size: 11.5px; letter-spacing: .1em; text-transform: uppercase;
              font-weight: 600; color: var(--accent-deep); }

/* Тикер: цифры перекатываются, а не мигают */
.ticker { display: inline-flex; overflow: hidden; }
.ticker__d { display: inline-block; transition: transform 180ms var(--e-out); }

/* ─── Нитка маршрута (инфографика прогресса) ────────────── */

.thread { padding: 14px 0 6px; }
.thread__rail {
  position: relative; height: 26px;
  display: flex; align-items: center;
}
.thread__base, .thread__done {
  position: absolute; left: 0; right: 0; height: 3px; border-radius: 2px;
}
.thread__base { background: #E3E0D9; }
.thread__done {
  right: auto; background: var(--accent);
  transition: width var(--t-slow) var(--e-out);
}
.thread__nodes { position: relative; width: 100%; height: 26px; }
.thread__node {
  position: absolute; top: 50%; width: 9px; height: 9px; border-radius: 50%;
  background: var(--surface-2); transform: translate(-50%, -50%);
  transition: background var(--t-base) var(--e-in-out), width 200ms var(--e-out),
              height 200ms var(--e-out);
  border: 2px solid var(--paper);
}
.thread__node.is-done { background: var(--accent); }
.thread__node.is-now  { width: 16px; height: 16px; background: var(--ink); }

/* ─── Ступени источника позиции ─────────────────────────── */

.source { display: flex; align-items: center; gap: 11px; }
.source__steps { display: flex; gap: 3px; flex-shrink: 0; }
.source__steps i {
  width: 15px; height: 5px; border-radius: 3px; background: var(--surface-2);
  transition: background var(--t-fast) var(--e-in-out);
}
.source__steps i.on { background: var(--ok); }
.source--weak .source__steps i.on { background: var(--warn); }
.source--lost .source__steps i.on { background: var(--route); }
.source__label { font-size: 13px; font-weight: 500; }

/* Строка «Помехи навигации» */
.alert {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 14px; border-radius: var(--r-card);
  background: #FDF3E3; border: 1px solid #F5DFB4; color: #7A4E05;
  font-size: 13.5px; font-weight: 500; width: 100%; text-align: left;
  cursor: pointer; font-family: inherit;
  animation: alert-in var(--t-base) var(--e-out);
}
@keyframes alert-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

/* ─── Нижняя шторка ─────────────────────────────────────── */

.dock {
  background: var(--paper);
  border-top: 1px solid var(--line);
  padding: 14px var(--pad) calc(14px + var(--safe-b));
  display: flex; flex-direction: column; gap: 12px;
  flex-shrink: 0;
}

/* Шторка обязана лежать НАД картой.

   Leaflet раздаёт своим панелям z-index до 800, а у шторки его не было
   вовсе — и карта проступала сквозь карточку остановки: текст «смазывался»
   с улицами. Порядок в разметке тут не помогает: позиционированный элемент
   с z-index кроет элемент без него.

   #overlay задаёт собственный контекст наложения выше любых панелей карты
   и не перехватывает нажатия, пока пуст. */
#overlay {
  position: absolute; inset: 0;
  z-index: 1000;
  pointer-events: none;
}
#overlay > * { pointer-events: auto; }

.sheet {
  position: absolute; left: 0; right: 0; bottom: 0;
  z-index: 2;
  background: var(--paper);
  border-radius: 18px 18px 0 0;
  border-top: 1px solid var(--line);
  max-height: 86%;
  display: flex; flex-direction: column;
  animation: sheet-in var(--t-base) var(--e-out);
}
@keyframes sheet-in { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet__grip { width: 36px; height: 4px; border-radius: 2px; background: var(--surface-2);
               margin: 10px auto 4px; flex-shrink: 0; }
.scrim { position: absolute; inset: 0; z-index: 1; background: rgba(28,28,28,.34);
         animation: fade-in var(--t-fast) var(--e-in-out); }
@keyframes fade-in { from { opacity: 0 } to { opacity: 1 } }

/* ─── Карта ─────────────────────────────────────────────── */

#map { flex: 1; background: var(--surface); }
.leaflet-container { font: inherit; background: var(--surface); }
.leaflet-control-attribution { font-size: 10px; background: rgba(255,255,255,.82); }

.me {
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--ink); border: 3px solid var(--paper);
  transition: transform var(--t-base) var(--e-out);
}
.stopdot {
  width: 13px; height: 13px; border-radius: 50%;
  background: var(--paper); border: 3px solid var(--route);
}
.stopdot.is-done { background: var(--accent); border-color: var(--accent); }

/* ─── Камера ────────────────────────────────────────────── */

.cam { position: relative; flex: 1; background: #000; overflow: hidden; }
.cam video { width: 100%; height: 100%; object-fit: cover; display: block; }
.cam__frame {
  position: absolute; inset: 12% 8%;
  border: 2px solid rgba(255,255,255,.5); border-radius: var(--r-card);
  transition: all 240ms var(--e-out);
}
.cam__frame.is-lock {
  border-color: var(--accent); border-width: 3px;
  inset: 18% 14%;
  box-shadow: 0 0 0 9999px rgba(0,0,0,.28);
}
.cam__hint {
  position: absolute; left: 0; right: 0; bottom: 22px; text-align: center;
  color: #fff; font-size: 14px; font-weight: 500;
  text-shadow: 0 1px 6px rgba(0,0,0,.6); padding: 0 24px;
}
@keyframes lock-pulse { from { opacity: .9; transform: scale(.98) } to { opacity: 0; transform: scale(1.06) } }
.cam__pulse {
  position: absolute; inset: 18% 14%; border-radius: var(--r-card);
  border: 3px solid var(--accent); pointer-events: none;
  opacity: 0;                       /* конечное состояние — база */
  animation: lock-pulse 460ms var(--e-out);
}

/* ─── Галочка подтверждения ─────────────────────────────── */

.check circle { fill: var(--ok); }
.check path {
  stroke: #fff; stroke-width: 2.4; fill: none; stroke-linecap: round; stroke-linejoin: round;
  stroke-dasharray: 26; stroke-dashoffset: 0;
  animation: draw var(--t-slow) var(--e-out) 80ms backwards;
}
@keyframes draw { from { stroke-dashoffset: 26 } }

/* ─── Паттерн лап: только пустые состояния, еле заметно ── */
.pawfield { position: absolute; inset: 0; opacity: .06; pointer-events: none; }

/* ─── Список ────────────────────────────────────────────── */

.row {
  display: flex; align-items: center; gap: 13px;
  padding: 13px 0; border-bottom: 1px solid var(--line);
  cursor: pointer; width: 100%; background: none; border-left: 0;
  border-right: 0; border-top: 0; font: inherit; color: inherit; text-align: left;
}
.row:last-child { border-bottom: 0; }
.row__n {
  width: 27px; height: 27px; border-radius: 50%; flex-shrink: 0;
  display: grid; place-items: center;
  font-size: 12.5px; font-weight: 600;
  background: var(--surface-2); color: var(--ink-2);
}
.row__n.is-done { background: var(--accent); color: var(--ink); }
.row__n.is-now  { background: var(--ink); color: var(--paper); }
.row__t { flex: 1; min-width: 0; }
.row__t b { display: block; font-weight: 500; font-size: 15px; }

/* ─── Служебное ─────────────────────────────────────────── */

.stack   { display: flex; flex-direction: column; gap: 12px; }
.stack-8 { display: flex; flex-direction: column; gap: 8px; }
.rowline { display: flex; align-items: center; gap: 10px; }
.spread  { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.grow    { flex: 1; min-width: 0; }
.sep     { height: 1px; background: var(--line); margin: 4px 0; }
.pad     { padding: 16px var(--pad); }

.badge {
  display: inline-flex; align-items: center; height: 24px; padding: 0 9px;
  border-radius: var(--r-chip); font-size: 12px; font-weight: 600;
  background: var(--accent); color: var(--ink);
}
.badge--quiet { background: var(--surface-2); color: var(--ink-2); }

/* Подпись «данные демонстрационные» — честность на экране */
.demo-note {
  font-size: 11.5px; color: var(--ink-3); line-height: 1.4;
  padding: 10px 0 0;
}

/* ─── Уважение к настройке пользователя ─────────────────── */

@media (prefers-reduced-motion: reduce) {
  /* Именно animation: none, а не короткая длительность. При duration .01ms
     Chrome оставляет анимацию на первом кадре: экран навсегда застревал
     сдвинутым на 6 px, и нижняя панель уходила за край окна. Проверено. */
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}
