/* Владивосток — путеводитель. Вёрстка рассчитана на телефон в руке. */

:root {
  --bg: #f4f6f8;
  --card: #ffffff;
  --ink: #16191d;
  --muted: #5f6873;
  --line: #dde2e8;
  --accent: #1f5fa9;
  --accent-ink: #ffffff;
  --ok: #17734a;
  --ok-bg: #e6f4ec;
  --warn: #8a5a00;
  --warn-bg: #fdf2dc;
  --bad: #a02334;
  --shadow: 0 4px 20px rgba(16, 22, 30, .14);
  --sheet-collapsed: 0px;
  --tabs-h: 56px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12151a;
    --card: #1b1f25;
    --ink: #e9edf2;
    --muted: #98a2ae;
    --line: #2b323a;
    --accent: #4a90d9;
    --accent-ink: #0b1017;
    --ok: #6edba4;
    --ok-bg: #14301f;
    --warn: #e8c37a;
    --warn-bg: #33290f;
    --bad: #ff9aa5;
    --shadow: 0 4px 20px rgba(0, 0, 0, .5);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0; height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  overscroll-behavior: none;
}

button { font: inherit; color: inherit; cursor: pointer; }

/* --- Карта --------------------------------------------------------------- */

#map {
  position: absolute; inset: 0;
  bottom: calc(var(--tabs-h) + var(--safe-b));
  background: var(--bg);
  /* Обязательно. Leaflet раздаёт своим слоям и кнопкам z-index вплоть до 800,
     и без собственного контекста наложения они перекрывают полосу ведения и
     панель: кнопка «завершить» оказывалась под кнопкой зума и не нажималась. */
  z-index: 0;
}

/* Пока идёт ведение, отодвигаем кнопки карты из-под верхней полосы */
body.is-guiding .leaflet-top { padding-top: 78px; }

.leaflet-container { background: var(--bg); font: inherit; }

/* Метка объекта */
.pin {
  display: flex; align-items: center; justify-content: center;
  width: 26px; height: 26px;
  border-radius: 50% 50% 50% 4px;
  transform: rotate(-45deg);
  color: #fff;
  border: 2px solid rgba(255,255,255,.85);
  box-shadow: 0 2px 6px rgba(0,0,0,.35);
  font-size: 12px;
}
.pin > span { transform: rotate(45deg); }
.pin--visited { opacity: .45; }

/* Моя позиция */
.me {
  width: 18px; height: 18px; border-radius: 50%;
  background: #1f7ae0; border: 3px solid #fff;
  box-shadow: 0 0 0 1px rgba(0,0,0,.25), 0 2px 8px rgba(0,0,0,.35);
}

.stop-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--card); border: 2px solid var(--accent);
}

/* --- Плавающие кнопки ---------------------------------------------------- */

.fabs {
  position: absolute; right: 12px;
  bottom: calc(var(--tabs-h) + var(--safe-b) + 16px);
  z-index: 500;
  display: flex; flex-direction: column; gap: 10px;
}
.fab {
  width: 46px; height: 46px; border-radius: 50%;
  background: var(--card); border: 1px solid var(--line);
  box-shadow: var(--shadow);
  font-size: 20px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
}
.fab.is-on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

/* --- Полоса ведения ------------------------------------------------------ */

/* Атрибут hidden обязан побеждать display:flex ниже, иначе полоса
   ведения висит на экране всегда. */
.guidebar[hidden] { display: none; }

