/* Data Globe (prototype). Override the custom properties to theme it. */
.data-globe {
  /* Brand tint: follows Mangrove's theme colour when present (space-separated RGB or any CSS colour) */
  --data-globe-tint: var(--mg-color-interactive, 0 79 145);
  /* --data-globe-ocean: optional ocean colour; defaults to dark navy, or a pale tint in brand mode */
  --data-globe-marker: rgb(var(--mg-color-accent-500, 254 193 36));
  --data-globe-marker-outline: #041a33;
  --data-globe-focus: #ffd24a;
  /* UI colours follow Mangrove's neutral tokens when the page has them */
  --data-globe-surface: rgb(var(--mg-color-neutral-0, 255 255 255));
  --data-globe-text: rgb(var(--mg-color-text, 26 26 26));
  --data-globe-muted: rgb(var(--mg-color-neutral-500, 102 102 102));
  --data-globe-border: rgb(var(--mg-color-neutral-100, 202 205 208));
  --data-globe-radius: var(--mg-radius-button, 4px);
  position: relative;
  font-family: inherit;
  color: inherit;
}

.data-globe__stage {
  position: relative;
  /* Keep the controls' z-indexes (1000+) inside the stage, so they can't paint over page chrome */
  isolation: isolate;
  overflow: hidden;
  /* Vertical swipes still scroll the page on touch screens */
  touch-action: pan-y;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
}
.data-globe__stage.is-dragging {
  cursor: grabbing;
}
.data-globe__stage:focus-visible {
  outline: 3px solid var(--data-globe-focus);
  outline-offset: -3px;
}
.data-globe__canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* Markers: HTML over the canvas, positioned every frame */
.data-globe__markers {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.data-globe__marker {
  --size: 10px;
  position: absolute;
  left: 0;
  top: 0;
  width: 0;
  height: 0;
  padding: 0;
  margin: 0;
  border: 0;
  background: none;
  pointer-events: auto;
  cursor: pointer;
}
/* Hit area at least 24px, per WCAG 2.2 target size */
.data-globe__marker::before {
  content: "";
  position: absolute;
  width: max(24px, var(--size));
  height: max(24px, var(--size));
  transform: translate(-50%, -50%);
  border-radius: 50%;
}
.data-globe__marker:focus {
  outline: none;
}
.data-globe__marker:focus-visible::before,
.data-globe__marker.is-selected::before {
  box-shadow: 0 0 0 3px var(--data-globe-focus);
}

/* Marker shapes (CSV `shape` column): shape as well as colour tells categories apart */
.data-globe__shape {
  position: absolute;
  left: 0;
  top: 0;
  display: block;
  width: var(--size, 10px);
  height: var(--size, 10px);
  box-sizing: border-box;
  transform: translate(-50%, -50%);
  transition: transform 0.15s ease;
}
.data-globe__shape--dot {
  border-radius: 50%;
  background: var(--data-globe-marker);
  border: 1.5px solid var(--data-globe-marker-outline);
}
.data-globe__shape--ring {
  border-radius: 50%;
  border: max(2px, calc(var(--size, 10px) * 0.22)) solid var(--data-globe-marker);
  box-shadow: 0 0 0 1.5px var(--data-globe-marker-outline);
}
.data-globe__shape--square {
  border-radius: 2px;
  background: var(--data-globe-marker);
  border: 1.5px solid var(--data-globe-marker-outline);
}
.data-globe__shape--diamond {
  width: calc(var(--size, 10px) * 0.8);
  height: calc(var(--size, 10px) * 0.8);
  transform: translate(-50%, -50%) rotate(45deg);
  background: var(--data-globe-marker);
  border: 1.5px solid var(--data-globe-marker-outline);
  box-shadow: 0 0 0 2px var(--data-globe-marker);
}
.data-globe__marker:hover .data-globe__shape,
.data-globe__marker.is-selected .data-globe__shape {
  transform: translate(-50%, -50%) scale(1.3);
}
.data-globe__marker:hover .data-globe__shape--diamond,
.data-globe__marker.is-selected .data-globe__shape--diamond {
  transform: translate(-50%, -50%) rotate(45deg) scale(1.3);
}

/* Spotlight pulse rings */
.data-globe__ring {
  position: absolute;
  left: -20px;
  top: -20px;
  width: 40px;
  height: 40px;
  box-sizing: border-box;
  border: 1.2px solid var(--data-globe-marker);
  border-radius: 50%;
  opacity: 0;
  pointer-events: none;
  animation: data-globe-ring 1.9s cubic-bezier(0.2, 0.7, 0.3, 1) forwards;
}
.data-globe__ring--strong {
  left: -36px;
  top: -36px;
  width: 72px;
  height: 72px;
  border-width: 2px;
}
@keyframes data-globe-ring {
  0% { transform: scale(0.18); opacity: 0.6; }
  8% { opacity: 0.92; }
  100% { transform: scale(1); opacity: 0; }
}

/* Spotlight label, anchored above the pulsing marker with a leader line */
.data-globe__callout {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 1000;
  width: 0;
  height: 0;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  text-align: left;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
}
.data-globe__callout::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  width: 1px;
  height: 32px;
  background: linear-gradient(rgb(255 255 255 / 0.7), rgb(255 255 255 / 0));
  transform-origin: top;
  transform: scaleY(0);
  transition: transform 0.45s ease 0.1s;
}
.data-globe__callout-card {
  position: absolute;
  left: 0;
  top: 0;
  display: block;
  box-sizing: border-box;
  overflow-wrap: anywhere;
  min-width: min(130px, var(--callout-max-width, 130px));
  max-width: min(230px, var(--callout-max-width, 230px));
  width: max-content;
  padding: 7px 11px 8px;
  border: 1px solid rgb(160 200 240 / 0.35);
  border-radius: 8px;
  background: rgb(6 28 54 / 0.9);
  color: #eef4fb;
  box-shadow: 0 8px 24px rgb(0 0 0 / 0.35);
  font-size: 0.8rem;
  line-height: 1.35;
  transform: translate(var(--card-x, -50%), calc(var(--card-y, -100%) + 8px)) scale(0.96);
  transition: transform 0.45s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.data-globe__callout-category {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.66rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #a9bdd3;
}
.data-globe__callout-category::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--data-globe-marker);
}
.data-globe__callout strong {
  display: block;
  font-size: 1rem;
  line-height: 1.25;
  margin-top: 2px;
}
.data-globe__callout-description {
  display: block;
  color: #c9d8e8;
  margin-top: 2px;
}
.data-globe__callout.is-on {
  opacity: 1;
  pointer-events: auto;
  transition: opacity 0.35s ease;
}
.data-globe__callout.is-on::after {
  transform: scaleY(1);
}
.data-globe__callout.is-on .data-globe__callout-card {
  transform: translate(var(--card-x, -50%), var(--card-y, -100%));
}
.data-globe__callout.is-out {
  opacity: 0;
  transition: opacity 0.5s ease;
}
.data-globe__callout.is-behind {
  visibility: hidden;
}

