:root {
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --brand: #2563eb;
  --brand-dark: #1d4ed8;
  --recent: #10b981;
  --aged: #f59e0b;
  --panel-bg: #ffffff;
  --shadow: 0 10px 40px rgba(15, 23, 42, 0.18);
  /* Height the fixed footer reserves; overlays and the map credits clear it. */
  --footer-h: 2.25rem;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
}

/* ---- Stage: full-viewport map with overlays ---- */
.stage {
  position: fixed;
  inset: 0;
  overflow: hidden;
}

.stage__map {
  position: absolute;
  inset: 0;
  z-index: 0;
  filter: saturate(0.9);
}

/* ---- Wizard: one card, centered, one question per step ---- */
.wizard {
  position: absolute;
  z-index: 500;
  left: 50%;
  top: 42%;
  transform: translate(-50%, -50%);
  width: min(500px, 92vw);
  background: var(--panel-bg);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 2rem 1.75rem;
  text-align: center;
  transition: opacity 0.45s ease, transform 0.45s ease;
}
/* Once an address is chosen, the wizard steps aside for the valuation panel. */
.stage.searched .wizard {
  opacity: 0;
  transform: translate(-50%, -60%) scale(0.97);
  pointer-events: none;
}

/* Lead-capture failure. Lives outside .wizard so the .searched fade doesn't hide
   it, and above the valuation panel so it is visible alongside the estimate. */
.wizard__notice {
  position: absolute;
  z-index: 600;
  left: 50%;
  top: 1rem;
  transform: translateX(-50%);
  width: min(500px, 92vw);
  margin: 0;
  padding: 0.75rem 1rem;
  background: var(--panel-bg);
  border: 1px solid var(--line);
  border-left: 3px solid var(--muted);
  border-radius: 10px;
  box-shadow: var(--shadow);
  text-align: center;
  font-size: 0.9rem;
}

/* Only the active step is shown; the rest are collapsed out of flow. */
.wizard__step { display: none; }
.wizard__step--active { display: block; animation: wizard-in 0.35s ease; }

@keyframes wizard-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.wizard__progress {
  margin: 0 0 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.7rem;
  color: var(--muted);
}

.wizard__title {
  font-size: clamp(1.35rem, 3.5vw, 1.9rem);
  line-height: 1.15;
  letter-spacing: -0.02em;
  margin: 0 0 0.6rem;
}

.wizard__note {
  margin: 0 0 1.25rem;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.5;
}

.wizard__form { display: block; }
.wizard__search { position: relative; }

.wizard__input {
  width: 100%;
  padding: 0.9rem 1.1rem;
  font-size: 1.1rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  outline: none;
}
.wizard__input:focus { border-color: var(--brand); box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.15); }

