/* Map view. Sticky island on the left, narrative cards on the right.
   Pale Atlantic behind the land so the silhouette carries the page. */

body { background: #e6eced; }

.stage { display: block; }

.mapwrap {
  position: sticky;
  top: 41px;
  height: 56svh;
  background: #eaf1f4;
  background-image: radial-gradient(circle at 50% 40%, #f2f7f9 0%, #e2ebef 100%);
  border-bottom: 1px solid #d3dde1;
  overflow: hidden;
  z-index: 1;
}
#map { width: 100%; height: 100%; display: block; }

.legend {
  position: absolute;
  left: 14px; bottom: 12px;
  background: rgba(251, 250, 247, 0.9);
  border: 1px solid #ccd6d8;
  border-radius: 7px;
  padding: 8px 10px;
  font-size: 11px;
  color: #574f47;
  max-width: 190px;
  min-width: 118px;
}
.legend .title { font-weight: 600; color: #2b2621; margin-bottom: 5px; }
.legend .ramp { display: flex; height: 8px; border-radius: 2px; overflow: hidden; margin-bottom: 4px; }
.legend .ramp span { flex: 1; }
.legend .ends { display: flex; justify-content: space-between; gap: 10px; }

.readout {
  position: absolute;
  right: 14px; top: 14px;
  background: rgba(251, 250, 247, 0.94);
  border: 1px solid #ccd6d8;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 12px;
  color: #574f47;
  min-width: 168px;
  max-width: 230px;
}
.readout h4 { margin: 0 0 6px; font-size: 15px; color: #2b2621; letter-spacing: -0.01em; }
.readout dl { margin: 0; display: grid; grid-template-columns: auto auto; gap: 2px 10px; }
.readout dt { color: #8a8175; }
.readout dd { margin: 0; text-align: right; font-weight: 600; color: #2b2621; }
.readout .tops { margin: 7px 0 0; padding-top: 6px; border-top: 1px solid #e2dcd2; }
.readout .tops span { display: block; }

/* map marks */
.muni { stroke: #fbfaf7; stroke-width: 1; cursor: pointer; transition: fill 0.5s ease, stroke-opacity 0.6s ease; }
.muni.bare { stroke-opacity: 0; }
.muni.dim { opacity: 0.35; }
.muni.sel { stroke: #2b2621; stroke-width: 2; }
.munilabel { font-size: 12.5px; fill: #4a443b; pointer-events: none; font-weight: 500; }
.munilabel.strong { fill: #2b2621; font-weight: 700; font-size: 14px; }
.prop { cursor: default; }
.placelabel { font-size: 12px; fill: #2b2621; font-weight: 600; paint-order: stroke; stroke: #f2f7f9; stroke-width: 3.5px; }
.halo { fill: none; stroke: #2b2621; stroke-width: 1.6; stroke-dasharray: 4 3; }

.scroller { position: relative; z-index: 2; padding: 0 0 20vh; }

.card {
  max-width: 560px;
  margin: 0 auto 46vh;
  background: #fbfaf7;
  border: 1px solid #dfe2dd;
  border-radius: 12px;
  padding: 22px 24px;
  box-shadow: 0 10px 28px rgba(43, 38, 33, 0.10);
}
.card:first-child { margin-top: 6vh; }
.card:last-child { margin-bottom: 8vh; }
.card .eyebrow { margin: 0 0 8px; font-size: 13px; color: #8a8175; font-weight: 500; }
.card h1 { font-size: clamp(27px, 3.4vw, 38px); line-height: 1.06; letter-spacing: -0.03em; margin: 0 0 12px; }
.card h2 { font-size: clamp(21px, 2.5vw, 27px); line-height: 1.14; letter-spacing: -0.02em; margin: 0 0 10px; }
.card p { margin: 0 0 10px; font-size: 16px; color: #574f47; }
.card p:last-child { margin-bottom: 0; }
.card b { color: #2b2621; }
.card .note { font-size: 13.5px; color: #8a8175; }
.card .hint { font-size: 13px; color: #8a8175; margin-top: 14px; }

.bars { margin-top: 12px; }
.bars .row { display: grid; grid-template-columns: 122px 1fr 62px; align-items: center; gap: 8px; margin-bottom: 5px; font-size: 13px; }
.bars .row .nm { color: #574f47; text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bars .row .tr { display: block; background: #e8e3d9; border-radius: 3px; height: 12px; overflow: hidden; }
.bars .row .fl { display: block; height: 100%; border-radius: 3px; background: #c2695f; transition: width 0.7s cubic-bezier(0.22, 1, 0.36, 1); }
.bars .row .vl { color: #2b2621; font-weight: 600; text-align: right; }
.bars .row.mute .fl { background: #cdc4b4; }
.bars .row.good .fl { background: #8f74a8; }
.bars.rank .row .tr { background: transparent; }

.topicpicker { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0 8px; }
.topicpicker button {
  font: inherit; font-size: 13px;
  padding: 6px 11px;
  border: 1px solid #d5cec2;
  background: #fff;
  color: #574f47;
  border-radius: 999px;
  cursor: pointer;
}
.topicpicker button:hover { border-color: #8a8175; }
.topicpicker button.on { background: #2b2621; color: #fbfaf7; border-color: #2b2621; }

.outro .ctas { display: flex; flex-wrap: wrap; gap: 9px; margin: 16px 0 4px; }
.outro .cta {
  display: inline-block; padding: 10px 15px; border: 1px solid #2b2621;
  border-radius: 6px; text-decoration: none; font-weight: 600; font-size: 14.5px;
}
.outro .cta.primary { background: #2b2621; color: #fbfaf7; }
.outro .cta:hover { background: #2b2621; color: #fbfaf7; }
.method { margin-top: 14px; font-size: 13.5px; color: #8a8175; }
.method summary { cursor: pointer; color: #574f47; font-weight: 600; }
.method p { font-size: 13.5px; color: #8a8175; margin-top: 8px; }
.credits { margin-top: 14px; font-size: 12.5px; color: #8a8175; }

@media (min-width: 940px) {
  .stage { display: grid; grid-template-columns: 1fr 480px; gap: 0; align-items: start; }
  .mapwrap {
    height: calc(100svh - 41px);
    border-bottom: 0;
    border-right: 1px solid #d3dde1;
  }
  .scroller { padding: 0 26px 30vh; }
  .card { margin: 0 0 44vh; max-width: none; }
  .card:first-child { margin-top: 22vh; }
}
@media (max-width: 939px) {
  /* The map is pinned to the top of the viewport and the cards slide underneath it,
     rather than scrolling over it and hiding the island. */
  .mapwrap {
    position: fixed;
    top: 41px; left: 0; right: 0;
    height: 46svh;
    z-index: 400;
  }
  .scroller { padding-top: calc(46svh + 52px); z-index: 1; }
  .card { margin: 0 14px 34vh; }
  .card:first-child { margin-top: 0; }
  .readout { font-size: 11px; min-width: 140px; padding: 8px 9px; }
  .readout h4 { font-size: 13px; }
}

/* Step rail, as on the story page */
.rail {
  position: fixed; left: 12px; top: 50%; transform: translateY(-50%);
  display: flex; flex-direction: column; gap: 7px; z-index: 450;
  padding: 9px 6px; border-radius: 999px;
  background: rgba(251, 250, 247, 0.85); border: 1px solid #ccd6d8;
}
.rail button { width: 7px; height: 7px; border-radius: 50%; border: 0; padding: 0; background: #cdc4b4; cursor: pointer; transition: transform 0.2s, background 0.2s; }
.rail button:hover { background: #8a8175; }
.rail button.active { background: #2b2621; transform: scale(1.45); }
.rail button.key { background: #d9a7a0; }
.rail button.key.active { background: #b25a50; }
@media (max-width: 939px) { .rail { display: none; } }

/* The active card is the one driving the map; the others step back */
.card { transition: opacity 0.45s ease, transform 0.45s ease; opacity: 0.5; transform: translateY(6px); }
.card.active { opacity: 1; transform: none; }
.card .bars .row .fl { width: 0; }
.muni { transition: fill 0.6s ease, opacity 0.6s ease; }
.halo { animation: halo 2.4s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
@keyframes halo { 0%, 100% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.12); opacity: 0.6; } }
@media (prefers-reduced-motion: reduce) { .card { opacity: 1; transform: none; } .halo { animation: none; } }
