/* Мобильный клиент Hodim. Один экран за раз, крупные цели нажатия,
   безопасные отступы под вырезы и жестовую панель Android. */

:root {
  --bg: #0f1115;
  --surface: #171a21;
  --surface-2: #1f232c;
  --fg: #e8eaee;
  --muted: #9aa3af;
  --line: #2a2f3a;
  --accent: #7aa2f7;
  --accent-fg: #0f1115;
  --ok: #7fd18b;
  --warn: #d19a45;
  --ad: #c78a4a;
  --radius: 14px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f6f7f9; --surface: #ffffff; --surface-2: #eef1f5;
    --fg: #14161a; --muted: #5f6672; --line: #dde1e8;
    --accent: #1d4ed8; --accent-fg: #ffffff;
    --ok: #15803d; --warn: #b45309; --ad: #92400e;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

/* Атрибут hidden обязан побеждать любой display из правил ниже:
   без этого .loader { display: flex } делает лоадер вечно видимым. */
[hidden] { display: none !important; }

html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: var(--bg); color: var(--fg);
  font: 16px/1.45 -apple-system, "Segoe UI", Roboto, system-ui, sans-serif;
  overscroll-behavior: none;
}

/* Всё приложение живёт внутри #app: он же система координат для карты,
   панели и оверлеев, он же «корпус телефона» на широком экране. */
#app { position: relative; width: 100%; height: 100%; overflow: hidden; background: var(--bg); }

.screen { display: none; height: 100%; flex-direction: column; }
.screen.active { display: flex; }

/* На десктопе показываем вертикальный экран телефона, а не растянутую страницу:
   бету обкатывают в том формате, в котором её увидит пользователь. */
@media (min-width: 700px) and (min-height: 600px) {
  body {
    display: grid; place-items: center;
    background: #0a0b0e;
    background-image: radial-gradient(circle at 50% 0%, #171a21 0%, #0a0b0e 60%);
  }
  #app {
    width: 402px;
    height: min(872px, calc(100vh - 40px));
    border-radius: 40px;
    border: 10px solid #05060a;
    box-shadow: 0 24px 70px rgba(0, 0, 0, .55), 0 0 0 1px #2a2f3a;
  }
  /* Вырез под фронтальную камеру — чтобы safe-area было видно как на телефоне */
  #app::before {
    content: ""; position: absolute; z-index: 10; top: 8px; left: 50%;
    transform: translateX(-50%);
    width: 108px; height: 26px; border-radius: 14px; background: #05060a;
  }
  :root { --safe-top: 30px; --safe-bottom: 10px; }
}

/* ------------------------------- анкета ------------------------------- */

/* Шапка: переключатель языка прижат вправо, заголовок под ним. */
.app-bar { padding: calc(var(--safe-top) + 18px) 20px 8px; }
.lang-picker { position: relative; display: flex; justify-content: flex-end; margin-bottom: 10px; }
.lang-current {
  display: inline-flex; align-items: center; gap: 7px;
  min-height: 34px; padding: 0 10px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface); color: var(--fg);
  font: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
}
.lang-current .caret {
  width: 0; height: 0; margin-left: 1px;
  border-left: 4px solid transparent; border-right: 4px solid transparent;
  border-top: 5px solid var(--muted);
}
.lang-picker svg { width: 20px; height: 14px; border-radius: 2px; display: block;
                   box-shadow: 0 0 0 1px rgba(0, 0, 0, .25) inset; }
.lang-menu {
  position: absolute; z-index: 20; top: calc(100% + 6px); right: 0;
  margin: 0; padding: 6px; list-style: none; min-width: 172px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, .45);
}
.lang-menu li {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: 8px; cursor: pointer; font-size: 14px;
}
.lang-menu li:hover, .lang-menu li:focus { background: var(--surface-2); outline: none; }
.lang-menu li.on { color: var(--accent); font-weight: 600; }
.app-bar h1 { margin: 0; font-size: 26px; letter-spacing: -0.02em; }
.app-bar .sub { margin: 4px 0 0; color: var(--muted); font-size: 14px; }

.fields {
  flex: 1; overflow-y: auto; overflow-x: hidden;
  padding: 12px 20px 20px;
}
.field { display: block; margin-bottom: 22px; }
.label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.big { display: block; font-size: 32px; font-weight: 700; letter-spacing: -0.02em; }
.hint { display: block; margin-top: 6px; font-size: 12px; color: var(--muted); }

input[type="range"] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 34px; background: transparent; margin: 6px 0 0;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 6px; border-radius: 3px; background: var(--surface-2);
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 28px; height: 28px; margin-top: -11px; border-radius: 50%;
  background: var(--accent); border: none;
}
input[type="range"]::-moz-range-track { height: 6px; border-radius: 3px; background: var(--surface-2); }
input[type="range"]::-moz-range-thumb {
  width: 28px; height: 28px; border: none; border-radius: 50%; background: var(--accent);
}

