/* Minimal layout for the read-only POI map. The map owns the viewport; the card panel floats over
   it on the right with its own scroll, so panning the map never moves the card. */

:root {
  --card-width: 22rem;
  --card-bg: #ffffff;
  --card-border: #d8d8d8;
  --text: #1b1b1b;
  --muted: #5a5a5a;
  --link: #0b5cad;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  color: var(--text);
}

#map {
  position: absolute;
  inset: 0;
}

/* Filter panel: a compact overlay in the top-left corner. It must never cover the map outright, so it
   is width-capped, scrollable and collapsible. */
.filters {
  position: absolute;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 2;
  width: 15rem;
  max-width: calc(100vw - 1.5rem);
  max-height: calc(100% - 1.5rem);
  display: flex;
  flex-direction: column;
  padding: 0.6rem 0.7rem 0.7rem;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 0.5rem;
  box-shadow: 0 2px 12px rgb(0 0 0 / 18%);
}

.filters__header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.filters__title {
  flex: 1 1 auto;
  margin: 0;
  font-size: 0.9rem;
}

.filters__toggle {
  flex: 0 0 auto;
  padding: 0.15rem 0.45rem;
  font-size: 0.75rem;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--card-border);
  border-radius: 0.25rem;
  cursor: pointer;
}

.filters__body {
  margin-top: 0.5rem;
  overflow-y: auto;
}

.filters__body[hidden] {
  display: none;
}

.filters__presets {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  padding-bottom: 0.5rem;
  margin-bottom: 0.5rem;
  border-bottom: 1px solid var(--card-border);
}

.filters__preset {
  padding: 0.2rem 0.5rem;
  font-size: 0.78rem;
  color: var(--text);
  background: #f2f4f7;
  border: 1px solid var(--card-border);
  border-radius: 999px;
  cursor: pointer;
}

.filters__preset:hover {
  background: #e6eaf0;
}

.filters__list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.filters__item + .filters__item {
  margin-top: 0.15rem;
}

.filters__label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.86rem;
  cursor: pointer;
}

.filters__named {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding-top: 0.5rem;
  margin-top: 0.5rem;
  font-size: 0.86rem;
  border-top: 1px solid var(--card-border);
  cursor: pointer;
}

.card {
  position: absolute;
  /* `top` and the bottom anchor are computed by app.js from the click position (Pitfall 8); the
     fallback below keeps the panel on screen if that script never runs. */
  top: 0.75rem;
  right: 0.75rem;
  bottom: 0.75rem;
  width: var(--card-width);
  max-width: calc(100vw - 1.5rem);
  max-height: calc(100% - 1.5rem);
  overflow-y: auto;
  padding: 0.85rem 1rem 1rem;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 0.5rem;
  box-shadow: 0 2px 12px rgb(0 0 0 / 18%);
}

/* `hidden` must win over the flex/block display below. */
.card[hidden] {
  display: none;
}

.card__header {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
}

.card__title {
  flex: 1 1 auto;
  margin: 0 0 0.6rem;
  font-size: 1.05rem;
  line-height: 1.3;
  word-break: break-word;
}

.card__close {
  flex: 0 0 auto;
  width: 1.75rem;
  height: 1.75rem;
  padding: 0;
  font-size: 1.1rem;
  line-height: 1;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--card-border);
  border-radius: 0.25rem;
  cursor: pointer;
}

.card__fields {
  margin: 0;
  font-size: 0.92rem;
}

