/*
 * HBS Bildergalerie
 * RC1-CSS-Datei.
 * Die ehemals in der Beta getesteten Features sind in diese Release-Datei überführt.
 */

/* Basis / Breiten */
.hbs-gallery {
    width: 100%;
    margin: 1.5rem auto;
}

.hbs-gallery--xsmall {
    max-width: 500px;
}

.hbs-gallery--small {
    max-width: 700px;
}

.hbs-gallery--medium {
    max-width: 950px;
}

.hbs-gallery--large {
    max-width: 1250px;
}

.hbs-gallery--full {
    max-width: 100%;
}

/* Hauptbild */
.hbs-gallery .hbs-gallery__open {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    aspect-ratio: 16 / 9;
    padding: 0;
    border: 0;
    background: #f3f3f3;
    cursor: zoom-in;
    overflow: hidden;
}

.hbs-gallery .hbs-gallery__open picture {
    display: block;
    width: 100%;
    height: 100%;
}

.hbs-gallery .hbs-gallery__image {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* Copyright-Overlay im Hauptbild
 *
 * Die Bühne ist fest, das sichtbare Bild wird per object-fit eingepasst.
 * JS berechnet die echte sichtbare Bildfläche und setzt die CSS-Variablen.
 * Dadurch sitzt das Overlay unten rechts am sichtbaren Bild und nicht am Bühnenrand.
 */
.hbs-gallery .hbs-gallery__copyright-overlay {
    position: absolute;
    right: calc(var(--hbs-gallery-image-inset-x, 0px) + .75rem);
    bottom: calc(var(--hbs-gallery-image-inset-y, 0px) + .75rem);
    left: auto;
    display: inline-block;
    max-width: calc(var(--hbs-gallery-visible-image-width, 100%) - 1.5rem);
    padding: .35rem .55rem;
    background: rgba(0, 0, 0, .55);
    color: #fff;
    font-size: .875rem;
    line-height: 1.2;
    border-radius: .25rem;
    text-align: right;
    pointer-events: none;
}

/* Metadaten unter dem Bild */
.hbs-gallery .hbs-gallery__meta {
    margin-top: .5rem;
    font-size: .95rem;
    line-height: 1.45;
}

.hbs-gallery .hbs-gallery__meta-title {
    font-weight: 700;
}

.hbs-gallery .hbs-gallery__meta-description {
    margin-top: .15rem;
}

.hbs-gallery .hbs-gallery__meta-credits {
    display: flex;
    flex-wrap: wrap;
    gap: .4rem .8rem;
    margin-top: .35rem;
    font-size: .875rem;
    opacity: .85;
}

/* Thumbnail-Leiste */
.hbs-gallery .hbs-gallery__thumbs-wrap {
    display: flex;
    align-items: center;
    gap: .5rem;
    margin-top: .75rem;
}

.hbs-gallery .hbs-gallery__thumbs {
    display: flex;
    flex: 1 1 auto;
    gap: .5rem;
    overflow-x: auto;
    scroll-behavior: smooth;
    padding: .25rem 0;
}

.hbs-gallery .hbs-gallery__thumb {
    flex: 0 0 auto;
    padding: 0;
    border: 2px solid transparent;
    background: transparent;
    cursor: pointer;
    opacity: .72;
    transition: opacity .2s ease-in-out, border-color .2s ease-in-out, transform .2s ease-in-out;
}

.hbs-gallery .hbs-gallery__thumb.is-active {
    border-color: currentColor;
    opacity: 1;
}

.hbs-gallery .hbs-gallery__thumb:hover,
.hbs-gallery .hbs-gallery__thumb:focus-visible {
    opacity: 1;
    transform: translateY(-1px);
}

.hbs-gallery .hbs-gallery__thumb picture,
.hbs-gallery .hbs-gallery__thumb img {
    display: block;
}

.hbs-gallery .hbs-gallery__thumb img {
    width: 140px;
    height: 90px;
    object-fit: cover;
}

.hbs-gallery .hbs-gallery__thumb-scroll {
    flex: 0 0 auto;
    width: 2rem;
    height: 2rem;
    border: 1px solid currentColor;
    background: transparent;
    cursor: pointer;
    font-size: 1.5rem;
    line-height: 1;
    transition: opacity .2s ease-in-out, border-color .2s ease-in-out, transform .2s ease-in-out;
}

.hbs-gallery .hbs-gallery__count {
    margin-top: .4rem;
    font-size: .875rem;
    opacity: .75;
    text-align: right;
}

/* Fokus / Accessibility */
.hbs-gallery .hbs-gallery__open:focus-visible,
.hbs-gallery .hbs-gallery__thumb:focus-visible,
.hbs-gallery .hbs-gallery__thumb-scroll:focus-visible,
.hbs-gallery-lightbox__close:focus-visible,
.hbs-gallery-lightbox__prev:focus-visible,
.hbs-gallery-lightbox__next:focus-visible {
    outline: 3px solid currentColor;
    outline-offset: 3px;
}

/* Lightbox */
.hbs-gallery-lightbox {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, .92);
    color: #fff;
}

.hbs-gallery-lightbox.is-open {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    gap: .75rem !important;
    padding: 1rem !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
}

.hbs-gallery-lightbox__image-wrap {
    position: relative !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: auto !important;
    height: auto !important;
    max-width: 92vw !important;
    max-height: calc(100dvh - 10rem) !important;
    overflow: visible !important;
}

.hbs-gallery-lightbox__image {
    display: block !important;
    width: auto !important;
    height: auto !important;
    max-width: 92vw !important;
    max-height: calc(100dvh - 10rem) !important;
    object-fit: contain !important;
}

