:root {
  --bg: #f5f2ea;
  --surface: #fffdf7;
  --ink: #162d2b;
  --muted: #60706d;
  --line: #d6d9cf;
  --accent: #ef6f4d;
  --accent-dark: #a23c25;
  --green: #1f655b;
  --shadow: 0 20px 60px rgba(25, 49, 45, 0.1);
  --radius: 18px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 92% 5%, rgba(239, 111, 77, 0.12), transparent 25rem),
    var(--bg);
  font-family: "DM Sans", system-ui, sans-serif;
  line-height: 1.55;
}

a { color: inherit; }

button, input { font: inherit; }

.skip-link {
  position: fixed;
  z-index: 10000;
  left: 1rem;
  top: 1rem;
  transform: translateY(-180%);
  padding: .7rem 1rem;
  color: white;
  background: var(--ink);
}

.skip-link:focus { transform: none; }

.site-header,
main,
footer {
  width: min(1180px, calc(100% - 2rem));
  margin-inline: auto;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.3rem 0;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: .65rem;
  font-weight: 700;
  text-decoration: none;
}

.brand__mark {
  display: grid;
  width: 2.1rem;
  height: 2.1rem;
  place-items: center;
  color: white;
  background: var(--green);
  border-radius: 50%;
  font-family: "DM Serif Display", serif;
  font-size: 1.25rem;
}

.portfolio-link { color: var(--muted); font-size: .9rem; text-decoration-thickness: 1px; }

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(300px, .9fr);
  gap: 2.5rem 4rem;
  align-items: end;
  padding: 5.5rem 0 4rem;
}

.hero__copy { max-width: 760px; }

.eyebrow {
  margin: 0 0 .55rem;
  color: var(--accent-dark);
  font-size: .76rem;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
}

h1, h2, p { margin-top: 0; }

h1,
.results__head h2,
.panel h2,
.caveat h2 {
  font-family: "DM Serif Display", Georgia, serif;
  font-weight: 400;
  line-height: 1.03;
}

h1 { max-width: 13ch; margin-bottom: 1.4rem; font-size: clamp(3rem, 7vw, 6.3rem); letter-spacing: -.045em; }
.hero__intro { max-width: 66ch; margin-bottom: 0; color: var(--muted); font-size: 1.08rem; }