.card__fields dt {
  margin-top: 0.55rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.card__fields dd {
  margin: 0.1rem 0 0;
  word-break: break-word;
}

.card__links {
  margin-top: 0.9rem;
  padding-top: 0.7rem;
  border-top: 1px solid var(--card-border);
  font-size: 0.92rem;
}

/* Walking route to the object: the line is drawn from the visitor's own position, so the button is
   the only control and the summary sits next to it. */
.card__route {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-top: 0.9rem;
}

.card__route-button {
  border: 1px solid var(--link);
  background: var(--link);
  color: #ffffff;
  border-radius: 0.4rem;
  padding: 0.45rem 0.85rem;
  font: inherit;
  font-size: 0.92rem;
  cursor: pointer;
}

.card__route-button:hover:not(:disabled) {
  filter: brightness(1.08);
}

.card__route-button:disabled {
  opacity: 0.6;
  cursor: progress;
}

.card__route-info {
  font-size: 0.88rem;
  opacity: 0.8;
}

.card__links a {
  color: var(--link);
  /* Ссылки идут подряд в одной строке (OSM и телефон), поэтому нужен зазор —
     иначе «Открыть в OpenStreetMap+7495…» читается как один адрес. */
  display: inline-block;
  margin-right: 0.75rem;
}

.card__links > * + * {
  margin-top: 0.3rem;
}

.card__photo {
  margin: 0.7rem 0 0;
}

.card__photo img {
  max-width: 100%;
  height: auto;
  border-radius: 0.25rem;
}

.card__photo figcaption {
  margin-top: 0.25rem;
  font-size: 0.78rem;
  color: var(--muted);
}

/* The local-language name, kept next to the title it belongs to rather than in the address block. */
.card__subtitle {
  margin: 0.15rem 0 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.card__note {
  margin: 0 0 0.5rem;
  font-size: 0.85rem;
  color: var(--muted);
  font-style: italic;
}

/* Kept out of the layout entirely while app.js has nothing honest to say. */
.card__note[hidden] {
  display: none;
}

/* Search: centred at the top, clear of the filter panel (left) and the navigation control (right). */
.search {
  position: absolute;
  top: 0.75rem;
  left: 50%;
  z-index: 2;
  width: 22rem;
  max-width: calc(100vw - 1.5rem);
  transform: translateX(-50%);
}

.search__row {
  display: flex;
  gap: 0.35rem;
  padding: 0.35rem;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 0.5rem;
  box-shadow: 0 2px 12px rgb(0 0 0 / 18%);
}

.search__input {
  flex: 1 1 auto;
  min-width: 0;
  padding: 0.35rem 0.5rem;
  font: inherit;
  font-size: 0.9rem;
  color: var(--text);
  background: transparent;
  border: 1px solid var(--card-border);
  border-radius: 0.3rem;
}

.search__submit {
  flex: 0 0 auto;
  padding: 0.35rem 0.7rem;
  font-size: 0.86rem;
  color: var(--text);
  background: #f2f4f7;
  border: 1px solid var(--card-border);
  border-radius: 0.3rem;
  cursor: pointer;
}

.search__submit:hover {
  background: #e6eaf0;
}

/* The dropdown hangs below the field and scrolls on its own: a long result list must never grow the
   panel past the viewport. */
.search__results {
  max-height: 20rem;
  margin: 0.35rem 0 0;
  padding: 0.25rem;
  overflow-y: auto;
  list-style: none;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 0.5rem;
  box-shadow: 0 2px 12px rgb(0 0 0 / 18%);
}

.search__results[hidden] {
  display: none;
}

.search__button {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  width: 100%;
  padding: 0.35rem 0.45rem;
  font: inherit;
  text-align: left;
  background: transparent;
  border: 0;
  border-radius: 0.3rem;
  cursor: pointer;
}

.search__button:hover {
  background: #f2f4f7;
}

.search__name {
  font-size: 0.9rem;
  color: var(--text);
  word-break: break-word;
}

.search__category {
  font-size: 0.75rem;
  color: var(--muted);
}

.search__empty,
.search__area {
  padding: 0.4rem 0.45rem;
  font-size: 0.82rem;
  color: var(--muted);
}

/* The area note is separated because it is a different KIND of statement than a hit: it explains where
   the search looked, not what it found. */
.search__area {
  margin-top: 0.25rem;
  border-top: 1px solid var(--card-border);
  font-style: italic;
}

/* Navigation tree (MAP-05): bottom-left, so it never fights the filter panel (top-left), the search
   field (top-centre) or the card (right). It is a shortcut, not a boundary — the map underneath keeps
   every gesture, and the hint inside says so. */
.nav {
  position: absolute;
  left: 0.75rem;
  bottom: 2.2rem;
  z-index: 2;
  width: 15rem;
  max-width: calc(100vw - 1.5rem);
  max-height: 45vh;
  display: flex;
  flex-direction: column;
  padding: 0.6rem 0.7rem 0.7rem;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 0.5rem;
  box-shadow: 0 2px 12px rgb(0 0 0 / 18%);
}

.nav__header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
}

.nav__title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
}

.nav__toggle {
  padding: 0.15rem 0.45rem;
  font: inherit;
  font-size: 0.78rem;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--card-border);
  border-radius: 0.3rem;
  cursor: pointer;
}

.nav__body {
  margin-top: 0.5rem;
  overflow-y: auto;
}

.nav__body[hidden] {
  display: none;
}

.nav__country + .nav__country {
  margin-top: 0.5rem;
}

.nav__country-button {
  display: block;
  width: 100%;
  padding: 0.2rem 0.25rem;
  font: inherit;
  font-size: 0.86rem;
  font-weight: 600;
  text-align: left;
  color: var(--text);
  background: transparent;
  border: 0;
  border-radius: 0.3rem;
  cursor: pointer;
}

.nav__cities {
  margin: 0.1rem 0 0;
  padding: 0 0 0 0.6rem;
  list-style: none;
}

.nav__city-button {
  display: block;
  width: 100%;
  padding: 0.2rem 0.25rem;
  font: inherit;
  font-size: 0.84rem;
  text-align: left;
  color: var(--text);
  background: transparent;
  border: 0;
  border-radius: 0.3rem;
  cursor: pointer;
  word-break: break-word;
}

.nav__country-button:hover,
.nav__city-button:hover {
  background: #f2f4f7;
}

/* The selected region is visible, not implied: without it the user cannot tell which branch produced
   the current view, and would re-click to find out. */
.nav__city-button[aria-current='true'],
.nav__country-button[aria-current='true'] {
  background: #e3ecf7;
  font-weight: 600;
}

/* The honesty line (D-21/D-22): a short list of cities is a property of the catalog, not a statement
   that no other cities exist in the data. */
.nav__hint {
  margin: 0.55rem 0 0;
  padding-top: 0.45rem;
  border-top: 1px solid var(--card-border);
  font-size: 0.74rem;
  line-height: 1.3;
  color: var(--muted);
}

.nav__empty {
  font-size: 0.82rem;
  color: var(--muted);
}

/* Attribution (MAP-06/D-24): a static strip along the bottom, always visible. It duplicates the
   MapLibre control on purpose — the control only exists once JS has run, while the OSM Tile Usage
   Policy requires the credit to be readable regardless. Deliberately not collapsible. */
.attribution {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 3;
  padding: 0.2rem 0.6rem;
  font-size: 0.72rem;
  line-height: 1.35;
  color: var(--text);
  background: rgb(255 255 255 / 90%);
  border-top: 1px solid var(--card-border);
}

.attribution a {
  color: var(--link);
}

/* Narrow screens: the two overlay panels would cover the map between them, so both collapse to their
   header button. The map stays the primary surface — a simple UI, not a dashboard. */
@media (max-width: 640px) {
  .filters,
  .nav {
    width: 12rem;
  }

  .nav {
    max-height: 30vh;
  }

  .filters__body[hidden],
  .nav__body[hidden] {
    display: none;
  }
}
