/*
 * Tokens der Bildergalerie (--gallery-*)
 *
 * Eine Stelle für Hauptgalerie der Detailseite (reader/gallery.html.twig),
 * diese Lightbox und die Großansicht des Widgets: Wer eine Farbe, Größe oder
 * Ecke ändert, ändert sie hier, und alle drei folgen.
 *
 *   -overlay-bg / -overlay-grid-bg / -overlay-large-bg   Hintergrund der drei Ebenen
 *   -tile-bg, -stage-item-bg                              Grund hinter Bildkacheln
 *   -control-bg(-hover|-mobile), -control-border(-hover),
 *   -control-shadow(-hover), -control-backdrop-blur       Knöpfe Schließen und Pfeile
 *   -close-size(-mobile), -close-font-size                Größe des Schließen-Knopfs
 *   -nav-size(-mobile), -nav-icon-size                    Größe der Pfeile
 *   -thumbs-bottom-spacing-mobile                         Abstand der Bildleiste unten (Telefon)
 *   -photo-count-*                                        Fotozähler und Knopf auf der Bühne
 *   -thumb-*, -image-radius                               Ecken von Vorschaubild und Bild
 *   -gap, -stage-height                                   Abstand und Höhe der Bühne
 *   -caption-color, -caption-font-size, -caption-space    Bildunterschrift in der Großansicht (Platz für zwei Zeilen)
 *   -caption-gap                                          Abstand zwischen Bild und Bildunterschrift
 */
:root {
    --gallery-gap: var(--space-2, 0.5rem);
    --gallery-stage-height: clamp(420px, 36vh, 560px);

    --gallery-overlay-bg: rgba(0, 0, 0, 0.9);
    --gallery-overlay-grid-bg: rgba(0, 0, 0, 0.92);
    --gallery-overlay-large-bg: rgba(0, 0, 0, 0.96);

    --gallery-tile-bg: #222;
    --gallery-stage-item-bg: #111;

    --gallery-control-bg: rgba(255, 255, 255, 0.12);
    --gallery-control-bg-hover: rgba(255, 255, 255, 0.2);
    --gallery-control-bg-mobile: rgba(255, 255, 255, 0.14);
    --gallery-control-border: rgba(255, 255, 255, 0.22);
    --gallery-control-border-hover: rgba(255, 255, 255, 0.35);
    --gallery-control-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
    --gallery-control-shadow-hover: 0 12px 30px rgba(0, 0, 0, 0.34);
    --gallery-control-backdrop-blur: 10px;

    --gallery-close-size: 3rem;
    --gallery-close-size-mobile: 40px;
    --gallery-close-font-size: 18px;

    --gallery-nav-size: 44px;
    --gallery-nav-size-mobile: 40px;
    --gallery-nav-icon-size: 20px;
    --gallery-thumbs-bottom-spacing-mobile: 8px;

    --gallery-photo-count-bg: rgba(0, 0, 0, 0.65);
    --gallery-photo-count-bg-hover: rgba(0, 0, 0, 0.8);
    --gallery-photo-count-radius: var(--border-radius, 8px);
    --gallery-photo-count-font-size: 14px;

    --gallery-thumb-active-outline: 2px solid var(--white, #fff);
    --gallery-thumb-radius: 6px;
    --gallery-image-radius: 10px;

    --gallery-caption-color: rgba(255, 255, 255, 0.92);
    --gallery-caption-font-size: 16px;
    --gallery-caption-space: 64px;
    --gallery-caption-gap: 0.25rem;
}

@media (max-width: 768px) {
    :root {
        --gallery-stage-height: clamp(260px, 42vh, 360px);
    }
}

/* Die gemeinsame Lightbox (lightbox.js). */

[data-lightbox] {
    cursor: zoom-in;
}

.lightbox {
    position: fixed;
    inset: 0;
    z-index: 1200;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    padding: 48px 0 16px;
    background: var(--gallery-overlay-large-bg, rgba(0, 0, 0, .96));
}

.lightbox[hidden] {
    display: none;
}

.lightbox__stage {
    margin: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: min(92vw, 1200px);
    flex: 1 1 auto;
    min-height: 0;
}

.lightbox__stage img {
    max-width: 100%;
    max-height: calc(100vh - 12rem);
    width: auto;
    height: auto;
    object-fit: contain;
    background: #fff;
    border-radius: var(--radius-image, var(--radius-tile, 10px));
}

.lightbox__stage figcaption {
    margin: 8px 0;
    color: #fff;
    font-size: .9rem;
    text-align: center;
}

.lightbox__close,
.lightbox__nav {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    color: #fff;
    background: var(--gallery-control-bg, rgba(255, 255, 255, .12));
    border: 1px solid var(--gallery-control-border, rgba(255, 255, 255, .22));
    border-radius: var(--border-radius, 8px);
    box-shadow: var(--gallery-control-shadow, 0 8px 24px rgba(0, 0, 0, .28));
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    transition: background .2s ease, border-color .2s ease;
}

.lightbox__close[hidden],
.lightbox__nav[hidden],
.lightbox__counter[hidden] {
    display: none;
}

@media (hover: hover) {
    .lightbox__close:hover,
    .lightbox__nav:hover {
        background: var(--gallery-control-bg-hover, rgba(255, 255, 255, .2));
        border-color: var(--gallery-control-border-hover, rgba(255, 255, 255, .35));
    }
}

.lightbox__close:focus-visible,
.lightbox__nav:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 3px;
}

.lightbox__close {
    position: fixed;
    top: 12px;
    right: 12px;
    z-index: 1;
    width: 3rem;
    height: 3rem;
}

.lightbox__nav {
    position: absolute;
    top: 50%;
    z-index: 1;
    width: 44px;
    height: 44px;
    transform: translateY(-50%);
}

.lightbox__nav svg {
    display: block;
    pointer-events: none;
}

.lightbox__nav--prev {
    left: 16px;
}

.lightbox__nav--next {
    right: 16px;
}

.lightbox__counter {
    position: fixed;
    top: 12px;
    left: 16px;
    display: flex;
    align-items: center;
    min-height: 3rem;
    color: #fff;
    font-size: .9375rem;
    font-variant-numeric: tabular-nums;
}

@media (max-width: 768px) {
    .lightbox {
        padding-top: 104px;
    }

    .lightbox__close,
    .lightbox__nav {
        width: 40px;
        height: 40px;
    }

    .lightbox__nav {
        top: 56px;
        transform: none;
    }

    .lightbox__nav--prev {
        left: 12px;
    }

    .lightbox__nav--next {
        right: 12px;
    }

    .lightbox__stage {
        width: 100%;
        padding: 0 12px;
        box-sizing: border-box;
    }
}
