.info-hotspot {
  position: relative;
  pointer-events: all;
  z-index: 10;
}
.info-hotspot-header {
  cursor: pointer;
}

/* --- Migrated from side-nav.css --- */

/* Info hotspot */
.info-hotspot {
  line-height: 1.5em;
}

/* Hover-capable pointers only: on a touch screen a tap must not leave a hotspot stuck "hovered". */
@media (hover: hover) {
  .info-hotspot:hover {
    z-index: 100;
  }
}

.info-hotspot.visible {
  z-index: 100;
}

/* Size, colour, border, blur and hover come from hotspot-look.css (.hs-badge); the header only
   adds what a popup needs: clipping and growing wider when it opens. */
.info-hotspot-header {
  position: relative;
  overflow: hidden;
  cursor: pointer;
}
.hs-badge.info-hotspot-header {
  /* the badge centres its icon; an opened popup header lays icon, title and close out left to right */
  justify-content: flex-start;
  transition:
    width 0.3s ease-in-out,
    border-radius 0.3s ease-in-out,
    var(--hs-transition);
}

.desktop .info-hotspot.visible .info-hotspot-header {
  width: 320px;
  border-radius: 8px;
}

.info-hotspot-icon-wrapper {
  width: 100%;
  max-width: 40px;
  height: 100%;
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mobile .info-hotspot-icon-wrapper {
  width: 50px;
  max-width: 50px;
  height: 50px;
}

.info-hotspot-title-wrapper {
  position: absolute;
  left: 40px;
  top: 0;
  width: 0;
  height: 40px;
  padding: 0;
  overflow: hidden;
  transition:
    width 0.3s,
    padding 0.3s;
}

.desktop .info-hotspot.visible .info-hotspot-title-wrapper {
  width: 240px;
  padding: 0 12px;
}

.info-hotspot-title {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  color: #fff;
  white-space: nowrap;
  font-weight: 500;
}

.info-hotspot-close-wrapper {
  position: absolute;
  left: 280px;
  top: 0;
  height: 40px;
  width: 40px;
  background-color: rgba(255, 255, 255, 0.1);
  visibility: hidden;
  opacity: 0;
  transition:
    opacity 0.3s,
    visibility 0s 0.3s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.desktop .info-hotspot.visible .info-hotspot-close-wrapper {
  visibility: visible;
  opacity: 1;
  transition:
    opacity 0.3s,
    visibility 0s 0s;
}

.info-hotspot-close-icon {
  width: 50%;
  height: 50%;
  margin: 25%;
}

.info-hotspot-text {
  position: absolute;
  width: 320px;
  max-height: 250px;
  top: 48px;
  left: 0;
  padding: 16px;
  /* the tour's panels and text (the palette, docs/colour-palette-plan.md); the old dark bubble on a page made before it */
  background-color: var(--pal-panel, rgba(0, 0, 0, 0.85));
  border: 1px solid var(--pal-line, rgba(255, 255, 255, 0.2));
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border-radius: 8px;
  color: var(--pal-text, #ffffff);
  font-size: 0.95rem;
  overflow-y: auto;
  visibility: hidden;
  opacity: 0;
  transform: translateY(-10px);
  transition:
    opacity 0.3s,
    transform 0.3s,
    visibility 0s 0.3s;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
}

.desktop .info-hotspot.visible .info-hotspot-text {
  visibility: visible;
  opacity: 1;
  transform: translateY(0);
  transition:
    opacity 0.3s,
    transform 0.3s,
    visibility 0s 0s;
}

/* Phones: the popup rules above are .desktop-only, so a tap used to toggle .visible with no visible
   result. Mirror them for .mobile with narrower widths. Tooltip/simple/modal have their own open
   state and are left alone. */
.mobile .info-hotspot.visible:not(.info-hotspot-variant-modal):not(.info-hotspot-variant-tooltip):not(.info-hotspot-variant-simple) .info-hotspot-header {
  width: min(280px, 78vw);
  border-radius: 8px;
}
.mobile .info-hotspot.visible:not(.info-hotspot-variant-modal):not(.info-hotspot-variant-tooltip):not(.info-hotspot-variant-simple) .info-hotspot-title-wrapper {
  left: 50px;
  width: calc(min(280px, 78vw) - 100px);
  height: 50px;
  padding: 0 8px;
}
.mobile .info-hotspot.visible:not(.info-hotspot-variant-modal):not(.info-hotspot-variant-tooltip):not(.info-hotspot-variant-simple) .info-hotspot-close-wrapper {
  left: calc(min(280px, 78vw) - 50px);
  width: 50px;
  height: 50px;
  visibility: visible;
  opacity: 1;
  transition:
    opacity 0.3s,
    visibility 0s 0s;
}
.mobile .info-hotspot.visible:not(.info-hotspot-variant-modal):not(.info-hotspot-variant-tooltip):not(.info-hotspot-variant-simple) .info-hotspot-text {
  visibility: visible;
  opacity: 1;
  transform: translateY(0);
  top: 58px;
  width: min(280px, 78vw);
  max-height: 40vh;
  transition:
    opacity 0.3s,
    transform 0.3s,
    visibility 0s 0s;
}

/* Custom Variants for Info Hotspots */

.desktop .info-hotspot-variant-tooltip.visible .info-hotspot-header {
  width: var(--hs-badge);
  border-radius: 50%;
}
.info-hotspot-variant-tooltip .info-tooltip {
  position: absolute;
  bottom: 55px;
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  background: var(--pal-panel, rgba(11, 25, 44, 0.98));
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  color: var(--pal-text, #fff);
  padding: 14px 18px;
  border-radius: 10px;
  font-size: 14px;
  line-height: 1.5;
  white-space: normal;
  min-width: 200px;
  max-width: 320px;
  opacity: 0;
  visibility: hidden;
  transition:
    opacity 0.3s ease,
    transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275),
    visibility 0.3s;
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.5);
  border: 1px solid var(--pal-line, rgba(255, 255, 255, 0.15));
  pointer-events: none;
  z-index: 100;
}
/* A tooltip shows when tapped open, hovered (pointers that can hover) or reached with the keyboard.
   :is() ignores a selector the browser does not understand instead of dropping the whole rule. */
:is(.info-hotspot-variant-tooltip.visible, .info-hotspot-variant-tooltip:has(:focus-visible)) .info-tooltip {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}
@media (hover: hover) {
  .info-hotspot-variant-tooltip:hover .info-tooltip {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
  }
}

/* Modal Variant & General SVG fix */
.info-hotspot-icon,
.info-hotspot-close-icon {
  width: 44px;
  height: 44px;
}
svg.info-hotspot-close-icon {
  color: #fff;
}
/* The pulsing variant's ring is .hs-pulse in hotspot-look.css */

/* Media styling inside popups/tooltips */
.info-hotspot-media {
  width: 100%;
  border-radius: 6px;
  margin-bottom: 12px;
  max-height: 200px;
  object-fit: contain;
  background: rgba(0, 0, 0, 0.2);
}

.info-hotspot-modal .info-hotspot-media {
  max-height: 45vh;
}

/* Global Modular Popup Structure */
.info-hotspot-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  padding: 16px;
  visibility: hidden;
  opacity: 0;
  transition:
    opacity 0.3s ease,
    visibility 0s 0.3s;
  pointer-events: none;
}
.info-hotspot-modal.visible {
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
  transition:
    opacity 0.3s ease,
    visibility 0s 0s;
}

/* Redefine internal elements for the modal context instead of the hotspot panel context */
.info-hotspot-modal .info-hotspot-header {
  position: relative;
  width: 100%;
  max-width: 500px;
  height: 60px;
  border-radius: 12px 12px 0 0;
  background-color: #2d2f33;
  box-shadow: none;
  cursor: default;
}
.info-hotspot-modal:hover .info-hotspot-header {
  width: 100%;
  max-width: 500px;
  border-radius: 12px 12px 0 0;
  cursor: default;
}

.info-hotspot-modal .info-hotspot-icon-wrapper {
  display: none;
}

.info-hotspot-modal .info-hotspot-title-wrapper {
  inset-inline-start: 0;
  width: 100%;
  padding: 0 20px;
}
.info-hotspot-modal:hover .info-hotspot-title-wrapper {
  width: 100%;
  padding: 0 20px;
}

.info-hotspot-modal .info-hotspot-title {
  inset-inline-start: 20px;
  position: absolute;
  font-size: 1.125rem;
  font-weight: 600;
}

.info-hotspot-modal .info-hotspot-close-wrapper {
  inset-inline-start: auto;
  inset-inline-end: 12px;
  top: 10px;
  background: transparent;
  visibility: visible;
  opacity: 1;
  cursor: pointer;
  transition: color 0.2s;
  color: #9ca3af;
}
.info-hotspot-modal .info-hotspot-close-wrapper:hover {
  color: #fff;
}
.info-hotspot-modal:hover .info-hotspot-close-wrapper {
  visibility: visible;
}

.info-hotspot-modal .info-hotspot-close-icon {
  margin: 0;
  width: 24px;
  height: 24px;
}

.info-hotspot-modal .info-hotspot-text {
  position: relative;
  box-sizing: border-box;
  top: 0;
  width: 100%;
  max-width: 500px;
  max-height: 70vh;
  border-radius: 0 0 12px 12px;
  background-color: #1e1f22;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  visibility: visible;
  opacity: 1;
  transform: none;
  text-align: start;
  border: 1px solid #4b5563;
  border-top: none;
  padding: 20px;
  font-size: 0.95rem;
  color: #d1d5db;
  white-space: pre-wrap;
}
.info-hotspot-modal:hover .info-hotspot-text {
  visibility: visible;
  opacity: 1;
  transform: none;
}

.desktop .info-hotspot-variant-simple.visible .info-hotspot-header {
  width: var(--hs-badge);
  border-radius: 50%;
}
.info-hotspot-variant-simple .simple-tooltip-label {
  position: absolute;
  bottom: 45px;
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  background: var(--pal-panel, rgba(0, 0, 0, 0.85));
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  color: var(--pal-text, #fff);
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transition:
    opacity 0.2s ease,
    transform 0.2s ease,
    visibility 0.2s;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
  border: 1px solid var(--pal-line, rgba(255, 255, 255, 0.2));
  pointer-events: none;
  z-index: 100;
}
:is(.info-hotspot-variant-simple.visible, .info-hotspot-variant-simple:has(:focus-visible)) .simple-tooltip-label {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}
@media (hover: hover) {
  .info-hotspot-variant-simple:hover .simple-tooltip-label {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
  }
}

/* The classic "original" PNG icons (the badge itself is styled in hotspot-look.css) */
img.info-hotspot-close-icon {
  width: 70% !important;
  height: 70% !important;
  margin: 15% !important;
  max-width: none !important;
  filter: brightness(0) invert(1) !important;
}

/* Custom icons (uploaded images or pasted SVG) fill the hotspot icon box */
.hs-custom-icon {
  display: inline-flex;
  width: 100%;
  height: 100%;
  align-items: center;
  justify-content: center;
}
.hs-custom-icon svg,
.hs-custom-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
