@import url("https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,600;9..144,700&family=Public+Sans:wght@400;500;600;700&display=swap");

:root {
  --bg: #eceff2;
  --bg-deep: #d9dde2;
  --panel: rgba(255, 255, 255, 0.92);
  --panel-strong: rgba(255, 255, 255, 0.97);
  --ink: #1f2d25;
  --muted: #5e695f;
  --border: rgba(53, 70, 52, 0.14);
  --shadow: 0 18px 40px rgba(40, 48, 58, 0.12);
  --federal: #4f6e3a;
  --state: #3d708f;
  --private: #b68044;
  --patch: #e5c567;
  --acquire: #2f8f5b;
  --release: #bb513a;
  --accent: #6a5234;
}

* {
  box-sizing: border-box;
}

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

body {
  font-family: "Public Sans", sans-serif;
  color: var(--ink);
  background: var(--bg);
}

.page-shell {
  width: min(1500px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 32px;
}

.hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 20px;
  padding: 22px 24px;
  border: 1px solid var(--border);
  border-radius: 28px;
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.96), rgba(250, 251, 252, 0.94));
  box-shadow: var(--shadow);
}

.hero-copy {
  flex: 1 1 480px;
}

.hero-brandbar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  flex-wrap: wrap;
  flex: 0 0 auto;
  gap: 14px 18px;
}

.hero-logo {
  display: block;
  max-height: 56px;
  width: auto;
  max-width: min(220px, 100%);
  object-fit: contain;
}

.eyebrow {
  margin: 0 0 8px;
  font-size: 1.25rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}

h1,
h2,
h3 {
  margin: 0;
  font-family: "Fraunces", serif;
  line-height: 1.05;
}

h1 {
  font-size: clamp(2.4rem, 5vw, 4.6rem);
  letter-spacing: -0.04em;
}

.lede {
  max-width: 62ch;
  margin: 14px 0 0;
  font-size: 1rem;
  line-height: 1.6;
  color: #354238;
}

.hero-meta {
  display: grid;
  gap: 14px;
  align-content: start;
}

.metric-card,
.panel,
.stats-card {
  border: 1px solid var(--border);
  background: var(--panel);
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow);
}

.metric-card {
  border-radius: 18px;
  padding: 16px 18px;
}

.metric-label {
  display: block;
  margin-bottom: 6px;
}

.metric-label,
.detail-grid span,
.proposal-meta span,
.proposal-primary-label,
.supplemental-label {
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin: 18px 0;
}

.stats-card {
  border-radius: 18px;
  padding: 18px;
}

.stats-card strong {
  display: block;
  margin-top: 6px;
  font-size: 1.8rem;
  font-family: "Fraunces", serif;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(320px, 390px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.explainer-panel {
  grid-column: 1 / -1;
  margin: 18px 0;
}

.sidebar {
  display: grid;
  gap: 16px;
  align-content: start;
}

.map-stack {
  display: grid;
  gap: 16px;
  align-content: start;
}

.panel {
  border-radius: 24px;
  padding: 18px;
}

.panel p {
  margin: 10px 0 0;
  line-height: 1.55;
  color: #39463c;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.explainer-heading {
  align-items: flex-start;
  flex-wrap: wrap;
}

.controls {
  display: grid;
  gap: 14px;
}

.control-group {
  display: grid;
  gap: 6px;
}

.filter-toggles {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  margin: 0;
}

.filter-toggles legend {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0 4px;
}

.filter-toggles label {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 0.85rem;
  cursor: pointer;
  padding: 2px 0;
}

label {
  font-size: 0.9rem;
  font-weight: 600;
}

input,
select,
button,
output {
  font: inherit;
}

input[type="search"],
select {
  width: 100%;
  padding: 12px 13px;
  border: 1px solid rgba(53, 70, 52, 0.16);
  border-radius: 14px;
  background: rgba(244, 246, 248, 0.85);
  color: var(--ink);
}

input[type="range"] {
  width: 100%;
  accent-color: var(--federal);
}

output {
  color: var(--muted);
  font-size: 0.9rem;
}

.button-row {
  display: flex;
  gap: 10px;
}

button {
  cursor: pointer;
  border: 0;
  border-radius: 14px;
  padding: 12px 14px;
  background: #4b6039;
  color: #fff;
  font-weight: 600;
  transition: transform 120ms ease;
}

button:hover {
  transform: translateY(-1px);
}

button:last-child {
  background: #875a34;
}

.wiki-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 10px 14px;
  border-radius: 14px;
  background: #4b6039;
  color: #fff;
  font-weight: 600;
  text-decoration: none;
  transition: transform 120ms ease;
}

.wiki-button:hover {
  transform: translateY(-1px);
}

.status-chip {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(94, 105, 95, 0.12);
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
}

.detail-body {
  display: grid;
  gap: 10px;
  color: #324037;
  line-height: 1.55;
  overflow: auto;
  padding-right: 4px;
}

.detail-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr);
  gap: 16px;
  align-items: start;
}

.detail-panel,
.ranking-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  align-self: start;
  max-height: 350px;
  overflow: hidden;
}

.ranking-panel .detail-body p {
  margin: 0 0 10px;
}

