/* Mapper design tokens — flat, bright, opinionated. Not Bootstrap utility soup. */

:root {
  --mp-bg: #faf8f4;
  --mp-surface: #ffffff;
  --mp-ink: #1c1c1e;
  --mp-ink-soft: #56565a;
  --mp-line: #e6e2da;
  --mp-accent: #ff6a3d;
  --mp-accent-soft: #ffe7dc;
  --mp-good: #1c7c54;
  --mp-radius: 10px;
  --mp-shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 4px 16px rgba(0, 0, 0, 0.06);
  --mp-font: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--mp-font);
  color: var(--mp-ink);
  background: var(--mp-bg);
  height: 100%;
  overflow: hidden;  /* prevent the page itself from scrolling — internal panes scroll instead */
}

/* Layout: 380px sidebar + flex main with map on top, results+detail below.
 * `position: fixed` pulls the shell out of document flow so a tall form inside
 * the sidebar can't push body height past 100vh — every child must scroll
 * internally with its own overflow. */
.mp-shell {
  position: fixed;
  inset: 0;
  display: grid;
  grid-template-columns: 380px 1fr;
  grid-template-rows: 100vh;
}

.mp-sidebar {
  background: var(--mp-surface);
  border-right: 1px solid var(--mp-line);
  min-height: 0;                 /* allow grid item to shrink below content height */
  overflow-y: auto;
  padding: 28px 24px 40px;
}

.mp-header { margin-bottom: 24px; }
.mp-title {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 6px;
}
.mp-tagline {
  margin: 0;
  font-size: 14px;
  color: var(--mp-ink-soft);
}

.mp-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 14px;
}
.mp-preset {
  font: inherit;
  font-size: 12px;
  font-weight: 500;
  padding: 5px 12px;
  border: 1px solid var(--mp-line);
  border-radius: 999px;
  background: white;
  color: var(--mp-ink);
  cursor: pointer;
  transition: background 100ms ease, border-color 100ms ease, color 100ms ease;
}
.mp-preset:hover {
  background: var(--mp-accent-soft);
  border-color: #ffc1a8;
  color: #6b2a14;
}
.mp-preset--reset {
  color: var(--mp-ink-soft);
  border-style: dashed;
}
.mp-preset--reset:hover {
  background: var(--mp-line);
  border-style: solid;
  color: var(--mp-ink);
}

.mp-weights { display: flex; flex-direction: column; gap: 8px; }

.mp-group { margin-top: 18px; }
.mp-group:first-of-type { margin-top: 0; }
.mp-group[open] > .mp-group-label { margin-bottom: 8px; }

.mp-group-label {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--mp-ink-soft);
  user-select: none;
  border-radius: 4px;
}
.mp-group-label::-webkit-details-marker { display: none; }
.mp-group-label:hover { background: rgba(0, 0, 0, 0.03); color: var(--mp-ink); }
.mp-group-label::before {
  content: "▾";
  font-size: 10px;
  display: inline-block;
  transition: transform 120ms ease;
  width: 8px;
}
.mp-group:not([open]) > .mp-group-label::before {
  transform: rotate(-90deg);
}

.mp-criterion {
  padding: 10px 12px;
  border-radius: var(--mp-radius);
  background: transparent;
  transition: background 120ms ease;
}
.mp-criterion[data-level="3"] { background: #fff3eb; }
.mp-criterion[data-level="4"] { background: var(--mp-accent-soft); box-shadow: inset 0 0 0 1px #ffc1a8; }

.mp-criterion-label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 14px;
  margin-bottom: 8px;
  gap: 8px;
}
.mp-criterion-name { font-weight: 500; }
.mp-criterion-value {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--mp-ink-soft);
}
.mp-criterion[data-level="2"] .mp-criterion-value { color: var(--mp-ink); }
.mp-criterion[data-level="3"] .mp-criterion-value { color: var(--mp-accent); }
.mp-criterion[data-level="4"] .mp-criterion-value { color: var(--mp-accent); text-transform: uppercase; }

