/*!
 * css/livemap.css — styles for live-map.html ("Live Map: Users Around the
 * World"). Isolated stylesheet, loaded only on that page. Reuses the site's
 * existing design tokens from css/style.css (:root custom properties) —
 * nothing here hardcodes a foreign palette. The firefly glow uses
 * --cat-comms (the teal "alive" accent shared across every color scheme,
 * see docs/design-system.md) with --primary as the map's structural accent.
 */

.livemap-hero {
  padding: clamp(1.6rem, 4vw, 2.4rem) 0 1rem;
  text-align: center;
}

.livemap-hero h1 {
  font-family: var(--font-display, var(--font));
  font-size: clamp(1.8rem, 4vw, 2.4rem);
  color: var(--text);
  margin: 0 0 .5rem;
}

.livemap-hero p {
  color: var(--text-light);
  max-width: 640px;
  margin: 0 auto;
  font-size: 1rem;
  line-height: 1.6;
}

.livemap-stats-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .6rem;
  margin-top: 1rem;
  flex-wrap: wrap;
}

.livemap-online-pill {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  font: 600 .85rem/1 var(--font);
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: .45rem .9rem .45rem .7rem;
}

.livemap-online-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--success, #0F7B6C);
  box-shadow: 0 0 0 0 color-mix(in srgb, var(--success, #0F7B6C) 55%, transparent);
  animation: livemapPillPulse 1.8s ease-out infinite;
  flex-shrink: 0;
}

@keyframes livemapPillPulse {
  0%   { box-shadow: 0 0 0 0 color-mix(in srgb, var(--success, #0F7B6C) 55%, transparent); }
  70%  { box-shadow: 0 0 0 7px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}

.livemap-privacy-note {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  font-size: .8rem;
  color: var(--text-lighter);
}

.livemap-privacy-note i { color: var(--text-lighter); }

/* ---------------------------------------------------------------- */
/* Map shell                                                          */
/* ---------------------------------------------------------------- */

.livemap-wrap {
  position: relative;
  width: 100%;
  max-width: var(--container);
  margin: 0 auto 2rem;
  padding-inline: clamp(1rem, 4vw, 2rem);
}

.livemap-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 2 / 1;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-md);
  touch-action: none; /* we own pan/pinch */
  cursor: grab;
}

.livemap-stage.is-dragging { cursor: grabbing; }

.livemap-svg {
  width: 100%;
  height: 100%;
  display: block;
}

/* Landmass + texture */
.livemap-land {
  fill: color-mix(in srgb, var(--primary) 7%, var(--surface));
  stroke: none;
}

/* Grain texture removed: it read as pixelated noise when zoomed in. The map is
   now clean high-detail vector land + hairline borders. */
.livemap-grain-rect {
  display: none;
}

.livemap-borders {
  fill: none;
  stroke: var(--border);
  stroke-width: .5;
  vector-effect: non-scaling-stroke;
}

.livemap-graticule {
  fill: none;
  stroke: var(--border-light);
  stroke-width: .4;
  vector-effect: non-scaling-stroke;
  opacity: .6;
}

/* ---------------------------------------------------------------- */
/* City markers                                                      */
/* ---------------------------------------------------------------- */

/* City markers show as text labels only. The little blue dots were removed —
   at low zoom they looked like anonymous-visitor fireflies and were confusing. */
.livemap-city-dot { display: none; }

.livemap-city-label {
  font: 600 3px var(--font);
  fill: var(--text-light);
  opacity: 0;
  transition: opacity .35s ease;
  pointer-events: none;
  paint-order: stroke;
  stroke: var(--surface);
  stroke-width: .5px;
  stroke-linejoin: round;
}

.livemap-city-label.is-visible { opacity: .9; }

/* ---------------------------------------------------------------- */
/* Firefly presence dots                                              */
/* ---------------------------------------------------------------- */

.livemap-firefly {
  cursor: pointer;
}

.livemap-firefly-core {
  fill: var(--cat-comms, var(--success, #0E9F8C));
  animation: livemapPulse 2.6s ease-in-out infinite;
  transform-box: fill-box;
  transform-origin: center;
}

.livemap-firefly-glow {
  fill: var(--cat-comms, var(--success, #0E9F8C));
  opacity: .35;
  filter: blur(.6px);
  animation: livemapGlow 2.6s ease-in-out infinite;
  transform-box: fill-box;
  transform-origin: center;
}

@keyframes livemapPulse {
  0%, 100% { opacity: .75; transform: scale(1); }
  50%      { opacity: 1;   transform: scale(1.18); }
}

@keyframes livemapGlow {
  0%, 100% { opacity: .22; transform: scale(1); }
  50%      { opacity: .5;  transform: scale(1.6); }
}

@media (prefers-reduced-motion: reduce) {
  .livemap-firefly-core, .livemap-firefly-glow, .livemap-online-dot {
    animation: none !important;
  }
}

/* ---------------------------------------------------------------- */
/* Controls cluster                                                   */
/* ---------------------------------------------------------------- */

.livemap-controls {
  position: absolute;
  right: 12px;
  bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: .35rem;
  z-index: 5;
}

.livemap-ctrl-btn {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 1rem;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: background var(--transition), border-color var(--transition), transform var(--transition);
}

.livemap-ctrl-btn:hover {
  background: var(--surface-2);
  border-color: var(--primary-light);
}

.livemap-ctrl-btn:active { transform: scale(.94); }

.livemap-ctrl-btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.livemap-zoom-readout {
  width: 38px;
  text-align: center;
  font: 600 .68rem/1 var(--font);
  color: var(--text-light);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .3rem 0;
}

/* ---------------------------------------------------------------- */
/* Empty state                                                       */
/* ---------------------------------------------------------------- */

.livemap-empty-state {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.4rem;
  font: 500 .9rem/1.4 var(--font);
  color: var(--text-light);
  box-shadow: var(--shadow);
  z-index: 4;
  pointer-events: none;
  max-width: 80%;
}

.livemap-empty-state.is-hidden { display: none; }

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

.livemap-popup {
  position: absolute;
  z-index: 8;
  min-width: 180px;
  max-width: 240px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: .75rem .9rem;
  font-size: .85rem;
  color: var(--text);
  transform: translate(-50%, calc(-100% - 14px));
  pointer-events: auto;
}

.livemap-popup.is-hidden { display: none; }

.livemap-popup::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -6px;
  width: 12px;
  height: 12px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  transform: translateX(-50%) rotate(45deg);
}

.livemap-popup-title {
  font-weight: 700;
  margin-bottom: .2rem;
  display: flex;
  align-items: center;
  gap: .35rem;
}

.livemap-popup-sub {
  color: var(--text-lighter);
  font-size: .75rem;
}

.livemap-popup-close {
  position: absolute;
  top: 4px;
  right: 6px;
  border: none;
  background: transparent;
  color: var(--text-lighter);
  font-size: .8rem;
  cursor: pointer;
  padding: .2rem;
  line-height: 1;
}

.livemap-popup-close:hover { color: var(--text); }

/* ---------------------------------------------------------------- */
/* Below-map info section                                             */
/* ---------------------------------------------------------------- */

.livemap-info-section {
  max-width: var(--container);
  margin: 0 auto 3rem;
  padding-inline: clamp(1rem, 4vw, 2rem);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}

.livemap-info-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.3rem;
}

.livemap-info-card h3 {
  font-size: 1rem;
  margin: 0 0 .4rem;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: .5rem;
}

.livemap-info-card h3 i { color: var(--primary); }

.livemap-info-card p {
  margin: 0;
  font-size: .88rem;
  color: var(--text-light);
  line-height: 1.6;
}

@media (max-width: 860px) {
  .livemap-info-section { grid-template-columns: 1fr; }
}

/* ---------------------------------------------------------------- */
/* Mobile                                                             */
/* ---------------------------------------------------------------- */

@media (max-width: 640px) {
  .livemap-stage { aspect-ratio: 4 / 3; }
  .livemap-controls { right: 8px; bottom: 8px; }
  .livemap-ctrl-btn, .livemap-zoom-readout { width: 34px; height: 34px; }
}

/* "City contours": built-up/urban-area polygons, revealed on zoom (opacity ramped in JS). */
.livemap-urban {
  fill: var(--primary);
  fill-opacity: .14;
  stroke: var(--primary);
  stroke-width: .35;
  vector-effect: non-scaling-stroke;
  pointer-events: none;
}
