:root {
  --ink: #17211b;
  --muted: #5b675f;
  --paper: #f7f5ee;
  --line: #d9d3c4;
  --green: #2e6f59;
  --blue: #245f85;
  --red: #b55242;
  --yellow: #d6a53a;
}

* {
  box-sizing: border-box;
}

/* Minimal Leaflet layout fallback. Without these rules tiles stack like normal images. */
.leaflet-container {
  overflow: hidden;
  position: relative;
  outline-offset: 1px;
}

.leaflet-pane,
.leaflet-tile,
.leaflet-marker-icon,
.leaflet-marker-shadow,
.leaflet-tile-container,
.leaflet-pane > svg,
.leaflet-pane > canvas,
.leaflet-zoom-box,
.leaflet-image-layer,
.leaflet-layer {
  position: absolute;
  left: 0;
  top: 0;
}

.leaflet-container {
  touch-action: pan-x pan-y;
}

.leaflet-tile,
.leaflet-marker-icon,
.leaflet-marker-shadow {
  user-select: none;
  -webkit-user-drag: none;
}

.leaflet-tile {
  border: 0;
  filter: saturate(0.86) contrast(0.96);
}

.leaflet-container img,
.leaflet-container svg {
  max-width: none !important;
  max-height: none !important;
}

.leaflet-tile-container {
  transform-origin: 0 0;
}

.leaflet-pane > svg path {
  pointer-events: auto;
}

.leaflet-pane {
  z-index: 400;
}

.leaflet-tile-pane {
  z-index: 200;
}

.leaflet-overlay-pane {
  z-index: 400;
}

.leaflet-shadow-pane {
  z-index: 500;
}

.leaflet-marker-pane {
  z-index: 600;
}

.leaflet-tooltip-pane {
  z-index: 650;
}

.leaflet-popup-pane {
  z-index: 700;
}

.leaflet-popup {
  position: absolute;
  margin-bottom: 20px;
  text-align: left;
}

.leaflet-popup-content-wrapper {
  padding: 1px;
  color: var(--ink);
  background: #ffffff;
  border: 1px solid rgba(23, 33, 27, 0.16);
  border-radius: 8px;
  box-shadow: 0 16px 34px rgba(23, 33, 27, 0.2);
}

.leaflet-popup-content {
  min-width: 210px;
  margin: 14px 16px;
  line-height: 1.35;
}

.leaflet-popup-tip-container {
  overflow: hidden;
  position: absolute;
  left: 50%;
  bottom: -20px;
  width: 40px;
  height: 20px;
  margin-left: -20px;
  pointer-events: none;
}

.leaflet-popup-tip {
  width: 16px;
  height: 16px;
  margin: -8px auto 0;
  background: #ffffff;
  border-right: 1px solid rgba(23, 33, 27, 0.16);
  border-bottom: 1px solid rgba(23, 33, 27, 0.16);
  transform: rotate(45deg);
  box-shadow: 0 10px 18px rgba(23, 33, 27, 0.12);
}

.leaflet-container a.leaflet-popup-close-button {
  position: absolute;
  top: 6px;
  right: 8px;
  width: 22px;
  height: 22px;
  color: var(--muted);
  text-align: center;
  text-decoration: none;
  font: 18px/22px system-ui, sans-serif;
}

.leaflet-container a.leaflet-popup-close-button:hover {
  color: var(--ink);
}

.leaflet-control {
  position: relative;
  z-index: 800;
  pointer-events: auto;
}

.leaflet-top,
.leaflet-bottom {
  position: absolute;
  z-index: 1000;
  pointer-events: none;
}

.leaflet-top {
  top: 0;
}

.leaflet-right {
  right: 0;
}

.leaflet-bottom {
  bottom: 0;
}

.leaflet-left {
  left: 0;
}

.leaflet-control {
  float: left;
  clear: both;
}

.leaflet-right .leaflet-control {
  float: right;
}

.leaflet-top .leaflet-control {
  margin-top: 12px;
}

.leaflet-right .leaflet-control {
  margin-right: 12px;
}

.leaflet-bottom .leaflet-control {
  margin-bottom: 12px;
}

.leaflet-left .leaflet-control {
  margin-left: 12px;
}

.leaflet-control-zoom a {
  display: block;
  width: 32px;
  height: 32px;
  color: var(--ink);
  background: rgba(247, 245, 238, 0.94);
  border-bottom: 1px solid rgba(23, 33, 27, 0.16);
  text-align: center;
  text-decoration: none;
  font: 700 20px/30px system-ui, sans-serif;
}

.leaflet-control-zoom {
  overflow: hidden;
  border: 1px solid rgba(23, 33, 27, 0.16);
  border-radius: 8px;
  box-shadow: 0 10px 26px rgba(23, 33, 27, 0.12);
}

