/* Animated Hotspots — Public-Viewer DOM-Layer.
   Spiegelt die styles aus
     frontend/src/components/viewer/hotspots-animated/MarkerTextOverlay.tsx (styled-jsx)
   Tokens kommen aus viewer-tokens.css (--vp-hs-*). */

.vp-hs-overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 1;
}
.vp-hs-overlay > * { pointer-events: auto; }

/* ── ICON Anchor + Heroicons-i + Hover-Card ──────────────────────── */
.vp-hs-info-anchor {
    --s: var(--vp-hs-scale, 1);
    position: absolute;
    left: 0;
    top: 0;
    width: calc(44px * var(--s));
    height: calc(44px * var(--s));
    pointer-events: auto;
    cursor: pointer;
    will-change: transform, opacity;
}
.vp-hs-info-glyph {
    position: absolute;
    left: 50%;
    top: 50%;
    width: calc(33px * var(--s));
    height: calc(33px * var(--s));
    transform: translate(-50%, -50%);
    color: var(--vp-hs-ink);
    pointer-events: none;
    z-index: 1;
}
.vp-hs-info-card {
    position: absolute;
    left: 50%;
    bottom: calc(100% + 14px);
    transform: translateX(-50%) translateY(8px);
    transform-origin: bottom center;
    width: 236px;
    background: var(--vp-hs-glass-strong);
    -webkit-backdrop-filter: var(--vp-hs-blur);
    backdrop-filter: var(--vp-hs-blur);
    border: 1px solid var(--vp-hs-glass-line);
    border-radius: 14px;
    box-shadow: var(--vp-hs-sh);
    padding: 14px 16px;
    opacity: 0;
    pointer-events: none;
    transition: 0.26s cubic-bezier(0.2, 0.8, 0.2, 1);
    z-index: 2;
}
.vp-hs-info-anchor:hover .vp-hs-info-card {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}
.vp-hs-info-card::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    width: 18px;
    height: 9px;
    margin-top: -1px;
    background: #171c28;
    clip-path: polygon(0 0, 100% 0, 50% 100%);
}
:root.vp-light .vp-hs-info-card::after,
.vp-light .vp-hs-info-card::after,
body.light .vp-hs-info-card::after {
    background: #f7f9fb;
}
.vp-hs-info-card .eye {
    font-family: "JetBrains Mono", ui-monospace, monospace;
    font-size: 9px;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--vp-hs-ink-dim);
    margin: 0;
}
.vp-hs-info-card h4 {
    margin: 4px 0 5px;
    font-family: "Onest", system-ui, sans-serif;
    font-weight: 600;
    font-size: 15px;
    color: var(--vp-hs-ink);
    letter-spacing: -0.01em;
    line-height: 1.2;
}
.vp-hs-info-card p {
    margin: 0;
    font-size: 12px;
    line-height: 1.5;
    color: var(--vp-hs-ink-dim);
}

/* ── Expanded ICON-Card (click-mode, smart-placement) ────────────── */
.vp-hs-info-expanded {
    position: absolute;
    width: 400px;
    background: var(--vp-hs-glass-strong);
    -webkit-backdrop-filter: var(--vp-hs-blur);
    backdrop-filter: var(--vp-hs-blur);
    border: 1px solid var(--vp-hs-glass-line);
    border-radius: 16px;
    box-shadow: var(--vp-hs-sh);
    padding: 18px 20px 20px;
    pointer-events: auto;
    cursor: default;
    z-index: 10;
    color: var(--vp-hs-ink);
    animation: vp-hs-expand-in 0.22s cubic-bezier(0.2, 0.8, 0.2, 1);
}
@keyframes vp-hs-expand-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}
.vp-hs-info-expanded[data-arrow-side="left"]::before {
    content: "";
    position: absolute;
    top: var(--arrow-y, 50%);
    left: 0;
    transform: translate(-100%, -50%);
    width: 11px;
    height: 22px;
    margin-left: 1px;
    background: var(--vp-hs-glass-strong);
    clip-path: polygon(100% 0, 100% 100%, 0 50%);
}
.vp-hs-info-expanded[data-arrow-side="right"]::before {
    content: "";
    position: absolute;
    top: var(--arrow-y, 50%);
    right: 0;
    transform: translate(100%, -50%);
    width: 11px;
    height: 22px;
    margin-right: 1px;
    background: var(--vp-hs-glass-strong);
    clip-path: polygon(0 0, 0 100%, 100% 50%);
}
.vp-hs-info-expanded .close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(255,255,255,0.06);
    border: 1px solid var(--vp-hs-glass-line);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--vp-hs-ink);
    transition: background 0.15s;
    padding: 0;
}
:root.vp-light .vp-hs-info-expanded .close,
.vp-light .vp-hs-info-expanded .close,
body.light .vp-hs-info-expanded .close {
    background: rgba(0,0,0,0.04);
}
.vp-hs-info-expanded .close:hover { background: rgba(255,255,255,0.13); }
:root.vp-light .vp-hs-info-expanded .close:hover,
.vp-light .vp-hs-info-expanded .close:hover,
body.light .vp-hs-info-expanded .close:hover { background: rgba(0,0,0,0.08); }
.vp-hs-info-expanded .media {
    display: block;
    width: 100%;
    height: 200px;
    object-fit: cover;
    border-radius: 10px;
    margin-bottom: 14px;
    background: rgba(0,0,0,0.20);
}
.vp-hs-info-expanded video.media { background: #000; }
.vp-hs-info-expanded .eye {
    font-family: "JetBrains Mono", ui-monospace, monospace;
    font-size: 10px;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--vp-hs-ink-dim);
    margin: 0;
}
.vp-hs-info-expanded h3 {
    margin: 6px 0 8px;
    font-family: "Onest", system-ui, sans-serif;
    font-weight: 600;
    font-size: 18px;
    color: var(--vp-hs-ink);
    letter-spacing: -0.01em;
    line-height: 1.25;
    padding-right: 36px;
}
.vp-hs-info-expanded p {
    margin: 0;
    font-size: 13px;
    line-height: 1.6;
    color: var(--vp-hs-ink-dim);
    white-space: pre-wrap;
}