.chips { display: flex; gap: 8px; }
.chips.wrap { flex-wrap: wrap; }
.chips.wrap button { flex: 0 0 auto; }
.chips button {
  /* Ряды с фиксированным числом кнопок («скільки вас», «скільки часу»)
     делят ширину поровну; переносимые группы ниже — по содержимому,
     иначе текст обрезается. */
  flex: 1 1 auto; min-width: 0; min-height: 46px; padding: 0 12px;
  white-space: nowrap;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); color: var(--fg);
  font: inherit; font-size: 15px; cursor: pointer;
}
.chips button.on { background: var(--accent); color: var(--accent-fg); border-color: transparent; font-weight: 600; }

.switch { display: inline-flex; align-items: center; gap: 8px; margin-top: 12px; font-size: 15px; }
.switch input { width: 22px; height: 22px; accent-color: var(--accent); }

.bottom-bar {
  padding: 12px 20px calc(var(--safe-bottom) + 16px);
  border-top: 1px solid var(--line); background: var(--surface);
}
.geo { margin: 0 0 10px; font-size: 13px; color: var(--muted); text-align: center; }
.geo.err { color: var(--warn); }

button.primary, a.secondary {
  display: block; width: 100%; min-height: 52px; border: none;
  border-radius: var(--radius); background: var(--accent); color: var(--accent-fg);
  font: inherit; font-size: 17px; font-weight: 600; cursor: pointer;
  text-align: center; line-height: 52px; text-decoration: none;
}
button.primary[disabled] { opacity: .45; }
a.secondary { background: var(--surface-2); color: var(--fg); margin-top: 14px; }
button.ghost { background: none; border: 1px solid var(--line); color: var(--fg);
               border-radius: 10px; font: inherit; cursor: pointer; }
button.ghost.small { min-height: 34px; padding: 0 12px; font-size: 14px; }

/* ------------------------------ маршрут ------------------------------- */

#map { position: absolute; inset: 0 0 45% 0; background: var(--surface-2); z-index: 0;
        transition: inset .22s ease; }

/* Карта на весь экран: панель уезжает вниз, остаётся кнопка возврата
   и компактная карточка выбранной точки. */
.map-full #map { inset: 0; }
.map-full .sheet { top: 100%; }

.map-fab {
  position: absolute; z-index: 5; top: calc(var(--safe-top) + 12px); right: 12px;
  min-height: 38px; padding: 0 16px; border-radius: 19px; border: none;
  background: var(--surface); color: var(--fg); font: inherit; font-size: 14px;
  font-weight: 600; cursor: pointer; box-shadow: 0 2px 10px rgba(0, 0, 0, .35);
}

.map-card {
  position: absolute; z-index: 6; left: 12px; right: 12px;
  bottom: calc(var(--safe-bottom) + 14px);
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 14px; padding: 14px 16px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .45);
}
.map-card .when { font-size: 13px; color: var(--muted); }
.map-card h3 { margin: 2px 0 6px; font-size: 17px; font-weight: 600; }
.map-card .row { display: flex; gap: 8px; margin-top: 10px; }
.map-card .row a, .map-card .row button {
  flex: 1 1 auto; min-height: 40px; line-height: 38px; text-align: center;
  border-radius: 10px; border: 1px solid var(--line); background: var(--surface-2);
  color: var(--fg); font: inherit; font-size: 14px; text-decoration: none; cursor: pointer;
}
.map-card .row a.nav { background: var(--accent); color: var(--accent-fg); border-color: transparent;
                       font-weight: 600; }
.map-pin { cursor: pointer; }
.map-pin.origin { background: var(--ok) !important; width: 14px !important; height: 14px !important;
                  box-shadow: 0 0 0 4px rgba(127, 209, 139, .25) !important; }

.sheet {
  z-index: 2;
  position: absolute; left: 0; right: 0; bottom: 0; top: 45%;
  background: var(--surface); border-radius: 20px 20px 0 0;
  border-top: 1px solid var(--line);
  padding: 0 16px calc(var(--safe-bottom) + 20px);
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  transition: top .22s ease;
}
.sheet.expanded { top: 8%; }
.grip {
  width: 44px; height: 5px; border-radius: 3px; background: var(--line);
  margin: 10px auto 12px; cursor: grab;
}

.budget-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.sheet-actions { display: flex; gap: 8px; }
.spent { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; }
.of { color: var(--muted); font-size: 14px; margin-left: 6px; }
.summary { margin: 6px 0 16px; color: var(--muted); font-size: 14px; }