.search {
  padding: 1.25rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.search > label { display: block; margin-bottom: .55rem; font-size: .82rem; font-weight: 700; }
.search__row { display: flex; gap: .55rem; }
.search input { min-width: 0; flex: 1; padding: .9rem 1rem; color: var(--ink); background: white; border: 1px solid #aeb8b3; border-radius: 9px; }
.search button[type="submit"] { padding: .9rem 1.05rem; color: white; background: var(--green); border: 0; border-radius: 9px; font-weight: 700; cursor: pointer; }
.search button[type="submit"]:hover { background: #174e47; }
.search__hint { margin: .8rem 0 0; color: var(--muted); font-size: .8rem; }
.text-button { padding: 0; color: var(--green); background: none; border: 0; text-decoration: underline; cursor: pointer; }

.scope-note {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 12rem 1fr;
  gap: 1rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: .9rem;
}

.scope-note strong { color: var(--ink); }
.scope-note p { margin: 0; }

.results { padding-bottom: 5rem; }
.results__head { display: flex; justify-content: space-between; gap: 2rem; align-items: end; margin-bottom: 1.1rem; }
.results__head h2 { margin: 0; font-size: clamp(2rem, 4vw, 3.4rem); }
.status { max-width: 32rem; margin: 0; color: var(--muted); text-align: right; }
.status[data-state="error"] { color: #9f2f25; font-weight: 600; }
.status[data-state="warning"] { color: #8a4b18; font-weight: 650; }

.map-shell {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

#map { width: 100%; height: min(62vh, 640px); min-height: 430px; background: #dde4df; }
.leaflet-container img.leaflet-tile { max-width: none !important; }
.leaflet-overlay-pane svg { filter: saturate(1.12); }

.legend {
  position: absolute;
  z-index: 500;
  right: 1rem;
  bottom: 1rem;
  display: flex;
  align-items: center;
  gap: .55rem;
  padding: .65rem .8rem;
  color: var(--ink);
  background: rgba(255, 253, 247, .92);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: .7rem;
  backdrop-filter: blur(10px);
}

.legend__bar { width: 88px; height: 8px; background: linear-gradient(90deg, #4cc9a7, #f1d44d, #ef6f4d, #9d1d3f); border-radius: 99px; }

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  margin: 1rem 0 2.8rem;
  overflow: hidden;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.stat-card { min-height: 8.3rem; padding: 1.15rem; background: var(--surface); }
.stat-card p { margin-bottom: 1.7rem; color: var(--muted); font-size: .78rem; }
.stat-card strong { display: block; font-family: "DM Serif Display", serif; font-size: clamp(1.35rem, 2.5vw, 2.3rem); font-weight: 400; line-height: 1; }

.analysis-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.1rem; }
.panel { min-height: 28rem; padding: 1.45rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.panel__head { padding-bottom: 1rem; border-bottom: 1px solid var(--line); }
.panel h2 { margin: 0; font-size: 2.1rem; }

.bars { padding-top: 1rem; }
.bar { display: grid; grid-template-columns: minmax(7rem, 1fr) 3fr 2.5rem; gap: .8rem; align-items: center; padding: .55rem 0; }
.bar__label { overflow: hidden; font-size: .85rem; text-overflow: ellipsis; white-space: nowrap; }
.bar__track { height: .65rem; overflow: hidden; background: #e8e7de; border-radius: 99px; }
.bar__fill { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.bar__count { color: var(--muted); font-size: .78rem; text-align: right; }

.area-list { margin: 0; padding: .5rem 0 0; list-style: none; counter-reset: area; }
.area-list li:not(.empty-state) { counter-increment: area; display: grid; grid-template-columns: 2rem 1fr auto; gap: .8rem; align-items: start; padding: .85rem 0; border-bottom: 1px solid var(--line); }
.area-list li:not(.empty-state)::before { content: counter(area, decimal-leading-zero); color: var(--accent-dark); font: 700 .7rem "DM Sans", sans-serif; }
.area-name { font-weight: 600; }
.area-note { display: block; margin-top: .18rem; color: var(--muted); font-size: .75rem; font-weight: 400; }
.area-count { color: var(--muted); font-size: .78rem; white-space: nowrap; }
.empty-state { padding: 2rem 0; color: var(--muted); }

.caveat { display: grid; grid-template-columns: 15rem 1fr; gap: 2rem; margin-top: 1.1rem; padding: 1.6rem; color: #f2eee5; background: var(--ink); border-radius: var(--radius); }
.caveat h2 { margin: 0; font-size: 1.7rem; }
.caveat p { margin: 0; color: #cbd3d0; }

footer { display: flex; justify-content: space-between; gap: 2rem; padding: 2rem 0 3rem; color: var(--muted); border-top: 1px solid var(--line); font-size: .78rem; }
footer p { margin: 0; }

button:focus-visible, input:focus-visible, a:focus-visible { outline: 3px solid #f0ad37; outline-offset: 3px; }

@media (max-width: 800px) {
  .hero { grid-template-columns: 1fr; padding-top: 3rem; }
  .scope-note, .caveat { grid-template-columns: 1fr; }
  .results__head { align-items: start; flex-direction: column; }
  .status { text-align: left; }
  .stats { grid-template-columns: 1fr 1fr; }
  .analysis-grid { grid-template-columns: 1fr; }
  footer { flex-direction: column; }
}

@media (max-width: 520px) {
  h1 { font-size: 3.35rem; }
  .search__row { flex-direction: column; }
  .stats { grid-template-columns: 1fr; }
  #map { min-height: 400px; }
  .legend { left: .75rem; right: .75rem; justify-content: center; }
  .portfolio-link { font-size: 0; }
  .portfolio-link span { font-size: 1rem; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