/* ── TAG-Pille (always-on, komplett DOM) ─────────────────────────── */
.vp-hs-tag-pill {
    --s: var(--vp-hs-scale, 1);
    position: absolute;
    left: 0;
    top: 0;
    display: flex;
    align-items: center;
    gap: calc(6px * var(--s));
    padding: calc(6px * var(--s)) calc(12px * var(--s)) calc(6px * var(--s)) calc(8px * var(--s));
    background: var(--vp-hs-glass-strong);
    -webkit-backdrop-filter: var(--vp-hs-blur);
    backdrop-filter: var(--vp-hs-blur);
    border: 1px solid var(--vp-hs-glass-line);
    border-radius: calc(13px * var(--s));
    box-shadow: var(--vp-hs-sh);
    color: var(--vp-hs-ink);
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
    pointer-events: auto;
    will-change: transform, opacity;
    transform-origin: bottom center;
}
.vp-hs-tag-pill .pin {
    width: calc(22px * var(--s));
    height: calc(22px * var(--s));
    border-radius: calc(6px * var(--s));
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--vp-hs-glass);
    border: 1px solid var(--vp-hs-glass-line);
}
.vp-hs-tag-pill .pin svg {
    width: calc(13px * var(--s));
    height: calc(13px * var(--s));
}
.vp-hs-tag-pill .txt {
    display: flex;
    flex-direction: column;
    line-height: 1.15;
}
.vp-hs-tag-pill .eye {
    font-family: "JetBrains Mono", ui-monospace, monospace;
    font-size: calc(8px * var(--s));
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--vp-hs-ink-dim);
}
.vp-hs-tag-pill .ttl {
    font-family: "Onest", system-ui, sans-serif;
    font-weight: 600;
    font-size: calc(13px * var(--s));
    margin-top: calc(1px * var(--s));
    letter-spacing: -0.01em;
}

/* ══ Hover-Titel an Hotspots ═════════════════════════════════════════════
   Gilt fuer ALLE Marker-Arten, nicht nur die animierten: klassische Marken,
   Flaechen und die animierten Stile teilen sich dieses eine Fenster.
   Das Gegenstueck im Editor steht in
   `frontend/src/components/viewer/three/HotspotTooltip.tsx` — Aenderungen
   hier gehoeren dort ebenfalls hinein, sonst zeigt die Vorschau etwas
   anderes als die fertige Tour.

   Vier Ebenen mit je einer Aufgabe:
     .vp-hs-tip         — die Position am Marker (kein Uebergang, sonst
                          schleppt sich das Fenster beim Drehen hinterher)
     .vp-hs-tip__anchor — das feste Ausrichten (ueber/unter dem Marker)
     .vp-hs-tip__box    — der Kasten: waechst aus der Marke heraus
     .vp-hs-tip__label  — der Text: kommt einen Wimpernschlag spaeter
   Getrennt, damit die Einblendung nie mit der Positionsverfolgung kollidiert.
   Bewegt werden ausschliesslich Transform und Deckkraft — kein Blur (der
   Compositor rechnete ihn sonst pro Bild neu) und keine Groessen. */
