:root {
  --bg: #f5f4ef;
  --panel: #fffef9;
  --text: #1f2933;
  --muted: #64707d;
  --line: #d8d7cf;
  --accent: #00796b;
  --accent-dark: #005b50;
  --warn: #9a5b00;
}

* {
  box-sizing: border-box;
}

.leaflet-container {
  overflow: hidden;
  background: #dfe8e4;
  outline: 0;
}

.leaflet-pane,
.leaflet-tile,
.leaflet-marker-icon,
.leaflet-marker-shadow,
.leaflet-tile-container,
.leaflet-pane > svg,
.leaflet-pane > canvas,
.leaflet-zoom-box,
.leaflet-image-layer,
.leaflet-layer {
  position: absolute;
  left: 0;
  top: 0;
}

.leaflet-tile-pane {
  z-index: 200;
}

.leaflet-overlay-pane {
  z-index: 400;
}

.leaflet-shadow-pane {
  z-index: 500;
}

.leaflet-marker-pane {
  z-index: 600;
}

.leaflet-tooltip-pane {
  z-index: 650;
}

.leaflet-popup-pane {
  z-index: 700;
}

.leaflet-supermarketBuildings-pane {
  z-index: 460;
}

.leaflet-supermarketPoints-pane {
  z-index: 520;
}

.leaflet-supermarketBuildings-pane path,
.leaflet-supermarketPoints-pane path {
  vector-effect: non-scaling-stroke;
}

.leaflet-tile,
.leaflet-marker-icon,
.leaflet-marker-shadow {
  user-select: none;
  -webkit-user-drag: none;
}

.leaflet-tile {
  border: 0;
  max-width: none;
}

.leaflet-control {
  position: relative;
  z-index: 800;
  pointer-events: auto;
}

.leaflet-top,
.leaflet-bottom {
  position: absolute;
  z-index: 1000;
  pointer-events: none;
}

.leaflet-top {
  top: 0;
}

.leaflet-bottom {
  bottom: 0;
}

.leaflet-right {
  right: 0;
}

.leaflet-left {
  left: 0;
}

.leaflet-popup {
  position: absolute;
  text-align: center;
  margin-bottom: 20px;
}

.leaflet-popup-content-wrapper {
  border-radius: 6px;
  background: white;
  box-shadow: 0 3px 14px rgb(0 0 0 / 20%);
  padding: 1px;
  text-align: left;
}

.leaflet-popup-content {
  margin: 12px 14px;
  min-width: 180px;
}

.leaflet-popup-tip-container {
  position: absolute;
  left: 50%;
  width: 24px;
  height: 12px;
  margin-left: -12px;
  overflow: hidden;
  pointer-events: none;
}

.leaflet-popup-tip {
  width: 12px;
  height: 12px;
  margin: -6px auto 0;
  transform: rotate(45deg);
  background: white;
  box-shadow: 0 3px 14px rgb(0 0 0 / 20%);
}

.leaflet-interactive {
  cursor: pointer;
}

.leaflet-zoom-animated {
  transform-origin: 0 0;
}

.leaflet-zoom-anim .leaflet-zoom-animated {
  transition: transform 250ms cubic-bezier(0, 0, 0.25, 1);
}

.leaflet-zoom-anim .leaflet-tile,
.leaflet-pan-anim .leaflet-tile {
  transition: none;
}

html,
body,
.app {
  height: 100%;
  margin: 0;
}

html,
body {
  overflow: hidden;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.app {
  display: grid;
  grid-template-columns: minmax(340px, 420px) 1fr;
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
}

.sidebar {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
  border-right: 1px solid var(--line);
  background: var(--panel);
}

.topbar {
  flex: 0 0 auto;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 20px 14px;
  border-bottom: 1px solid var(--line);
}

.topbar-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 8px;
}

#info {
  font-size: 18px;
  font-weight: 700;
  font-style: italic;
  font-family: Georgia, "Times New Roman", serif;
}

/* The collapse handle only matters on the stacked mobile layout. */
.sidebar-handle {
  display: none;
}

.about {
  width: min(420px, calc(100vw - 32px));
  max-width: none;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 18px 50px rgb(0 0 0 / 25%);
}

.about::backdrop {
  background: rgb(0 0 0 / 35%);
}

.about-inner {
  position: relative;
  padding: 22px 24px 24px;
}