.hbs-gallery-lightbox__caption {
    position: static !important;
    display: block !important;
    width: min(92vw, 1200px) !important;
    max-height: 7rem !important;
    overflow-y: auto !important;
    color: #fff !important;
    text-align: center !important;
    font-size: .95rem !important;
    line-height: 1.3 !important;
    padding: 0 .5rem !important;
    box-sizing: border-box !important;
}

.hbs-gallery-lightbox__copyright {
    position: absolute;
    right: .75rem;
    bottom: .75rem;
    display: inline-block;
    max-width: calc(100% - 1.5rem);
    padding: .35rem .55rem;
    background: rgba(0, 0, 0, .6);
    color: #fff;
    font-size: .9rem;
    line-height: 1.2;
    border-radius: .25rem;
    text-align: right;
    pointer-events: none;
}

.hbs-gallery-lightbox__copyright[hidden] {
    display: none;
}

.hbs-gallery-lightbox__close,
.hbs-gallery-lightbox__prev,
.hbs-gallery-lightbox__next {
    position: absolute;
    border: 0;
    background: rgba(0, 0, 0, .45);
    color: #fff;
    cursor: pointer;
    transition: opacity .2s ease-in-out, border-color .2s ease-in-out, transform .2s ease-in-out;
}

.hbs-gallery-lightbox__close {
    top: 1rem;
    right: 1rem;
    width: 2.5rem;
    height: 2.5rem;
    font-size: 2rem;
    line-height: 1;
}

.hbs-gallery-lightbox__prev,
.hbs-gallery-lightbox__next {
    top: 50%;
    transform: translateY(-50%);
    width: 3rem;
    height: 4rem;
    font-size: 3rem;
    line-height: 1;
    opacity: 0;
}

.hbs-gallery-lightbox:hover .hbs-gallery-lightbox__prev,
.hbs-gallery-lightbox:hover .hbs-gallery-lightbox__next {
    opacity: .55;
}

.hbs-gallery-lightbox__prev:hover,
.hbs-gallery-lightbox__next:hover,
.hbs-gallery-lightbox__prev:focus-visible,
.hbs-gallery-lightbox__next:focus-visible {
    opacity: 1;
}

.hbs-gallery-lightbox__prev {
    left: 1rem;
}

.hbs-gallery-lightbox__next {
    right: 1rem;
}

/* Mobile */
@media (max-width: 640px) {
    .hbs-gallery .hbs-gallery__thumb img {
        width: 96px;
        height: 64px;
    }

    .hbs-gallery .hbs-gallery__thumb-scroll {
        display: none;
    }

    .hbs-gallery .hbs-gallery__copyright-overlay,
    .hbs-gallery-lightbox__copyright {
        right: .5rem;
        bottom: .5rem;
        max-width: calc(100% - 1rem);
        font-size: .75rem;
    }

    .hbs-gallery-lightbox__prev,
    .hbs-gallery-lightbox__next {
        width: 2.5rem;
        background: transparent;
    }
}

/* Smartphone quer: Bild priorisieren, Caption ausblenden */
@media (max-height: 520px) and (orientation: landscape) {
    .hbs-gallery-lightbox.is-open {
        flex-direction: row !important;
        padding: .5rem 3.5rem !important;
        gap: 0 !important;
    }

    .hbs-gallery-lightbox__image-wrap {
        max-width: calc(100vw - 7rem) !important;
        max-height: calc(100dvh - 1rem) !important;
    }

    .hbs-gallery-lightbox__image {
        max-width: calc(100vw - 7rem) !important;
        max-height: calc(100dvh - 1rem) !important;
    }

    .hbs-gallery-lightbox__caption {
        display: none !important;
    }

    .hbs-gallery-lightbox__close {
        top: .5rem !important;
        right: .5rem !important;
    }

    .hbs-gallery-lightbox__prev {
        left: .5rem !important;
    }

    .hbs-gallery-lightbox__next {
        right: .5rem !important;
    }
}

/* Bewegungen reduzieren, wenn Nutzer das systemweit wünscht */
@media (prefers-reduced-motion: reduce) {
    .hbs-gallery .hbs-gallery__figure,
    .hbs-gallery .hbs-gallery__thumb,
    .hbs-gallery .hbs-gallery__open,
    .hbs-gallery .hbs-gallery__thumb-scroll,
    .hbs-gallery-lightbox__close,
    .hbs-gallery-lightbox__prev,
    .hbs-gallery-lightbox__next {
        transition: none;
        scroll-behavior: auto;
    }
}

/* Ausrichtung der Bildinformationen */
.hbs-gallery--meta-left .hbs-gallery__meta {
    text-align: left;
}

.hbs-gallery--meta-center .hbs-gallery__meta {
    text-align: center;
}

.hbs-gallery--meta-right .hbs-gallery__meta {
    text-align: right;
}

.hbs-gallery--meta-center .hbs-gallery__meta-credits {
    justify-content: center;
}

.hbs-gallery--meta-right .hbs-gallery__meta-credits {
    justify-content: flex-end;
}

/* Weicher Bildwechsel */
.hbs-gallery .hbs-gallery__stage {
    display: grid;
}

.hbs-gallery .hbs-gallery__figure {
    grid-area: 1 / 1;
    display: block;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition:
        opacity var(--hbs-gallery-transition-duration, 350ms) ease-in-out,
        visibility 0s linear var(--hbs-gallery-transition-duration, 350ms);
}

.hbs-gallery .hbs-gallery__figure.is-active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transition-delay: 0s;
}

.hbs-gallery--transition-none .hbs-gallery__figure {
    transition: none;
}

@media (prefers-reduced-motion: reduce) {
    .hbs-gallery .hbs-gallery__figure {
        transition: none;
    }
}

