/* BRUK — веб-мапа. Палітра як у застосунку: монохром + червоний бренду. */
:root {
  --red: #A20E00;
  --red-soft: rgba(162, 14, 0, 0.1);
  --you: #FC8A80;
  --ink: #111;
  --muted: #6b6b6b;
  --line: #e6e6e6;
  --bg: #fff;
  --chip: #f2f2f2;
  --shadow: 0 6px 13px rgba(0,0,0,.12), 0 0.5px 4px rgba(0,0,0,.12);
  --radius: 20px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: #f4f3ef;
  color: var(--ink);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; cursor: pointer; }
a { color: #0a64d6; }
[hidden] { display: none !important; }

#map { position: fixed; inset: 0; }
.mapboxgl-ctrl-bottom-left, .mapboxgl-ctrl-bottom-right { bottom: calc(48px + var(--safe-b)); }

/* ---------- Верх: пошук, фільтр, підказка ---------- */
.top {
  position: fixed; z-index: 3;
  top: calc(8px + var(--safe-t)); left: 16px; right: 16px;
  max-width: 480px;
  display: flex; flex-direction: column; gap: 10px;
}
.top-row { display: flex; align-items: center; gap: 8px; }
.top-row .search { flex: 1; min-width: 0; }
.fab.back { flex: none; text-decoration: none; }
.embed .fab.back { display: none; }
.search {
  display: flex; align-items: center; gap: 8px;
  height: 48px; padding: 0 8px 0 16px;
  background: var(--bg); border-radius: 24px; box-shadow: var(--shadow);
}
.search-icon { width: 20px; height: 20px; fill: none; stroke: var(--ink); stroke-width: 2; flex: none; }
.search input {
  flex: 1; min-width: 0; border: 0; outline: 0; background: transparent;
  font-size: 16px; color: var(--ink);
}
.search input::-webkit-search-cancel-button { display: none; }
.results {
  list-style: none; margin: 0; padding: 6px 0;
  background: var(--bg); border-radius: 16px; box-shadow: var(--shadow);
  max-height: 50vh; overflow-y: auto;
}
.results li { padding: 10px 16px; cursor: pointer; }
.results li:hover, .results li[aria-selected="true"] { background: var(--chip); }
.results .addr { font-weight: 600; }
.results .sub { font-size: 13px; color: var(--muted); }
.results .empty { color: var(--muted); cursor: default; }
.results .empty:hover { background: none; }

.pill {
  align-self: flex-start; display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-radius: 999px; background: var(--red); color: #fff;
  font-size: 15px; font-weight: 500; box-shadow: var(--shadow); max-width: 100%;
}
.pill button { background: none; border: 0; padding: 0; color: #fff; }
#filter-pill-open { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.hint {
  display: flex; align-items: center; gap: 10px;
  padding: 14px; border-radius: 16px; font-size: 15px;
  background: rgba(255,255,255,.92); backdrop-filter: blur(12px);
  box-shadow: 0 4px 10px rgba(0,0,0,.12);
}
.hint::before { content: ""; flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--red); }
.hint span { flex: 1; }

.icon-btn {
  flex: none; width: 36px; height: 36px; border: 0; border-radius: 50%;
  background: transparent; color: var(--muted); font-size: 16px; line-height: 1;
}
.icon-btn.small { width: 28px; height: 28px; font-size: 13px; }