.guidebar {
  position: absolute; top: 0; left: 0; right: 0; z-index: 600;
  display: flex; align-items: center; gap: 12px;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) 12px 10px;
  background: var(--accent); color: var(--accent-ink);
  box-shadow: var(--shadow);
}
.guidebar__arrow { flex: 0 0 auto; transition: transform .25s ease-out; }
.guidebar__body { flex: 1 1 auto; min-width: 0; }
.guidebar__target {
  font-size: .82rem; opacity: .9;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.guidebar__nums { display: flex; align-items: baseline; gap: 7px; flex-wrap: wrap; }
.guidebar__big { font-size: 1.7rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.guidebar__unit { font-size: .8rem; opacity: .9; }
.guidebar__dist { font-size: .9rem; opacity: .95; margin-left: auto; }
.guidebar__stop {
  flex: 0 0 auto; width: 36px; height: 36px; border-radius: 50%;
  background: rgba(255,255,255,.18); border: 0; color: inherit; font-size: 16px;
}

/* --- Выдвижная панель ---------------------------------------------------- */

.sheet {
  position: absolute; left: 0; right: 0;
  bottom: calc(var(--tabs-h) + var(--safe-b));
  max-height: 78%;
  display: flex; flex-direction: column;
  background: var(--card);
  border-radius: 16px 16px 0 0;
  box-shadow: var(--shadow);
  z-index: 550;
  transform: translateY(102%);
  transition: transform .22s ease-out;
}
.sheet.is-open { transform: translateY(0); }

.sheet__grip { padding: 8px 0 4px; display: flex; justify-content: center; flex: 0 0 auto; }
.sheet__grip span { width: 40px; height: 4px; border-radius: 2px; background: var(--line); }
.sheet__body { overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 4px 16px 20px; }

/* Шапка с кнопкой «назад»: без неё до объекта приходилось каждый раз
   заново пробираться через меню. */
.backbar {
  display: flex; align-items: center; gap: 4px;
  margin: -4px -16px 4px; padding: 2px 8px 8px;
  border-bottom: 1px solid var(--line);
  position: sticky; top: -4px; background: var(--card); z-index: 2;
}
.backbar button {
  display: flex; align-items: center; gap: 6px;
  border: 0; background: none; color: var(--accent);
  font-size: .92rem; font-weight: 600; padding: 8px 8px;
}
.backbar__arrow { font-size: 1.15rem; line-height: 1; }
.backbar__close { margin-left: auto; color: var(--muted) !important; font-weight: 400 !important; }

/* --- Нижние вкладки ------------------------------------------------------ */

.tabs {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 700;
  height: calc(var(--tabs-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--card); border-top: 1px solid var(--line);
}
.tab {
  border: 0; background: none; font-size: .78rem; color: var(--muted);
  display: flex; align-items: center; justify-content: center; padding: 0 2px;
}
.tab.is-active { color: var(--accent); font-weight: 600; }

/* --- Содержимое панели --------------------------------------------------- */

.sheet h2 { font-size: 1.05rem; margin: 6px 0 2px; }
.sheet h3 { font-size: .95rem; margin: 14px 0 6px; }
.sheet p { margin: 6px 0; }
.hint { color: var(--muted); font-size: .87rem; }

.list { list-style: none; margin: 8px 0 0; padding: 0; }
.list > li { border-top: 1px solid var(--line); }
.list > li:first-child { border-top: 0; }

.row {
  display: flex; align-items: flex-start; gap: 11px;
  padding: 11px 0; width: 100%;
  background: none; border: 0; text-align: left;
}
.row__badge {
  flex: 0 0 auto; width: 28px; height: 28px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 13px;
}
.row__main { flex: 1 1 auto; min-width: 0; }
.row__name { font-weight: 600; font-size: .95rem; }
.row__meta { color: var(--muted); font-size: .83rem; margin-top: 2px; }
.row__side { flex: 0 0 auto; text-align: right; color: var(--muted); font-size: .83rem; font-variant-numeric: tabular-nums; }
.row.is-visited .row__name { color: var(--muted); font-weight: 500; }

/* Варианты «по силам» */
.opts { margin: 8px 0 2px; display: flex; flex-direction: column; gap: 8px; }
.opt {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 10px 12px; text-align: left;
  border: 1px solid var(--line); border-radius: 11px; background: var(--card);
}
.opt__ico { font-size: 17px; flex: 0 0 auto; width: 22px; text-align: center; }
.opt__main { flex: 1 1 auto; min-width: 0; }
.opt__title { font-weight: 600; font-size: .9rem; }
.opt__sub { color: var(--muted); font-size: .81rem; margin-top: 1px; }
.opt__num { flex: 0 0 auto; text-align: right; font-variant-numeric: tabular-nums; font-size: .85rem; }

.chip {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: .74rem; font-weight: 600; vertical-align: middle;
}
.chip--ok { background: var(--ok-bg); color: var(--ok); }
.chip--over { background: var(--warn-bg); color: var(--warn); }

.btn {
  display: block; width: 100%; padding: 13px;
  border: 0; border-radius: 12px;
  background: var(--accent); color: var(--accent-ink);
  font-weight: 600; font-size: 1rem; margin-top: 12px;
}
.btn--ghost { background: none; border: 1px solid var(--line); color: var(--ink); }

.photo {
  width: 100%; border-radius: 12px; display: block;
  background: var(--bg); margin: 10px 0 4px; aspect-ratio: 4 / 3; object-fit: cover;
}
.credit { color: var(--muted); font-size: .74rem; margin: 0 0 8px; }
.credit a { color: inherit; }

.notice { border-radius: 10px; padding: 10px 12px; font-size: .87rem; margin: 10px 0; }
.notice--warn { background: var(--warn-bg); color: var(--warn); }
.notice--ok { background: var(--ok-bg); color: var(--ok); }

.field { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.field:first-of-type { border-top: 0; }
.field label { font-size: .93rem; }
.field input[type=range] { flex: 1 1 auto; max-width: 55%; }
.field output { font-variant-numeric: tabular-nums; font-size: .9rem; color: var(--muted); min-width: 4.5em; text-align: right; }

.switch { position: relative; width: 46px; height: 27px; flex: 0 0 auto; }
.switch input { opacity: 0; width: 100%; height: 100%; margin: 0; }
.switch i {
  position: absolute; inset: 0; border-radius: 999px;
  background: var(--line); transition: background .15s; pointer-events: none;
}
.switch i::after {
  content: ''; position: absolute; top: 3px; left: 3px;
  width: 21px; height: 21px; border-radius: 50%;
  background: #fff; transition: transform .15s;
  box-shadow: 0 1px 3px rgba(0,0,0,.3);
}
.switch input:checked + i { background: var(--accent); }
.switch input:checked + i::after { transform: translateX(19px); }

/* --- Заставка ------------------------------------------------------------ */

.boot {
  position: absolute; inset: 0; z-index: 900;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
  transition: opacity .3s;
}
.boot.is-done { opacity: 0; pointer-events: none; }
.boot__inner { text-align: center; padding: 24px; max-width: 20rem; }
.boot__title { font-size: 1.5rem; font-weight: 700; letter-spacing: -.01em; }
.boot__status { color: var(--muted); font-size: .9rem; margin: 8px 0 16px; min-height: 2.6em; }
.boot__bar { height: 4px; border-radius: 2px; background: var(--line); overflow: hidden; }
.boot__bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .3s; }
