/* Петербург вместе — Telegram Mini App.
   Поверхности наследуются из themeParams клиента; цвета дней — собственные. */

:root {
  --bg: #ffffff;
  --text: #11161d;
  --link: #1a6dc4;

  --text-2: color-mix(in oklab, var(--text) 74%, var(--bg));
  --text-3: color-mix(in oklab, var(--text) 64%, var(--bg));
  --surface: color-mix(in oklab, var(--text) 6%, var(--bg));
  --surface-2: color-mix(in oklab, var(--text) 11%, var(--bg));
  --line: color-mix(in oklab, var(--text) 14%, var(--bg));
  --pin-ring: #ffffff;
  --shadow-1: 0 2px 6px rgba(9, 14, 22, .22);
  --shadow-2: 0 6px 18px rgba(9, 14, 22, .26);
  --shadow-sheet: 0 -8px 30px rgba(9, 14, 22, .22);

  /* Заливка плашек дня. --day-ink — текст поверх неё: в светлой теме
     цвета тёмные и несут белый текст, в тёмной наоборот. */
  --day-ink: #ffffff;
  --d1: #9E5716;
  --d2: #1F7A5C;
  --d3: #4E5AA8;
  --d4: #0F7284;

  --ease: cubic-bezier(.16, 1, .3, 1);
  --vh: 100dvh;
}

[data-scheme="dark"] {
  --bg: #17212b;
  --text: #f2f5f8;
  --link: #6ab3f3;
  --pin-ring: #101418;
  --shadow-1: 0 2px 6px rgba(0, 0, 0, .5);
  --shadow-2: 0 6px 18px rgba(0, 0, 0, .55);
  --shadow-sheet: 0 -8px 30px rgba(0, 0, 0, .5);

  --day-ink: #10161d;
  --d1: #E8A155;
  --d2: #46BE94;
  --d3: #8E98E8;
  --d4: #35B6CC;
}

