* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  margin: 0;
  padding: 0;
  overflow-x: hidden;
}

body {
  font-family: "PT Sans", Arial, Helvetica, sans-serif;
  color: #1f1f1f;
  background: #ffffff;
}

.interactive {
  width: 100%;
  max-width: 650px;
  margin: 0 auto;
  padding: 14px;
}

.header {
  margin-bottom: 10px;
}

h1 {
  margin: 0;
  font-size: clamp(1.6rem, 3.5vw, 2.3rem);
  line-height: 1.1;
}

.dek {
  margin: 6px 0 0;
  color: #555555;
  font-size: 13px;
  line-height: 1.35;
}

.summary-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 28px;
  padding-top: 10px;
  /* border-top: 1px solid #d8d8d8; */
}

.summary-row > div {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.summary-label {
  color: #666666;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.map-wrapper {
  position: relative;
  width: 100%;
}

#map {
  position: relative;
  width: 100%;
  height: 430px;
  min-height: 0;
  max-height: none;
  aspect-ratio: auto;
  overflow: hidden;
  border: 1px solid #cccccc;
}

.leaflet-container {
  position: relative;
  overflow: hidden;
}

/* Prevent generic page image rules from resizing Leaflet tiles. */
.leaflet-container img,
.leaflet-container .leaflet-tile,
.leaflet-container .leaflet-marker-icon,
.leaflet-container .leaflet-marker-shadow {
  max-width: none !important;
  max-height: none !important;
}

.legend {
  position: absolute;
  z-index: 800;
  left: 14px;
  bottom: 14px;
  max-width: 170px;
  padding: 11px 12px;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid #bdbdbd;
  border-radius: 4px;
  font-size: 0.8rem;
  line-height: 1.55;
}

.legend strong {
  display: block;
  margin-bottom: 5px;
}

.swatch {
  display: inline-block;
  width: 13px;
  height: 13px;
  margin-right: 7px;
  border: 1px solid rgba(0, 0, 0, 0.2);
  vertical-align: -2px;
}

.score-0 { background: #f1f4cb; }
.score-1 { background: #fed98e; }
.score-2 { background: #fe9929; }
.score-3 { background: #d95f0e; }
.score-4 { background: #7f0000; }
.score-missing { background: #d9d9d9; }


.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.scale-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px solid #bdbdbd;
  border-radius: 4px;
  background: #ffffff;
  color: #1f1f1f;
  font: inherit;
  font-weight: 700;
  text-align: left;
}

.scale-toggle-icon {
  margin-left: 12px;
  font-size: 1.2rem;
  line-height: 1;
}

.scale-explainer[hidden] {
  display: none;
}

.scale-explainer {
  margin-top: 8px;
  padding: 16px;
  border: 1px solid #d4d4d4;
  background: #ffffff;
}

.scale-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 15px;
  margin-bottom: 13px;
}

.scale-heading h2 {
  flex: 0 0 auto;
  margin: 0;
  font-size: 1rem;
}

.scale-heading p {
  /* max-width: 720px; */
  margin: 0;
  color: #555555;
  font-size: 0.82rem;
  line-height: 1.4;
}

.scale-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0;
}

.scale-item {
  min-width: 0;
  padding: 0 10px 2px;
  border-left: 1px solid #d7d7d7;
}

.scale-item:first-child {
  padding-left: 0;
  border-left: 0;
}

.scale-item:last-child {
  padding-right: 0;
}

.scale-band {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 26px;
  margin-bottom: 7px;
  border: 1px solid rgba(0, 0, 0, 0.16);
  font-size: 0.8rem;
  font-weight: 700;
}

.scale-item strong {
  display: block;
  margin-bottom: 3px;
  font-size: 0.82rem;
}

.scale-item span {
  display: block;
  color: #555555;
  font-size: 0.72rem;
  line-height: 1.3;
}

.scale-item .score-4 {
  color: #ffffff;
}

.timeline {
  width: 100%;
  margin-top: 12px;
}

.button-row {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 10px;
}

button {
  min-width: 44px;
  padding: 8px 14px;
  border: 1px solid #9b9b9b;
  border-radius: 4px;
  background: #ffffff;
  color: #1f1f1f;
  cursor: pointer;
}

button:hover,
button:focus-visible {
  background: #f1f1f1;
}

#play-button {
  min-width: 78px;
}

.slider-label {
  display: block;
  margin-bottom: 8px;
  font-weight: 700;
  text-align: center;
}

#date-slider {
  width: 100%;
}

.slider-endpoints {
  display: flex;
  justify-content: space-between;
  color: #666666;
  font-size: 0.8rem;
}

.heat-popup {
  min-width: 210px;
}

.popup-location {
  margin: 0 0 3px;
  font-size: 1rem;
}

.popup-date {
  margin: 0;
  color: #666666;
  font-size: 0.8rem;
}

.popup-score {
  margin: 12px 0 8px;
}

.popup-change {
  margin: 8px 0 0;
  font-weight: 700;
}

.source-note {
  margin-top: 14px;
  color: #666666;
  font-size: 0.75rem;
  line-height: 1.4;
}

@media (max-width: 700px) {
  .interactive {
    padding: 11px;
  }

  h1 {
    font-size: clamp(1.75rem, 8vw, 2.2rem);
  }

  .summary-row {
    gap: 14px 26px;
  }

  #map {
    height: 430px;
  }

  .legend {
    left: 8px;
    bottom: 8px;
    max-width: 145px;
    padding: 8px 9px;
    font-size: 0.72rem;
  }

  .scale-heading {
    display: block;
  }

  .scale-heading h2 {
    margin-bottom: 5px;
  }

  .scale-grid {
    grid-template-columns: 1fr;
    gap: 9px;
  }

  .scale-item,
  .scale-item:first-child,
  .scale-item:last-child {
    display: grid;
    grid-template-columns: 34px 82px 1fr;
    align-items: center;
    gap: 8px;
    padding: 0;
    border-left: 0;
  }

  .scale-band {
    height: 28px;
    margin: 0;
  }

  .scale-item strong,
  .scale-item span {
    margin: 0;
  }
}

@media (max-width: 430px) {
  #map {
    height: 400px;
  }

  .summary-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
}
