/* ==========================================================================
   AWOOGA — Visitor "Sonar" heatmap
   A premium navy teaser band on the About page + a full-screen interactive
   Leaflet heatmap modal. Public, IP-free, fed by visitor_map_api.php.
   Class prefix: .sonar (teaser) and .vmap (modal) — kept separate from the
   admin portal's .bp-vmap map so the two never collide.
   ========================================================================== */

/* ---------- Teaser band -------------------------------------------------- */
.sonar {
  position: relative;
  overflow: hidden;
  color: var(--cream);
  background:
    radial-gradient(120% 90% at 80% -10%, rgba(201, 162, 39, 0.20), transparent 55%),
    linear-gradient(165deg, var(--navy-800), var(--navy-900) 70%);
}
/* Faint concentric "sonar sweep" rings behind the copy. */
.sonar::before {
  content: "";
  position: absolute;
  top: 50%; right: -8%;
  width: min(58vw, 720px); aspect-ratio: 1;
  transform: translateY(-50%);
  border-radius: 50%;
  background:
    repeating-radial-gradient(circle at center,
      rgba(227, 195, 90, 0.10) 0 1px,
      transparent 1px 46px);
  -webkit-mask-image: radial-gradient(circle at center, #000 0%, transparent 72%);
          mask-image: radial-gradient(circle at center, #000 0%, transparent 72%);
  pointer-events: none;
}
@media (prefers-reduced-motion: no-preference) {
  .sonar::after {
    content: "";
    position: absolute;
    top: 50%; right: -8%;
    width: min(58vw, 720px); aspect-ratio: 1;
    transform: translateY(-50%);
    border-radius: 50%;
    background: conic-gradient(from 0deg,
      transparent 0deg, rgba(227, 195, 90, 0.16) 24deg, transparent 60deg);
    -webkit-mask-image: radial-gradient(circle at center, #000 0%, transparent 72%);
            mask-image: radial-gradient(circle at center, #000 0%, transparent 72%);
    animation: sonar-sweep 7s linear infinite;
    pointer-events: none;
  }
}
@keyframes sonar-sweep { to { transform: translateY(-50%) rotate(360deg); } }

.sonar__inner { position: relative; z-index: 1; max-width: 760px; }
.sonar .eyebrow { color: var(--brass-lt); }
.sonar .eyebrow::before { background: var(--brass-lt); }
.sonar h2 { color: var(--cream); font-size: clamp(1.7rem, 3.4vw, 2.5rem); }
.sonar p { color: rgba(247, 241, 227, 0.84); font-size: 1.08rem; max-width: 62ch; }
.sonar .sonar__lead { font-size: clamp(1.1rem, 1.6vw, 1.28rem); color: rgba(247, 241, 227, 0.92); }

/* Live stat chips (filled in by JS; render gracefully if the feed is empty) */
.sonar__stats {
  display: flex; flex-wrap: wrap; gap: 0.75rem;
  margin: 1.8rem 0 2rem; padding: 0; list-style: none;
}
.sonar__stat {
  display: flex; flex-direction: column; gap: 0.1rem;
  padding: 0.7rem 1.15rem;
  background: rgba(247, 241, 227, 0.06);
  border: 1px solid rgba(227, 195, 90, 0.28);
  border-radius: var(--radius-sm);
  min-width: 7.5rem;
}
.sonar__stat-num {
  font-family: var(--font-display); font-weight: 600;
  font-size: clamp(1.5rem, 3vw, 2rem); line-height: 1; color: var(--cream);
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}
.sonar__stat-label {
  font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.16em;
  font-weight: 700; color: var(--brass-lt);
}
.sonar__stat.is-loading .sonar__stat-num { opacity: 0.45; }

.sonar__actions { display: flex; flex-wrap: wrap; gap: 0.8rem; align-items: center; }
.sonar__note { font-size: 0.82rem; color: rgba(247, 241, 227, 0.55); }

/* ---------- Full-screen modal ------------------------------------------- */
.vmap-modal {
  position: fixed; inset: 0; z-index: 1000;
  display: none;
  padding: clamp(0px, 2vw, 26px);
  background: rgba(6, 16, 28, 0.74);
  -webkit-backdrop-filter: blur(6px);
          backdrop-filter: blur(6px);
  opacity: 0;
  transition: opacity 0.32s var(--ease);
}
.vmap-modal.is-open { display: flex; opacity: 1; }
body.vmap-lock { overflow: hidden; }

.vmap-shell {
  position: relative;
  display: flex; flex-direction: column;
  width: 100%; height: 100%;
  margin: auto;
  max-width: 1340px;
  background: linear-gradient(165deg, #0e2842, var(--navy-900));
  border: 1px solid rgba(227, 195, 90, 0.22);
  border-radius: clamp(0px, 1.4vw, var(--radius-lg));
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  transform: translateY(14px) scale(0.992);
  transition: transform 0.32s var(--ease);
}
.vmap-modal.is-open .vmap-shell { transform: none; }

/* Header */
.vmap-head {
  display: flex; align-items: center; gap: 1rem;
  padding: 0.95rem clamp(1rem, 2.5vw, 1.7rem);
  border-bottom: 1px solid rgba(247, 241, 227, 0.10);
  background: rgba(8, 22, 38, 0.6);
}
.vmap-head__title { display: flex; flex-direction: column; min-width: 0; }
.vmap-head__title .eyebrow { color: var(--brass-lt); margin: 0 0 0.2rem; }
.vmap-head__title .eyebrow::before { background: var(--brass-lt); }
.vmap-head h3 {
  margin: 0; color: var(--cream); font-size: clamp(1.15rem, 2.2vw, 1.5rem);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.vmap-head__spacer { flex: 1; }
.vmap-close {
  flex: none; width: 42px; height: 42px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: rgba(247, 241, 227, 0.08);
  border: 1px solid rgba(247, 241, 227, 0.18);
  color: var(--cream);
  transition: background 0.2s var(--ease), transform 0.2s var(--ease);
}
.vmap-close:hover { background: var(--red); border-color: var(--red); transform: rotate(90deg); }
.vmap-close svg { width: 20px; height: 20px; }

/* Controls bar */
.vmap-controls {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem 1.1rem;
  padding: 0.8rem clamp(1rem, 2.5vw, 1.7rem);
  border-bottom: 1px solid rgba(247, 241, 227, 0.08);
  background: rgba(8, 22, 38, 0.35);
}
.vmap-ctl-group { display: flex; flex-direction: column; gap: 0.35rem; }
.vmap-ctl-label {
  font-size: 0.62rem; text-transform: uppercase; letter-spacing: 0.16em;
  font-weight: 700; color: rgba(227, 195, 90, 0.85);
}
.vmap-segment { display: inline-flex; background: rgba(247,241,227,0.05); border: 1px solid rgba(247,241,227,0.14); border-radius: 999px; padding: 3px; gap: 2px; }
.vmap-seg-btn {
  appearance: none; border: 0; background: transparent;
  color: rgba(247, 241, 227, 0.7);
  font-size: 0.82rem; font-weight: 600;
  padding: 0.4rem 0.9rem; border-radius: 999px;
  transition: background 0.2s var(--ease), color 0.2s var(--ease);
  white-space: nowrap;
}
.vmap-seg-btn:hover { color: var(--cream); }
.vmap-seg-btn.is-active { background: var(--brass); color: var(--navy-900); }
.vmap-seg-btn.is-active:hover { color: var(--navy-900); }

.vmap-custom__row { display: inline-flex; align-items: center; gap: 0.4rem; }
.vmap-date {
  background: rgba(247, 241, 227, 0.06);
  border: 1px solid rgba(247, 241, 227, 0.16);
  color: var(--cream);
  border-radius: 8px; padding: 0.4rem 0.55rem;
  font: inherit; font-size: 0.8rem;
  color-scheme: dark;
}
.vmap-custom .vmap-dash { color: rgba(247,241,227,0.5); }
.vmap-apply {
  appearance: none; border: 1px solid rgba(227,195,90,0.5); background: transparent;
  color: var(--brass-lt); font-weight: 600; font-size: 0.8rem;
  padding: 0.42rem 0.85rem; border-radius: 8px;
  transition: background 0.2s var(--ease), color 0.2s var(--ease);
}
.vmap-apply:hover { background: var(--brass); color: var(--navy-900); border-color: var(--brass); }

/* Body: map + aside */
.vmap-body { position: relative; flex: 1; display: flex; min-height: 0; }
.vmap-canvas {
  flex: 1; min-width: 0;
  background: #0a1726;
}
/* Leaflet dark skin */
.vmap-canvas.leaflet-container { font-family: var(--font-sans); background: #0a1726; }
.vmap-canvas .leaflet-control-zoom a {
  background: rgba(14, 40, 66, 0.92); color: var(--cream);
  border-color: rgba(247, 241, 227, 0.18);
}
.vmap-canvas .leaflet-control-zoom a:hover { background: var(--navy-700); }
.vmap-canvas .leaflet-control-attribution {
  background: rgba(8, 22, 38, 0.7); color: rgba(247, 241, 227, 0.55);
}
.vmap-canvas .leaflet-control-attribution a { color: rgba(227, 195, 90, 0.8); }
.vmap-canvas .leaflet-popup-content-wrapper {
  background: #0e2842; color: var(--cream);
  border: 1px solid rgba(227, 195, 90, 0.3); border-radius: 12px;
  box-shadow: 0 14px 40px rgba(0,0,0,0.5);
}
.vmap-canvas .leaflet-popup-tip { background: #0e2842; border: 1px solid rgba(227, 195, 90, 0.3); }
.vmap-canvas .leaflet-popup-content { margin: 0.7rem 0.9rem; font-size: 0.85rem; line-height: 1.5; }
.vmap-pop__place { font-family: var(--font-display); font-weight: 600; font-size: 0.98rem; color: var(--cream); }
.vmap-pop__sub { color: rgba(247, 241, 227, 0.7); }
.vmap-pop__visits { color: var(--brass-lt); font-weight: 700; }

/* Aside: stats + country bars */
.vmap-aside {
  flex: none; width: 310px;
  display: flex; flex-direction: column;
  border-left: 1px solid rgba(247, 241, 227, 0.10);
  background: rgba(8, 22, 38, 0.55);
}
.vmap-aside__totals {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 1px; background: rgba(227, 195, 90, 0.14);
  border-bottom: 1px solid rgba(247, 241, 227, 0.10);
}
.vmap-total {
  background: rgba(8, 22, 38, 0.85);
  padding: 0.9rem 0.6rem; text-align: center;
}
.vmap-total__num {
  display: block; font-family: var(--font-display); font-weight: 600;
  font-size: 1.35rem; line-height: 1; color: var(--cream);
  font-variant-numeric: tabular-nums;
}
.vmap-total__label {
  font-size: 0.6rem; text-transform: uppercase; letter-spacing: 0.12em;
  font-weight: 700; color: var(--brass-lt); margin-top: 0.3rem; display: block;
}
.vmap-aside__scroll { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.vmap-aside__head {
  padding: 0.9rem 1.1rem 0.4rem;
  font-size: 0.66rem; text-transform: uppercase; letter-spacing: 0.16em;
  font-weight: 700; color: rgba(227, 195, 90, 0.85);
}
.vmap-countries {
  flex: 1; overflow-y: auto; padding: 0.3rem 0.7rem 1rem;
  scrollbar-width: thin; scrollbar-color: rgba(227,195,90,0.4) transparent;
}
.vmap-country {
  position: relative;
  display: grid; grid-template-columns: auto 1fr auto; align-items: center;
  gap: 0.65rem; padding: 0.42rem 0.7rem; border-radius: 10px;
  min-height: 2.35rem;
  overflow: hidden;
}
.vmap-country + .vmap-country { margin-top: 2px; }
.vmap-country:hover { background: rgba(247, 241, 227, 0.04); }
/* The brass "bar" fill behind each country row. */
.vmap-country__bar {
  position: absolute; inset: 0 auto 0 0;
  width: 0;
  background: linear-gradient(90deg, rgba(201,162,39,0.34), rgba(201,162,39,0.05));
  border-radius: 10px;
  z-index: 0;
  transition: width 0.6s var(--ease);
}
/* Keep the bar behind; lift only the actual content (NOT the bar). */
.vmap-country > :not(.vmap-country__bar) { position: relative; z-index: 1; }
.vmap-country__flag {
  display: block; width: 24px; height: 18px; flex: none;
  border-radius: 3px; object-fit: cover;
  box-shadow: 0 0 0 1px rgba(247, 241, 227, 0.20);
}
.vmap-country__flag--none {
  display: grid; place-items: center; font-size: 0.92rem;
  background: rgba(247, 241, 227, 0.07); box-shadow: none;
}
.vmap-country__name {
  color: var(--cream); font-size: 0.86rem; font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.vmap-country__count {
  color: var(--brass-lt); font-weight: 700; font-size: 0.84rem;
  font-variant-numeric: tabular-nums;
}

/* Loading + empty + legend overlays on the map */
.vmap-overlay {
  position: absolute; inset: 0; z-index: 500;
  display: none; place-items: center;
  background: rgba(8, 22, 38, 0.55);
  -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
  text-align: center; padding: 2rem;
}
.vmap-overlay.is-on { display: grid; }
.vmap-overlay__card { max-width: 30ch; }
.vmap-overlay__card h4 { color: var(--cream); margin: 0 0 0.4rem; font-size: 1.2rem; }
.vmap-overlay__card p { color: rgba(247, 241, 227, 0.7); margin: 0; font-size: 0.92rem; }
.vmap-spinner {
  width: 38px; height: 38px; margin: 0 auto 0.9rem;
  border-radius: 50%;
  border: 3px solid rgba(227, 195, 90, 0.25);
  border-top-color: var(--brass-lt);
  animation: vmap-spin 0.8s linear infinite;
}
@keyframes vmap-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .vmap-spinner { animation: none; } }

.vmap-legend {
  position: absolute; left: 14px; bottom: 26px; z-index: 450;
  display: flex; align-items: center; gap: 0.55rem;
  padding: 0.5rem 0.75rem;
  background: rgba(8, 22, 38, 0.8);
  border: 1px solid rgba(247, 241, 227, 0.14);
  border-radius: 999px;
  font-size: 0.68rem; color: rgba(247, 241, 227, 0.78);
  pointer-events: none;
}
.vmap-legend__bar {
  width: 90px; height: 8px; border-radius: 999px;
  background: linear-gradient(90deg, #1d4d78, #c9a227, #e3c35a, #b8473f);
}

/* ---------- Responsive --------------------------------------------------- */
@media (max-width: 880px) {
  .vmap-body { flex-direction: column; }
  .vmap-canvas { min-height: 0; flex: 1 1 auto; }
  .vmap-aside {
    width: 100%; flex: 0 0 auto;
    max-height: 38vh;
    border-left: 0; border-top: 1px solid rgba(247, 241, 227, 0.10);
    flex-direction: row;
  }
  .vmap-aside__totals {
    grid-template-columns: 1fr; grid-auto-rows: 1fr;
    width: 132px; flex: none; border-bottom: 0;
    border-right: 1px solid rgba(247, 241, 227, 0.10);
  }
  .vmap-aside__scroll { flex: 1; min-width: 0; display: flex; flex-direction: column; }
  .vmap-legend { display: none; }
}
@media (max-width: 560px) {
  .vmap-controls { gap: 0.6rem 0.8rem; }
  .vmap-custom { display: none; }   /* presets are enough on small screens */
  .vmap-aside { max-height: 42vh; }
}