.leaflet-control-zoom a:last-child {
  border-bottom: 0;
}

.leaflet-control-attribution {
  padding: 3px 6px;
  background: rgba(247, 245, 238, 0.78);
}

.leaflet-interactive {
  cursor: grab;
}

.leaflet-zoom-animated {
  transform-origin: 0 0;
}

.leaflet-zoom-hide {
  visibility: hidden;
}

html,
body {
  margin: 0;
  min-height: 100%;
  color: var(--ink);
  background: var(--paper);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body {
  overflow-x: hidden;
}

.scrolly {
  display: grid;
  grid-template-columns: minmax(0, 58vw) minmax(360px, 1fr);
  min-height: 100vh;
}

.map-pane {
  position: sticky;
  top: 0;
  height: 100vh;
  border-right: 1px solid var(--line);
}

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

#map.is-map-hidden {
  background: #ffffff;
}

#map.is-map-hidden .leaflet-tile-pane,
#map.is-map-hidden .leaflet-control-attribution {
  opacity: 0;
  pointer-events: none;
}

.leaflet-basemap-toggle {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  color: var(--ink);
  background: rgba(247, 245, 238, 0.94);
  border: 1px solid rgba(23, 33, 27, 0.18);
  border-radius: 8px;
  box-shadow: 0 10px 26px rgba(23, 33, 27, 0.12);
  cursor: pointer;
}

.leaflet-basemap-toggle:hover,
.leaflet-basemap-toggle:focus-visible {
  border-color: rgba(23, 33, 27, 0.5);
  outline: 0;
}

.leaflet-basemap-toggle svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.map-label {
  position: absolute;
  left: 24px;
  bottom: 24px;
  z-index: 500;
  display: grid;
  gap: 4px;
  min-width: 190px;
  padding: 14px 16px;
  color: var(--ink);
  background: rgba(247, 245, 238, 0.92);
  border: 1px solid rgba(23, 33, 27, 0.14);
  border-radius: 8px;
  box-shadow: 0 14px 34px rgba(23, 33, 27, 0.12);
  backdrop-filter: blur(10px);
}

.map-label strong {
  font-size: 14px;
  line-height: 1.2;
}

.map-label span {
  color: var(--muted);
  font-size: 13px;
}

.story-pane {
  min-height: 400vh;
  padding: 12vh clamp(24px, 5vw, 72px);
}

.step {
  display: flex;
  min-height: 82vh;
  flex-direction: column;
  justify-content: center;
  border-top: 1px solid var(--line);
  opacity: 0.34;
  transition:
    opacity 180ms ease,
    transform 180ms ease;
}

.step.is-active {
  opacity: 1;
  transform: translateX(-6px);
}

.kicker {
  margin: 0 0 12px;
  color: var(--green);
  font-size: 13px;
  font-weight: 750;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  max-width: 10ch;
  margin: 0;
  font-size: clamp(42px, 5.5vw, 76px);
  line-height: 0.98;
  letter-spacing: 0;
}

h2 {
  max-width: 11ch;
  font-size: clamp(36px, 4.2vw, 58px);
}

p {
  max-width: 34rem;
  margin: 20px 0 0;
  color: var(--muted);
  font-size: clamp(17px, 1.3vw, 20px);
  line-height: 1.55;
}

.note-text {
  margin-top: 42px;
  color: rgba(91, 103, 95, 0.78);
  font-size: 14px;
  line-height: 1.45;
}

.fact-list {
  display: grid;
  gap: 10px;
  max-width: 34rem;
  margin: 24px 0 0;
}

.fact-list div {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  gap: 14px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.fact-list dt {
  color: var(--muted);
  font-size: 14px;
}

.fact-list dd {
  margin: 0;
  color: var(--ink);
  font-size: 15px;
  font-weight: 760;
}

.scale-legend {
  max-width: 34rem;
  margin-top: 22px;
}

.scale-ramp {
  height: 14px;
  border: 1px solid rgba(23, 33, 27, 0.18);
  border-radius: 999px;
  background: linear-gradient(90deg, rgb(222, 238, 226), rgb(16, 82, 69));
}

.scale-labels {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.scale-labels strong {
  color: var(--ink);
}

.size-ranges,
.size-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  max-width: 34rem;
  margin-top: 14px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 680;
}

.size-ranges button {
  padding: 4px 8px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.56);
  border: 1px solid rgba(23, 33, 27, 0.12);
  border-radius: 999px;
  cursor: pointer;
  font: inherit;
}

.size-ranges button:hover,
.size-ranges button:focus-visible,
.size-ranges button.is-hovered {
  border-color: rgba(23, 33, 27, 0.42);
  outline: 0;
}

