:root {
  /* «Лёд»: светлый голубой фон и шапка, насыщенный голубой — только у кнопок и линии
     маршрута; еда — оранжевым */
  --bg: #f5f9fd;
  --surface: #ffffff;
  --bg-soft: #edf4fb;
  --text: #13293d;
  --muted: #5b6f82;
  --line: #d7e7f3;
  --accent: #2a78c2;          /* линии и метки на карте, рамки */
  --accent-strong: #2a78c2;   /* кнопки с белым текстом — контраст 4,7:1 */
  --accent-soft: #e6f3fc;
  --accent-ink: #124b78;      /* текст на мягком голубом и в шапке */
  --food: #f29b4a;
  --chip-on-text: #ffffff;
  --header-bg: #d6ecfb;
  --header-text: #124b78;
  --header-tint: rgba(18, 75, 120, .08);  /* подложка переключателя городов */
  --shadow: 0 1px 2px rgba(18, 60, 100, .06), 0 4px 14px rgba(18, 60, 100, .07);
  --shadow-hover: 0 2px 4px rgba(18, 60, 100, .08), 0 8px 24px rgba(18, 60, 100, .12);
  --radius: 16px;
  --panel-width: 470px;  /* +7% к прежним 440 */
}

/* Тема одна — светлая, и на телефоне с тёмной темой тоже: так решили, чтобы сайт везде
   выглядел одинаково. color-scheme: light — браузер не перекрашивает поля и полосы прокрутки. */
:root { color-scheme: light; }

