/* ==========================================================================
   TERRITORY MAP — /mapa
   MapLibre GL surfaces restyled onto the Quaerion system. Loads after
   system.css and maplibre-gl.css.
   ========================================================================== */

.map-hero { padding: var(--s7) 0 var(--s4); }
.map-hero h1 { max-width: 18ch; margin-top: var(--s3); font-size: 1.95rem; }
.map-hero .lead { max-width: 60ch; margin-top: var(--s4); }

.map-toolbar { display: grid; gap: var(--s3); padding-bottom: var(--s3); }
.map-toolbar strong { font: 600 1.12rem var(--display); letter-spacing: -.04em; }
.map-toolbar small { display: block; margin-top: 2px; color: var(--ink-muted); font-size: .78rem; }
.map-filters { display: flex; gap: var(--s2); overflow-x: auto; padding-bottom: var(--s1); scrollbar-width: none; }
.map-filters::-webkit-scrollbar { display: none; }
.map-filters .filter { flex: none; }

/* --- stage ---------------------------------------------------------------- */

.map-shell { display: grid; grid-template-columns: 1fr; gap: var(--s3); }
.map-stage { position: relative; height: 64vh; min-height: 380px; overflow: hidden; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--tint); }
.map-stage:fullscreen { height: 100vh; border-radius: 0; }
#map { position: absolute; inset: 0; }

.map-controls { position: absolute; z-index: 5; right: var(--s3); bottom: var(--s8); display: grid; gap: var(--s2); }
.map-controls div { display: grid; overflow: hidden; border: 1px solid var(--line-strong); border-radius: var(--r-sm); background: var(--canvas); box-shadow: var(--shadow-card); }
.map-controls button { display: grid; place-items: center; width: 44px; height: 44px; border: 0; background: none; color: var(--ink-soft); font-size: 1rem; cursor: pointer; transition: background .15s ease, color .15s ease; }
.map-controls button + button { border-top: 1px solid var(--line); }
.map-controls button:hover { background: var(--purple-wash); color: var(--purple-deep); }

