/* ==========================================================================
Hotspot-Bild: zentrierte Grafik mit interaktiven Punkten. Beim Überfahren (bzw.
bei Tastaturfokus) eines Punktes erscheint ein Tooltip mit Bildausschnitt und
Text – standardmäßig über dem Punkt, per .popup-below darunter, wenn oben kein
Platz ist.

Markup:
  <div class="hotspot-figure"
       style="--hotspot-image: url('../img/foo.png')"
       data-img-width="2303" data-img-height="1538">
    <img src="img/foo.png" alt="…" />

--hotspot-image: der url()-Pfad wird relativ zu DIESER Datei (css/) aufgelöst,
nicht relativ zum HTML-Dokument – daher ../img/ und nicht img/. Das <img src>
dagegen ist relativ zum HTML-Dokument.
    <div class="hotspots" aria-label="…">
      <div class="hotspot" data-x="32" data-y="25">
        <button type="button" class="hotspot-point" aria-describedby="hs-1" aria-label="…"></button>
        <div class="hotspot-popup" id="hs-1" role="tooltip">
          <div class="hotspot-preview" aria-hidden="true"></div>
          <div class="hotspot-popup-body"><h3>…</h3><p>…</p></div>
        </div>
      </div>
    </div>
  </div>

--hotspot-image  Bildquelle für den Vorschau-Ausschnitt (identisch zum <img>).
data-x/data-y    Punktposition in Prozent der Bildfläche.
data-img-width/  native Pixelmaße des Bildes; nötig, um den Vorschau-Ausschnitt
data-img-height  auf den Punkt zu zentrieren (Fallback: img.naturalWidth/Height).

Ein-/Ausblenden übernimmt CSS (:hover / :focus-within). js/hotspot-figure.js
berechnet Punktpositionen, Klappseite (.popup-below) und den Vorschau-Ausschnitt.
========================================================================== */

.hotspot-figure {
    position: relative;
    text-align: center;
    margin-top: 2rem;

    img {
        max-height: 75vh;
        max-width: 100%;
    }
}

/* Hotspots: Overlay über der gesamten .hotspot-figure-Fläche; js berechnet
   left/top je Punkt anhand der tatsächlich gerenderten Bildgröße. */
.hotspot-figure .hotspots {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

/* Hotspot = unsichtbarer Anker auf dem Bild; enthält den sichtbaren Punkt und
   den Tooltip. left/top setzt das js, die negativen margins zentrieren die Box
   auf den Punkt. */
.hotspot-figure .hotspot {
    position: absolute;
    width: 1rem;
    height: 1rem;
    margin: -0.5rem 0 0 -0.5rem;
    pointer-events: auto;
    z-index: 5;
}

.hotspot-figure .hotspot:hover,
.hotspot-figure .hotspot:focus-within {
    z-index: 30;
}

.hotspot-figure .hotspot-point {
    position: absolute;
    inset: 0;
    margin: 0;
    padding: 0;
    border: none;
    background: transparent;
    cursor: pointer;

    &:before,
    &:after {
        content: '';
        position: absolute;
        inset: 0;
        border-radius: 50%;
        background: var(--accent);
    }

    &:before {
        box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.85), 0 2px 8px rgba(0, 0, 0, 0.35);
        transition: transform 0.2s ease, background 0.2s ease;
    }

    &:after {
        opacity: 0.45;
        animation: hotspot-pulse 2.2s ease-out infinite;
    }
}

.hotspot-figure .hotspot:hover .hotspot-point:before,
.hotspot-figure .hotspot:focus-within .hotspot-point:before {
    transform: scale(1.35);
    background: var(--accent-dark);
}

@keyframes hotspot-pulse {
    0% {
        transform: scale(1);
        opacity: 0.45;
    }

    100% {
        transform: scale(2.4);
        opacity: 0;
    }
}

/* Tooltip: nimmt den größten Teil der Bildbreite ein, Bild links (quadratisch),
   Text rechts. Standardmäßig über dem Punkt; .popup-below (js) klappt ihn
   darunter. Die horizontale Verschiebung --popup-shift (js) hält ihn im Bild. */
.hotspot-figure .hotspot-popup {
    position: absolute;
    left: 50%;
    bottom: calc(100% + 0.75rem);
    transform: translateX(calc(-50% + var(--popup-shift, 0px)));

    width: min(44rem, 82vw);

    display: flex;
    align-items: flex-start;
    gap: 1.25rem;

    padding: 1.1rem;
    border-radius: 0.6em;
    background: var(--white);
    color: #494949;
    box-shadow: 0 16px 44px rgba(0, 0, 0, 0.28);

    opacity: 0;
    visibility: hidden;
    transition: opacity 0.18s ease, visibility 0.18s ease;
}

.hotspot-figure .hotspot:hover .hotspot-popup,
.hotspot-figure .hotspot:focus-within .hotspot-popup {
    opacity: 1;
    visibility: visible;
}

.hotspot-figure .hotspot.popup-below .hotspot-popup {
    bottom: auto;
    top: calc(100% + 0.75rem);
}

/* Quadratischer Ausschnitt der Grafik, zentriert auf den Punkt. Größe und Zoom
   hängen zusammen: js skaliert background-size mit PREVIEW_SCALE (= 9rem/12rem),
   sodass trotz kleinerer Box derselbe Bildausschnitt sichtbar bleibt.
   background-size und -position setzt das js. */
.hotspot-figure .hotspot-preview {
    width: 9rem;
    height: 9rem;
    flex-shrink: 0;
    border-radius: 0.4em;
    background-image: var(--hotspot-image);
    background-color: var(--white);
    background-repeat: no-repeat;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.1);
}

.hotspot-figure .hotspot-popup-body {
    min-width: 0;
    text-align: justify;

    h3 {
        color: var(--title);
        font-weight: 500;
        font-size: 0.95rem;
        margin: 0 0 0.4rem;
    }

    p {
        font-size: 0.78rem;
        line-height: 1.5;
        margin: 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    .hotspot-figure .hotspot-point:after {
        animation: none;
    }
}
