/*
 * Answer block: ```map - places on a real map of the world, each one a
 * button that opens its own breakdown (blocks/map.js draws it from the
 * names, coordinates and facts the model writes; answer_blocks/map.py
 * teaches the format).
 *
 * Every colour is a blocks.css token, so both themes and any palette apply.
 * A group of places takes one of six colours (--ab-map-c) AND a marker
 * shape of its own (map.js SHAPES: six, none used twice), and a place in no
 * group takes a seventh, so groups still read apart in the mono palette and
 * to a colour-blind reader.
 *
 * The picture is 720 units wide. Inside a narrow column (a phone, the Lumi
 * panel) it keeps a readable minimum width and the frame scrolls sideways,
 * rather than shrinking the names to nothing.
 */
.ab-map {
  --ab-map-c: var(--ab-accent);
  margin: 18px 0 20px;
  padding: 0;
  min-width: 0;
  max-width: 100%;
  background: var(--ab-card);
  border: 1px solid var(--ab-hair);
  border-radius: var(--ab-radius);
  overflow: hidden;
  container: ab-map / inline-size;
  font-family: var(--ab-font-ui);
  color: var(--ab-ink);
}
.ab-map *, .ab-map *::before, .ab-map *::after { box-sizing: border-box; }
.ab-map .ab-map-g0 { --ab-map-c: var(--ab-good); }
.ab-map .ab-map-g1 { --ab-map-c: var(--ab-warn); }
.ab-map .ab-map-g2 { --ab-map-c: var(--ab-calc); }
.ab-map .ab-map-g3 { --ab-map-c: var(--ab-measure); }
.ab-map .ab-map-g4 { --ab-map-c: var(--ab-accent); }
.ab-map .ab-map-g5 { --ab-map-c: var(--ab-ink); }

.ab-map-title {
  padding: 14px 16px 10px;
  font: 600 15.5px/1.35 var(--ab-font-ui);
  color: var(--ab-ink);
  overflow-wrap: anywhere;
}

/* ── The picture ──────────────────────────────────────────────────────── */
.ab-map-frame {
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  border-top: 1px solid var(--ab-hair);
  border-bottom: 1px solid var(--ab-hair);
}
.ab-map-title + .ab-map-frame { border-top: 1px solid var(--ab-hair); }
.ab-map > .ab-map-frame:first-child { border-top: 0; }
.ab-map-svg {
  display: block;
  width: 100%;
  min-width: 540px;
  height: auto;
}
.ab-map-sea { fill: var(--ab-card); }
.ab-map-grat { stroke: var(--ab-hair); stroke-width: 1; opacity: 0.55; }
.ab-map-land {
  /* a step off the sea in either theme, whatever the palette */
  fill: color-mix(in srgb, var(--ab-ink) 9%, var(--ab-card));
  stroke: var(--ab-rule);
  stroke-width: 1;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}
.ab-map-border {
  fill: none;
  stroke: var(--ab-rule);
  stroke-width: 0.8;
  stroke-dasharray: 3 3;
  opacity: 0.7;
  vector-effect: non-scaling-stroke;
}
.ab-map-water {
  fill: var(--ab-muted);
  font: italic 500 12px/1 var(--ab-font-ui);
  letter-spacing: 0.04em;
}

.ab-map-link {
  fill: none;
  stroke: var(--ab-map-c);
  stroke-width: 2;
  stroke-linecap: round;
}
.ab-map-link.is-dashed { stroke-width: 1.6; stroke-dasharray: 5 5; }
.ab-map-head { fill: var(--ab-map-c); stroke: none; }
.ab-map-route { transition: opacity 0.15s ease; }
.ab-map-route.is-quiet { opacity: 0.28; }

.ab-map-place { cursor: pointer; outline: none; }
.ab-map-hit { fill: transparent; stroke: none; }
.ab-map-ring { fill: none; stroke: none; stroke-width: 2; }
.ab-map-dot { fill: var(--ab-map-c); stroke: var(--ab-card); stroke-width: 1.5; }
.ab-map-name {
  fill: var(--ab-muted);
  font: 500 12.5px/1 var(--ab-font-ui);
  /* a halo in the card's colour keeps a name readable across a coastline */
  paint-order: stroke;
  stroke: var(--ab-card);
  stroke-width: 3.5px;
  stroke-linejoin: round;
}
.ab-map-key { font-weight: 700; fill: var(--ab-ink); }
.ab-map-place:hover .ab-map-name,
.ab-map-place.is-on .ab-map-name { fill: var(--ab-ink); }
.ab-map-place.is-on .ab-map-name { font-weight: 700; }
.ab-map-place:hover .ab-map-ring { stroke: var(--ab-map-c); opacity: 0.5; }
.ab-map-place.is-on .ab-map-ring { stroke: var(--ab-map-c); opacity: 1; }
.ab-map-place:focus-visible .ab-map-ring { stroke: var(--ab-ink); opacity: 1; stroke-dasharray: 3 2; }