.about-inner h2 {
  margin: 0 0 10px;
  font-size: 19px;
}

.about-inner p {
  margin: 0 0 10px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
}

.about-inner a {
  color: var(--accent-dark);
  font-weight: 600;
}

.about-link {
  margin-top: 14px;
}

.about-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 32px;
  height: 32px;
  font-size: 22px;
  color: var(--muted);
}

h1 {
  margin: 0 0 4px;
  font-size: 22px;
  line-height: 1.2;
}

p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

button,
input,
select {
  font: inherit;
}

button {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  color: var(--accent-dark);
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
}

button:hover {
  border-color: var(--accent);
}

.maplibregl-ctrl button,
.maplibregl-ctrl button:hover {
  width: 29px;
  height: 29px;
  border: 0;
  border-radius: 0;
  background-color: transparent;
  color: inherit;
  cursor: pointer;
  font-size: 0;
  line-height: normal;
  padding: 0;
}

.maplibregl-ctrl button + button {
  border-top: 1px solid #ddd;
}

.controls {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: 1fr 120px;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

input,
select {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  color: var(--text);
  padding: 8px 10px;
  font-size: 14px;
  text-transform: none;
}

.results {
  flex: 1;
  min-height: 0;
  margin: 0;
  padding: 0;
  overflow: auto;
  list-style: none;
}

.result {
  display: grid;
  gap: 6px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}

.result:hover,
.result.active {
  background: #eef7f4;
}

.result-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  font-size: 15px;
  font-weight: 800;
}

.result-meta {
  color: var(--muted);
  font-size: 13px;
}

.area {
  color: var(--brand-color, var(--accent-dark));
  white-space: nowrap;
}

.area.missing {
  color: var(--muted);
}

.hover-popup {
  pointer-events: none;
}

.map-wrap,
#map {
  min-width: 0;
  min-height: 0;
  height: 100%;
}

.popup h2 {
  margin: 0 0 6px;
  font-size: 16px;
}

.popup p {
  margin: 3px 0;
}

.person-location {
  position: relative;
  width: 24px;
  height: 30px;
  filter: drop-shadow(0 2px 5px rgb(0 0 0 / 35%));
  pointer-events: none;
}

.person-location-head,
.person-location-body {
  position: absolute;
  left: 50%;
  display: block;
  transform: translateX(-50%);
  background: #111827;
  border: 2px solid white;
}

.person-location-head {
  top: 0;
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

.person-location-body {
  top: 13px;
  width: 16px;
  height: 16px;
  border-radius: 8px 8px 9px 9px;
}

.person-location-body::after {
  position: absolute;
  bottom: -8px;
  left: 50%;
  width: 0;
  height: 0;
  border-top: 8px solid #111827;
  border-right: 5px solid transparent;
  border-left: 5px solid transparent;
  content: "";
  transform: translateX(-50%);
}

@media (max-width: 760px) {
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: 45dvh 55dvh;
    height: 100dvh;
  }

  .sidebar {
    height: auto;
    min-height: 0;
    grid-row: 2;
    border-top: 1px solid var(--line);
    border-right: 0;
  }

  .map-wrap {
    grid-row: 1;
  }

  .topbar {
    padding: 10px 16px 12px;
  }

  .controls {
    grid-template-columns: 1fr 120px;
    padding: 12px 16px;
  }

  .result {
    padding: 12px 16px;
  }

  /* Tappable chevron the user taps to collapse the list and free up map. */
  .sidebar-handle {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 100%;
    height: 30px;
    padding: 0;
    border: 0;
    border-radius: 0;
    border-bottom: 1px solid var(--line);
    background: var(--panel);
    color: var(--muted);
  }

  /* Chevron points down to collapse the list; flips up to reveal it again. */
  .sidebar-handle-chevron {
    transition: transform 150ms ease;
  }

  .app.sidebar-collapsed .sidebar-handle-chevron {
    transform: rotate(180deg);
  }

  /* Collapsed: hand the freed rows to the map, keep just the handle + title. */
  .app.sidebar-collapsed {
    grid-template-rows: 1fr auto;
  }

  .app.sidebar-collapsed .controls,
  .app.sidebar-collapsed .results {
    display: none;
  }

  .app.sidebar-collapsed .topbar {
    border-bottom: 0;
  }
}
