:root {
  --bg: #f6f5f2;
  --card-bg: #ffffff;
  --ink: #1f2420;
  --muted: #6b6f6c;
  --accent: #2f6f4f;
  --accent-soft: #e4efe8;
  --border: #dedad2;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
}

/* ---------- landing ---------- */
.landing {
  max-width: 760px;
  margin: 60px auto;
  padding: 0 24px;
  text-align: center;
}
.landing h1 { font-size: 1.7rem; margin-bottom: 24px; }
.landing .name-field {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-bottom: 32px;
}
.landing .name-field label { font-weight: 600; }
.landing .name-field input {
  width: 100%;
  max-width: 320px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 1rem;
  font-family: inherit;
  text-align: center;
}
.landing .explain {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px 24px;
  text-align: right;
  margin-bottom: 28px;
}
.landing .explain h2 { margin: 0 0 10px; font-size: 1.05rem; color: var(--accent); }
.landing .explain p { color: var(--muted); line-height: 1.7; margin: 0 0 12px; }
.landing .explain p:last-child { margin-bottom: 0; }
.landing .cta-btn, .example-page .cta-btn {
  padding: 12px 32px;
  border-radius: 10px;
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}
.landing .cta-btn:disabled { opacity: .4; cursor: not-allowed; }
.landing .explain ul { color: var(--muted); line-height: 1.7; margin: 0; padding-inline-start: 20px; }
.landing .explain li { margin-bottom: 6px; }
.landing .explain li strong { color: var(--ink); }
.landing .consent-check {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin-bottom: 20px;
  font-weight: 600;
  cursor: pointer;
}
.landing .consent-check input { width: 18px; height: 18px; }
.details-form { display: flex; flex-direction: column; gap: 14px; }
.details-form .q { display: flex; flex-direction: column; gap: 6px; font-weight: 600; border: none; padding: 0; margin: 0; }
.details-form legend { font-weight: 600; margin-bottom: 6px; padding: 0; }
.details-form input[type="text"],
.details-form input[type="number"],
.details-form select {
  max-width: 320px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: .95rem;
  font-family: inherit;
  font-weight: normal;
  background: #fff;
}
.details-form .inline-opt { display: inline-flex; align-items: center; gap: 4px; margin-inline-end: 16px; font-weight: normal; cursor: pointer; }
.details-form fieldset.q { display: block; }
.landing .explain .form-error { color: #b3261e; margin: 0; }

/* ---------- survey ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 24px;
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 5;
}
.topbar .back { text-decoration: none; color: var(--muted); }
.mode-pill {
  background: var(--accent-soft);
  color: var(--accent);
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
}
.mode-switch { display: flex; gap: 8px; }
.mode-switch a {
  text-decoration: none;
  color: var(--muted);
  padding: 4px 10px;
  border-radius: 8px;
  font-size: 0.85rem;
}
.mode-switch a.active { background: var(--ink); color: #fff; }
.rank-badge {
  background: #fbf1da;
  color: #8a6a1f;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 600;
  white-space: nowrap;
}

.rank-up-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.rank-up-overlay[hidden] { display: none; }
.rank-up-message {
  position: relative;
  background: rgba(255, 255, 255, 0.97);
  border: 2px solid var(--accent);
  border-radius: 16px;
  padding: 18px 32px;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--accent);
  text-align: center;
  opacity: 0;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.18);
  animation: rank-up-message-pop 2.3s ease forwards;
}
@keyframes rank-up-message-pop {
  0% { opacity: 0; transform: scale(0.6); }
  15% { opacity: 1; transform: scale(1.08); }
  25% { transform: scale(1); }
  82% { opacity: 1; }
  100% { opacity: 0; transform: scale(1); }
}
.rank-up-particle {
  position: absolute;
  top: 50%;
  left: 50%;
  font-size: 1.6rem;
  opacity: 0;
  animation: rank-up-particle-fly 1.8s ease-out forwards;
  animation-delay: var(--delay, 0s);
}
@keyframes rank-up-particle-fly {
  0% { opacity: 1; transform: translate(-50%, -50%) rotate(0deg) translate(0, 0) scale(0.5); }
  8% { opacity: 1; }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) rotate(var(--angle)) translate(var(--distance), 0) rotate(calc(-1 * var(--angle))) scale(1.3);
  }
}
.counter { margin-inline-start: auto; color: var(--muted); font-size: 0.85rem; }
.undo-btn {
  padding: 5px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--muted);
  font-size: 0.82rem;
  cursor: pointer;
}
.undo-btn:hover { border-color: var(--accent); color: var(--accent); }
.undo-btn:disabled { opacity: .5; cursor: not-allowed; }
.pair-error { text-align: center; }
.pair-error button:disabled { opacity: .5; cursor: not-allowed; }

main { max-width: 1100px; margin: 0 auto; padding: 20px 24px 80px; }
main h1 { text-align: center; font-size: 1.3rem; margin-bottom: 24px; }

.pair {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 16px;
  align-items: start;
}
#pair-container[hidden] { display: none; }

.tie-row { text-align: center; margin-top: 20px; }
.tie-row #tie-btn {
  padding: 10px 22px;
  border-radius: 10px;
  border: 1px solid var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
}
.tie-row #tie-btn:hover:not(:disabled) { background: var(--accent); color: #fff; }
.tie-row #tie-btn.chosen { background: var(--accent); color: #fff; }
.tie-row #tie-btn:disabled { opacity: .5; cursor: not-allowed; }

.completion-screen {
  max-width: 500px;
  margin: 60px auto;
  text-align: center;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 40px 24px;
}
.completion-screen h2 { color: var(--accent); margin: 0 0 10px; }
.completion-screen p { color: var(--muted); line-height: 1.6; }

/* Shared by every button row across the reason/round-actions/rank-prompt/
   feedback panels below - only .actions justify-content and panel
   background/border colors vary per panel. */
.actions { display: flex; gap: 10px; }
.actions button {
  padding: 9px 18px; border-radius: 10px; border: 1px solid var(--border);
  background: #fff; cursor: pointer; font-size: 0.9rem;
}
.actions button.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.actions button:disabled { opacity: .5; cursor: not-allowed; }

.mini-card {
  max-width: 500px;
  margin: 28px auto 0;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
  text-align: center;
}
.mini-card .actions { justify-content: center; }

.round-actions p { color: var(--muted); margin: 0 0 14px; }

.rank-prompt { background: #fffaf0; border-color: #f0dfa8; }
.rank-prompt p { color: #8a6a1f; margin: 0 0 14px; font-weight: 600; }

.feedback-box { text-align: right; margin-top: 20px; }
.feedback-box label { font-weight: 600; display: block; margin-bottom: 6px; }
.feedback-hint { color: var(--muted); font-size: 0.85rem; line-height: 1.6; margin: 0 0 10px; }
.feedback-box textarea {
  width: 100%; min-height: 90px; margin-bottom: 12px;
  border: 1px solid var(--border); border-radius: 8px; padding: 8px;
  font-family: inherit; font-size: 0.9rem; resize: vertical;
}
.feedback-error { color: #b13c3c; font-size: 0.85rem; margin: 0 0 10px; }
/* Pinned just under the sticky topbar (where the undo button lives), so it's
   seen wherever the expert has scrolled to. */
.undo-error {
  position: fixed; top: 56px; left: 50%; transform: translateX(-50%); z-index: 20;
  margin: 0; padding: 8px 16px; text-align: center;
  background: #fff4f4; border: 1px solid #e9b8b8; border-radius: 10px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
}
.feedback-box .actions { justify-content: space-between; }

.final-thanks p { color: var(--accent); font-weight: 600; }
.vs {
  align-self: center;
  color: var(--muted);
  font-weight: 700;
}

.combo-card {
  background: var(--card-bg);
  border: 2px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  transition: border-color .15s;
}
.combo-card.chosen { border-color: var(--accent); }

.combo-card .parcels-label { font-size: 0.8rem; color: var(--muted); margin-bottom: 6px; }
.combo-card .map-wrap {
  background: #fbfbf9;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 12px;
  height: 260px;
}
/* MapLibre requires its container to have explicit, non-zero dimensions. */
.map3d { width: 100%; height: 100%; }

.building-label {
  direction: rtl;
  text-align: center;
  font-size: 0.58rem;
  font-weight: 600;
  line-height: 1.15;
  padding: 1px 4px;
  border-radius: 4px;
  white-space: pre; /* units and floors on two short lines - narrower than one long line */
  pointer-events: none; /* never intercepts clicks meant for the map/choose button */
}
.building-label--own { background: rgba(47, 111, 79, 0.82); color: #fff; }
.building-label--context { background: rgba(255, 255, 255, 0.75); color: #4f534f; }

.details-list { list-style: none; margin: 0 0 14px; padding: 0; }
.details-list li {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 5px 0;
  border-bottom: 1px dashed var(--border);
  font-size: 0.9rem;
}
.details-list li:last-child { border-bottom: none; }
.details-list .lbl { display: flex; gap: 6px; align-items: center; color: var(--ink); }
.details-list .val { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* One box per topic (existing state / potential / proximity), each styled like the map box. */
.detail-box {
  background: #fbfbf9;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 12px;
}
.detail-box h4 { margin: 0 0 6px; font-size: 0.85rem; color: var(--accent); }
.detail-box .note { margin: 0 0 4px; font-size: 0.8rem; color: var(--muted); }
.detail-box dl { margin: 0; }
.detail-box dl > div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 0;
  border-bottom: 1px dashed var(--border);
  font-size: 0.9rem;
}
.detail-box dl > div:last-child { border-bottom: none; }
.detail-box dt { color: var(--muted); white-space: nowrap; }
.detail-box dd { margin: 0; color: var(--ink); font-variant-numeric: tabular-nums; text-align: left; }
@media (max-width: 520px) {
  .detail-box dl > div { flex-direction: column; gap: 0; }
  .detail-box dd { text-align: right; }
}

.score-bar-row .val { min-width: 90px; text-align: left; }
.score-bar {
  position: relative;
  width: 100%;
  height: 6px;
  background: var(--border);
  border-radius: 4px;
  margin-top: 4px;
  overflow: hidden;
}
.score-bar > span { position: absolute; inset: 0; background: var(--accent); border-radius: 4px; }
.abstract-line { width: 100%; }

.choose-btn {
  width: 100%;
  padding: 10px;
  border-radius: 10px;
  border: none;
  background: var(--ink);
  color: #fff;
  font-size: 0.95rem;
  cursor: pointer;
}
.choose-btn:hover:not(:disabled) { background: var(--accent); }
.choose-btn:disabled { opacity: .5; cursor: not-allowed; }
/* The saved choice stays at full strength while its pair is locked. */
.combo-card.chosen .choose-btn:disabled, .tie-row #tie-btn.chosen:disabled { opacity: 1; }
.combo-card.chosen .choose-btn { background: var(--accent); }

.reason-panel {
  max-width: 700px;
  margin: 28px auto 0;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
}
.reason-panel h3 { margin: 0 0 6px; font-size: 1rem; }
.reason-panel .reason-hint { margin: 0 0 12px; color: var(--muted); font-size: 0.85rem; line-height: 1.5; }
.reason-panel #chosen-label { color: var(--accent); }
.reasons { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.reason-opt {
  display: flex; align-items: center; gap: 8px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 0.88rem;
  cursor: pointer;
}
.reason-opt:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.reason-opt[hidden] { display: none; }
.reason-opt .reason-rank {
  margin-inline-start: auto;
  flex-shrink: 0;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}
.reason-opt .reason-rank:empty { display: none; }
.reason-opt .reason-rank.primary {
  background: var(--accent); color: #fff; padding: 2px 8px; border-radius: 999px;
}
.reason-opt .reason-rank.secondary {
  color: var(--accent); border: 1px solid var(--accent); padding: 1px 7px; border-radius: 999px;
}
#reason-other-text {
  width: 100%; min-height: 60px; margin-bottom: 12px;
  border: 1px solid var(--border); border-radius: 8px; padding: 8px;
  font-family: inherit; font-size: 0.88rem; resize: vertical;
}
.reason-panel .actions { justify-content: space-between; }

@media (max-width: 760px) {
  .pair { grid-template-columns: 1fr; }
  .vs { display: none; }
  .reasons { grid-template-columns: 1fr; }
}

/* ---------- city map after an answer ---------- */
.map-check {
  max-width: 900px;
  margin: 28px auto 0;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
}
.map-check h3 { margin: 0 0 10px; font-size: 1rem; }
.map-check h4 { margin: 16px 0 8px; font-size: 0.95rem; }
.map-legend { list-style: none; margin: 0 0 10px; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 0.88rem; }
.map-legend li { display: flex; align-items: center; gap: 6px; }
.map-legend .swatch { width: 14px; height: 14px; border-radius: 3px; flex-shrink: 0; }
.map-legend a { color: var(--muted); font-size: 0.8rem; }
.city-map-wrap { position: relative; height: 460px; border-radius: 10px; overflow: hidden; border: 1px solid var(--border); }
#city-map { width: 100%; height: 100%; }
.basemap-toggle { position: absolute; top: 10px; left: 10px; /* the zoom buttons sit top-right */ display: flex; z-index: 2; }
.basemap-toggle button {
  padding: 5px 12px; border: 1px solid var(--border); background: #fff; cursor: pointer; font-size: 0.82rem;
}
.basemap-toggle button:first-child { border-radius: 0 8px 8px 0; }
.basemap-toggle button:last-child { border-radius: 8px 0 0 8px; }
.basemap-toggle button.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.city-marker {
  padding: 3px 9px; border-radius: 999px; color: #fff; font-size: 0.8rem; font-weight: 600;
  white-space: nowrap; box-shadow: 0 1px 4px rgba(0, 0, 0, .35); pointer-events: none;
}
.map-distance { color: var(--muted); font-size: 0.85rem; margin: 8px 0 0; }
.map-options { display: grid; gap: 8px; margin-bottom: 12px; }
.map-opt {
  display: flex; align-items: center; gap: 8px;
  border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px;
  font-size: 0.88rem; cursor: pointer;
}
.map-opt:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
#map-reason-text {
  width: 100%; min-height: 70px; margin-bottom: 12px;
  border: 1px solid var(--border); border-radius: 8px; padding: 8px;
  font-family: inherit; font-size: 0.88rem; resize: vertical;
}
.map-check .actions { justify-content: flex-end; }

@media (max-width: 760px) {
  .city-map-wrap { height: 340px; }
}

/* "How to read the map" page shown before the survey */
.example-page { max-width: 760px; }
.example-intro { text-align: center; color: var(--muted); }
.example-card { margin: 0 auto 16px; }
.example-map { height: 380px; margin-bottom: 0; }
.example-legend { flex-direction: column; gap: 8px; margin: 0 0 20px; }
.example-legend .swatch { display: inline-block; width: 18px; height: 12px; border-radius: 3px; vertical-align: middle; margin-inline-end: 6px; }
.example-legend .swatch-line { background: transparent; border-top: 3px solid #d62828; height: 0; }
.example-legend .swatch-own { background: #2f6f4f; }
.example-legend .swatch-context { background: #9c968a; }
.example-legend .swatch-park { background: #a9cf9d; }
.example-legend .swatch-road { background: #bdb6a8; }
.example-tips { background: var(--card-bg); border: 1px solid var(--border); border-radius: 12px; padding: 14px 18px; }
.example-tips h2 { margin: 0 0 8px; font-size: 1.05rem; color: var(--accent); }
.example-tips ul { margin: 0; padding-inline-start: 20px; color: var(--muted); line-height: 1.7; }
.example-actions { text-align: center; margin-top: 20px; }
@media (max-width: 520px) { .example-map { height: 300px; } }

/* Consent text: unresolved placeholders must be impossible to miss (scripts/check_release.py fails while any remain). */
.consent-text h3 { margin: 14px 0 4px; font-size: 0.95rem; }
.consent-text { max-height: 60vh; overflow-y: auto; }
.todo { background: #fff3a3; color: #7a4b00; padding: 0 4px; border-radius: 3px; font-weight: 600; }
