
.map-section {
  grid-column: 1 / -1;
  margin: 1.5rem 0;
}

.story-view-controls {
  counter-reset: story-step;
  display: grid;
  gap: 0.7rem;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 1.2rem 0;
}

.story-view-button {
  background: linear-gradient(180deg, #ffffff, #f6faf9);
  border: 1px solid var(--color-border);
  border-radius: 14px;
  color: var(--color-text);
  cursor: pointer;
  font: inherit;
  font-weight: 800;
  line-height: 1.2;
  min-height: 54px;
  padding: 0.75rem 0.9rem;
  text-align: left;
}

.story-view-button:hover,
.story-view-button:focus-visible,
.story-view-button[aria-pressed="true"] {
  background: var(--color-accent);
  border-color: var(--color-accent);
  box-shadow: 0 12px 26px rgba(47, 127, 115, 0.18);
  color: #ffffff;
}

.map-controls-toggle {
  background: var(--color-text);
  border: 1px solid var(--color-text);
  border-radius: 999px;
  color: #ffffff;
  cursor: pointer;
  font: inherit;
  font-size: 0.92rem;
  font-weight: 800;
  margin: 0 0 0.85rem;
  padding: 0.6rem 0.85rem;
}

.map-controls-toggle:hover,
.map-controls-toggle:focus-visible {
  background: var(--color-accent-dark);
  border-color: var(--color-accent-dark);
}

.food-access-map-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 22px;
  box-shadow: 0 22px 55px rgba(15, 23, 42, 0.12);
  display: grid;
  overflow: hidden;
  position: relative;
}

#food-access-map {
  height: 680px;
  width: 100%;
}

.map-panel {
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(203, 213, 225, 0.88);
  border-radius: 16px;
  box-shadow: 0 16px 34px rgba(15, 23, 42, 0.14);
  color: var(--color-text);
  padding: 1rem;
}

.map-layer-panel,
.map-legend-panel {
  position: absolute;
  right: 1rem;
  width: min(300px, calc(100% - 2rem));
  z-index: 2;
}

.map-layer-panel {
  top: 1rem;
}

.map-legend-panel {
  top: 17rem;
}

.food-access-map-card.controls-collapsed .map-panel {
  display: none;
}

.map-panel h4 {
  margin: 0 0 0.65rem;
}

.map-panel label {
  align-items: center;
  display: block;
  font-weight: 700;
  margin: 0.55rem 0;
}

.map-panel input {
  height: 1.1rem;
  margin-right: 0.45rem;
  width: 1.1rem;
}

.legend-item {
  align-items: center;
  display: flex;
  gap: 0.5rem;
  line-height: 1.3;
  margin: 0.5rem 0;
}

.poverty-legend {
  color: var(--color-muted);
  display: grid;
  font-size: 0.78rem;
  gap: 0.35rem;
  margin: 0.5rem 0 0.8rem;
}

.poverty-ramp {
  background: linear-gradient(90deg, #f7fbff, #c6dbef, #6baed6, #2171b5, #08306b);
  border: 1px solid var(--color-border);
  border-radius: 999px;
  display: block;
  height: 12px;
  width: 100%;
}

.poverty-ramp-labels {
  display: flex;
  justify-content: space-between;
}

.legend-dot {
  border: 1px solid #ffffff;
  border-radius: 50%;
  display: inline-block;
  height: 12px;
  width: 12px;
}

.legend-swatch {
  border: 1px solid rgba(15, 23, 42, 0.16);
  display: inline-block;
  height: 12px;
  width: 18px;
}

.legend-swatch.gap-no-snap {
  background: rgba(185, 28, 28, 0.72);
}

.legend-swatch.gap-limited-snap {
  background: rgba(249, 115, 22, 0.72);
}

.legend-dot.snap {
  background: #2563eb;
}

.legend-dot.market {
  background: #16a34a;
}

.legend-line.boundary {
  border-top: 2px solid #4b5563;
  display: inline-block;
  height: 0;
  width: 18px;
}

.what-to-look-for {
  background: var(--color-callout);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  margin-top: 1rem;
  padding: 1rem;
}

.what-to-look-for h3 {
  margin-top: 0;
}

.what-to-look-for p {
  margin: 0.7rem 0 0;
}

.map-note {
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-radius: var(--radius);
  color: var(--color-text);
  margin-top: 1rem;
  padding: 0.9rem 1rem;
}

.map-note.neutral {
  background: var(--color-accent-soft);
  border-color: rgba(47, 127, 115, 0.28);
}

.map-popup-title {
  color: var(--color-text);
  display: block;
  font-weight: 800;
  margin-bottom: 0.35rem;
}

.map-popup-row {
  color: var(--color-muted);
  margin: 0.15rem 0;
}

@media (max-width: 800px) {
  .story-view-controls {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #food-access-map {
    height: 560px;
  }

  .food-access-map-card {
    gap: 0.85rem;
    overflow: visible;
    padding: 0.85rem;
  }

  .map-layer-panel,
  .map-legend-panel {
    position: static;
    width: 100%;
  }
}

@media (max-width: 560px) {
  .story-view-controls {
    grid-template-columns: 1fr;
  }

  .story-view-button {
    min-height: 48px;
  }

  #food-access-map {
    border-radius: 16px;
    height: 460px;
  }
}