.wizard__error { color: #b91c1c; font-size: 0.85rem; margin: 0.5rem 0 0; text-align: left; }

/* Consent checkbox on the email step. Left-aligned against the centered card so
   the sentence reads as a statement the person is agreeing to. */
.wizard__check {
  display: flex; gap: 0.6rem; align-items: flex-start;
  margin: 0.85rem 0 0; text-align: left; cursor: pointer;
  font-size: 0.85rem; line-height: 1.45; color: var(--ink);
}
.wizard__check input { margin-top: 0.2rem; flex: 0 0 auto; width: 1rem; height: 1rem; accent-color: var(--brand); }

.wizard__actions {
  display: flex;
  justify-content: center;
  gap: 0.6rem;
  margin-top: 1.35rem;
}

.wizard__btn {
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 600;
  border-radius: 10px;
  padding: 0.7rem 1.3rem;
  border: 1px solid transparent;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.wizard__btn--primary { color: #fff; background: var(--brand); }
.wizard__btn--primary:hover { background: var(--brand-dark); }
.wizard__btn--ghost { color: var(--muted); background: transparent; border-color: var(--line); }
.wizard__btn--ghost:hover { color: var(--ink); border-color: var(--muted); }
/* Locked until an address is picked AND ownership is attested. Still clickable,
   so the click can say what is missing. */
.wizard__btn.is-locked { opacity: 0.45; }
.wizard__btn--primary.is-locked:hover { background: var(--brand); }

/* ---- Suggestions dropdown ---- */
.suggestions {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  margin: 0;
  padding: 0.35rem;
  list-style: none;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  text-align: left;
  max-height: 320px;
  overflow-y: auto;
  z-index: 600;
}
.suggestion {
  padding: 0.6rem 0.75rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.95rem;
}
.suggestion:hover,
.suggestion--active { background: #f1f5f9; }
.suggestion--empty { color: var(--muted); cursor: default; }
.suggestion--empty:hover { background: transparent; }

/* ---- Results panel: slides in from the top-left corner ---- */
.panel {
  position: absolute;
  z-index: 400;
  left: 1rem;
  top: 1rem;
  transform: translateX(calc(-100% - 1.5rem));
  width: min(460px, calc(100vw - 2rem));
  max-height: calc(100vh - 2rem - var(--footer-h));
  max-height: calc(100dvh - 2rem - var(--footer-h));
  overflow-y: auto;
  overflow-x: hidden; /* the card itself never scrolls sideways */
  overscroll-behavior: contain; /* don't chain scroll into the map */
  background: var(--panel-bg);
  border-radius: 18px;
  box-shadow: var(--shadow);
  transition: transform 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}
.stage.searched .panel:not(:empty) {
  transform: translateX(0);
  padding-bottom: 1rem;
}

.result { padding: 1.5rem 1.5rem 1rem; }

.result__nodata { text-align: center; padding: 1.5rem 0; }
.result__nodata h2 { margin: 0 0 0.5rem; font-size: 1.3rem; }
.result__nodata p { color: var(--muted); margin: 0; }

.result__header { text-align: center; padding-bottom: 1rem; border-bottom: 1px solid var(--line); }
.result__label { text-transform: uppercase; letter-spacing: 0.08em; font-size: 0.72rem; color: var(--muted); }
.result__estimate { font-size: clamp(2rem, 7vw, 2.6rem); font-weight: 700; letter-spacing: -0.02em; line-height: 1.1; }
.result__range { color: var(--muted); font-size: 1rem; margin-top: 0.15rem; }
.result__address { margin-top: 0.5rem; font-size: 0.95rem; color: var(--ink); overflow-wrap: anywhere; }
.result__factor {
  margin: 0.85rem auto 0; max-width: 34rem;
  font-size: 0.9rem; line-height: 1.5; color: var(--ink);
  border-left: 3px solid var(--brand); padding: 0.4rem 0 0.4rem 0.75rem;
  text-align: left;
}
.result__factor--muted { color: var(--muted); border-left-color: var(--muted); }

.facts {
  display: flex; flex-wrap: wrap; gap: 0.5rem 1.5rem;
  justify-content: center;
  list-style: none; margin: 1rem 0; padding: 0;
}
.facts li { display: flex; flex-direction: column; align-items: center; font-size: 0.75rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.facts li span { font-size: 1.1rem; font-weight: 600; color: var(--ink); text-transform: none; letter-spacing: 0; }

.result__comps h3 { font-size: 1rem; margin: 1rem 0 0.25rem; }
.result__hint { color: var(--muted); font-size: 0.82rem; margin: 0 0 0.75rem; }

/* Lead capture (opt-in for an agent valuation) */
.lead {
  display: block; margin: 1.25rem auto; max-width: 34rem;
  background: #f8fafc; border: 1px solid var(--line); border-radius: 12px; padding: 1rem 1.15rem;
}
.lead__title { font-size: 1rem; margin: 0 0 0.75rem; }
.lead__form { display: flex; flex-direction: column; gap: 0.7rem; text-align: left; }
.lead__field { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.85rem; color: var(--muted); }
.lead__field input {
  font-size: 1rem; padding: 0.55rem 0.65rem; border: 1px solid var(--line);
  border-radius: 8px; background: var(--panel-bg); color: var(--ink);
}
.lead__check { display: flex; gap: 0.55rem; align-items: flex-start; font-size: 0.82rem; line-height: 1.45; color: var(--ink); }
.lead__check input { margin-top: 0.2rem; flex: 0 0 auto; }
.lead__check a { color: var(--brand); }
.lead__submit {
  margin-top: 0.25rem; align-self: flex-start; cursor: pointer;
  font-size: 0.95rem; font-weight: 600; color: #fff; background: var(--brand);
  border: 0; border-radius: 8px; padding: 0.6rem 1rem;
}
.lead__submit:hover { background: var(--brand-dark); }
.lead__error { color: #b91c1c; font-size: 0.85rem; margin: 0 0 0.25rem; }
.lead__thanks h3 { margin: 0 0 0.35rem; font-size: 1.05rem; }
.lead__thanks p { margin: 0; color: var(--muted); font-size: 0.9rem; }

/* Simple static / admin pages */
.page { max-width: 42rem; margin: 3rem auto; padding: 0 1.25rem calc(1.25rem + var(--footer-h)); color: var(--ink); line-height: 1.6; }
.page h1 { margin-bottom: 0.5rem; }
.page h2 { margin: 1.5rem 0 0.4rem; font-size: 1.05rem; }
.page__meta { color: var(--muted); font-size: 0.85rem; }
.admin { max-width: 60rem; margin: 2.5rem auto; padding: 0 1.25rem calc(1.25rem + var(--footer-h)); }
.admin__count { color: var(--muted); font-weight: 400; }
.admin__table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.admin__table th, .admin__table td { text-align: left; padding: 0.4rem 0.6rem; border-bottom: 1px solid var(--line); }
.admin__table tr.is-revoked { color: var(--muted); text-decoration: line-through; }

.comps { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.comps th { text-align: left; color: var(--muted); font-weight: 600; padding: 0.4rem 0.5rem; border-bottom: 1px solid var(--line); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.03em; white-space: nowrap; }
.comps td { padding: 0.5rem 0.5rem; border-bottom: 1px solid #f1f5f9; vertical-align: top; }
/* Only the address column may break mid-word; that keeps the table inside the
   card on narrow screens without ever splitting a number or a date. */
.comps td:first-child { overflow-wrap: anywhere; }
.comps td:nth-child(2), .comps td:nth-child(3) { white-space: nowrap; }
.comps .num { text-align: right; white-space: nowrap; }
.comps__row--aged { background: rgba(245, 158, 11, 0.06); }
/* Sales past the leading sample: rendered, revealed by the "See all" toggle. */
.comps__row--extra { display: none; }
.result__comps.is-expanded .comps__row--extra { display: table-row; }
/* Sample count on the left, the expand link pushed to the right edge. */
.result__hint--split {
  display: flex; flex-wrap: wrap; align-items: baseline;
  justify-content: space-between; gap: 0.15rem 0.75rem;
}
.comps__more {
  margin-left: auto;
  background: none; border: 0; padding: 0; cursor: pointer;
  font: inherit; color: var(--brand); text-decoration: underline;
  white-space: nowrap;
}
.comps__more:hover { color: var(--brand-dark); }

.badge {
  display: inline-block;
  margin-left: 0.35rem;
  padding: 0.05rem 0.4rem;
  border-radius: 999px;
  background: rgba(245, 158, 11, 0.15);
  color: #b45309;
  font-size: 0.68rem;
  white-space: nowrap;
}

.disclaimer {
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.4;
  margin: 1.25rem 0 0;
  padding-top: 0.75rem;
  border-top: 1px solid var(--line);
}

/* Keep Leaflet under our overlays */
.leaflet-container { z-index: 0; }
/* Lift the map credits (an OSM licence requirement) clear of the footer. */
.leaflet-bottom { bottom: var(--footer-h); }

/* ---- Site footer: fixed on every page, above the map stage ---- */
.site-footer {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 700;
  min-height: var(--footer-h);
  padding: 0.55rem 1rem;
  text-align: center;
  font-size: 0.75rem;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.93);
  border-top: 1px solid var(--line);
}
.site-footer a { color: var(--muted); }
.site-footer a:hover { color: var(--brand); }

@media (max-width: 560px) {
  .panel { left: 0.75rem; top: 0.75rem; width: calc(100vw - 1.5rem); border-radius: 14px; }
  .wizard { width: 94vw; padding: 1.75rem 1.35rem; }
}