/* 5-position segmented control */
.mp-segmented {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  user-select: none;
}
.mp-segmented input[type="radio"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.mp-seg {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 28px;
  border-radius: 6px;
  background: var(--mp-line);
  cursor: pointer;
  transition: background 100ms ease, transform 80ms ease;
}
.mp-seg:hover { background: #d8d2c5; }
.mp-seg-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: rgba(0,0,0,0.25);
}
/* Selected state — gradient by level so the visual scale conveys intensity */
.mp-segmented input[type="radio"]:checked + .mp-seg { background: var(--mp-ink); }
.mp-segmented input[type="radio"]:checked + .mp-seg .mp-seg-dot { background: white; }
.mp-segmented input[type="radio"]:checked + .mp-seg-0 { background: #c8c4ba; }
.mp-segmented input[type="radio"]:checked + .mp-seg-1 { background: #6b8e7f; }
.mp-segmented input[type="radio"]:checked + .mp-seg-2 { background: #d97a3c; }
.mp-segmented input[type="radio"]:checked + .mp-seg-3 { background: #c44a1f; }
.mp-segmented input[type="radio"]:checked + .mp-seg-4 {
  background: var(--mp-accent);
  box-shadow: 0 0 0 2px rgba(255,106,61,0.25);
}
.mp-segmented input[type="radio"]:focus-visible + .mp-seg {
  outline: 2px solid var(--mp-accent);
  outline-offset: 2px;
}

.mp-criterion-desc {
  font-size: 12px;
  color: var(--mp-ink-soft);
  margin: 6px 0 0;
}

.mp-survivor-note {
  margin: 0 0 10px;
  padding: 8px 10px;
  border-radius: 6px;
  background: var(--mp-accent-soft);
  font-size: 13px;
  color: #6b2a14;
}
.mp-empty-hint { display: block; margin-top: 4px; font-size: 12px; color: var(--mp-ink-soft); }

.mp-cold-start {
  margin: 8px 0;
  padding: 14px 16px;
  border: 1px dashed var(--mp-line);
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--mp-ink-soft);
}

/* Static pages (Impressum etc.) — readable column on neutral background */
.mp-page {
  max-width: 720px;
  margin: 40px auto;
  padding: 0 24px 64px;
  font-size: 15px;
  line-height: 1.6;
}
.mp-page h1 { font-size: 28px; letter-spacing: -0.02em; margin: 16px 0 8px; }
.mp-page h2 { font-size: 15px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--mp-ink-soft); margin: 28px 0 8px; }
.mp-page p { margin: 0 0 12px; }
.mp-page ul { margin: 0 0 12px; padding-left: 22px; }
.mp-page li { margin-bottom: 6px; }
.mp-page code {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
  font-size: 13px;
  background: var(--mp-line);
  padding: 1px 6px;
  border-radius: 4px;
}
.mp-page a { color: var(--mp-accent); }
.mp-page-lede { color: var(--mp-ink-soft); margin: 0 0 24px; }
.mp-page-meta { color: var(--mp-ink-soft); font-size: 13px; margin-top: 4px; }
.mp-page-back {
  display: inline-block;
  font-size: 13px;
  color: var(--mp-ink-soft);
  text-decoration: none;
  margin-bottom: 8px;
}
.mp-page-back:hover { color: var(--mp-accent); }

/* Tiny footer link in the sidebar */
.mp-sidebar-footer {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--mp-line);
  font-size: 11px;
  color: var(--mp-ink-soft);
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.mp-sidebar-footer a { color: var(--mp-ink-soft); text-decoration: none; }
.mp-sidebar-footer a:hover { color: var(--mp-accent); }
.mp-sidebar-footer span { color: var(--mp-line); }

/* Filter stats overlay on map */
.mp-map-wrap { position: relative; grid-area: map; min-height: 0; }
.mp-stats {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 1000;
  background: rgba(255,255,255,0.95);
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  box-shadow: var(--mp-shadow);
}
.mp-stats[hidden] { display: none; }

.mp-legend {
  position: absolute;
  bottom: 12px;
  left: 12px;
  z-index: 1000;
  background: rgba(255,255,255,0.95);
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 12px;
  box-shadow: var(--mp-shadow);
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  max-width: 60%;
}
.mp-legend[hidden] { display: none; }
.mp-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}
.mp-legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 1px solid white;
  box-shadow: 0 0 0 0.5px rgba(0,0,0,0.2);
}

/* Main column: map + results + detail */
.mp-main {
  display: grid;
  grid-template-columns: 1fr 320px;
  grid-template-rows: 55% 45%;
  grid-template-areas:
    "map detail"
    "results detail";
  min-height: 0;
}

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

.mp-results {
  grid-area: results;
  border-top: 1px solid var(--mp-line);
  background: var(--mp-surface);
  overflow-y: auto;
  padding: 18px 24px;
}
.mp-results-title {
  margin: 0 0 12px;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--mp-ink-soft);
}
.mp-result-list { list-style: none; margin: 0; padding: 0; }
.mp-result {
  display: grid;
  grid-template-columns: 32px 1fr 60px;
  align-items: center;
  gap: 12px;
  padding: 10px 8px;
  border-bottom: 1px solid var(--mp-line);
  cursor: pointer;
  transition: background 80ms ease;
}
.mp-result:hover { background: var(--mp-accent-soft); }
.mp-result.is-active {
  background: var(--mp-accent-soft);
  box-shadow: inset 3px 0 0 var(--mp-accent);
}
.mp-result:focus-visible {
  outline: 2px solid var(--mp-accent);
  outline-offset: -2px;
}
.mp-result-rank {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--mp-ink-soft);
  text-align: right;
}
.mp-result-name { font-weight: 500; margin-bottom: 4px; font-size: 14px; }
.mp-result-bar {
  height: 4px;
  background: var(--mp-line);
  border-radius: 999px;
  overflow: hidden;
}
.mp-result-bar-fill {
  height: 100%;
  background: var(--mp-good);
}
.mp-result-score {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--mp-good);
  text-align: right;
}