.ranking-panel .detail-body p:last-child {
  margin-bottom: 0;
}

.list-panel {
  grid-column: 1 / -1;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.detail-grid div,
.detail-note {
  padding: 12px;
  border-radius: 16px;
  background: rgba(244, 246, 248, 0.85);
  border: 1px solid rgba(53, 70, 52, 0.1);
}

.detail-grid span,
.proposal-meta span {
  display: block;
  margin-bottom: 4px;
}

.proposal-list {
  display: grid;
  gap: 10px;
  max-height: 720px;
  overflow: auto;
  padding-right: 4px;
}

.proposal-item {
  border: 1px solid rgba(53, 70, 52, 0.1);
  border-radius: 18px;
  background: rgba(244, 246, 248, 0.85);
  padding: 14px;
  cursor: pointer;
  transition: transform 120ms ease, border-color 120ms ease, box-shadow 120ms ease;
}

.proposal-item:hover,
.proposal-item.is-active {
  transform: translateY(-1px);
  border-color: rgba(95, 122, 70, 0.38);
  box-shadow: 0 12px 28px rgba(40, 48, 58, 0.1);
}

.proposal-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.proposal-title strong {
  font-size: 1rem;
}

.proposal-rank {
  font-family: "Fraunces", serif;
  font-size: 1.15rem;
}

.proposal-primary {
  margin: 0 0 8px;
  font-size: 0.96rem;
  line-height: 1.5;
}

.proposal-primary-label,
.supplemental-label {
  margin-right: 0.5em;
}

.proposal-primary-value {
  font-weight: 700;
  color: var(--ink);
}

.proposal-supplemental {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.96rem;
  line-height: 1.5;
}

.proposal-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 10px;
}

.proposal-inline {
  margin: 6px 0 0;
  color: #445046;
  font-size: 0.94rem;
  line-height: 1.5;
}

.proposal-badge-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.badge.same {
  background: rgba(61, 112, 143, 0.12);
  color: #244a61;
}

.badge.cross {
  background: rgba(191, 81, 58, 0.12);
  color: #823424;
}

.badge.warn {
  background: rgba(182, 128, 68, 0.16);
  color: #7a5124;
}

.badge.bridge {
  background: #3a6b8a;
  color: #ffffff;
}

.badge.landowner {
  background: #4a6b3a;
  color: #ffffff;
}

.badge.oil {
  background: #8a5a1a;
  color: #ffffff;
}

.map-panel {
  position: relative;
  align-self: start;
  height: clamp(560px, 72vh, 760px);
  border: 1px solid var(--border);
  border-radius: 28px;
  overflow: hidden;
  background: var(--panel-strong);
  box-shadow: var(--shadow);
}

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

.map-legend {
  position: absolute;
  right: 18px;
  bottom: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 220px;
  padding: 12px 14px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(53, 70, 52, 0.14);
  box-shadow: var(--shadow);
  z-index: 500;
}

.legend-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.legend-title {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #5c6357;
}

.map-legend span {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.88rem;
}

.is-hidden {
  display: none;
}

.legend-swatch {
  width: 14px;
  height: 14px;
  border-radius: 4px;
  display: inline-block;
}

.legend-swatch.patch {
  background: var(--patch);
}

.legend-swatch.acquire {
  background: var(--acquire);
}

.legend-swatch.release {
  background: var(--release);
}

.legend-swatch.value-1 {
  background: #440154;
}

.legend-swatch.value-2 {
  background: #3b528b;
}

.legend-swatch.value-3 {
  background: #21918c;
}

.legend-swatch.value-4 {
  background: #5ec962;
}

.legend-swatch.value-5 {
  background: #fde725;
}

.leaflet-popup-content-wrapper,
.leaflet-popup-tip {
  background: rgba(255, 255, 255, 0.98);
}

.popup h3 {
  margin-bottom: 6px;
  font-size: 1rem;
}

.popup p {
  margin: 6px 0;
  line-height: 1.45;
}

.empty-state {
  padding: 14px;
  border-radius: 16px;
  background: rgba(244, 246, 248, 0.85);
  color: #536055;
}

@media (max-width: 1100px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .hero {
    flex-direction: column;
    align-items: flex-start;
  }

  .hero-brandbar {
    justify-content: flex-start;
  }

  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .map-panel,
  #map {
    height: 620px;
  }
}

@media (max-width: 720px) {
  .page-shell {
    width: min(100% - 20px, 100%);
    padding-top: 12px;
  }

  .hero,
  .panel {
    padding: 16px;
    border-radius: 20px;
  }

  .panel-heading {
    align-items: flex-start;
  }

  .wiki-button {
    width: 100%;
  }

  .hero-brandbar {
    gap: 10px 14px;
  }

  .hero-logo {
    max-height: 46px;
    max-width: min(180px, 100%);
  }

  .stats {
    grid-template-columns: 1fr;
  }

  .detail-grid,
  .proposal-meta,
  .detail-row {
    grid-template-columns: 1fr;
  }

  .button-row {
    flex-direction: column;
  }

  .detail-panel,
  .ranking-panel {
    max-height: none;
  }

  .map-panel,
  #map {
    height: 520px;
  }
}
