:root {
  --bg: #eef1ea;
  --surface: #fbfaf6;
  --ink: #1e2b27;
  --ink-soft: #4a5852;
  --brand: #4f6f63;
  --brand-dark: #3a544a;
  --sand: #c89b6c;
  --calm: #6b8f6a;
  --moderate: #c9973f;
  --stress: #b5654a;
  --line: #d9ddd3;

  --font-display: "Newsreader", Georgia, serif;
  --font-ui: "IBM Plex Sans", system-ui, sans-serif;
}

* { box-sizing: border-box; }

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

body {
  font-family: var(--font-ui);
  color: var(--ink);
  background: var(--bg);
  display: flex;
  flex-direction: column;
}

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---------- Header ---------- */
.site-header {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 14px 24px;
  background: var(--brand);
  color: white;
}

.wordmark {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.search-wrap {
  flex: 1;
  max-width: 480px;
}

#search-input {
  width: 100%;
  padding: 9px 14px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-family: var(--font-ui);
  font-size: 15px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
}

#search-input:focus-visible {
  outline: 3px solid var(--sand);
  outline-offset: 1px;
}

#search-input::placeholder {
  color: var(--ink-soft);
}

/* ---------- Layout ---------- */
.layout {
  flex: 1;
  display: grid;
  grid-template-columns: 320px 1fr;
  min-height: 0;
}

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--line);
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.sidebar-toggle {
  display: none;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  font-size: 13px;
  color: var(--ink-soft);
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.dot-calm { background: var(--calm); }
.dot-moderate { background: var(--moderate); }
.dot-stress { background: var(--stress); }

/* ---------- Location list ---------- */
.location-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.location-item {
  border: none;
  background: transparent;
  text-align: left;
  width: 100%;
  padding: 10px 8px;
  border-radius: 8px;
  cursor: pointer;
  font-family: var(--font-ui);
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 10px;
}

.location-item:hover,
.location-item:focus-visible {
  background: var(--bg);
}

.location-item:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: -2px;
}

.location-item .name {
  font-size: 14.5px;
  line-height: 1.3;
}

.location-item[hidden] { display: none; }

.empty-state {
  padding: 24px 8px;
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 1.5;
}

/* ---------- Detail panel ---------- */
.detail-panel {
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.detail-panel h2 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 20px;
  margin: 0 0 10px;
}

.score-row {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
}

.score-chip {
  flex: 1;
  background: var(--bg);
  border-radius: 8px;
  padding: 8px 10px;
}

.score-chip .label {
  font-size: 12px;
  color: var(--ink-soft);
  display: block;
}

.score-chip .value {
  font-size: 20px;
  font-weight: 600;
  font-family: var(--font-display);
}

.detail-facts {
  font-size: 13.5px;
  color: var(--ink-soft);
  line-height: 1.7;
}

.detail-close {
  background: none;
  border: none;
  color: var(--brand-dark);
  font-family: var(--font-ui);
  font-size: 13.5px;
  cursor: pointer;
  padding: 0;
  margin-top: 10px;
  text-decoration: underline;
}

/* ---------- Map ---------- */
.map-wrap {
  position: relative;
}

#map {
  width: 100%;
  height: 100%;
}

.map-status {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 1000;
  background: var(--surface);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 13px;
  color: var(--ink-soft);
  box-shadow: 0 1px 4px rgba(30, 43, 39, 0.15);
}

.map-status[hidden] { display: none; }

/* Popup styling to match the rest of the site instead of Leaflet defaults */
.leaflet-popup-content-wrapper {
  border-radius: 8px;
  font-family: var(--font-ui);
}

.popup-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 16px;
  margin: 0 0 4px;
}

.popup-scores {
  font-size: 13px;
  color: var(--ink-soft);
}

/* ---------- Mobile ---------- */
@media (max-width: 760px) {
  .layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }

  .site-header {
    flex-wrap: wrap;
  }

  .sidebar {
    border-right: none;
    border-bottom: 1px solid var(--line);
    max-height: 45vh;
  }

  .sidebar.collapsed {
    max-height: none;
    overflow: visible;
  }

  .sidebar.collapsed .legend,
  .sidebar.collapsed .location-list,
  .sidebar.collapsed .detail-panel {
    display: none;
  }

  .sidebar-toggle {
    display: block;
    width: 100%;
    padding: 8px;
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 8px;
    font-family: var(--font-ui);
    font-size: 13.5px;
    color: var(--ink);
    cursor: pointer;
  }
}