/* Comfortaa — только для надписи «Знаю место»; лежит у нас, кириллица 700 (OFL, fonts/Comfortaa-OFL.txt) */
@font-face {
  font-family: "Comfortaa";
  src: url("/static/fonts/comfortaa-cyrillic-700.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
  unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

* { box-sizing: border-box; }

/* Для поисковиков и экранных дикторов: заголовок страницы города, которого не видно глазами. */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

a { color: inherit; }
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* Рамка фокуса — только при навигации с клавиатуры, не при касании */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

.layout {
  display: grid;
  grid-template-columns: var(--panel-width) 1fr;
  height: 100vh;
  height: 100dvh;
}

.panel {
  overflow-y: auto;
  border-right: 1px solid var(--line);
  background: var(--bg);
}

.map-wrap { position: relative; }
.map { position: absolute; inset: 0; background: var(--bg-soft); }
.map-error {
  position: absolute;
  inset: 16px 16px auto;
  padding: 12px 16px;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  color: var(--muted);
}

/* Шапка */
.header {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  background: var(--header-bg);
  color: var(--header-text);
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: "Comfortaa", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  font-weight: 700;
  font-size: 25px;
  letter-spacing: -.03em;  /* Comfortaa широкая — подтягиваем, чтобы шапка влезала на телефоне */
  text-decoration: none;
  white-space: nowrap;
}

/* Знак: пунктир прогулки от старта к метке — как static/img/logo.svg, цвета из темы */
.logo-mark { width: 40px; height: 40px; flex: none; margin: -7px 0; }
.logo-route { fill: var(--accent); }
.logo-start { fill: var(--header-bg); stroke: var(--accent); stroke-width: 3.5; }
.logo-pin { fill: var(--food); }
.logo-hole { fill: var(--surface); }

/* При загрузке знак «проходит маршрут»: старт, точки по порядку, метка падает в финиш (~1 с, один раз) */
.logo-start, .logo-route circle, .logo-drop { transform-box: fill-box; animation: logo-pop .26s cubic-bezier(.3, 1.6, .5, 1) both; }
.logo-start { transform-origin: center; animation-delay: .05s; }
.logo-route circle { transform-origin: center; }
.logo-route circle:nth-child(1) { animation-delay: .17s; }
.logo-route circle:nth-child(2) { animation-delay: .25s; }
.logo-route circle:nth-child(3) { animation-delay: .34s; }
.logo-route circle:nth-child(4) { animation-delay: .45s; }
.logo-route circle:nth-child(5) { animation-delay: .53s; }
.logo-drop { transform-origin: 50% 100%; animation: logo-drop .5s cubic-bezier(.3, 0, .4, 1) .62s both; }
@keyframes logo-pop {
  from { opacity: 0; transform: scale(0); }
  to { opacity: 1; transform: scale(1); }
}
@keyframes logo-drop {
  0% { opacity: 0; transform: translateY(-60%); }
  45% { opacity: 1; transform: translateY(0) scale(1.08, .86); }
  70% { transform: translateY(-8%) scale(.97, 1.04); }
  100% { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .logo-start, .logo-route circle, .logo-drop { animation: none; }
}

.cities {
  display: flex;
  gap: 2px;
  padding: 3px;
  border-radius: 999px;
  background: var(--header-tint);
}
.cities a {
  padding: 6px 12px;
  border-radius: 999px;
  text-decoration: none;
  color: var(--header-text);
  opacity: .85;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
}
.cities a[aria-current="page"] { background: var(--surface); color: var(--header-text); opacity: 1; box-shadow: var(--shadow); }

/* Фильтры */
/* minmax(0, 1fr): иначе лента фильтров на телефоне растягивает колонку шире экрана */
.filters { padding: 18px 20px 8px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }

.search {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow);
  color: var(--text);
  font: inherit;
}
.search:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.filter-title {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  cursor: pointer;
  font-size: 14px;
  transition: background .15s, border-color .15s, color .15s;
}
.chip:hover { border-color: var(--accent); }
.chip[aria-pressed="true"] {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
  color: var(--chip-on-text);
}

/* «Гулять с ребёнком»: заметная, но спокойная — мягкая бирюза, а не залитая кнопка */

/* Возраст ребёнка и коляска — появляются при «С ребёнком» */
.filter-hint { margin-left: 6px; font-weight: 400; letter-spacing: 0; text-transform: none; }
.kids .stroller { justify-self: start; margin-top: 8px; }
.kids-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
  margin: 6px 0;
  color: var(--accent-ink);
  font-size: 14px;
  font-weight: 500;
}
.stroller-badge {
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-size: 12px;
  font-weight: 500;
}
.stroller-badge.stroller-no { background: var(--bg-soft); color: var(--muted); }
.stroller-note { margin: 0 0 8px; color: var(--muted); font-size: 14px; font-style: italic; }
.playroom { color: var(--muted); font-weight: 400; font-size: 14px; }

/* Точка старта */
.origin-current {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  padding: 8px 8px 8px 14px;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-weight: 600;
  font-size: 14px;
}
.origin-current span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.origin-clear {
  flex: none;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 50%;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
}
.origin-form { display: grid; gap: 8px; margin-top: 10px; }
.origin-search { display: flex; gap: 8px; }
.origin-search .search { flex: 1; min-width: 0; }
.origin-search .button { flex: none; }
.origin-hint { color: var(--muted); font-size: 13px; }
.origin-results {
  list-style: none;
  margin: 0;
  padding: 4px;
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.origin-result {
  display: grid;
  gap: 2px;
  width: 100%;
  padding: 10px 12px;
  border: 0;
  border-radius: 10px;
  background: none;
  text-align: left;
  cursor: pointer;
}
.origin-result:hover { background: var(--accent-soft); }
.origin-result-name { font-weight: 600; }
.origin-result-address { color: var(--muted); font-size: 13px; }
.origin-empty { padding: 10px 12px; color: var(--muted); font-size: 14px; }

.filters-body { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
.filters-toggle { display: none; }

.toolbar { display: flex; align-items: center; gap: 12px; }
.count { flex: 1; color: var(--muted); font-size: 14px; }
.link-button {
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent-strong);
  font-weight: 600;
  cursor: pointer;
  font-size: 14px;
}
.link-button:disabled { color: var(--muted); cursor: default; }

/* Список маршрутов */
.routes { list-style: none; margin: 0; padding: 4px 16px 24px; display: grid; gap: 12px; }
.route-card {
  display: block;
  padding: 16px 16px 14px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  text-decoration: none;
  cursor: pointer;
  transition: box-shadow .2s, border-color .2s, transform .2s;
}
.route-card:hover, .route-card.is-hovered {
  border-color: var(--accent);
  box-shadow: var(--shadow-hover);
  transform: translateY(-1px);
}
.route-card h3 { margin: 0 0 6px; font-size: 17px; line-height: 1.3; letter-spacing: -.01em; }
.route-card p { margin: 8px 0 0; color: var(--muted); font-size: 14px; }

.meta { display: flex; flex-wrap: wrap; gap: 4px 12px; color: var(--muted); font-size: 13px; }
.meta span:first-child { color: var(--accent-ink); font-weight: 600; }
.tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 10px; }
.tag {
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-size: 12px;
  font-weight: 500;
}

.empty { padding: 24px 20px; color: var(--muted); }

/* Еда по выбору: есть ли она по пути и что стало с заведением */
.playroom-filter { margin-top: 6px; }
.food-line { margin-top: 6px; font-size: 13px; color: var(--accent-ink); font-weight: 500; }
.food-line.food-missing { color: var(--muted); font-weight: 400; }
.food-note {
  margin-top: 4px;
  padding: 4px 10px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-size: 13px;
}
.food-note.food-kept { background: var(--bg-soft); color: var(--muted); }

.credits { padding: 0 20px 28px; color: var(--muted); font-size: 12px; line-height: 1.5; }
.credits a { color: inherit; }

/* Карточка маршрута */
.detail { padding: 18px 20px 32px; }
.back { display: inline-block; margin-bottom: 12px; }
.detail h1 { margin: 0 0 10px; font-size: 26px; line-height: 1.15; letter-spacing: -.02em; }
.detail .lead { margin: 12px 0; }
.detail .meta { font-size: 14px; }

.actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0 8px; }
.button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 11px 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  text-decoration: none;
  cursor: pointer;
  font-weight: 600;
  transition: filter .15s, box-shadow .15s;
}
.button:hover { box-shadow: var(--shadow); }
.button.primary {
  border-color: transparent;
  background: var(--accent-strong);
  color: #fff;
  box-shadow: 0 4px 14px rgba(42, 120, 194, .3);
}
.button.primary:hover { filter: brightness(1.08); }