.point {
  display: grid; grid-template-columns: 52px 1fr; gap: 12px;
  padding: 14px 0; border-top: 1px solid var(--line);
}
.point .time { font-variant-numeric: tabular-nums; font-weight: 600; font-size: 15px; }
.point .dur { color: var(--muted); font-size: 12px; margin-top: 2px; }
.point h3 { margin: 0 0 2px; font-size: 17px; font-weight: 600; letter-spacing: -0.01em; }
.point .meta { color: var(--muted); font-size: 13px; margin: 0 0 8px; }
.point .desc { font-size: 14px; color: var(--fg); margin: 0 0 8px; opacity: .85; }
.point img {
  width: 100%; max-height: 170px; object-fit: cover;
  border-radius: 10px; margin-bottom: 8px; background: var(--surface-2);
}
.point .credit { font-size: 11px; color: var(--muted); margin: -4px 0 8px; }
.point .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.point .actions a, .point .actions button {
  min-height: 40px; padding: 0 14px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--fg);
  font: inherit; font-size: 14px; line-height: 38px; text-decoration: none; cursor: pointer;
}
.point .actions a.nav { background: var(--accent); color: var(--accent-fg); border-color: transparent; font-weight: 600; }

.tag { display: inline-block; padding: 1px 8px; border-radius: 20px;
       font-size: 11px; border: 1px solid currentColor; margin-left: 6px; vertical-align: 1px; }
.tag.free { color: var(--ok); }
.tag.ad { color: var(--ad); }
.tag.event { color: var(--accent); }

.leg {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 0 8px 64px; color: var(--muted); font-size: 13px;
}
.leg a { color: var(--accent); text-decoration: none; border: 1px solid var(--line);
         border-radius: 8px; padding: 4px 10px; }

.feedback { margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--line); }
.feedback p { margin: 0 0 10px; font-size: 15px; }
.attribution { margin: 20px 0 0; font-size: 11px; color: var(--muted); text-align: center; }

/* Полосы прокрутки прячем: внутри «телефона» их не бывает, а на десктопе
   они ломали ощущение реального экрана. Прокрутка при этом работает. */
#app ::-webkit-scrollbar { width: 0; height: 0; }
#app * { scrollbar-width: none; }

/* ------------------------ афіша, картка, установка --------------------- */

.linkish {
  display: block; width: 100%; margin-top: 10px; padding: 8px;
  background: none; border: none; color: var(--accent);
  font: inherit; font-size: 14px; cursor: pointer;
}
.row-bar { display: flex; align-items: center; gap: 12px; }
.row-bar h1 { font-size: 20px; }

.event {
  display: block; padding: 14px 0; border-top: 1px solid var(--line);
  color: inherit; text-decoration: none;
}
.event .when { font-size: 13px; color: var(--accent); font-weight: 600; }
.event h3 { margin: 3px 0 4px; font-size: 16px; font-weight: 600; }
.event .meta { margin: 0; font-size: 13px; color: var(--muted); }

/* Карточка точки поверх маршрута: данные, которые не влезли в список */
.detail { position: absolute; inset: 0; z-index: 30; background: var(--bg); overflow-y: auto; }
.detail-inner { padding: 0 16px calc(var(--safe-bottom) + 24px); }
.detail img { width: 100%; max-height: 240px; object-fit: cover;
              border-radius: 0 0 14px 14px; margin: 0 -16px 14px; width: calc(100% + 32px); }
.detail h2 { margin: 0 0 4px; font-size: 22px; letter-spacing: -0.02em; }
.detail .kicker { color: var(--muted); font-size: 13px; margin: 0 0 14px; }
.detail section { padding: 14px 0; border-top: 1px solid var(--line); }
.detail section h4 { margin: 0 0 8px; font-size: 13px; color: var(--muted); font-weight: 600; }
.detail .anchor { display: flex; justify-content: space-between; padding: 5px 0; font-size: 15px; }
.detail .close {
  position: sticky; top: 0; z-index: 2; display: block; margin: 0 0 0 auto;
  padding: calc(var(--safe-top) + 10px) 4px 10px;
  background: none; border: none; color: var(--fg); font: inherit; font-size: 15px; cursor: pointer;
}

/* Плашки живут в потоке над кнопкой, а не поверх неё: как оверлей они
   перекрывали «Скласти маршрут», и до маршрута было не добраться. */
.install-bar {
  margin: 0 20px 12px; padding: 12px 14px; border-radius: 14px;
  display: flex; flex-direction: column; gap: 10px;
  background: var(--surface-2); border: 1px solid var(--line); font-size: 14px;
}
.install-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.install-actions button { flex: 1 1 auto; }
.install-bar button {
  min-height: 34px; padding: 0 12px; border-radius: 9px; border: none;
  background: var(--accent); color: var(--accent-fg); font: inherit; font-weight: 600; cursor: pointer;
}
.install-bar button.ghost { background: none; border: 1px solid var(--line); color: var(--fg); font-weight: 400; }

/* ------------------------------ служебное ----------------------------- */

.loader {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 16px;
  background: color-mix(in srgb, var(--bg) 88%, transparent); z-index: 50;
}
.spinner {
  width: 38px; height: 38px; border-radius: 50%;
  border: 3px solid var(--line); border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.toast {
  position: absolute; left: 16px; right: 16px; bottom: calc(var(--safe-bottom) + 20px);
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 12px; padding: 12px 16px; font-size: 14px; z-index: 60;
}

.empty { padding: 24px 4px; color: var(--muted); font-size: 15px; }
