/*
 * Standalone WooCommerce product-image gallery.
 *
 * This component intentionally does not target Divi or WooCommerce gallery
 * classes. It can therefore run beside the legacy paired modules while one
 * product template is being verified.
 */
.fm-product-image-gallery,
.fm-product-image-gallery__modal {
    --fm-product-gallery-grey: #e9e9eb;
    --fm-product-gallery-arrow-grey: #c9c9cc;
    --fm-product-gallery-modal-backdrop: rgba(7, 19, 27, 0.9);
}

.fm-product-image-gallery {
    width: 100%;
}

.fm-product-image-gallery *,
.fm-product-image-gallery *::before,
.fm-product-image-gallery *::after,
.fm-product-image-gallery__modal *,
.fm-product-image-gallery__modal *::before,
.fm-product-image-gallery__modal *::after {
    box-sizing: border-box;
}

.fm-product-image-gallery__data {
    display: none;
}

.fm-product-image-gallery__stage {
    position: relative;
    display: flex;
    align-items: stretch;
    height: clamp(250px, 56vw, 430px);
    padding: 6px 35px;
    background: var(--fm-product-gallery-grey);
}

.fm-product-image-gallery__main-image-button {
    display: flex;
    width: 100%;
    min-width: 0;
    min-height: 0;
    align-items: center;
    justify-content: center;
    padding: 0;
    overflow: hidden;
    border: 0;
    background: #fff;
    cursor: zoom-in;
}