.mp-detail {
  grid-area: detail;
  background: var(--mp-surface);
  border-left: 1px solid var(--mp-line);
  overflow-y: auto;
  padding: 18px 20px;
}
.mp-detail:empty::before {
  content: "Click a neighborhood on the map or in the list to see its score breakdown.";
  display: block;
  color: var(--mp-ink-soft);
  font-size: 13px;
  line-height: 1.5;
}
.mp-detail-name { margin: 0 0 4px; font-size: 18px; }
.mp-detail-meta { margin: 0 0 16px; color: var(--mp-ink-soft); font-size: 13px; }
.mp-detail-meta a { color: var(--mp-accent); text-decoration: none; }
.mp-detail-meta a:hover { text-decoration: underline; }

/* Primary CTA inside the right-side detail panel — opens the spot page. */
.mp-detail-cta {
  display: inline-flex;
  align-items: center;
  margin-top: 12px;
  padding: 8px 14px;
  background: var(--mp-accent);
  color: white;
  border-radius: 999px;
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  transition: transform 80ms ease, background 100ms ease;
}
.mp-detail-cta:hover { background: #e6562b; transform: translateX(2px); }

.mp-detail-section { margin-top: 16px; }
.mp-detail-section-title {
  margin: 0 0 8px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--mp-ink-soft);
}

