/* Product gallery. Keep the scrolling track inside its own frame. */
#html-body.catalog-product-view #gallery {
    --ws-gallery-gap: .75rem;
    --ws-gallery-thumb-limit: 4;
    --ws-thumbnail-size: clamp(2.75rem, 14vw, 3.5rem);
    display: flex;
    flex-direction: column !important;
    gap: var(--ws-gallery-gap);
    min-inline-size: 0;
    max-inline-size: 100%;
    aspect-ratio: auto !important;
}

#html-body.catalog-product-view #gallery .ws-gallery-mainwrap,
#html-body.catalog-product-view #gallery [data-track] {
    inline-size: 100%;
    min-inline-size: 0;
    max-inline-size: 100%;
}

#html-body.catalog-product-view #gallery .ws-gallery-mainwrap {
    overflow: hidden;
}

#html-body.catalog-product-view #gallery [data-track] {
    position: relative;
    overflow-x: auto !important;
    overflow-y: hidden;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
}

#html-body.catalog-product-view #gallery [data-track] > div {
    flex: 0 0 100%;
    min-inline-size: 0;
    max-inline-size: 100%;
    height: 100%;
    min-height: 0;
}

#html-body.catalog-product-view #gallery [data-track] > div > button {
    width: 100%;
    height: 100%;
    min-height: 0;
    overflow: hidden;
    grid-template: minmax(0, 1fr) / minmax(0, 1fr);
}

#html-body.catalog-product-view #gallery [data-track] img {
    width: 100% !important;
    height: 100% !important;
    max-width: 100%;
    max-height: 100%;
    aspect-ratio: auto !important;
    object-fit: contain !important;
    object-position: center !important;
}

.ws-gallery-thumbnails {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
}

.ws-gallery-thumbnail {
    position: relative;
    display: grid;
    flex: none;
    place-items: center;
    inline-size: var(--ws-thumbnail-size);
    aspect-ratio: 1;
    overflow: hidden;
    border: 1px solid #e5e5e5;
    border-radius: .375rem;
    background: #fff;
}

.ws-gallery-thumbnail:hover {
    border-color: #8b8b8b;
}

.ws-gallery-thumbnail[aria-current="true"] {
    border-color: #b69000;
    box-shadow: inset 0 0 0 1px #ffd400;
}

.ws-gallery-thumbnail:focus-visible {
    outline: 2px solid #574600;
    outline-offset: 2px;
}

.ws-gallery-thumbnail img {
    width: 100%;
    height: 100%;
    min-height: 0;
    padding: .125rem;
    object-fit: contain;
}

.ws-gallery-thumbnail-video,
.ws-gallery-overflow-count {
    position: absolute;
    inset: 0;
    display: grid;
    place-content: center;
    color: #fff;
}

.ws-gallery-thumbnail-video {
    background: rgb(0 0 0 / 28%);
}

.ws-gallery-overflow-count {
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgb(0 0 0 / 62%);
    font-weight: 700;
}

.ws-gallery-pager--dots .ws-gallery-thumbnails {
    justify-content: center;
}

.ws-gallery-dot {
    inline-size: 1rem;
    border-radius: 50%;
}

.ws-gallery-dot[aria-current="true"] {
    background: #ffd400;
}

#html-body.catalog-product-view #gallery > dialog img {
    width: auto;
    height: auto;
    max-width: calc(100vw - 32px);
    max-height: calc(100svh - 64px);
    object-fit: contain;
}

@media (min-width: 1024px) {
    #html-body.catalog-product-view #gallery {
        --ws-gallery-thumb-limit: var(--ws-gallery-desktop-thumb-limit);
        --ws-thumbnail-size: 4.25rem;
    }

    #html-body.catalog-product-view #gallery .ws-gallery-mainwrap,
    #html-body.catalog-product-view #gallery [data-track] {
        height: auto !important;
        min-height: 0 !important;
    }

    #html-body.catalog-product-view #gallery .ws-gallery-mainwrap {
        max-height: none !important;
        aspect-ratio: auto !important;
    }

    #html-body.catalog-product-view #gallery [data-track] {
        max-height: 38rem !important;
        aspect-ratio: 1 !important;
    }
}
