/*
 * AFL Product Gallery
 * Version 1.1.0
 */

.afl-product-gallery {
    width: 100%;
    max-width: 720px;
    --afl-pg-thumb-size: 94px;
    --afl-pg-thumb-gap: 16px;
    --afl-pg-border: #d1d1d1;
    --afl-pg-border-active: #555;
    --afl-pg-arrow: #111;
}

.afl-product-gallery *,
.afl-product-gallery *::before,
.afl-product-gallery *::after {
    box-sizing: border-box;
}

/* Hauptbild */
.afl-product-gallery__main {
    appearance: none;
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    padding: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    cursor: zoom-in;
}

.afl-product-gallery__main-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    opacity: 1;
    transition: opacity .18s ease;
}

.afl-product-gallery__main-image.is-changing {
    opacity: 0;
}

/* Navigation */
.afl-product-gallery__navigation {
    display: grid;
    grid-template-columns: 34px minmax(0, 1fr) 34px;
    align-items: center;
    gap: 10px;
    margin-top: 30px;
}

/* Thumbnail-Scroller */
.afl-product-gallery__thumbnails {
    display: flex;
    gap: var(--afl-pg-thumb-gap);
    min-width: 0;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-behavior: smooth;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
    padding: 2px;
    -webkit-overflow-scrolling: touch;
}

.afl-product-gallery__thumbnails::-webkit-scrollbar {
    display: none;
}

/* Thumbnail */
.afl-product-gallery__thumb {
    appearance: none;
    flex: 0 0 var(--afl-pg-thumb-size);
    width: var(--afl-pg-thumb-size);
    height: var(--afl-pg-thumb-size);
    padding: 7px;
    background: #fff;
    border: 1px solid var(--afl-pg-border);
    border-radius: 0;
    box-shadow: none;
    cursor: pointer;
    scroll-snap-align: start;
    transition: border-color .18s ease, opacity .18s ease;
}

.afl-product-gallery__thumb img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    pointer-events: none;
}

.afl-product-gallery__thumb:hover {
    border-color: #999;
}

.afl-product-gallery__thumb.is-active {
    border-color: var(--afl-pg-border-active);
}

.afl-product-gallery__thumb:focus-visible,
.afl-product-gallery__arrow:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 2px;
}

/* Pfeile */
.afl-product-gallery__arrow {
    appearance: none;
    border: 0;
    background: transparent;
    width: 34px;
    height: 50px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font: inherit;
    font-size: 32px;
    font-weight: 300;
    line-height: 1;
    color: var(--afl-pg-arrow);
    cursor: pointer;
    transition: opacity .18s ease;
}

.afl-product-gallery__arrow:hover {
    opacity: .55;
}

.afl-product-gallery__arrow:disabled {
    opacity: .18;
    cursor: default;
}

/* Tablet / Mobile */
@media (max-width: 767px) {
    .afl-product-gallery {
        --afl-pg-thumb-size: 76px;
        --afl-pg-thumb-gap: 10px;
    }

    .afl-product-gallery__navigation {
        grid-template-columns: 28px minmax(0, 1fr) 28px;
        gap: 5px;
        margin-top: 18px;
    }

    .afl-product-gallery__thumb {
        padding: 5px;
    }

    .afl-product-gallery__arrow {
        width: 28px;
        font-size: 28px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .afl-product-gallery__main-image,
    .afl-product-gallery__thumb,
    .afl-product-gallery__arrow {
        transition: none;
    }

    .afl-product-gallery__thumbnails {
        scroll-behavior: auto;
    }
}


/* Lightbox-Hinweis auf dem Hauptbild */
.afl-product-gallery__zoom-hint {
    position: absolute;
    right: 16px;
    bottom: 16px;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: rgba(255,255,255,.92);
    border: 1px solid rgba(0,0,0,.14);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    line-height: 1;
    color: #111;
    pointer-events: none;
    opacity: .85;
    transition: opacity .18s ease, transform .18s ease;
}

.afl-product-gallery__main:hover .afl-product-gallery__zoom-hint {
    opacity: 1;
    transform: scale(1.05);
}

.afl-product-gallery__main:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 2px;
}

/* Lightbox */
body.afl-pg-lightbox-open {
    overflow: hidden;
}

.afl-product-gallery__lightbox[hidden] {
    display: none !important;
}

.afl-product-gallery__lightbox {
    position: fixed;
    inset: 0;
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 28px;
}

.afl-product-gallery__lightbox-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, .88);
}

.afl-product-gallery__lightbox-content {
    position: relative;
    z-index: 1;
    width: min(94vw, 1400px);
    height: min(92vh, 1000px);
    display: flex;
    align-items: center;
    justify-content: center;
}

.afl-product-gallery__lightbox-image {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    user-select: none;
    -webkit-user-drag: none;
}

.afl-product-gallery__lightbox-close {
    appearance: none;
    position: absolute;
    top: -6px;
    right: -6px;
    z-index: 3;
    width: 46px;
    height: 46px;
    border: 0;
    border-radius: 50%;
    background: rgba(255,255,255,.96);
    color: #111;
    font: inherit;
    font-size: 32px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.afl-product-gallery__lightbox-arrow {
    appearance: none;
    position: absolute;
    top: 50%;
    z-index: 3;
    width: 48px;
    height: 64px;
    transform: translateY(-50%);
    border: 0;
    background: rgba(255,255,255,.92);
    color: #111;
    font: inherit;
    font-size: 42px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.afl-product-gallery__lightbox-arrow--prev {
    left: 8px;
}

.afl-product-gallery__lightbox-arrow--next {
    right: 8px;
}

.afl-product-gallery__lightbox-close:hover,
.afl-product-gallery__lightbox-arrow:hover {
    background: #fff;
}

.afl-product-gallery__lightbox-close:focus-visible,
.afl-product-gallery__lightbox-arrow:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 3px;
}

@media (max-width: 767px) {
    .afl-product-gallery__zoom-hint {
        right: 10px;
        bottom: 10px;
        width: 34px;
        height: 34px;
        font-size: 20px;
    }

    .afl-product-gallery__lightbox {
        padding: 12px;
    }

    .afl-product-gallery__lightbox-content {
        width: 100%;
        height: 92vh;
    }

    .afl-product-gallery__lightbox-close {
        top: 4px;
        right: 4px;
        width: 42px;
        height: 42px;
        font-size: 29px;
    }

    .afl-product-gallery__lightbox-arrow {
        width: 42px;
        height: 56px;
        font-size: 36px;
        background: rgba(255,255,255,.86);
    }

    .afl-product-gallery__lightbox-arrow--prev {
        left: 2px;
    }

    .afl-product-gallery__lightbox-arrow--next {
        right: 2px;
    }
}
