/* ==========================================================================
   Totem-Show: animierte Abfolge fuer den Totem V2.
   Aufbau und Ablauf macht js/totem-show.js (WebGL). Ohne WebGL oder ohne
   JavaScript bleibt das Ersatzbild (.ts-fallback) stehen.

   <figure class="totem-show">
       <div class="ts-stage">   Bild, Video, Zeichenflaeche, Stichwort   </div>
       <figcaption class="ts-panel">   Muster, Farben, Blaetter   </figcaption>
   </figure>
   ========================================================================== */

.totem-show {
    display: block;
    width: 100%;
    margin: 0 auto;
}

/* Vor dem Aufbau liegt das Ersatzbild direkt in der Figur */
.totem-show > .ts-fallback {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 800 / 1026;
    object-fit: contain;
}

.ts-stage {
    position: relative;
    width: 100%;
    aspect-ratio: 800 / 1026;
    overflow: hidden;
}

.ts-stage > .ts-fallback,
.ts-stage > .ts-video,
.ts-stage > .ts-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
}

.ts-stage > .ts-fallback {
    object-fit: contain;
    transition: opacity 0.6s ease;
}

.ts-stage > .ts-canvas {
    opacity: 0;
    transition: opacity 0.6s ease;
}

.totem-show.ts-ready .ts-canvas {
    opacity: 1;
}

.totem-show.ts-ready .ts-fallback {
    opacity: 0;
}

/* Montage-Video (Teil 1) liegt unter der Zeichenflaeche und ist nur in Teil 1 zu sehen */
.ts-stage > .ts-video {
    /* Das Video fuellt die Buehne exakt wie die Zeichenflaeche, damit beim Wechsel nichts springt.
       Es ist dafuer auf 544 x 704 gebaut (Vielfache von 16) und wird hier auf das Seitenverhaeltnis gestreckt. */
    object-fit: fill;
    opacity: 0;
    transition: opacity 0.5s ease;
    pointer-events: none;
}

.totem-show.ts-montage .ts-video {
    opacity: 1;
}

.totem-show.ts-ready.ts-montage .ts-canvas {
    opacity: 0;
}

/* Stichwort zum laufenden Abschnitt (Montage, Licht aus). Waehrend der Muster leer. */
.ts-status {
    position: absolute;
    left: 50%;
    bottom: 8px;
    transform: translateX(-50%);
    max-width: calc(100% - 16px);
    padding: 3px 10px;
    border-radius: 9999px;
    background: rgba(6, 6, 8, 0.78);
    border: 1px solid rgba(0, 240, 255, 0.28);
    color: #ffffff;
    font-family: var(--font-mono, 'Space Grotesk', monospace);
    font-size: 0.68rem;
    letter-spacing: 0.03em;
    line-height: 1.4;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    pointer-events: none;
    transition: opacity 0.4s ease;
}

.ts-status.is-empty {
    opacity: 0;
}

/* Schild oben links: der Montageschritt, den das Montage-Video gerade zeigt */
.ts-step {
    position: absolute;
    top: 10px;
    left: 10px;
    max-width: calc(100% - 20px);
    padding: 4px 10px;
    border-radius: 9999px;
    background: rgba(6, 6, 8, 0.82);
    border: 1px solid rgba(0, 240, 255, 0.45);
    color: #ffffff;
    font-family: var(--font-mono, 'Space Grotesk', monospace);
    font-size: 0.66rem;
    font-weight: 500;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    pointer-events: none;
    transition: opacity 0.35s ease;
}

.ts-step.is-empty {
    opacity: 0;
}

/* Bedienfeld unter dem Bild */
.ts-panel {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 6px;
    background: rgba(12, 12, 18, 0.9);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.ts-row {
    display: flex;
    align-items: center;
    gap: 4px;
}

.ts-key {
    flex: 0 0 52px;
    font-family: var(--font-mono, 'Space Grotesk', monospace);
    font-size: 0.62rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-muted, #8e8e96);
}

.ts-val {
    flex: 1 1 auto;
    min-width: 0;
    color: #ffffff;
    font-family: var(--font-mono, 'Space Grotesk', monospace);
    font-size: 0.72rem;
    letter-spacing: 0.02em;
    line-height: 1.3;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ts-btn {
    flex: 0 0 auto;
    width: 30px;
    height: 30px;
    padding: 0;
    border-radius: 50%;
    background: rgba(30, 30, 42, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.22);
    color: #ffffff;
    font-size: 1.05rem;
    line-height: 1;
    display: grid;
    place-items: center;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.ts-btn:hover {
    background: #ffffff;
    color: #000000;
    border-color: #ffffff;
}

/* Montage von vorn: klar beschrifteter Knopf unter den Zeilen (nur mit Montage-Video) */
.ts-replay {
    margin-top: 2px;
    padding: 8px 12px;
    border-radius: 8px;
    background: rgba(30, 30, 42, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.22);
    color: #ffffff;
    font-family: var(--font-mono, 'Space Grotesk', monospace);
    font-size: 0.74rem;
    letter-spacing: 0.03em;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.ts-replay:hover {
    background: #ffffff;
    color: #000000;
    border-color: #ffffff;
}

.ts-replay:focus-visible {
    outline: 2px solid #00f0ff;
    outline-offset: 2px;
}

/* Die Automatik hat in dieser Zeile weitergeschaltet: der Knopf leuchtet einmal auf */
.ts-btn.ts-flash {
    animation: tsFlash 0.9s ease-out 1;
}

@keyframes tsFlash {
    0% {
        background: #00f0ff;
        border-color: #00f0ff;
        color: #000000;
        box-shadow: 0 0 0 0 rgba(0, 240, 255, 0.9), 0 0 14px rgba(0, 240, 255, 0.9);
    }
    60% {
        background: rgba(0, 240, 255, 0.55);
        border-color: #00f0ff;
        color: #000000;
    }
    100% {
        box-shadow: 0 0 0 9px rgba(0, 240, 255, 0), 0 0 0 rgba(0, 240, 255, 0);
    }
}

/* Automatik an und aus */
.ts-auto {
    margin-top: 2px;
    padding: 7px 12px;
    border-radius: 8px;
    background: rgba(30, 30, 42, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.22);
    color: #ffffff;
    font-family: var(--font-mono, 'Space Grotesk', monospace);
    font-size: 0.72rem;
    letter-spacing: 0.03em;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.ts-auto.is-on {
    border-color: rgba(0, 240, 255, 0.6);
    color: #9ff6ff;
}

.ts-auto:hover {
    background: #ffffff;
    color: #000000;
    border-color: #ffffff;
}

.ts-btn:focus-visible,
.ts-auto:focus-visible {
    outline: 2px solid #00f0ff;
    outline-offset: 2px;
}