.stops {
  list-style: none;
  margin: 20px 0 0;
  padding: 18px 16px 2px;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.stop {
  position: relative;
  display: grid;
  grid-template-columns: 32px 1fr;
  gap: 12px;
  padding-bottom: 18px;
  cursor: pointer;
}
.stop::before {
  content: "";
  position: absolute;
  left: 15px;
  top: 32px;
  bottom: 0;
  border-left: 2px solid var(--accent-soft);
}
.stop:last-child::before { display: none; }
.stop.next-by-transport::before { border-left-style: dashed; }
.stop-num {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--accent-strong);
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.stop.is-food .stop-num { background: var(--food); box-shadow: 0 0 0 3px rgba(242, 155, 74, .22); }
.stop-name { font-weight: 600; padding-top: 5px; }
.stop-name:hover { color: var(--accent-strong); }
.stop-address { color: var(--muted); font-size: 13px; }
.stop-note { margin-top: 2px; font-size: 14px; }
.stop-links { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 4px; font-size: 13px; }
.stop-links a { color: var(--muted); text-decoration: none; border-bottom: 1px dotted currentColor; }
.stop-links a:hover { color: var(--accent-strong); }
.stop-description { margin-top: 4px; color: var(--muted); font-size: 14px; font-style: italic; }
.leg.leg-walk { background: none; padding-left: 0; color: var(--muted); font-weight: 400; }
.leg {
  display: inline-block;
  margin-bottom: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-size: 13px;
  font-weight: 500;
}

.report { margin-top: 8px; padding-top: 12px; border-top: 1px solid var(--line); }
.report-toggle { color: var(--muted); }
.report-text {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  resize: vertical;
}
.report-text:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.rate {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 8px 0 4px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}
.rate-title { flex-basis: 100%; color: var(--muted); font-size: 14px; }
.rate-button { min-height: 40px; }

.wish {
  flex-basis: 100%;
  display: grid;
  gap: 10px;
  margin-top: 6px;
  padding: 14px;
  border-radius: var(--radius);
  background: var(--accent-soft);
}
.wish-question { color: var(--accent-ink); font-weight: 600; }
.wish .actions { margin: 0; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--accent-ink);
  color: #fff;
  box-shadow: var(--shadow-hover);
  font-weight: 600;
  z-index: 10;
}

.sheet-handle { display: none; }