/* ── Legend ───────────────────────────────────────────────────────────── */
.ab-map-legend {
  display: flex; flex-wrap: wrap; gap: 6px 22px;
  padding: 11px 16px;
  font: 500 12.5px/1.35 var(--ab-font-ui);
  color: var(--ab-muted);
}
.ab-map-leg { display: inline-flex; align-items: center; gap: 8px; min-width: 0; }
.ab-map-swatch { flex: 0 0 auto; overflow: visible; }

/* ── The card of the chosen place ─────────────────────────────────────── */
.ab-map-cards { border-top: 1px solid var(--ab-hair); }
.ab-map-legend + .ab-map-cards { border-top: 1px solid var(--ab-hair); }
/* !important: the app rounds anything whose class says "card". */
.ab-map .ab-map-cards, .ab-map .ab-map-card { border-radius: 0 !important; }
.ab-map-card { padding: 14px 16px 6px; }
.ab-map-card[hidden] { display: none; }
.ab-map-card-head { display: flex; align-items: baseline; gap: 10px; }
.ab-map-card-key {
  flex: 0 0 auto;
  min-width: 24px; padding: 3px 7px;
  border-radius: 999px;
  background: var(--ab-map-c);
  color: var(--ab-card);
  font: 700 12px/1.2 var(--ab-font-ui);
  text-align: center;
}
.ab-map-card-name { font: 650 16.5px/1.3 var(--ab-font-ui); color: var(--ab-ink); overflow-wrap: anywhere; }
.ab-map-card-about { margin-top: 4px; font: 400 13.5px/1.45 var(--ab-font-ui); color: var(--ab-muted); }
.ab-map .ab-map-facts { margin: 10px 0 0; padding: 0; }
.ab-map-fact {
  display: grid;
  grid-template-columns: minmax(96px, 150px) minmax(0, 1fr);
  gap: 4px 18px;
  padding: 10px 0;
  border-top: 1px solid var(--ab-hair);
}
.ab-map-fact.is-bare { grid-template-columns: minmax(0, 1fr); }
.ab-map .ab-map-fact dt {
  margin: 0;
  font: 500 12.5px/1.5 var(--ab-font-ui);
  color: var(--ab-muted);
}
.ab-map .ab-map-fact dd {
  margin: 0; min-width: 0;
  font: 400 14.5px/1.5 var(--ab-font-ui);
  color: var(--ab-ink);
  overflow-wrap: anywhere;
}
.ab-map .ab-map-fact dd > :first-child { margin-top: 0; }
.ab-map .ab-map-fact dd > :last-child { margin-bottom: 0; }
@container ab-map (max-width: 460px) {
  .ab-map-fact { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 520px) {
  .ab-map-fact { grid-template-columns: minmax(0, 1fr); }
}

.ab-map-nav {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px 12px 10px;
  border-top: 1px solid var(--ab-hair);
}
/* Doubled class: styles.css shapes every button at high weight. */
.ab-map .ab-map-nav button.ab-map-btn.ab-map-btn {
  appearance: none;
  height: 32px; min-height: 0 !important; min-width: 0;
  padding: 0 12px;
  border: 1px solid var(--ab-hair);
  border-radius: 999px !important;
  background: transparent;
  color: var(--ab-ink);
  font: 500 12.5px/1 var(--ab-font-ui);
  cursor: pointer;
}
.ab-map .ab-map-nav button.ab-map-btn.ab-map-btn:hover { border-color: var(--ab-rule); background: var(--ab-paper); }
.ab-map-count { font: 500 12px/1 var(--ab-font-mono); color: var(--ab-muted); }

.ab-map-note,
.ab-map-tail {
  padding: 10px 16px;
  border-top: 1px solid var(--ab-hair);
  font: 400 12.5px/1.45 var(--ab-font-ui);
  color: var(--ab-muted);
}

@media (prefers-reduced-motion: reduce) { .ab-map-route { transition: none; } }

/* A printed or downloaded page has no clicks: lay every card out. */
:is(.ab-page-print, .ab-page-standalone) .ab-map-card[hidden] { display: block; }
:is(.ab-page-print, .ab-page-standalone) .ab-map-nav { display: none; }
:is(.ab-page-print, .ab-page-standalone) .ab-map-card + .ab-map-card { border-top: 1px solid var(--ab-hair); }
.ab-page-print .ab-map-svg { min-width: 0; }
@media print {
  .ab-map-card[hidden] { display: block; }
  .ab-map-nav { display: none; }
}