/* ---------- Низ: кнопки й бігучий рядок ---------- */
.bottom { position: fixed; z-index: 2; left: 0; right: 0; bottom: 0; pointer-events: none; }
.toolbar {
  display: flex; flex-direction: column; align-items: flex-end; gap: 10px;
  padding: 16px; pointer-events: none;
}
.fab {
  position: relative; pointer-events: auto;
  width: 48px; height: 48px; border: 0; border-radius: 50%;
  background: var(--bg); box-shadow: var(--shadow);
  display: grid; place-items: center;
}
.fab svg { width: 22px; height: 22px; fill: none; stroke: var(--ink); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.fab svg .fill { fill: var(--ink); stroke: none; }
.fab.on { background: var(--red); }
.fab.on svg { stroke: #fff; }
.fab .dot {
  position: absolute; top: 0; right: 0; width: 12px; height: 12px; border-radius: 50%;
  background: var(--red); border: 2px solid #fff;
}

/* Плашка «нагороди — в застосунку»: напівпрозора, над бігучим рядком ліворуч від кнопок. */
.app-promo {
  position: absolute; left: 16px; bottom: calc(88px + var(--safe-b));
  max-width: calc(100% - 96px); pointer-events: auto;
  display: flex; align-items: center; gap: 6px;
  padding: 6px 6px 6px 14px; border-radius: 16px; font-size: 13px; line-height: 1.3;
  background: rgba(255,255,255,.5); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 2px 8px rgba(0,0,0,.08);
}
.app-promo::before { content: ""; flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--red); }
.app-promo span { flex: 1; }

.ticker {
  pointer-events: auto; position: relative; overflow: hidden;
  height: 48px; background: var(--bg); padding-bottom: var(--safe-b);
  box-sizing: content-box;
}
.ticker-track {
  position: absolute; top: 0; left: 0; height: 48px;
  display: flex; align-items: center; white-space: nowrap; will-change: transform;
}
.ticker-item {
  display: inline-flex; align-items: baseline; gap: 8px; height: 48px; align-items: center;
  border: 0; background: none; padding: 0;
}
.ticker-item .t { font-size: 16px; font-weight: 600; }
.ticker-item .a { font-size: 13px; font-weight: 500; color: var(--red); }
.ticker-sep { display: inline-block; width: 5px; height: 5px; border-radius: 50%; background: var(--ink); margin: 0 28px; flex: none; }

/* ---------- Картка будинку ---------- */
.panel {
  position: fixed; z-index: 4; left: 0; right: 0; bottom: 0;
  max-height: min(78vh, 640px); display: flex; flex-direction: column;
  background: var(--bg); border-radius: var(--radius) var(--radius) 0 0;
  box-shadow: 0 -4px 20px rgba(0,0,0,.15); overflow: hidden;
  animation: rise .32s cubic-bezier(.2,.9,.3,1);
}
@keyframes rise { from { transform: translateY(30%); opacity: 0; } }
.grabber { width: 40px; height: 4px; border-radius: 3px; background: #d1d1d6; margin: 10px auto 4px; flex: none; }
.close {
  position: absolute; top: 8px; right: 14px; width: 30px; height: 30px; border: 0; border-radius: 50%;
  background: #e5e5ea; color: #8e8e93; font-size: 13px; font-weight: 700; z-index: 1;
}
.panel-body {
  overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
  padding: 4px 0 calc(24px + var(--safe-b));
}
.panel-body > * { margin-left: 20px; margin-right: 20px; }
.panel-body > .photos { margin-left: 0; margin-right: 0; }
.panel-body > * + * { margin-top: 20px; }

.photos { display: flex; gap: 8px; overflow-x: auto; padding: 4px 20px 0; scroll-snap-type: x mandatory; scroll-padding: 0 20px; }
.photos figure { margin: 0; flex: none; width: 260px; scroll-snap-align: start; }
.photos img, .photo-skeleton {
  display: block; width: 260px; height: 180px; object-fit: cover; border-radius: 12px; background: #f2f2f7;
}
.photo-skeleton { width: auto; margin: 4px 20px 0; height: 200px; border-radius: 0; animation: pulse 1.2s ease-in-out infinite alternate; }
@keyframes pulse { to { opacity: .55; } }
.photos figcaption { margin-top: 4px; font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.photos figcaption a { color: inherit; text-decoration: none; }
.panel-body > .photos + .photo-cta { margin-top: 10px; }
.photo-cta { display: grid; grid-template-columns: 20px 1fr; gap: 4px 10px; align-items: start; color: var(--muted); }
.photo-cta svg { margin-top: 1px; }
.photo-cta p { margin: 0; font-size: 13px; line-height: 1.4; }
.photo-cta .btn { grid-column: 2; justify-self: start; margin-top: 6px; padding: 7px 14px; font-size: 13px; }

.eyebrow { font-size: 12px; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); padding-right: 36px; }
h1.title { margin: 6px 0 0; font-size: 22px; line-height: 1.25; padding-right: 20px; }
.badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.badge { font-size: 11px; font-weight: 500; padding: 3px 8px; border-radius: 999px; background: var(--chip); color: var(--muted); }
.badge.yes { background: rgba(52,199,89,.15); color: #248a3d; }
.badge.no { background: rgba(255,59,48,.1); color: #d70015; }
.badge.partial { background: rgba(255,149,0,.15); color: #c93400; }
.badge.war { background: var(--red-soft); color: var(--red); }
hr.div { border: 0; border-top: 1px solid var(--line); }

.section h3 { margin: 0 0 8px; font-size: 15px; font-weight: 600; }
.section p, .section .text { margin: 0; font-size: 15px; color: #3c3c43; white-space: pre-line; }
.summary { font-size: 15px; white-space: pre-line; }
.small, .section.sources .text { font-size: 12px; color: #8e8e93; }
.muted { color: var(--muted); }
.link-btn { background: none; border: 0; padding: 0; color: #0a64d6; font-weight: 500; font-size: 15px; }

.war-block { padding: 12px; border-left: 2px solid var(--red); }
.war-block h3 { color: var(--red); }
.war-item + .war-item { margin-top: 10px; }
.war-item .d { font-size: 13px; font-weight: 600; }
.war-item .s { font-size: 12px; }

.facts-dl { margin: 0; }
.facts-dl dt { font-size: 12px; color: var(--muted); }
.facts-dl dd { margin: 0 0 10px; font-size: 15px; }

.research { padding: 16px; border-radius: 16px; background: #f2f2f7; }
.research h3 { margin: 0 0 8px; font-size: 15px; }
.research p { margin: 0 0 12px; font-size: 15px; color: #3c3c43; }

.btn {
  display: inline-block; border: 0; border-radius: 999px; padding: 10px 18px;
  font-size: 15px; font-weight: 600; text-decoration: none;
}
.btn.primary { background: var(--red); color: #fff; }
.btn.ghost { background: var(--chip); color: var(--ink); }

/* ---------- Шторки: фільтри, «Про BRUK» ---------- */
.sheet {
  position: fixed; z-index: 5; inset: 0; background: rgba(0,0,0,.3);
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet-card {
  width: 100%; max-width: 560px; max-height: 85vh; overflow-y: auto;
  background: var(--bg); border-radius: var(--radius) var(--radius) 0 0;
  padding: 16px 20px calc(20px + var(--safe-b));
  animation: rise .28s cubic-bezier(.2,.9,.3,1);
}
.sheet-head { display: flex; align-items: center; justify-content: space-between; }
.sheet-head h2 { margin: 0; font-size: 20px; }
.sheet p { font-size: 15px; }
.group-title { margin: 22px 0 10px; font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--line); background: var(--bg); border-radius: 999px;
  padding: 8px 14px; font-size: 15px;
}
.chip .n { color: var(--muted); margin-left: 4px; }
.chip[aria-pressed="true"] { background: var(--red); border-color: var(--red); color: #fff; }
.chip[aria-pressed="true"] .n { color: rgba(255,255,255,.8); }
.sheet-foot {
  position: sticky; bottom: calc(-20px - var(--safe-b)); background: var(--bg);
  display: flex; gap: 10px; justify-content: flex-end; padding: 16px 0 4px; margin-top: 12px;
}
.install { margin-top: 16px; padding: 16px; border-radius: 16px; background: #f2f2f7; }
.install p { margin-top: 0; }

/* ---------- «Ти тут» ---------- */
.you-dot {
  width: 22px; height: 22px; border-radius: 50%; background: var(--you);
  border: 4px solid #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25);
}

.error {
  position: fixed; z-index: 6; left: 16px; right: 16px; bottom: calc(80px + var(--safe-b));
  max-width: 480px; margin: 0 auto; padding: 12px 16px; border-radius: 12px;
  background: #1c1c1e; color: #fff; font-size: 14px;
}

/* ---------- Комп'ютер: картка збоку, а не знизу ---------- */
@media (min-width: 900px) {
  .panel {
    left: 16px; right: auto; top: calc(122px + var(--safe-t)); bottom: 80px;
    width: 420px; max-height: none; border-radius: var(--radius);
    animation-name: slide;
  }
  .filter-on .panel, .filter-on .explore .sheet-card { top: calc(174px + var(--safe-t)); } /* під плашкою фільтра, а не поверх неї */
  @keyframes slide { from { transform: translateX(-20px); opacity: 0; } }
  .grabber { visibility: hidden; height: 0; margin: 14px 0 0; }
  .sheet { align-items: center; }
  .sheet-card { border-radius: var(--radius); }
  .ticker-item .t { font-size: 15px; }
}

@media (prefers-reduced-motion: reduce) {
  .panel, .sheet-card { animation: none; }
}

/* Вбудована мапа на головній сторінці: без заставки й підказки */
.embed .bruk-splash, .embed #hint { display: none !important; }

/* Будинок без фото: рамка з дверима (firstPhotoSlot в app.js) */
.first-photo { display: grid; justify-items: center; gap: 10px; text-align: center; padding: 24px 20px;
  border: 1.5px dashed rgba(128,128,128,.6); border-radius: 16px; }
.first-photo svg { display: block; max-width: 100%; height: auto; }
.first-photo b { font-size: 17px; }
.first-photo p { margin: 0; font-size: 14px; color: var(--muted, #6b6b73); max-width: 30ch; }

/* ---------- Розділи: «Прогулянки» і «Біля мене» — чипи під пошуком (explore.js) ---------- */
.explore-chips { display: flex; gap: 8px; flex-wrap: nowrap; }
.explore-chips .chip {
  display: inline-flex; align-items: center; gap: 6px; border: 0; padding: 8px 14px;
  font-size: 15px; font-weight: 500; box-shadow: 0 2px 8px rgba(0,0,0,.14);
}
.explore-chips .chip svg { width: 17px; height: 17px; fill: none; stroke: var(--red); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.explore-chips .chip[aria-pressed="true"] svg { stroke: #fff; }

/* Шторка не затуляє мапу: будинки лишаються клікабельними. */
.sheet.explore { background: transparent; pointer-events: none; }
.explore .sheet-card {
  pointer-events: auto; max-height: min(72vh, 640px); padding-top: 8px;
  box-shadow: 0 -4px 20px rgba(0,0,0,.15);
}
.explore .sheet-card::before { content: ""; display: block; width: 40px; height: 4px; border-radius: 3px; background: #d1d1d6; margin: 2px auto 10px; }
.explore .sheet-head { gap: 4px; margin-bottom: 8px; }
.explore .sheet-head h2 { flex: 1; min-width: 0; font-size: 20px; line-height: 1.25; }
.back-btn { display: grid; place-items: center; margin-left: -8px; color: var(--ink); }
.back-btn svg, .explore svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.explore .lead { margin: 0 0 6px; font-size: 14px; }
.explore .small.foot { margin: 8px 0 0; }

.explore .mini-route { flex: none; width: 72px; height: 52px; border-radius: 12px; background: #f1efe9; }
.explore .mini-route polyline { fill: none; stroke: var(--red); stroke-width: 2; stroke-dasharray: 1 4; stroke-linecap: round; }
.explore .mini-route circle { fill: #fff; stroke: var(--red); stroke-width: 1.6; }
.explore .walk-head .mini-route { display: block; width: 100%; height: 120px; margin-bottom: 12px; }
.walk-rows { display: flex; flex-direction: column; }
.walk-row { display: flex; align-items: center; gap: 14px; border: 0; background: none; text-align: left; padding: 12px 0; border-top: 1px solid var(--line); }
.walk-row b { font-size: 16px; font-weight: 600; }
.walk-row .sub { font-size: 13px; color: var(--muted); }
.walk-row .walk-figures { margin-top: 2px; }
.walk-meta { display: flex; align-items: center; gap: 6px; font-size: 15px; color: var(--muted); }
.walk-meta svg { width: 18px; height: 18px; flex: none; }
.walk-figures { font-size: 13px; font-weight: 500; color: var(--ink); }
.walk-head { padding: 0; }
.walk-head p { margin: 8px 0 0; font-size: 15px; }

.list-title { margin: 22px 0 6px; font-size: 13px; font-weight: 500; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.rows { border-top: 1px solid var(--line); }
.row {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 56px;
  border: 0; background: none; padding: 10px 0; text-align: left;
}
.row + .row { border-top: 1px solid var(--line); }
.row:hover { background: #fafafa; }
.row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.row-main b { font-size: 15px; font-weight: 600; }
.row .sub { font-size: 14px; color: var(--muted); }
.row .clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.row .detail { flex: none; font-size: 14px; color: var(--muted); }
.war-row .detail { color: var(--red); font-weight: 500; }
.war-row .detail::after { content: " ⚠"; }
.row .chev { flex: none; color: #c4c4c7; }
.row .chev svg { width: 16px; height: 16px; }
.initial {
  flex: none; width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center;
  background: var(--chip); color: var(--ink); font-weight: 700; font-size: 15px;
}
.stop-pin {
  flex: none; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center;
  background: #fff; border: 2px solid var(--red); color: var(--red); font-size: 12px; font-weight: 700;
}
.sticky-cta { position: sticky; bottom: calc(-20px - var(--safe-b)); padding: 16px 0 4px; margin-top: 8px; background: linear-gradient(rgba(255,255,255,0), #fff 30%); }
.btn.wide { display: block; width: 100%; height: 52px; font-size: 17px; }

.empty-state { display: grid; justify-items: center; gap: 8px; text-align: center; padding: 36px 16px; }
.empty-state p { margin: 0; max-width: 34ch; }
.empty-icon { width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; background: var(--red-soft); color: var(--red); }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid #d1d1d6; border-top-color: var(--red); animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Прогулянка на мапі ---------- */
.walking .top, .walking .bottom { display: none; }
.walk-ui { position: fixed; inset: 0; z-index: 3; pointer-events: none; }
.walk-top {
  position: absolute; top: calc(8px + var(--safe-t)); left: 16px; right: 16px;
  display: flex; align-items: center; justify-content: center;
}
.walk-top .fab { position: absolute; left: 0; top: 0; pointer-events: auto; }
.walk-top .fab svg { stroke-width: 2.4; }
.walk-progress {
  margin: 0 56px; max-width: 320px; padding: 8px 14px; border-radius: 999px; text-align: center;
  background: rgba(255,255,255,.88); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 2px 8px rgba(0,0,0,.08); font-size: 12px; font-weight: 600; pointer-events: auto;
}
#walk-progress-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.walk-progress .bar { width: 170px; max-width: 100%; height: 5px; margin: 6px auto 0; border-radius: 3px; background: #e5e5ea; overflow: hidden; }
.walk-progress .bar span { display: block; height: 100%; width: 0; background: var(--red); border-radius: 3px; transition: width .3s; }
.walk-bottom {
  position: absolute; left: 0; right: 0; bottom: 0; margin: 0 auto; max-width: 520px;
  padding: 0 20px calc(12px + var(--safe-b)); display: flex; flex-direction: column; gap: 16px;
}
.walk-stop {
  pointer-events: auto; display: flex; flex-direction: column; gap: 6px; text-align: left;
  border: 0; border-radius: 20px; padding: 16px 18px 18px; background: var(--bg);
  box-shadow: 0 4px 10px rgba(0,0,0,.12);
}
.walk-stop .label { font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--red); }
.walk-stop .title { font-size: 17px; font-weight: 600; }
.walk-stop .teaser { font-size: 15px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.walk-stop .teaser:empty { display: none; }
.walk-controls {
  pointer-events: auto; display: flex; gap: 4px; padding: 8px; border-radius: 999px;
  background: var(--bg); box-shadow: var(--shadow);
}
.walk-controls button { border: 0; background: none; height: 52px; border-radius: 999px; font-size: 15px; font-weight: 600; }
.walk-controls .seg { flex: 1; }
.walk-controls .seg.dark { background: #1c1c1e; color: #fff; }
.walk-controls .seg-icon { width: 44px; flex: none; display: grid; place-items: center; }
.walk-controls svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.walk-controls button:disabled { color: #c7c7cc; cursor: default; }
.walking .panel { z-index: 4; }

.walk-pin { border: 0; background: none; padding: 0; display: flex; flex-direction: column; align-items: center; cursor: pointer; }
.walk-pin .head {
  width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center;
  background: #fff; border: 2px solid var(--red); color: var(--red); font-size: 12px; font-weight: 700;
  box-shadow: 0 1px 2px rgba(0,0,0,.15);
}
.walk-pin .stick { display: none; }
.walk-pin.current { z-index: 2; }
.walk-pin.current .head { width: 40px; height: 40px; font-size: 16px; background: var(--red); color: #fff; border: 3px solid #fff; }
.walk-pin.current .stick { display: block; width: 3px; height: 40px; border-radius: 2px; background: var(--red); }
.walk-pin.current::after { content: ""; width: 12px; height: 5px; border-radius: 50%; background: var(--you); filter: blur(1px); }

@media (min-width: 900px) {
  .sheet.explore { align-items: stretch; justify-content: flex-start; }
  .explore .sheet-card {
    position: fixed; left: 16px; top: calc(122px + var(--safe-t)); bottom: 80px; width: 420px; max-height: none;
    border-radius: var(--radius); box-shadow: 0 4px 20px rgba(0,0,0,.15); animation-name: slide;
  }
  .explore .sheet-card::before { display: none; }
  .walk-bottom { left: auto; right: 16px; margin: 0; width: 440px; }
  .walking .panel { bottom: 16px; }
}

/* Поділитися сторінкою будинку (app.js, shareBuilding) */
.section.share { padding-top: 4px; }