.vp-hs-tip {
    position: absolute;
    left: 0;
    top: 0;
    z-index: 9998;
    pointer-events: none;
    opacity: 0;
    --vp-tip-in: 180ms;
    --vp-tip-out: 120ms;
    --vp-tip-stagger: 40ms;
    /* Aufgehen: schnell los, weich aus — ohne Ueberschwingen.
       Zugehen: flach und kurz, es soll wegfallen, nicht zurueckkriechen. */
    --vp-tip-ease-in: cubic-bezier(0.16, 1, 0.3, 1);
    --vp-tip-ease-out: cubic-bezier(0.4, 0, 1, 1);
    --vp-tip-rest-y: 4px;
    --vp-tip-label-y: 3px;
    /* Wachstumspunkt ist die markerseitige Kante — das Fenster kommt damit aus
       der Marke heraus statt daneben zu erscheinen. */
    --vp-tip-origin: bottom center;
}
.vp-hs-tip[data-side="bottom"] {
    --vp-tip-rest-y: -4px;
    --vp-tip-label-y: -3px;
    --vp-tip-origin: top center;
}
/* Eigene Zeichenebene nur solange etwas zu sehen ist. Ein Dauer-Layer fuer ein
   meist unsichtbares Element waere Ballast. */
.vp-hs-tip.is-visible,
.vp-hs-tip.is-closing {
    will-change: transform;
}
.vp-hs-tip__anchor {
    position: absolute;
    left: 0;
    top: 0;
    transform: translate(-50%, -100%);
    pointer-events: none;
}
.vp-hs-tip[data-side="bottom"] .vp-hs-tip__anchor {
    transform: translate(-50%, 0);
}
/* Ruhestellung = Ausgangspunkt des Aufgehens. Ohne Uebergang: hierher kehrt
   das Fenster nur zurueck, wenn es ohnehin schon unsichtbar ist. */
.vp-hs-tip__box {
    display: block;
    max-width: 260px;
    overflow: hidden;
    padding: 7px 11px;
    border-radius: 11px;
    background: var(--vp-hs-glass-strong);
    border: 1px solid var(--vp-hs-glass-line);
    box-shadow: var(--vp-hs-sh);
    -webkit-backdrop-filter: var(--vp-hs-blur);
    backdrop-filter: var(--vp-hs-blur);
    color: var(--vp-hs-ink);
    transform-origin: var(--vp-tip-origin);
    transform: translateY(var(--vp-tip-rest-y)) scale(0.9);
    opacity: 0;
    transition: none;
}
.vp-hs-tip__label {
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-family: "Onest", system-ui, -apple-system, sans-serif;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.25;
    letter-spacing: -0.01em;
    transform: translateY(var(--vp-tip-label-y));
    opacity: 0;
    transition: none;
}
/* ── Aufgehen ── */
.vp-hs-tip.is-visible .vp-hs-tip__box {
    transform: translateY(0) scale(1);
    opacity: 1;
    transition: transform var(--vp-tip-in) var(--vp-tip-ease-in),
                opacity var(--vp-tip-in) var(--vp-tip-ease-in);
    will-change: transform, opacity;
}
/* Der Text kommt einen Wimpernschlag nach dem Kasten. */
.vp-hs-tip.is-visible .vp-hs-tip__label {
    transform: translateY(0);
    opacity: 1;
    transition: transform var(--vp-tip-in) var(--vp-tip-ease-in) var(--vp-tip-stagger),
                opacity var(--vp-tip-in) var(--vp-tip-ease-in) var(--vp-tip-stagger);
    will-change: transform, opacity;
}
/* ── Zugehen ── kein Rueckweg, keine Staffelung: alles faellt gemeinsam weg,
   der Kasten schrumpft nur einen Hauch. */
.vp-hs-tip.is-closing .vp-hs-tip__box {
    transform: translateY(0) scale(0.96);
    opacity: 0;
    transition: transform var(--vp-tip-out) var(--vp-tip-ease-out),
                opacity var(--vp-tip-out) var(--vp-tip-ease-out);
    will-change: transform, opacity;
}
.vp-hs-tip.is-closing .vp-hs-tip__label {
    transform: translateY(0);
    opacity: 0;
    transition: opacity var(--vp-tip-out) var(--vp-tip-ease-out);
}
/* Auf schmalen Bildschirmen darf der Titel nicht die halbe Szene zudecken. */
@media (max-width: 640px) {
    .vp-hs-tip__box {
        max-width: 62vw;
        padding: 6px 10px;
    }
    .vp-hs-tip__label {
        font-size: 12px;
    }
}
/* Ohne Zeigergeraet gibt es kein Ueberfahren — dort bleibt das Fenster aus.
   Zweite Absicherung; die Logik in viewer.js prueft dasselbe. */
@media (hover: none) {
    .vp-hs-tip { display: none; }
}
/* Wer wenig Bewegung will, bekommt nur eine Ueberblendung: keine Skalierung,
   kein Versatz, keine Staffelung. */
@media (prefers-reduced-motion: reduce) {
    .vp-hs-tip__box,
    .vp-hs-tip__label,
    .vp-hs-tip.is-visible .vp-hs-tip__box,
    .vp-hs-tip.is-visible .vp-hs-tip__label,
    .vp-hs-tip.is-closing .vp-hs-tip__box,
    .vp-hs-tip.is-closing .vp-hs-tip__label {
        transform: none;
        transition: opacity 0.1s linear;
    }
}