.map-legend { position: absolute; z-index: 5; top: var(--s3); left: var(--s3); display: grid; gap: 7px; padding: var(--s3) var(--s4); border: 1px solid var(--line); border-radius: var(--r-sm); background: rgba(255,255,255,.94); backdrop-filter: blur(8px); box-shadow: var(--shadow-card); }
.map-legend span { display: flex; align-items: center; gap: var(--s2); color: var(--ink-soft); font-size: .74rem; font-weight: 600; }
.map-legend i { width: 10px; height: 10px; border: 2px solid #fff; border-radius: 50%; background: var(--purple); box-shadow: 0 0 0 1px var(--line-strong); }
.map-legend i.is-verified { background: #2f7a10; }

/* --- side list ------------------------------------------------------------ */

.map-list-panel { display: flex; flex-direction: column; overflow: hidden; max-height: 62vh; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--tint); }
.map-list-head { padding: var(--s4); border-bottom: 1px solid var(--line); color: var(--ink-muted); font-size: .69rem; font-weight: 750; letter-spacing: .08em; text-transform: uppercase; }
.map-list { flex: 1; overflow-y: auto; padding: var(--s2); scrollbar-width: thin; }
.map-row { display: flex; align-items: center; gap: var(--s3); width: 100%; min-height: 52px; padding: var(--s3); border: 0; border-radius: var(--r-sm); background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; transition: background .15s ease; }
.map-row:hover { background: var(--canvas); }
.map-row.is-selected { background: var(--purple-wash); }
.map-row-dot { flex: none; width: 10px; height: 10px; border: 2px solid #fff; border-radius: 50%; background: var(--purple); box-shadow: 0 0 0 1px var(--line-strong); }
.map-row-dot.is-verified { background: #2f7a10; }
.map-row-body { min-width: 0; }
.map-row-body strong { display: block; overflow: hidden; font-size: .87rem; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.map-row-body small { display: block; margin-top: 2px; overflow: hidden; color: var(--ink-muted); font-size: .74rem; text-overflow: ellipsis; white-space: nowrap; }
.map-list-empty { padding: var(--s6) var(--s4); color: var(--ink-muted); font-size: .84rem; text-align: center; }

.map-note { margin-top: var(--s4); padding: var(--s4); border: 1px solid var(--line); border-left: 3px solid var(--purple-line); border-radius: var(--r-sm); background: var(--tint); color: var(--ink-soft); font-size: .8rem; line-height: 1.55; }
.map-note b { color: var(--ink); }

/* --- popup ---------------------------------------------------------------- */

.map-pop-shell .maplibregl-popup-content { padding: 0; border: 1px solid var(--line); border-radius: var(--r); background: var(--canvas); box-shadow: var(--shadow-lift); }
.map-pop-shell .maplibregl-popup-tip { border-top-color: var(--canvas); border-bottom-color: var(--canvas); }
.map-pop-shell .maplibregl-popup-close-button { top: 6px; right: 6px; width: 34px; height: 34px; border-radius: 50%; background: rgba(255,255,255,.9); color: var(--ink); font-size: 1.1rem; line-height: 1; }
.map-pop-shell .maplibregl-popup-close-button:hover { background: var(--tint-2); }

.map-pop { width: min(276px, 74vw); overflow: hidden; border-radius: var(--r); }
.map-pop-cover { display: block; }
.map-pop-cover .cover { aspect-ratio: 16 / 9; border-radius: 0; }
.map-pop-body { padding: var(--s4); }
.map-pop-cat { color: var(--purple); font-size: .67rem; font-weight: 750; letter-spacing: .06em; text-transform: uppercase; }
.map-pop-body h3 { margin-top: 4px; font-size: 1.02rem; }
.map-pop-city { margin-top: 3px; color: var(--ink-muted); font-size: .77rem; }
.map-pop-tagline { margin-top: var(--s3); color: var(--ink-soft); font-size: .82rem; line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.map-pop-meta { display: flex; align-items: center; gap: var(--s2); margin-top: var(--s3); }
.map-pop-meta span { color: var(--ink-muted); font-size: .73rem; }
.map-pop-actions { display: grid; gap: var(--s2); margin-top: var(--s4); }
.map-pop-actions .btn { flex: 1; }
.map-pop-note { margin-top: var(--s3); color: var(--ink-muted); font-size: .68rem; line-height: 1.4; }

/* MapLibre's own attribution, matched to the system */
.maplibregl-ctrl-attrib { font-size: .68rem; }
.maplibregl-ctrl-bottom-right { z-index: 4; }


/* --- mobile tabs ----------------------------------------------------------
   Stacking a 64vh map above a scrolling list makes both cramped. On phones
   the two share one surface and a tab decides which is showing. */

.map-tabs { display: flex; gap: 3px; margin-bottom: var(--s3); padding: 3px; border: 1px solid var(--line); border-radius: var(--r-pill); background: var(--tint); }
.map-tabs button { flex: 1; min-height: 42px; border: 0; border-radius: var(--r-pill); background: none; color: var(--ink-muted); font: 650 .84rem var(--ui); cursor: pointer; }
.map-tabs button[aria-pressed="true"] { background: var(--canvas); color: var(--ink); box-shadow: var(--shadow-card); }

.map-shell[data-pane="mapa"] .map-list-panel { display: none; }
.map-shell[data-pane="lista"] .map-stage { display: none; }

/* ==========================================================================
   PROGRESSIVE ENHANCEMENT
   ========================================================================== */

@media (min-width: 600px) {
  .map-hero h1 { font-size: 2.4rem; }
  .map-toolbar { display: flex; align-items: center; justify-content: space-between; gap: var(--s4); flex-wrap: wrap; padding-bottom: var(--s4); }
  .map-pop-actions { display: flex; }
  .map-stage { height: 58vh; }
}

@media (min-width: 940px) {
  .map-hero { padding: var(--s8) 0 var(--s5); }
  .map-hero h1 { font-size: 3rem; }
  /* Both panes fit side by side, so the tab switch is retired. */
  .map-tabs { display: none; }
  .map-shell { grid-template-columns: minmax(0, 1fr) 296px; gap: var(--s4); align-items: stretch; }
  .map-shell[data-pane] .map-stage,
  .map-shell[data-pane] .map-list-panel { display: flex; }
  .map-shell[data-pane] .map-stage { display: block; }
  .map-stage { height: clamp(440px, 62vh, 680px); }
  .map-list-panel { max-height: none; }
  .map-controls button { width: 38px; height: 38px; }
  .map-controls { bottom: var(--s7); }
}