@supports not (color: color-mix(in oklab, red, blue)) {
  :root { --text-2: #37414f; --text-3: #525c69; --surface: #f1f3f5; --surface-2: #e5e8eb; --line: #dde1e5; }
  [data-scheme="dark"] { --text-2: #c6ced7; --text-3: #98a3af; --surface: #1e2a36; --surface-2: #27353f; --line: #2c3a46; }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  background: var(--bg);
  color: var(--text);
  font: 400 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

button { font: inherit; color: inherit; border: 0; background: none; margin: 0; cursor: pointer; }
a { color: var(--link); }

:focus-visible { outline: 2px solid var(--day, var(--link)); outline-offset: 2px; border-radius: 6px; }

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

.ic {
  width: 18px; height: 18px; flex: 0 0 auto;
  fill: none; stroke: currentColor; stroke-width: 1.75;
  stroke-linecap: round; stroke-linejoin: round;
}
.ic use { pointer-events: none; }

/* ── каркас ─────────────────────────────────────────────── */

.app {
  height: var(--vh);
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr) auto;
}

/* ── лента дней ─────────────────────────────────────────── */

.days {
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top);
}

.days-track {
  display: flex;
  gap: 7px;
  padding: 10px 14px 11px;
  overflow-x: auto;
  scrollbar-width: none;
}
.days-track::-webkit-scrollbar { display: none; }

.day {
  flex: 1 1 0;
  min-width: 70px;
  display: grid;
  gap: 1px;
  padding: 8px 9px 10px;
  border-radius: 14px;
  background: var(--surface);
  text-align: left;
  transition: background .22s var(--ease), color .22s var(--ease);
}

.day-top { display: flex; align-items: baseline; gap: 5px; }
.day-num {
  font-size: 22px; font-weight: 700; line-height: 1.05;
  letter-spacing: -.025em; font-variant-numeric: tabular-nums;
}
.day-mon { font-size: 12px; font-weight: 600; color: var(--text-3); }
.day-name { font-size: 12.5px; font-weight: 500; color: var(--text-2); white-space: nowrap; }

.day[aria-pressed="true"] {
  background: var(--day);
  color: var(--day-ink);
  box-shadow: var(--shadow-1);
}
.day[aria-pressed="true"] .day-mon,
.day[aria-pressed="true"] .day-name { color: var(--day-ink); }

@media (hover: hover) {
  .day:hover:not([aria-pressed="true"]) { background: var(--surface-2); }
}

/* ── карта ──────────────────────────────────────────────── */

.stage { position: relative; min-height: 0; background: var(--surface); isolation: isolate; }
.map { position: absolute; inset: 0; }

.map-fallback {
  position: absolute; inset: 0;
  display: grid; place-content: center;
  margin: 0; padding: 0 32px;
  text-align: center; font-size: 15px; line-height: 1.5; color: var(--text-2);
  z-index: 4;
}

.refit, .theme {
  position: absolute; right: 12px;
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border-radius: 12px;
  background: var(--bg);
  color: var(--day);
  box-shadow: var(--shadow-1);
  transition: transform .2s var(--ease);
}
.theme { top: 12px; color: var(--text-2); }
.refit { top: 60px; }
.refit, .theme { z-index: 5; }
.refit:active, .theme:active { transform: scale(.93); }
.refit .ic, .theme .ic { width: 21px; height: 21px; }

.pin-anchor { line-height: 0; padding: 7px; }

.pin-label {
  position: absolute;
  left: 50%; bottom: calc(100% - 2px);
  transform: translateX(-50%);
  max-width: 132px;
  padding: 2px 7px 3px;
  border-radius: 7px;
  background: var(--bg);
  color: var(--text);
  font-size: 11.5px; font-weight: 600; line-height: 1.35;
  letter-spacing: -.005em;
  white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
  box-shadow: var(--shadow-1);
  pointer-events: none;
}
.pin-label.is-active { background: var(--pin); color: var(--day-ink); }

.pin {
  position: relative;
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--pin);
  color: var(--day-ink);
  font-size: 15px; font-weight: 700;
  font-variant-numeric: tabular-nums;
  box-shadow: var(--shadow-1), 0 0 0 2.5px var(--pin), 0 0 0 4px var(--pin-ring);
  transition: transform .3s var(--ease), opacity .3s var(--ease), filter .3s var(--ease);
}
.pin-img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  border-radius: 50%;
  opacity: 0;
  transition: opacity .35s var(--ease);
}
.pin.has-photo .pin-img { opacity: 1; }
.pin.has-photo .pin-fallback { opacity: 0; }

.pin-n {
  position: absolute; right: -4px; bottom: -4px;
  width: 19px; height: 19px;
  display: none; place-items: center;
  border-radius: 50%;
  background: var(--pin);
  color: var(--day-ink);
  font-size: 11px; font-weight: 700;
  box-shadow: 0 0 0 2px var(--pin-ring);
}
.pin.has-photo .pin-n { display: grid; }

.pin.is-active { transform: scale(1.18); box-shadow: var(--shadow-2), 0 0 0 3px var(--pin), 0 0 0 5px var(--pin-ring); }
.pin.is-dim { opacity: .45; filter: grayscale(1); transform: scale(.68); }

.pin-home {
  width: 26px; height: 26px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--bg);
  color: var(--text-2);
  box-shadow: var(--shadow-1), 0 0 0 1.5px var(--line);
}
.pin-home .ic { width: 15px; height: 15px; }

.maplibregl-ctrl-attrib { font-size: 10px; }

/* ── сводка по первому тапу ─────────────────────────────── */

.peek {
  position: absolute; left: 12px; right: 12px; bottom: 28px;
  z-index: 6;
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr);
  gap: 12px;
  padding: 10px;
  border-radius: 16px;
  background: var(--bg);
  box-shadow: var(--shadow-2);
  animation: peek-in .34s var(--ease) both;
}
@keyframes peek-in {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}

