/* Dotted world map of where visitors come from.
   Data is fetched from two static JSON files; see assets/js/visitor-map.js. */

.visitor-map {
  --vmap-land: #b4b4c2;
  --vmap-dot: var(--global-theme-color);
  --vmap-location: #d4418e;
  --vmap-ink: #595959;
  --vmap-muted: #828282;
  --vmap-card: rgb(255 255 255 / 96%);

  max-width: 420px;
  margin: 0 auto;
  position: relative;
  /* Stays out of the layout until there is data to draw. */
  display: none;
}

.visitor-map.is-ready {
  display: block;
}

html[data-theme="dark"] .visitor-map {
  --vmap-land: #6b6b7a;
  --vmap-location: #f2a6d0;
  --vmap-ink: #eee6f3;
  --vmap-muted: #b8b8b8;
  --vmap-card: rgb(64 64 64 / 97%);
}

.vmap-summary {
  color: var(--vmap-ink);
  margin-bottom: 0.35rem;
  text-align: center;
}

.vmap-summary-number {
  display: block;
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 1.35rem;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  line-height: 1;
}

.vmap-summary-label {
  color: var(--vmap-muted);
  display: block;
  font-size: 0.65rem;
  letter-spacing: 0.14em;
  margin-top: 0.25rem;
  text-transform: uppercase;
}

.vmap-legend {
  align-items: center;
  color: var(--vmap-muted);
  display: flex;
  font-size: 0.58rem;
  flex-wrap: wrap;
  gap: 0.8rem;
  justify-content: center;
  letter-spacing: 0.02em;
  margin: -0.05rem 0 0.2rem;
}

.vmap-legend-item {
  align-items: center;
  display: inline-flex;
  gap: 0.26rem;
}

.vmap-legend-dot {
  border-radius: 50%;
  display: inline-block;
  height: 0.36rem;
  width: 0.36rem;
}

.vmap-legend-country {
  background: var(--vmap-dot);
}

.vmap-legend-location {
  background: var(--vmap-location);
  transition: opacity 140ms ease;
}

.visitor-map:not(.cities-visible) .vmap-legend-location {
  opacity: 0.34;
}

.vmap-svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

.vmap-source {
  border-left: 1px solid color-mix(in srgb, var(--vmap-muted) 32%, transparent);
  color: var(--vmap-muted);
  font-size: 0.52rem;
  font-style: normal;
  font-weight: 400;
  letter-spacing: 0.015em;
  line-height: 1;
  padding-left: 0.8rem;
  white-space: nowrap;
}

.vmap-land {
  fill: var(--vmap-land);
}

.vmap-dot {
  fill: var(--vmap-dot);
  fill-opacity: 0.78;
  cursor: pointer;
  outline: none;
  transition: fill-opacity 120ms ease, filter 120ms ease;
}

.vmap-dot:hover,
.vmap-dot:focus-visible {
  fill-opacity: 1;
  filter: drop-shadow(0 0 2px var(--vmap-dot));
}

.vmap-location-dots {
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease;
  visibility: hidden;
}

.vmap-location-dots.is-visible {
  opacity: 1;
  pointer-events: auto;
  visibility: visible;
}

.vmap-location-dot {
  cursor: pointer;
  fill: var(--vmap-location);
  outline: none;
  stroke: var(--vmap-card);
  stroke-width: 0.7px;
  transform-box: fill-box;
  transform-origin: center;
  transition: filter 120ms ease, transform 120ms ease;
}

.vmap-location-dot:hover,
.vmap-location-dot:focus-visible {
  filter: drop-shadow(0 0 2px var(--vmap-location));
  transform: scale(1.22);
}

.vmap-tooltip {
  background: var(--vmap-card);
  border: 1px solid color-mix(in srgb, var(--vmap-muted) 45%, transparent);
  border-radius: 7px;
  box-shadow: 0 7px 24px rgb(0 0 0 / 16%);
  color: var(--vmap-ink);
  font-size: 0.78rem;
  left: 0;
  line-height: 1.35;
  max-width: calc(100% - 8px);
  opacity: 0;
  padding: 0.55rem 0.65rem;
  pointer-events: none;
  position: absolute;
  top: 0;
  transform: translate(-50%, calc(-100% - 10px));
  transition: opacity 90ms ease;
  visibility: hidden;
  width: max-content;
  z-index: 2;
}

.vmap-tooltip.is-visible {
  opacity: 1;
  visibility: visible;
}

.vmap-tooltip-heading {
  align-items: baseline;
  display: flex;
  gap: 0.85rem;
  justify-content: space-between;
  white-space: nowrap;
}

.vmap-tooltip-country {
  font-size: 0.88rem;
  font-weight: 600;
}

.vmap-tooltip-total {
  color: var(--vmap-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.vmap-tooltip-location-context {
  color: var(--vmap-muted);
  display: block;
  font-size: 0.7rem;
  margin-top: 0.14rem;
  white-space: nowrap;
}

.vmap-tooltip-regions {
  border-top: 1px solid color-mix(in srgb, var(--vmap-muted) 25%, transparent);
  display: block;
  margin-top: 0.38rem;
  padding-top: 0.35rem;
}

.vmap-tooltip-regions-label {
  color: var(--vmap-muted);
  display: block;
  font-size: 0.67rem;
  letter-spacing: 0.08em;
  margin-bottom: 0.16rem;
  text-transform: uppercase;
}

.vmap-tooltip-region {
  align-items: baseline;
  display: flex;
  gap: 0.75rem;
  justify-content: space-between;
  white-space: nowrap;
}

.vmap-tooltip-region-name {
  white-space: nowrap;
}

.vmap-tooltip-region-count {
  color: var(--vmap-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

@media (prefers-reduced-motion: reduce) {
  .vmap-dot,
  .vmap-location-dots,
  .vmap-location-dot,
  .vmap-tooltip,
  .vmap-legend-location {
    transition: none;
  }
}
