/* MOV.AP map (Task 6). Loaded by /mapa directly and injected by map.js elsewhere (home, dossier).
   The map sits on whatever context it is placed in (poster green or dossier paper): the chip bar reads --fg/--bg,
   the basemap and the panel are always paper. */

/* ------------------------------------------------------------------ /mapa page head */
.map-page__head { padding-top: var(--s-6); padding-bottom: var(--s-4); }
.map-page__kicker {
  margin: 0 0 var(--s-2);
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.map-page__title { margin: 0 0 var(--s-3); font-size: var(--display-2); }
.map-page__lede { max-width: var(--measure); margin: 0; font-size: var(--text-md); line-height: 1.4; }

/* ------------------------------------------------------------------ frame */
.movap-map {
  --map-h: clamp(30rem, 74vh, 46rem);
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  max-width: 100%;
  color: var(--fg);
}
.movap-map--full { --map-h: clamp(30rem, calc(100svh - 10rem), 60rem); }
.movap-map--dossier { --map-h: clamp(18rem, 52vh, 28rem); }
.movap-map__fallback { margin: 0; padding-block: var(--s-6); }
.movap-map[data-map-state="error"] .movap-map__fallback { color: var(--alarm); }

.movap-map__bar {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  padding: var(--s-3) max(var(--gutter), calc((100% - var(--wrap)) / 2 + var(--gutter)));
  overflow-x: auto;
  scrollbar-width: none;
  overscroll-behavior-x: contain;
}
.movap-map__bar::-webkit-scrollbar { display: none; }
.movap-map__chips { display: flex; flex: 1 1 auto; gap: var(--s-2); min-width: 0; }
@media (max-width: 48rem) {
  .movap-map__chips { flex: 0 0 auto; } /* the whole bar scrolls sideways; the chips never shrink under "Lista" */
}
@media (min-width: 48.01rem) {
  .movap-map__bar { overflow: visible; }
  .movap-map__chips { flex-wrap: wrap; }
}

.map-chip {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 0.5em;
  min-height: 2.75rem;
  padding: 0.5rem 0.85rem 0.45rem;
  border: 1.5px solid var(--rule-color);
  background: transparent;
  color: var(--fg);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
  transition: background-color var(--dur) var(--ease-out), color var(--dur) var(--ease-out);
}
.map-chip:hover { border-color: var(--fg); }
.map-chip[aria-pressed="true"],
.map-chip[aria-expanded="true"] { border-color: var(--fg); background: var(--fg); color: var(--bg); }
.map-chip:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.map-chip .icon { width: 1.25em; height: 1.25em; }
.map-chip[hidden] { display: none; }
.map-chip--list { margin-left: auto; }

.movap-map__body {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  height: var(--map-h);
  overflow: hidden;
  border-top: var(--rule-heavy) solid var(--fg);
  border-bottom: var(--rule-heavy) solid var(--fg);
  background: var(--paper-50);
  color: var(--ink-900);
}
.movap-map--dossier .movap-map__body { border: 2px solid var(--ink-900); }
.movap-map__canvas { position: relative; grid-area: 1 / 1; min-width: 0; min-height: 0; }
.movap-map .maplibregl-map { font-family: var(--font-mono); }
.movap-map .maplibregl-ctrl-group { border-radius: 0; box-shadow: 0 0 0 1.5px var(--ink-900); }
.movap-map .maplibregl-ctrl-group button { width: 36px; height: 36px; }
.movap-map .maplibregl-ctrl-group button:focus-visible { box-shadow: inset 0 0 0 3px var(--ink-900); }
.movap-map .maplibregl-ctrl-scale { border-color: var(--ink-900); background: rgb(244 242 228 / 0.85); color: var(--ink-900); font-size: 11px; }
.movap-map .maplibregl-ctrl-attrib { font-size: 11px; }

@media (min-width: 48.01rem) {
  .movap-map--panel .movap-map__body { grid-template-columns: minmax(0, 1fr) 360px; }
}

/* approximate-location badge and ring legend (on the map) */
.movap-map__approx {
  position: absolute;
  top: var(--s-2);
  left: var(--s-2);
  z-index: 2;
  margin: 0;
  padding: 0.3rem 0.55rem 0.25rem;
  border: 1.5px solid var(--red-700);
  background: var(--paper-50);
  color: var(--red-700);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  pointer-events: none;
}
.movap-map__approx[hidden], .movap-map__legend[hidden] { display: none; }
.movap-map__legend {
  position: absolute;
  left: var(--s-2);
  bottom: 2.4rem;
  z-index: 2;
  max-width: min(19rem, calc(100% - 1rem));
  padding: var(--s-2) var(--s-3);
  border: 1.5px solid var(--ink-900);
  background: rgb(244 242 228 / 0.94);
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.45;
  pointer-events: none;
}
.movap-map__legend ul { margin: 0 0 var(--s-1); padding: 0; list-style: none; }
.movap-map__legend li { display: flex; align-items: center; gap: var(--s-2); }
.movap-map__footer { margin: 0; color: var(--red-700); font-weight: 600; }
@media (max-width: 48rem) {
  .movap-map--panel .movap-map__legend,
  .movap-map--list .movap-map__legend { display: none; }
  /* Dossier (static map, Z1–Z7 legend): on phones the legend would cover most of the map, so it sits under it. */
  .movap-map--dossier .movap-map__body { height: auto; grid-template-rows: var(--map-h) auto; }
  .movap-map--dossier .movap-map__legend {
    position: static;
    grid-row: 2;
    max-width: none;
    border: 0;
    border-top: 2px solid var(--ink-900);
    background: var(--paper-50);
  }
}

.map-swatch {
  flex: 0 0 auto;
  display: inline-block;
  width: 1.4rem;
  height: 0;
  border-top: 3px solid var(--swatch, var(--ink-900));
  vertical-align: middle;
}
.map-swatch--dashed { border-top-style: dashed; }
.map-swatch--fill { height: 0.7rem; border: 1.5px solid var(--swatch); background: rgb(6 64 62 / 0.2); }

/* ------------------------------------------------------------------ markers */
.map-marker {
  --marker: #B5B0A3;
  /* no position here: MapLibre's .maplibregl-marker is absolute (and anchors the ::before/::after rings) */
  width: 20px;
  height: 20px;
  padding: 0;
  border: 3px solid var(--paper-50);
  border-radius: 50%;
  background: var(--marker);
  box-shadow: 0 0 0 1.5px var(--ink-900);
  cursor: pointer;
}
.map-marker::before { content: ""; position: absolute; inset: -12px; border-radius: 50%; } /* 44 px hit area */
.map-marker--approx {
  border: 4px solid var(--marker);
  background: rgb(244 242 228 / 0.7);
  box-shadow: 0 0 0 1.5px var(--ink-900), inset 0 0 0 1.5px var(--ink-900);
}
.map-marker--featured { width: 24px; height: 24px; }
.map-marker--featured::after {
  content: "";
  position: absolute;
  inset: -4px;
  border: 2px solid var(--marker);
  border-radius: 50%;
  animation: map-pulse 2.2s var(--ease-out) infinite;
  pointer-events: none;
}
.map-marker.is-selected { box-shadow: 0 0 0 1.5px var(--ink-900), 0 0 0 5px var(--paper-50), 0 0 0 7px var(--ink-900); }
.map-marker:focus-visible { outline: 3px solid var(--ink-900); outline-offset: 5px; }
@keyframes map-pulse {
  from { transform: scale(1); opacity: 0.95; }
  to { transform: scale(2.6); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .map-marker--featured::after { animation: none; opacity: 0; }
}

/* ------------------------------------------------------------------ panel (paper context) */
.map-panel,
.map-list {
  --bg: var(--paper-50);
  --bg-raised: var(--paper-100);
  --fg: var(--ink-900);
  --fg-muted: var(--ink-600);
  --rule-color: var(--paper-300);
  --accent: var(--red-700);
  --alarm: var(--red-700);
  --cite: var(--red-700);
  --focus: var(--ink-900);
  --btn-bg: var(--ink-900);
  --btn-fg: var(--paper-50);
  --btn-shadow: var(--red-600);
  color-scheme: light;
  background: var(--bg);
  color: var(--fg);
}
.map-panel {
  position: relative;
  z-index: 3;
  grid-area: 1 / 2;
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-left: var(--rule-heavy) solid var(--ink-900);
}
.map-panel[hidden] { display: none; }
.map-panel:focus { outline: none; }
.map-panel:focus-visible { outline: 3px solid var(--ink-900); outline-offset: -3px; }
.map-panel__scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: var(--s-5) var(--s-5) var(--s-6);
  font-size: var(--text-sm);
  line-height: 1.5;
}
.map-panel__handle { display: none; }
.map-panel__close {
  position: absolute;
  top: var(--s-2);
  right: var(--s-2);
  z-index: 1;
  display: grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  border: 0;
  background: var(--bg);
  color: var(--fg);
}
.map-panel__close .icon { width: 1.4rem; height: 1.4rem; }
.map-panel__close:focus-visible,
.map-panel__handle:focus-visible { outline: 3px solid var(--focus); outline-offset: -3px; }

.map-panel__badges { display: flex; flex-wrap: wrap; gap: var(--s-2) var(--s-3); align-items: center; margin: 0 2.5rem var(--s-3) 0; }
.map-status { padding: 0.25rem 0.5rem 0.2rem; border: 1.5px solid var(--ink-900); }
.map-status--incident { --status: var(--amber-500); }
.map-panel__approx {
  display: inline-flex;
  align-items: center;
  gap: 0.3em;
  color: var(--red-700);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.map-panel__approx .icon { width: 1.1em; height: 1.1em; }
.map-panel__title { margin: 0 0 var(--s-2); font-size: clamp(1.45rem, 1.2rem + 0.8vw, 1.85rem); line-height: 0.95; }
.map-panel__meta { margin: 0 0 var(--s-3); color: var(--fg-muted); font-family: var(--font-mono); font-size: var(--text-xs); }
.map-panel__meta span { display: block; }
.map-panel__detail { margin: 0 0 var(--s-3); font-weight: 600; }
.map-panel__summary { margin: 0 0 var(--s-4); }
.map-panel__summary--clamp { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 4; line-clamp: 4; overflow: hidden; }
.map-panel__h {
  margin: var(--s-5) 0 var(--s-2);
  padding-top: var(--s-2);
  border-top: 2px solid var(--ink-900);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 600;
  font-stretch: normal;
  letter-spacing: 0.06em;
  line-height: 1.4;
}
.map-panel__note { margin: var(--s-2) 0 0; color: var(--fg-muted); font-family: var(--font-mono); font-size: var(--text-xs); }
.map-panel__more { margin: var(--s-2) 0 0; }
.map-panel__more .link-mono { font-size: var(--text-xs); }
.map-panel__actions { display: flex; flex-wrap: wrap; gap: var(--s-3); margin: var(--s-5) 0 0; }
.map-panel__cta { width: 100%; white-space: normal; text-align: center; }

.map-facts { margin: 0; }
.map-facts__row {
  display: grid;
  grid-template-columns: minmax(6.5rem, 38%) minmax(0, 1fr);
  gap: var(--s-3);
  padding: var(--s-2) 0;
  border-bottom: var(--rule) solid var(--rule-color);
}
.map-facts dt { color: var(--fg-muted); font-family: var(--font-mono); font-size: var(--text-xs); letter-spacing: 0.03em; line-height: 1.5; text-transform: uppercase; }
.map-facts dd { margin: 0; }
.map-facts__row--alarm dd { color: var(--alarm); font-weight: 600; }
.map-facts .tag-unknown { margin: 0 var(--s-2) var(--s-1) 0; }
.map-facts__note { color: var(--fg-muted); }

.map-timeline { margin: var(--s-3) 0 0 0.4rem; font-size: var(--text-sm); }
.map-timeline > li { padding-bottom: var(--s-3); }

.map-links { margin: 0; }
.map-links a { padding: var(--s-2) 0; }

.map-receptors { margin: 0; padding: 0; list-style: none; }
.map-receptors li { display: flex; justify-content: space-between; gap: var(--s-3); padding: 0.35rem 0; border-bottom: var(--rule) solid var(--rule-color); }
.map-receptors__d { font-family: var(--font-mono); font-weight: 600; white-space: nowrap; }

/* ring info */
.map-rings { margin-top: var(--s-5); }
.map-rings__list { margin: 0; padding: 0; list-style: none; }
.map-rings__item { padding: var(--s-2) 0 var(--s-3); border-bottom: var(--rule) solid var(--rule-color); }
.map-rings__head { display: flex; align-items: center; gap: var(--s-2); margin: 0 0 var(--s-1); font-family: var(--font-mono); font-size: var(--text-xs); text-transform: uppercase; }
.map-rings__label { margin: 0 0 var(--s-1); }
.map-rings__caveat { margin: 0 0 var(--s-1); color: var(--fg-muted); font-style: italic; }
.map-rings__sources { margin: 0; }
.map-rings__sub { margin: var(--s-3) 0 var(--s-1); font-family: var(--font-mono); font-size: var(--text-xs); text-transform: uppercase; }
.map-source { display: block; padding: 0.15rem 0; font-family: var(--font-mono); font-size: var(--text-xs); line-height: 1.5; color: inherit; text-decoration-color: var(--accent); text-underline-offset: 0.25em; }
.map-rings__footer {
  margin: var(--s-3) 0 0;
  padding: 0.4rem 0.6rem 0.35rem;
  border: 1.5px solid currentColor;
  color: var(--red-700);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

/* ------------------------------------------------------------------ list (full mode) */
.map-list {
  position: absolute;
  inset: 0 auto 0 0;
  z-index: 4;
  width: min(22rem, 100%);
  overflow-y: auto;
  padding: var(--s-4) var(--s-4) var(--s-6);
  border-right: var(--rule-heavy) solid var(--ink-900);
}
.map-list[hidden] { display: none; }
.map-list:focus { outline: none; }
.map-list .map-panel__close { position: absolute; }
.map-list__title { margin: var(--s-2) 3rem var(--s-3) 0; font-size: 1.5rem; }
.map-list ul { margin: 0 0 var(--s-5); padding: 0; list-style: none; border-top: 2px solid var(--ink-900); }
.map-list li { border-bottom: var(--rule) solid var(--rule-color); }
.map-list__item {
  display: grid;
  grid-template-columns: 1rem minmax(0, 1fr);
  column-gap: var(--s-2);
  width: 100%;
  padding: var(--s-2) 0;
  border: 0;
  background: none;
  text-align: left;
}
.map-list__item:hover .map-list__name { text-decoration: underline; }
.map-list__item:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.map-list__dot { grid-row: span 2; width: 0.8rem; height: 0.8rem; margin-top: 0.3rem; border: 1.5px solid var(--ink-900); background: var(--marker, #B5B0A3); }
.map-list__dot--incident { background: var(--ink-900); border-color: var(--amber-500); border-radius: 50%; }
.map-list__name { font-weight: 650; line-height: 1.3; }
.map-list__meta { grid-column: 2; color: var(--fg-muted); font-family: var(--font-mono); font-size: var(--text-xs); }

/* ------------------------------------------------------------------ phone: bottom sheet */
@media (max-width: 48rem) {
  .map-panel {
    position: absolute;
    inset: auto 0 0 0;
    grid-area: auto;
    height: var(--sheet-h, var(--_sheet, 58%));
    border-left: 0;
    border-top: var(--rule-heavy) solid var(--ink-900);
    transition: height 220ms var(--ease-out);
  }
  .map-panel[data-sheet="peek"] { --_sheet: 38%; }
  .map-panel[data-sheet="half"] { --_sheet: 58%; }
  .map-panel[data-sheet="full"] { --_sheet: 94%; }
  .map-panel.is-dragging { transition: none; }
  .map-panel__handle {
    display: block;
    flex: 0 0 auto;
    width: 100%;
    height: 1.9rem;
    padding: 0;
    border: 0;
    background: var(--bg);
    cursor: grab;
    touch-action: none;
  }
  .map-panel__handle::before {
    content: "";
    display: block;
    width: 2.75rem;
    height: 4px;
    margin: 0 auto;
    background: var(--ink-900);
  }
  .map-panel__close { top: 0.15rem; }
  .map-panel__scroll { padding: var(--s-1) var(--gutter) var(--s-6); }
  .map-list { width: 100%; border-right: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .map-panel, .map-chip { transition: none; }
}

/* a document link whose URL failed the client-side allow-list: same layout, no link */
.map-links__nolink { display: grid; grid-template-columns: 1.5rem minmax(0, 1fr); column-gap: var(--s-3); padding: var(--s-2) 0; }
.map-links__nolink .icon { width: 1.4rem; height: 1.4rem; color: var(--fg-muted); }