.fm-product-image-gallery__main-image {
    display: block;
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.fm-product-image-gallery__stage-arrow,
.fm-product-image-gallery__modal-arrow,
.fm-product-image-gallery__thumb-arrow {
    appearance: none;
    border: 0;
    font: inherit;
    cursor: pointer;
}

.fm-product-image-gallery__stage-arrow {
    position: absolute;
    z-index: 2;
    top: 0;
    bottom: 0;
    display: flex;
    width: 35px;
    padding: 0;
    align-items: center;
    justify-content: center;
    border: 0;
    background: transparent;
    color: var(--fm-product-gallery-arrow-grey);
    font-family: Arial, sans-serif;
    font-size: 36px;
    font-weight: 300;
    line-height: 1;
    opacity: 0;
    pointer-events: none;
    transition: color 0.3s ease, opacity 0.3s ease;
}

.fm-product-image-gallery__stage-arrow--prev {
    left: 0;
}

.fm-product-image-gallery__stage-arrow--next {
    right: 0;
}

.fm-product-image-gallery:hover .fm-product-image-gallery__stage-arrow,
.fm-product-image-gallery:focus-within .fm-product-image-gallery__stage-arrow {
    opacity: 1;
    pointer-events: auto;
}

.fm-product-image-gallery__stage-arrow:hover,
.fm-product-image-gallery__stage-arrow:focus-visible {
    color: var(--dark-blue, #0c384f);
}

.fm-product-image-gallery--single-image .fm-product-image-gallery__stage-arrow,
.fm-product-image-gallery--single-image .fm-product-image-gallery__rail {
    display: none;
}

.fm-product-image-gallery__modal--single-image .fm-product-image-gallery__rail,
.fm-product-image-gallery__modal--single-image .fm-product-image-gallery__modal-arrow {
    display: none;
}

.fm-product-image-gallery__rail {
    position: relative;
    width: 100%;
    margin-top: 10px;
}

.fm-product-image-gallery__thumb-viewport {
    overflow: hidden;
    margin: 0 26px;
}

.fm-product-image-gallery__thumb-list {
    display: flex;
    gap: 10px;
    width: 100%;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.fm-product-image-gallery__thumb {
    position: relative;
    display: block;
    flex: 0 0 calc((100% - 40px) / 5);
    min-width: 0;
    padding: 0;
    overflow: hidden;
    border: 0;
    background: #fff;
    cursor: pointer;
    opacity: 0.72;
    transition: opacity 0.3s ease, outline-color 0.3s ease, transform 0.3s ease;
}

.fm-product-image-gallery__thumb[aria-current="true"],
.fm-product-image-gallery__thumb:hover,
.fm-product-image-gallery__thumb:focus-visible {
    opacity: 1;
}

.fm-product-image-gallery__thumb:focus-visible,
.fm-product-image-gallery__main-image-button:focus-visible,
.fm-product-image-gallery__stage-arrow:focus-visible,
.fm-product-image-gallery__thumb-arrow:focus-visible,
.fm-product-image-gallery__modal-arrow:focus-visible {
    outline: 3px solid var(--orange, #f47721);
    outline-offset: 3px;
}

.fm-product-image-gallery__modal .fm-product-image-gallery__thumb:focus-visible,
.fm-product-image-gallery__modal .fm-product-image-gallery__thumb-arrow:focus-visible,
.fm-product-image-gallery__modal .fm-product-image-gallery__modal-arrow:focus-visible {
    outline: 3px solid var(--orange, #f47721);
    outline-offset: 3px;
}

.fm-product-image-gallery__thumb img {
    display: block;
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: contain;
    background: #fff;
}

.fm-product-image-gallery__thumb-arrow {
    position: absolute;
    z-index: 2;
    top: 50%;
    display: flex;
    width: 22px;
    height: 32px;
    padding: 0;
    align-items: center;
    justify-content: center;
    transform: translateY(-50%);
    background: transparent;
    color: var(--orange, #f47721);
    font-size: 18px;
    line-height: 1;
    transition: color 0.3s ease, transform 0.3s ease;
}

.fm-product-image-gallery__thumb-arrow--prev {
    left: -2px;
}

.fm-product-image-gallery__thumb-arrow--next {
    right: -2px;
}

.fm-product-image-gallery__thumb-arrow:hover,
.fm-product-image-gallery__thumb-arrow:focus-visible {
    color: var(--blue, #105daa);
}

.fm-product-image-gallery__rail.is-static .fm-product-image-gallery__thumb-arrow {
    display: none;
}

.fm-product-image-gallery__modal[hidden] {
    display: none;
}

.fm-product-image-gallery__modal {
    position: fixed;
    z-index: 2147483647;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 24px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.fm-product-image-gallery__modal.is-open {
    opacity: 1;
    pointer-events: auto;
}

.fm-product-image-gallery__modal-backdrop {
    position: absolute;
    inset: 0;
    background: var(--fm-product-gallery-modal-backdrop);
}

.fm-product-image-gallery__modal-dialog {
    position: relative;
    z-index: 1;
    display: flex;
    width: min(1180px, 100%);
    max-height: 100%;
    min-height: 0;
    flex-direction: column;
    outline: none;
    transform: translateY(10px);
    transition: transform 0.3s ease;
}

.fm-product-image-gallery__modal.is-open .fm-product-image-gallery__modal-dialog {
    transform: translateY(0);
}

.fm-product-image-gallery__modal-stage {
    position: relative;
    display: flex;
    min-height: 0;
    flex: 1 1 auto;
    align-items: center;
    justify-content: center;
    padding: 30px 72px;
}

.fm-product-image-gallery__modal-figure {
    display: flex;
    min-width: 0;
    min-height: 0;
    max-height: calc(100vh - 210px);
    margin: 0;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.fm-product-image-gallery__modal-image {
    display: block;
    width: auto;
    max-width: 100%;
    height: auto;
    max-height: calc(100vh - 250px);
    object-fit: contain;
    background: #fff;
    transition: opacity 0.3s ease;
}

.fm-product-image-gallery__modal-arrow {
    position: absolute;
    z-index: 2;
    top: 50%;
    display: flex;
    width: 54px;
    height: 72px;
    padding: 0;
    align-items: center;
    justify-content: center;
    transform: translateY(-50%);
    background: transparent;
    color: #fff;
    font-size: 34px;
    line-height: 1;
    transition: color 0.3s ease, transform 0.3s ease;
}

.fm-product-image-gallery__modal-arrow--prev {
    left: 4px;
}

.fm-product-image-gallery__modal-arrow--next {
    right: 4px;
}

.fm-product-image-gallery__modal-arrow:hover,
.fm-product-image-gallery__modal-arrow:focus-visible {
    color: var(--orange, #f47721);
}

.fm-product-image-gallery__modal .fm-product-image-gallery__rail {
    flex: 0 0 auto;
    width: min(760px, 100%);
    margin: 0 auto;
}

.fm-product-image-gallery__modal .fm-product-image-gallery__thumb {
    background: #fff;
}

.fm-product-image-gallery__screen-reader-text {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

html.fm-product-image-gallery-modal-open {
    height: 100%;
    overflow: hidden !important;
    overscroll-behavior: none;
}

body.fm-product-image-gallery-modal-open {
    position: fixed !important;
    top: var(--fm-product-image-gallery-scroll-y, 0);
    right: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden !important;
    overscroll-behavior: none;
}

@media (hover: none) {
    .fm-product-image-gallery__stage-arrow {
        opacity: 1;
        pointer-events: auto;
    }
}

@media (max-width: 980px) {
    .fm-product-image-gallery__thumb {
        flex-basis: calc((100% - 30px) / 4);
    }
}

@media (max-width: 767px) {
    .fm-product-image-gallery__stage {
        padding-right: 36px;
        padding-left: 36px;
    }

    .fm-product-image-gallery__stage-arrow {
        width: 36px;
        font-size: 22px;
    }

    .fm-product-image-gallery__thumb {
        flex-basis: calc((100% - 20px) / 3);
    }

    .fm-product-image-gallery__modal {
        padding: 12px;
    }

    .fm-product-image-gallery__modal-stage {
        padding: 40px 42px 20px;
    }

    .fm-product-image-gallery__modal-figure,
    .fm-product-image-gallery__modal-image {
        max-height: calc(100vh - 190px);
    }

    .fm-product-image-gallery__modal-arrow {
        width: 38px;
        font-size: 48px;
    }
}

@media (max-width: 479px) {
    .fm-product-image-gallery__stage {
        height: 250px;
        padding-right: 30px;
        padding-left: 30px;
    }

    .fm-product-image-gallery__stage-arrow {
        width: 30px;
        font-size: 20px;
    }

    .fm-product-image-gallery__thumb {
        flex-basis: calc((100% - 10px) / 2);
    }

    .fm-product-image-gallery__thumb-viewport {
        margin: 0 22px;
    }

    .fm-product-image-gallery__modal-stage {
        padding-right: 34px;
        padding-left: 34px;
    }

}