/* Телефоны: карта на весь экран, список — выдвижная шторка снизу (как в приложениях карт).
   Положение шторки задаёт app.js через --sheet-y: 0 — развёрнута, больше — ниже. */
@media (max-width: 800px) {
  :root { --sheet-top: calc(56px + env(safe-area-inset-top)); }

  html, body { overflow: hidden; overscroll-behavior: none; }
  .layout { display: block; height: 100dvh; }
  .map-wrap { position: fixed; inset: 0; }

  .panel {
    position: fixed;
    left: 0;
    right: 0;
    top: var(--sheet-top);
    height: calc(100dvh - var(--sheet-top));
    z-index: 5;
    border-right: 0;
    border-radius: 20px 20px 0 0;
    box-shadow: 0 -4px 24px rgba(18, 60, 100, .2);
    transform: translateY(var(--sheet-y, 50dvh));
    transition: transform .28s cubic-bezier(.2, .8, .2, 1);
    overflow-y: hidden;
    overscroll-behavior: contain;
    padding-bottom: env(safe-area-inset-bottom);
    will-change: transform;
  }
  .panel.is-full { overflow-y: auto; }
  .panel.is-dragging { transition: none; }

  .sheet-handle {
    display: block;
    position: sticky;
    top: 0;
    z-index: 3;
    height: 20px;
    background: var(--header-bg);  /* сливается с шапкой в одну полосу */
    cursor: grab;
  }
  .sheet-handle::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 8px;
    width: 40px;
    height: 5px;
    margin-left: -20px;
    border-radius: 3px;
    background: var(--header-text);
    opacity: .35;
  }

  .header { top: 20px; padding: 4px 16px 12px; gap: 8px; }
  .logo { font-size: 20px; }
  .cities a { padding: 6px 10px; font-size: 14px; }

  .filters { padding: 12px 0 4px; gap: 12px; }
  .filters-body { gap: 12px; }
  .filters:not(.is-open) .filters-body { display: none; }
  .filters-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 16px;
    min-height: 44px;
    padding: 0 14px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--surface);
    box-shadow: var(--shadow);
    color: var(--text);
    font-weight: 600;
    cursor: pointer;
    text-align: left;
  }
  .filters-summary {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--accent-ink);
    font-weight: 500;
    font-size: 14px;
  }
  .filters-toggle-arrow { color: var(--muted); transition: transform .2s; }
  .filters.is-open .filters-toggle-arrow { transform: rotate(180deg); }
  .filters > .search, .filter-title, .toolbar,
  .origin-current, .origin-form { margin-left: 16px; margin-right: 16px; }
  .kids .stroller, .playroom-filter { margin-left: 16px; }
  .search { font-size: 16px; } /* меньше 16px — iOS увеличивает страницу при фокусе */
  /* С отступами по бокам ширина 100% вылезла бы за экран — тянет сетка фильтров. */
  .filters > .search { width: auto; }
  /* Фильтры — горизонтальная лента, чтобы не занимать пол-экрана */
  .chips {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding: 0 16px 2px;
    scrollbar-width: none;
  }
  .chips::-webkit-scrollbar { display: none; }
  .chip { flex: none; min-height: 36px; }
  .toolbar { flex-wrap: wrap; min-height: 32px; }
  .link-button { min-height: 32px; }

  .routes { padding: 0 12px 24px; gap: 10px; }
  .route-card { padding: 14px; }
  .route-card:hover { border-color: transparent; box-shadow: var(--shadow); transform: none; }
  .route-card:active { border-color: var(--accent); }

  .detail { padding: 8px 16px 32px; }
  .detail h1 { font-size: 22px; }
  .actions .button { flex: 1 1 auto; justify-content: center; min-height: 44px; }

  .map-error { top: calc(12px + env(safe-area-inset-top)); }
  .toast { bottom: calc(24px + env(safe-area-inset-bottom)); }
}

/* Узкие телефоны (360–375px): надпись, знак и переключатель городов ужимаются, чтобы влезть в строку */
@media (max-width: 389px) {
  .logo { font-size: 18px; gap: 6px; }
  .logo-mark { width: 34px; height: 34px; margin: -5px 0; }
  .cities a { padding: 6px 8px; }
}