/* Legend (data-legend="true"), built from the CSV categories */
.data-globe__legend {
  position: absolute;
  left: 12px;
  bottom: 12px;
  z-index: 1003;
  padding: 8px 12px;
  border: 1px solid rgb(160 200 240 / 0.22);
  border-radius: 8px;
  background: rgb(8 34 64 / 0.85);
  color: #eef4fb;
  font-size: 0.8rem;
}
.data-globe__legend ul {
  display: grid;
  gap: 5px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.data-globe__legend li {
  display: flex;
  align-items: center;
  gap: 9px;
}
.data-globe__legend-swatch {
  position: relative;
  flex: none;
  width: 14px;
  height: 14px;
  --size: 11px;
}
.data-globe__legend-swatch .data-globe__shape {
  left: 50%;
  top: 50%;
}
@media (max-width: 520px) {
  .data-globe__legend {
    display: none;
  }
}

/* Tooltip (hover) and popover (click) */
.data-globe__tooltip,
.data-globe__popover {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 1001;
  background: var(--data-globe-surface);
  color: var(--data-globe-text);
  border-radius: 8px;
  box-shadow: 0 6px 20px rgb(0 0 0 / 0.3);
  font-size: 0.875rem;
  line-height: 1.4;
}
.data-globe__tooltip {
  max-width: 240px;
  padding: 6px 10px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.12s;
}
.data-globe__tooltip.is-on {
  opacity: 1;
}
.data-globe__tooltip strong,
.data-globe__tooltip span {
  display: block;
}
.data-globe__tooltip-status {
  font-size: 0.75rem;
  color: var(--data-globe-muted);
}
.data-globe__popover {
  width: min(280px, calc(100% - 16px));
  padding: 12px 48px 12px 14px;
  z-index: 1002;
}
.data-globe__tooltip.is-behind,
.data-globe__popover.is-behind {
  visibility: hidden;
}
.data-globe__popover-category {
  margin: 0;
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--data-globe-muted);
}
.data-globe__popover-title {
  margin: 2px 0 4px;
  font-size: 1rem;
  line-height: 1.3;
}
.data-globe__popover-description {
  margin: 0 0 8px;
}
.data-globe__popover-link {
  font-weight: 500;
}
.data-globe__popover-close {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: inherit;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
}
.data-globe__popover-close:hover {
  background: rgb(0 0 0 / 0.06);
}