.peek-shot {
  position: relative;
  width: 76px; height: 76px;
  border-radius: 11px;
  overflow: hidden;
  background: color-mix(in oklab, var(--day) 18%, var(--bg));
}
.peek-shot img { width: 100%; height: 100%; object-fit: cover; display: block; }
.peek-shot span {
  position: absolute; left: 5px; top: 5px;
  min-width: 20px; height: 20px; padding: 0 5px;
  display: grid; place-items: center;
  border-radius: 6px;
  background: var(--day);
  color: var(--day-ink);
  font-size: 11.5px; font-weight: 700;
}

.peek-body { display: grid; align-content: start; gap: 2px; min-width: 0; padding-right: 26px; }
.peek-body p { margin: 0; }
.peek-name {
  font-size: 16px; font-weight: 700; letter-spacing: -.012em; line-height: 1.2;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.peek-meta {
  font-size: 12.5px; color: var(--text-3);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.peek-open {
  justify-self: start;
  display: inline-flex; align-items: center; gap: 5px;
  margin-top: 7px; min-height: 34px; padding: 0 12px;
  border-radius: 10px;
  background: var(--day);
  color: var(--day-ink);
  font-size: 13.5px; font-weight: 600;
  transition: transform .18s var(--ease);
}
.peek-open:active { transform: scale(.96); }
.peek-open .ic { width: 15px; height: 15px; }

.peek-close {
  position: absolute; right: 6px; top: 6px;
  width: 30px; height: 30px;
  display: grid; place-items: center;
  border-radius: 9px;
  color: var(--text-3);
}
.peek-close .ic { width: 17px; height: 17px; }

/* ── полоса остановок ───────────────────────────────────── */

.strip {
  display: flex;
  align-items: center;
  padding: 11px 14px calc(11px + env(safe-area-inset-bottom));
  overflow-x: auto;
  scrollbar-width: none;
  background: var(--bg);
  border-top: 1px solid var(--line);
}
.strip::-webkit-scrollbar { display: none; }

.origin {
  flex: 0 0 auto;
  display: flex; align-items: center; gap: 6px;
  padding: 7px 11px;
  border-radius: 12px;
  background: var(--surface);
  color: var(--text-3);
  font-size: 12.5px; font-weight: 500;
  white-space: nowrap;
}
.origin .ic { width: 15px; height: 15px; }

.leg {
  flex: 0 0 auto;
  display: flex; align-items: center; gap: 4px;
  padding: 0 10px;
  color: var(--text-3);
  font-size: 12px; font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.leg .ic { width: 15px; height: 15px; }
.leg::before { content: ""; width: 12px; height: 1px; background: var(--line); }

.stop {
  flex: 0 0 auto;
  display: flex; align-items: center; gap: 9px;
  padding: 7px 14px 7px 7px;
  border-radius: 13px;
  background: var(--surface);
  transition: background .22s var(--ease), box-shadow .22s var(--ease);
}
.stop-n {
  width: 24px; height: 24px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--day);
  color: var(--day-ink);
  font-size: 12.5px; font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.stop-label { display: grid; gap: 1px; text-align: left; }
.stop-name { font-size: 14.5px; font-weight: 600; letter-spacing: -.008em; white-space: nowrap; }
.stop-meta { font-size: 11.5px; color: var(--text-3); white-space: nowrap; }

.stop[aria-current="true"] {
  background: color-mix(in oklab, var(--day) 15%, var(--bg));
  box-shadow: inset 0 0 0 1.5px var(--day);
}
.stop[aria-current="true"] .stop-meta { color: var(--text-2); }

@media (hover: hover) {
  .stop:hover:not([aria-current="true"]) { background: var(--surface-2); }
  .refit:hover, .theme:hover { background: var(--surface); }
  .pin:hover:not(.is-active) { transform: scale(1.12); }
  .pin.is-dim:hover { transform: scale(.86); opacity: .55; }
  .act-alt:hover { background: var(--surface-2); }
  .act-ghost:hover { color: var(--text-2); }
}

.strip.is-entering > * { animation: rise .42s var(--ease) both; }
@keyframes rise {
  from { opacity: 0; transform: translateY(9px); }
  to { opacity: 1; transform: none; }
}

/* ── карточка места ─────────────────────────────────────── */

.scrim {
  position: fixed; inset: 0; z-index: 30;
  background: rgba(8, 12, 18, .42);
  opacity: 0;
  transition: opacity .3s var(--ease);
}
.scrim.is-open { opacity: 1; }

.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  max-height: 88%;
  display: flex; flex-direction: column;
  background: var(--bg);
  border-radius: 20px 20px 0 0;
  box-shadow: var(--shadow-sheet);
  transform: translateY(101%);
  transition: transform .4s var(--ease);
  touch-action: pan-y;
}
.sheet.is-open { transform: none; }

.grab { display: block; width: 100%; padding: 9px 0 3px; }
.grab span {
  display: block; width: 36px; height: 4px; margin: 0 auto;
  border-radius: 2px; background: var(--surface-2);
}

.sheet-body {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 6px 20px calc(22px + env(safe-area-inset-bottom));
}

.sheet-shot {
  position: relative;
  margin: 2px -20px 0;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: var(--surface);
}
.sheet-shot img { width: 100%; height: 100%; object-fit: cover; display: block; }

.photo-credit {
  display: flex; align-items: center; gap: 7px;
  margin-top: 14px;
  font-size: 12px; line-height: 1.4; color: var(--text-3);
  text-align: left;
}
.photo-credit .ic { width: 15px; height: 15px; flex: 0 0 auto; }

.sheet-shot + .sheet-tag { margin-top: 14px; display: inline-flex; }

.sheet-tag {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 12.5px; font-weight: 600; color: var(--day);
}
.sheet-tag i { width: 8px; height: 8px; border-radius: 50%; background: var(--day); display: block; }

.sheet h1 {
  margin: 7px 0 0;
  font-size: 25px; line-height: 1.14; font-weight: 700;
  letter-spacing: -.022em;
  text-wrap: balance;
}

.chips { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 14px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 11px 6px 9px;
  border-radius: 10px;
  background: var(--surface);
  font-size: 13px; color: var(--text-2);
}
.chip .ic { width: 16px; height: 16px; color: var(--text-3); }
.chip-price { background: color-mix(in oklab, var(--day) 10%, var(--bg)); color: var(--day); font-weight: 600; }
.chip-price .ic { color: var(--day); }

.summary { margin: 16px 0 0; font-size: 16.5px; line-height: 1.42; letter-spacing: -.008em; }
.detail { margin: 11px 0 0; font-size: 15px; line-height: 1.55; color: var(--text-2); }

.rows { margin-top: 18px; border-top: 1px solid var(--line); }
.row {
  display: flex; gap: 11px; align-items: flex-start;
  padding: 13px 0;
  border-bottom: 1px solid var(--line);
  font-size: 14.5px; line-height: 1.42; color: var(--text-2);
}
.row .ic { margin-top: 1px; color: var(--text-3); }
.row b { display: block; font-weight: 600; color: var(--text); }
.row-warn .ic { color: var(--d1); }

.acts { display: grid; gap: 9px; margin-top: 18px; }
.acts-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }

.act {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 14px;
  border-radius: 13px;
  font-size: 15px; font-weight: 600; letter-spacing: -.008em;
  text-decoration: none;
  transition: transform .18s var(--ease);
}
.act:active { transform: scale(.975); }
.act-main { background: var(--day); color: var(--day-ink); box-shadow: var(--shadow-1); }
.act-alt { background: var(--surface); color: var(--text); }
.act-ghost { background: none; color: var(--text-3); font-weight: 500; font-size: 13.5px; min-height: 42px; }
.act .ic { width: 17px; height: 17px; }

@media (min-width: 560px) {
  body { background: var(--surface-2); }
  .app {
    width: 480px;
    margin: 0 auto;
    background: var(--bg);
    box-shadow: 0 0 0 1px var(--line);
  }
  .sheet { left: 50%; right: auto; width: 480px; transform: translate(-50%, 101%); }
  .sheet.is-open { transform: translate(-50%, 0); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