.mp-detail-closest { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.mp-detail-closest li {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}
.mp-detail-poi-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mp-detail-distance {
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  color: var(--mp-ink-soft);
}

/* Per-criterion color pills (also used for map markers) */
.mp-pill {
  display: inline-flex;
  align-items: center;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  background: var(--mp-line);
  color: white;
  white-space: nowrap;
}
.mp-pill--quietness     { background: #6c757d; }
.mp-pill--parks         { background: #2e7d32; }
.mp-pill--lakes         { background: #0288d1; }
.mp-pill--supermarkets  { background: #1565c0; }
.mp-pill--restaurants   { background: #ef6c00; }
.mp-pill--cafes_bakeries{ background: #8d6e63; }
.mp-pill--bars          { background: #c2185b; }
.mp-pill--transit       { background: #212121; }
.mp-pill--bus_tram      { background: #37474f; }
.mp-pill--bike_infra    { background: #558b2f; }
.mp-pill--kindergarten  { background: #9c27b0; }
.mp-pill--schools       { background: #6a1b9a; }
.mp-pill--playgrounds   { background: #fbc02d; color: #3a2c00; }
.mp-pill--pharmacies    { background: #c62828; }
.mp-pill--hospitals     { background: #ad1457; }
.mp-pill--gyms          { background: #ef5350; }
.mp-pill--culture       { background: #5e35b1; }
.mp-detail-scores { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.mp-detail-scores li {
  display: grid;
  grid-template-columns: 1fr 80px 40px;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}
.mp-detail-bar {
  height: 4px;
  background: var(--mp-line);
  border-radius: 999px;
  overflow: hidden;
  display: block;
}
.mp-detail-bar-fill {
  height: 100%;
  background: var(--mp-good);
  display: block;
}
.mp-detail-val {
  font-variant-numeric: tabular-nums;
  text-align: right;
  color: var(--mp-ink-soft);
}

/* Leaflet polygon styling tweaks */
.mp-empty { color: var(--mp-ink-soft); font-size: 13px; padding: 12px 0; }

@media (max-width: 900px) {
  html, body { overflow: auto; height: auto; }
  .mp-shell {
    position: static;
    inset: auto;
    grid-template-columns: 1fr;
    grid-template-rows: auto auto;
    height: auto;
  }
  .mp-main { grid-template-columns: 1fr; grid-template-rows: 50vh auto auto; grid-template-areas: "map" "results" "detail"; }
}

/* Desktop: breathing room above the map column. Sidebar already has internal
 * top padding (28px); the map and detail panes butt right against the viewport
 * top without this. box-sizing keeps the inner grid rows resolving correctly. */
@media (min-width: 901px) {
  .mp-main {
    padding-top: 20px;
    box-sizing: border-box;
  }
}

/* Static pages (Impressum) need natural body scroll. */
body.mp-static-page,
html:has(body.mp-static-page) { overflow: auto; height: auto; }

/* Spot detail page — full-bleed two-column with map */
body.mp-spot-page,
html:has(body.mp-spot-page) { overflow: hidden; height: 100%; }
.mp-spot {
  position: fixed;
  inset: 0;
  display: grid;
  grid-template-rows: auto 1fr;
}
.mp-spot-header {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 16px 24px;
  background: var(--mp-surface);
  border-bottom: 1px solid var(--mp-line);
  flex-shrink: 0;
}
.mp-spot-back {
  display: inline-flex;
  align-items: center;
  padding: 6px 14px;
  border: 1px solid var(--mp-line);
  border-radius: 999px;
  font-size: 13px;
  color: var(--mp-ink-soft);
  text-decoration: none;
  transition: background 100ms ease, color 100ms ease, border-color 100ms ease;
  flex-shrink: 0;
}
.mp-spot-back:hover {
  background: var(--mp-accent-soft);
  border-color: #ffc1a8;
  color: #6b2a14;
}
.mp-spot-title {
  flex: 1 1 auto;
  min-width: 0;
}
.mp-spot-title h1 {
  margin: 0;
  font-size: 18px;
  letter-spacing: -0.01em;
}
.mp-spot-title p {
  margin: 2px 0 0;
  font-size: 13px;
  color: var(--mp-ink-soft);
}

.mp-spot-match {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  padding: 6px 14px;
  background: var(--mp-good);
  color: white;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.mp-spot-main {
  display: grid;
  grid-template-columns: 360px 1fr;
  min-height: 0;
}
.mp-spot-side {
  background: var(--mp-surface);
  border-right: 1px solid var(--mp-line);
  overflow-y: auto;
  padding: 20px 24px 32px;
  min-height: 0;
}
.mp-spot-map {
  min-height: 0;
}
.mp-spot-map { width: 100%; height: 100%; }

.mp-spot-crit {
  margin-bottom: 14px;
}
.mp-spot-crit-list {
  list-style: none;
  margin: 6px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.mp-spot-crit-list li {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  padding: 4px 0;
  border-bottom: 1px dotted var(--mp-line);
}
.mp-spot-crit-list li:last-child { border-bottom: none; }

@media (max-width: 800px) {
  body.mp-spot-page,
  html:has(body.mp-spot-page) { overflow: auto; height: auto; }
  .mp-spot { position: static; grid-template-rows: auto auto; }
  .mp-spot-main { grid-template-columns: 1fr; grid-template-rows: 60vh auto; }
  .mp-spot-side { border-right: 0; border-top: 1px solid var(--mp-line); }
}