/* Zoom, reset and pause controls */
.data-globe__controls,
.data-globe__views {
  position: absolute;
  top: 12px;
  z-index: 1003;
  display: flex;
  padding: 4px;
  border-radius: 10px;
  background: var(--data-globe-surface);
  box-shadow: 0 0 0 1px rgb(0 0 0 / 0.08), 0 3px 12px rgb(0 0 0 / 0.1);
}
.data-globe__controls {
  right: 12px;
  flex-direction: column;
  gap: 2px;
}
.data-globe__views {
  left: 12px;
  gap: 2px;
}
.data-globe__btn {
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--data-globe-text);
  font: inherit;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease, scale 0.15s ease;
}
.data-globe__btn:active {
  scale: 0.96;
}
.data-globe__view {
  display: flex;
  align-items: center;
  gap: 6px;
  width: auto;
  padding: 0 12px;
  font-size: 0.8rem;
  font-weight: 600;
}
.data-globe__view[aria-pressed="true"] {
  background: rgb(var(--mg-color-neutral-50, 230 235 240));
  box-shadow: inset 0 0 0 1px rgb(0 0 0 / 0.05);
}
.data-globe__btn:hover {
  background: rgb(var(--mg-color-neutral-25, 240 243 246));
}
.data-globe__icon {
  display: block;
  width: 18px;
  height: 18px;
  margin: auto;
}
.data-globe__popover-close .data-globe__icon {
  width: 16px;
  height: 16px;
}
.data-globe__btn:focus-visible,
.data-globe__popover-close:focus-visible {
  outline: 3px solid var(--data-globe-focus);
  outline-offset: 1px;
}

.data-globe__attribution {
  margin: 4px 0 0;
  font-size: 0.7rem;
  color: var(--data-globe-muted);
}
.data-globe__attribution a {
  color: inherit;
}

/* Accessible list of the same locations */
.data-globe__list {
  margin-top: 8px;
}
/* data-list="hidden": out of sight but still read by screen readers, and shown while a keyboard
   user is inside it so focus is never invisible */
.data-globe__list--hidden:not(:focus-within) {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
.data-globe__list summary {
  cursor: pointer;
}
.data-globe__list ul {
  margin: 8px 0 0;
  padding-left: 1.25rem;
}
.data-globe__list li {
  margin-bottom: 4px;
}
.data-globe__list-item {
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  font-weight: 700;
  text-decoration: underline;
  cursor: pointer;
}
.data-globe__notice {
  padding: 8px 12px;
  border-left: 4px solid var(--data-globe-focus);
  background: #fff8e1;
  color: #3a2a00;
}

@media (prefers-reduced-motion: reduce) {
  .data-globe *,
  .data-globe *::before,
  .data-globe *::after {
    transition: none !important;
  }
}

.data-globe__callout.is-detached::after { visibility: hidden; }