.size-ranges button.is-active {
  color: #ffffff;
  background: var(--ink);
  border-color: var(--ink);
}

.size-ranges button.is-muted {
  opacity: 0.48;
}

.pill-hint {
  display: inline-flex;
  align-items: center;
  color: var(--muted);
  font-size: 13px;
  font-weight: 680;
}

.size-legend span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
}

.swatch {
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 1px solid rgba(23, 33, 27, 0.22);
  border-radius: 2px;
}

.swatch-small {
  background: var(--green);
}

.swatch-medium {
  background: var(--yellow);
}

.swatch-large {
  background: var(--red);
}

.histogram {
  width: min(100%, 34rem);
  min-height: 280px;
  margin-top: 20px;
  color: var(--muted);
}

.histogram svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

.histogram-axis text,
.histogram-x-label {
  fill: var(--muted);
  font-size: 12px;
}

.histogram-axis path,
.histogram-axis line {
  stroke: rgba(23, 33, 27, 0.26);
}

.histogram-grid line {
  stroke: rgba(23, 33, 27, 0.1);
}

.histogram-bar {
  stroke: rgba(23, 33, 27, 0.12);
  stroke-width: 0.5;
}

.histogram-range-band.small {
  fill: rgba(46, 111, 89, 0.08);
}

.histogram-range-band.medium {
  fill: rgba(214, 165, 58, 0.08);
}

.histogram-range-band.large {
  fill: rgba(181, 82, 66, 0.07);
}

.histogram-range-marker {
  stroke: rgba(23, 33, 27, 0.34);
  stroke-width: 1;
  stroke-dasharray: 3 4;
}

.histogram-range-label {
  fill: var(--muted);
  font-size: 11px;
  font-weight: 720;
}

.histogram-marker {
  stroke-width: 2;
  stroke-dasharray: 5 4;
}

.histogram-marker.median {
  stroke: var(--ink);
}

.histogram-marker.average {
  stroke: var(--blue);
}

.histogram-marker-label {
  fill: var(--ink);
  font-size: 12px;
  font-weight: 720;
}

.interaction-hint {
  max-width: 34rem;
  margin-top: 12px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.building-popup {
  min-width: 210px;
  color: var(--ink);
}

.building-popup strong {
  display: block;
  margin-bottom: 8px;
  font-size: 14px;
}

.building-popup dl {
  display: grid;
  gap: 6px;
  margin: 0;
}

.building-popup dl div {
  display: grid;
  grid-template-columns: 86px 1fr;
  gap: 8px;
}

.building-popup dt {
  color: var(--muted);
  font-size: 12px;
}

.building-popup dd {
  margin: 0;
  font-size: 12px;
  font-weight: 720;
}

.story-nav {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 1200;
  display: grid;
  grid-template-columns: 42px;
  gap: 8px;
  justify-items: center;
  padding: 10px;
  color: var(--ink);
  background: rgba(247, 245, 238, 0.92);
  border: 1px solid rgba(23, 33, 27, 0.16);
  border-radius: 8px;
  box-shadow: 0 14px 34px rgba(23, 33, 27, 0.14);
  backdrop-filter: blur(10px);
}

.story-nav-button {
  width: 42px;
  height: 42px;
  padding: 0;
  color: var(--ink);
  background: #ffffff;
  border: 1px solid rgba(23, 33, 27, 0.18);
  border-radius: 8px;
  cursor: pointer;
  font-size: 22px;
  font-weight: 760;
  line-height: 1;
}

.story-nav-button:hover:not(:disabled),
.story-nav-button:focus-visible {
  border-color: rgba(23, 33, 27, 0.48);
  outline: 0;
}

.story-nav-button:disabled {
  cursor: default;
  opacity: 0.36;
}

.story-nav-counter {
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
  line-height: 1;
}

@media (max-width: 820px) {
  .scrolly {
    display: block;
  }

  .map-pane {
    height: 58vh;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .story-pane {
    min-height: auto;
    padding: 4vh 22px 12vh;
  }

  .step {
    min-height: 72vh;
    transform: none;
  }

  .step.is-active {
    transform: none;
  }

  .map-label {
    right: 14px;
    bottom: 14px;
    left: 14px;
  }

  h1,
  h2 {
    max-width: 12ch;
  }

  .scale-labels {
    display: grid;
  }

  .size-ranges button,
  .size-legend span {
    white-space: normal;
  }

  .histogram {
    min-height: 230px;
  }

  .story-nav {
    right: 14px;
    bottom: 14px;
    grid-template-columns: 38px;
    padding: 8px;
  }

  .story-nav-button {
    width: 38px;
    height: 38px;
  }
}
