.hotspots {
  margin: 0;
}

/* the dots are positioned in percent of this wrapper, which always
   matches the image box — even when the inline card below grows the figure */
.hotspots__canvas {
  position: relative;
}

.hotspots__image {
  display: block;
  width: 100%;
  height: auto;
}

.hotspots__spot {
  position: absolute;
  transform: translate(-50%, -50%);
}

.hotspots__marker {
  position: relative;
  display: block;
  width: 1.5rem;
  height: 1.5rem;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
}

.hotspots__marker::before,
.hotspots__marker::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: currentColor;
  color: var(--hotspots-color, #023e84);
}

/* the ring stays hidden behind the dot and is emitted
   the moment the dot reaches its full size (35% of the cycle) */
.hotspots__marker::before {
  opacity: 0;
  animation: hotspots-pulse-ring 2s cubic-bezier(0.215, 0.61, 0.355, 1) infinite;
}

.hotspots__marker::after {
  box-shadow: 0 0 8px rgba(0, 0, 0, 0.3);
  animation: hotspots-pulse-dot 2s cubic-bezier(0.455, 0.03, 0.515, 0.955) infinite;
}

.hotspots__label {
  position: absolute;
  top: 50%;
  left: calc(100% + 0.625rem);
  transform: translateY(-50%);
  padding: 0.5rem 0.875rem;
  border-radius: 999px;
  background: #fff;
  color: var(--hotspots-label-color, var(--hotspots-color, #023e84));
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.hotspots__spot[data-label="left"] .hotspots__label {
  left: auto;
  right: calc(100% + 0.625rem);
}

/* an open spot paints above the tags of its neighbours */
.hotspots__spot:has(.hotspots__marker[aria-expanded="true"]) {
  z-index: 20;
}

.hotspots__popover {
  position: absolute;
  bottom: calc(100% + 0.75rem);
  left: 50%;
  z-index: 10;
  width: max-content;
  /* --hotspots-popover-max is set by the script to the width
     of the image container, so popovers never exceed it */
  max-width: min(20rem, var(--hotspots-popover-max, 80vw));
  padding: 1rem;
  border-radius: 0.375rem;
  background: #fff;
  color: #1a1a1a;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.25);
  transform: translateX(-50%);
}

.hotspots__popover-image {
  display: block;
  width: calc(100% + 2rem);
  max-width: none;
  height: auto;
  margin: -1rem -1rem 0.75rem;
  border-radius: 0.375rem 0.375rem 0 0;
}

/* instead of overflowing the image container, the popover
   snaps its left or right edge to the dot */
.hotspots__spot[data-align-x="left"] .hotspots__popover {
  left: 0;
  right: auto;
  transform: none;
}

.hotspots__spot[data-align-x="right"] .hotspots__popover {
  left: auto;
  right: 0;
  transform: none;
}

.hotspots__spot[data-align-y="bottom"] .hotspots__popover {
  bottom: auto;
  top: calc(100% + 0.75rem);
}

/* small screens: the script re-homes the open card as the last
   child of the figure, where it flows in line below the image */
.hotspots__popover.hotspots__popover--inline {
  position: static;
  width: auto;
  max-width: none;
  margin-top: 0.75rem;
  transform: none;
}

.hotspots__popover--inline .hotspots__popover-image {
  max-height: 16rem;
  object-fit: cover;
}

.hotspots__title {
  margin: 0 0 0.5rem;
  font-size: 1rem;
  font-weight: 600;
}

.hotspots__text {
  font-size: 0.875rem;
  line-height: 1.5;
}

.hotspots__text p {
  margin: 0 0 0.5rem;
}

.hotspots__text p:last-child {
  margin-bottom: 0;
}

@keyframes hotspots-pulse-ring {
  0%,
  34.9% {
    transform: scale(1);
    opacity: 0;
  }
  35% {
    transform: scale(1);
    opacity: 0.7;
  }
  100% {
    transform: scale(2.2);
    opacity: 0;
  }
}

@keyframes hotspots-pulse-dot {
  0% {
    transform: scale(0.7);
  }
  35% {
    transform: scale(1);
  }
  70%,
  100% {
    transform: scale(0.7);
  }
}

@media (prefers-reduced-motion: reduce) {
  .hotspots__marker::before {
    animation: none;
    opacity: 0;
  }

  .hotspots__marker::after {
    animation: none;
  }
}
