/*
 * LPW Product Gallery Pro 1.2
 * A small presentation layer for the native WooCommerce gallery.
 * All rules are scoped to the enhanced gallery to reduce theme conflicts.
 */
.woocommerce-product-gallery.lpwpg-enhanced {
    --lpwpg-thumb-size: 76px;
    --lpwpg-effective-thumb-size: var(--lpwpg-thumb-size);
    --lpwpg-gap: 12px;
    --lpwpg-thumb-gap: 7px;
    --lpwpg-border: #e3e7ea;
    --lpwpg-text: #263238;
    --lpwpg-bg: #fff;
    --lpwpg-control-bg: rgba(255, 255, 255, 0.95);
    position: relative;
    min-width: 0;
    box-sizing: border-box;
}

.woocommerce-product-gallery.lpwpg-enhanced *,
.woocommerce-product-gallery.lpwpg-enhanced *::before,
.woocommerce-product-gallery.lpwpg-enhanced *::after {
    box-sizing: border-box;
}

.woocommerce-product-gallery.lpwpg-enhanced .flex-viewport,
.woocommerce-product-gallery.lpwpg-enhanced > .woocommerce-product-gallery__wrapper {
    width: 100% !important;
    min-width: 0;
    margin: 0 !important;
    background: var(--lpwpg-bg);
    border: 1px solid var(--lpwpg-border);
    overflow: hidden;
}

.woocommerce-product-gallery.lpwpg-enhanced.lpwpg-rounded .flex-viewport,
.woocommerce-product-gallery.lpwpg-enhanced.lpwpg-rounded > .woocommerce-product-gallery__wrapper {
    border-radius: 10px;
}

/* Keep the main product area steady as visitors move between images. */
.woocommerce-product-gallery.lpwpg-enhanced.lpwpg-ratio-square .flex-viewport,
.woocommerce-product-gallery.lpwpg-enhanced.lpwpg-ratio-square > .woocommerce-product-gallery__wrapper {
    aspect-ratio: 1 / 1;
    height: auto !important;
}

.woocommerce-product-gallery.lpwpg-enhanced.lpwpg-ratio-portrait .flex-viewport,
.woocommerce-product-gallery.lpwpg-enhanced.lpwpg-ratio-portrait > .woocommerce-product-gallery__wrapper {
    aspect-ratio: 4 / 5;
    height: auto !important;
}

.woocommerce-product-gallery.lpwpg-enhanced:not(.lpwpg-ratio-auto) .woocommerce-product-gallery__wrapper,
.woocommerce-product-gallery.lpwpg-enhanced:not(.lpwpg-ratio-auto) .woocommerce-product-gallery__image,
.woocommerce-product-gallery.lpwpg-enhanced:not(.lpwpg-ratio-auto) .woocommerce-product-gallery__image > a {
    height: 100%;
}

.woocommerce-product-gallery.lpwpg-enhanced .woocommerce-product-gallery__image > a {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff;
}

.woocommerce-product-gallery.lpwpg-enhanced .woocommerce-product-gallery__image img {
    display: block;
    width: 100%;
    max-width: 100%;
    height: 100%;
    max-height: 100%;
    margin: 0 auto;
    object-fit: contain;
    object-position: center;
}

.woocommerce-product-gallery.lpwpg-enhanced.lpwpg-ratio-auto .woocommerce-product-gallery__image img {
    height: auto;
}

/* Keep WooCommerce's normal full-screen control. */
.woocommerce-product-gallery.lpwpg-enhanced .woocommerce-product-gallery__trigger {
    z-index: 30;
    top: 12px;
    right: 12px;
    width: 38px;
    height: 38px;
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 999px;
    background: var(--lpwpg-control-bg);
    box-shadow: 0 2px 9px rgba(0, 0, 0, 0.06);
}

/* Native WooCommerce thumbnails. */
.woocommerce-product-gallery.lpwpg-enhanced .flex-control-thumbs {
    margin: 0 !important;
    padding: 0 !important;
    list-style: none !important;
    min-width: 0;
}

.woocommerce-product-gallery.lpwpg-enhanced .flex-control-thumbs li {
    margin: 0 !important;
    padding: 0 !important;
    list-style: none !important;
}

.woocommerce-product-gallery.lpwpg-enhanced .flex-control-thumbs img {
    display: block;
    width: 100% !important;
    height: 100% !important;
    margin: 0 !important;
    object-fit: contain;
    background: #fff;
    border: 2px solid transparent;
    border-radius: 7px;
    opacity: 0.78;
    cursor: pointer;
    transition: border-color 140ms ease, opacity 140ms ease, box-shadow 140ms ease;
}

.woocommerce-product-gallery.lpwpg-enhanced .flex-control-thumbs img:hover,
.woocommerce-product-gallery.lpwpg-enhanced .flex-control-thumbs img:focus,
.woocommerce-product-gallery.lpwpg-enhanced .flex-control-thumbs img.flex-active {
    opacity: 1;
    border-color: #263238;
}

.woocommerce-product-gallery.lpwpg-enhanced .flex-control-thumbs img.flex-active {
    box-shadow: 0 0 0 1px #263238;
}

/* Simple previous and next buttons. They are click controls only. */
.woocommerce-product-gallery.lpwpg-enhanced .lpwpg-arrow {
    position: absolute;
    z-index: 24;
    top: 50%;
    width: 40px;
    height: 40px;
    margin: 0;
    padding: 0;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(0, 0, 0, 0.10);
    border-radius: 999px;
    background: var(--lpwpg-control-bg);
    color: var(--lpwpg-text);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.07);
    cursor: pointer;
}

.woocommerce-product-gallery.lpwpg-enhanced .lpwpg-arrow span {
    display: block;
    margin-top: -2px;
    font-family: Arial, sans-serif;
    font-size: 32px;
    font-weight: 300;
    line-height: 1;
}

.woocommerce-product-gallery.lpwpg-enhanced .lpwpg-arrow:disabled {
    opacity: 0.24;
    cursor: default;
}

.woocommerce-product-gallery.lpwpg-enhanced .lpwpg-counter {
    position: absolute;
    z-index: 24;
    right: 12px;
    bottom: 12px;
    min-width: 50px;
    padding: 6px 9px;
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 999px;
    background: var(--lpwpg-control-bg);
    color: var(--lpwpg-text);
    font-size: 12px;
    font-weight: 600;
    line-height: 1;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    pointer-events: none;
}

.woocommerce-product-gallery.lpwpg-enhanced .lpwpg-dots {
    display: none;
}

/* This was used in v1.1 and is intentionally removed from the UI in v1.2. */
.woocommerce-product-gallery.lpwpg-enhanced .lpwpg-mobile-fullscreen {
    display: none !important;
}

.woocommerce-product-gallery.lpwpg-enhanced.lpwpg-single-image .lpwpg-arrow,
.woocommerce-product-gallery.lpwpg-enhanced.lpwpg-single-image .lpwpg-counter,
.woocommerce-product-gallery.lpwpg-enhanced.lpwpg-single-image .lpwpg-dots {
    display: none !important;
}

@media (min-width: 769px) {
    /* Left thumbnails are removed from document flow. This means the thumbnail
     * rail can never make the whole gallery taller than the main image. */
    .woocommerce-product-gallery.lpwpg-enhanced.lpwpg-desktop-left {
        padding-left: calc(var(--lpwpg-effective-thumb-size) + var(--lpwpg-gap));
    }

    .woocommerce-product-gallery.lpwpg-enhanced.lpwpg-desktop-left .flex-control-thumbs {
        position: absolute;
        top: 0;
        bottom: 0;
        left: 0;
        width: var(--lpwpg-effective-thumb-size) !important;
        display: flex !important;
        flex-direction: column;
        gap: var(--lpwpg-thumb-gap);
        overflow-x: hidden;
        overflow-y: auto;
        overscroll-behavior: contain;
        scrollbar-width: thin;
        scroll-snap-type: y proximity;
    }

    .woocommerce-product-gallery.lpwpg-enhanced.lpwpg-desktop-left .flex-control-thumbs li {
        float: none !important;
        width: var(--lpwpg-effective-thumb-size) !important;
        height: var(--lpwpg-effective-thumb-size) !important;
        flex: 0 0 var(--lpwpg-effective-thumb-size);
        scroll-snap-align: start;
    }

    .woocommerce-product-gallery.lpwpg-enhanced.lpwpg-desktop-left .lpwpg-arrow-prev {
        left: calc(var(--lpwpg-effective-thumb-size) + var(--lpwpg-gap) + 10px);
    }

    .woocommerce-product-gallery.lpwpg-enhanced.lpwpg-desktop-left .lpwpg-arrow-next {
        right: 10px;
    }

    .woocommerce-product-gallery.lpwpg-enhanced.lpwpg-desktop-bottom .flex-control-thumbs {
        display: grid !important;
        grid-auto-flow: column;
        grid-auto-columns: var(--lpwpg-thumb-size);
        gap: 8px;
        overflow-x: auto;
        overflow-y: hidden;
        margin-top: 10px !important;
        padding-bottom: 3px !important;
        overscroll-behavior-inline: contain;
        scrollbar-width: thin;
    }

    .woocommerce-product-gallery.lpwpg-enhanced.lpwpg-desktop-bottom .flex-control-thumbs li {
        float: none !important;
        width: var(--lpwpg-thumb-size) !important;
        height: var(--lpwpg-thumb-size) !important;
    }

    .woocommerce-product-gallery.lpwpg-enhanced.lpwpg-desktop-bottom .lpwpg-arrow-prev {
        left: 10px;
    }

    .woocommerce-product-gallery.lpwpg-enhanced.lpwpg-desktop-bottom .lpwpg-arrow-next {
        right: 10px;
    }

    .woocommerce-product-gallery.lpwpg-enhanced.lpwpg-desktop-bottom .lpwpg-arrow {
        top: calc((100% - var(--lpwpg-thumb-size) - 13px) / 2);
    }

    .woocommerce-product-gallery.lpwpg-enhanced.lpwpg-desktop-bottom .lpwpg-counter {
        bottom: calc(var(--lpwpg-thumb-size) + 23px);
    }
}

@media (max-width: 768px) {
    .woocommerce-product-gallery.lpwpg-enhanced {
        display: block !important;
        width: 100% !important;
        max-width: 100% !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
        padding: 0 !important;
    }

    .woocommerce-product-gallery.lpwpg-enhanced .flex-viewport,
    .woocommerce-product-gallery.lpwpg-enhanced > .woocommerce-product-gallery__wrapper {
        width: 100% !important;
    }

    .woocommerce-product-gallery.lpwpg-enhanced .woocommerce-product-gallery__trigger {
        top: 9px;
        right: 9px;
        width: 36px;
        height: 36px;
    }

    .woocommerce-product-gallery.lpwpg-enhanced .lpwpg-arrow {
        width: 36px;
        height: 36px;
    }

    .woocommerce-product-gallery.lpwpg-enhanced .lpwpg-arrow span {
        font-size: 29px;
    }

    .woocommerce-product-gallery.lpwpg-enhanced .lpwpg-arrow-prev {
        left: 8px;
    }

    .woocommerce-product-gallery.lpwpg-enhanced .lpwpg-arrow-next {
        right: 8px;
    }

    .woocommerce-product-gallery.lpwpg-enhanced .lpwpg-counter {
        right: 9px;
        min-width: 46px;
        padding: 6px 8px;
        font-size: 11px;
    }

    .woocommerce-product-gallery.lpwpg-enhanced.lpwpg-mobile-dots .flex-control-thumbs,
    .woocommerce-product-gallery.lpwpg-enhanced.lpwpg-mobile-hidden .flex-control-thumbs {
        display: none !important;
    }

    .woocommerce-product-gallery.lpwpg-enhanced.lpwpg-mobile-dots .lpwpg-dots {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 3px;
        width: 100%;
        min-height: 30px;
        margin: 5px auto 0;
        padding: 0 5px;
        overflow-x: auto;
        scrollbar-width: none;
    }

    .woocommerce-product-gallery.lpwpg-enhanced.lpwpg-mobile-dots .lpwpg-dots::-webkit-scrollbar {
        display: none;
    }

    .woocommerce-product-gallery.lpwpg-enhanced .lpwpg-dot,
    .woocommerce-product-gallery.lpwpg-enhanced .lpwpg-dot.is-active {
        position: relative;
        width: 24px;
        min-width: 24px;
        height: 26px;
        margin: 0;
        padding: 0;
        border: 0;
        border-radius: 999px;
        background: transparent;
        box-shadow: none;
        cursor: pointer;
    }

    .woocommerce-product-gallery.lpwpg-enhanced .lpwpg-dot::before {
        content: '';
        position: absolute;
        top: 50%;
        left: 50%;
        width: 7px;
        height: 7px;
        transform: translate(-50%, -50%);
        border-radius: 999px;
        background: #c8cdd2;
        transition: width 140ms ease, background 140ms ease;
    }

    .woocommerce-product-gallery.lpwpg-enhanced .lpwpg-dot.is-active::before {
        width: 18px;
        background: #263238;
    }

    .woocommerce-product-gallery.lpwpg-enhanced.lpwpg-mobile-dots .lpwpg-counter {
        bottom: 40px;
    }

    .woocommerce-product-gallery.lpwpg-enhanced.lpwpg-mobile-dots .lpwpg-arrow {
        top: calc((100% - 35px) / 2);
    }

    .woocommerce-product-gallery.lpwpg-enhanced.lpwpg-mobile-strip .flex-control-thumbs {
        display: grid !important;
        grid-auto-flow: column;
        grid-auto-columns: 58px;
        gap: 7px;
        overflow-x: auto;
        overflow-y: hidden;
        margin-top: 8px !important;
        padding: 0 2px 3px !important;
        overscroll-behavior-inline: contain;
        scrollbar-width: none;
        scroll-snap-type: x proximity;
    }

    .woocommerce-product-gallery.lpwpg-enhanced.lpwpg-mobile-strip .flex-control-thumbs::-webkit-scrollbar {
        display: none;
    }

    .woocommerce-product-gallery.lpwpg-enhanced.lpwpg-mobile-strip .flex-control-thumbs li {
        float: none !important;
        width: 58px !important;
        height: 58px !important;
        scroll-snap-align: start;
    }

    .woocommerce-product-gallery.lpwpg-enhanced.lpwpg-mobile-strip .lpwpg-counter {
        bottom: 74px;
    }

    .woocommerce-product-gallery.lpwpg-enhanced.lpwpg-mobile-strip .lpwpg-arrow {
        top: calc((100% - 67px) / 2);
    }

    .woocommerce-product-gallery.lpwpg-enhanced.lpwpg-mobile-hidden .lpwpg-dots {
        display: none !important;
    }

    /* Keep the native PhotoSwipe controls available on touch devices. */
    body.lpwpg-pswp-open .pswp__button--arrow--left,
    body.lpwpg-pswp-open .pswp__button--arrow--right,
    body.lpwpg-pswp-open .pswp__button--close,
    body.lpwpg-pswp-open .pswp__counter {
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
        pointer-events: auto !important;
    }

    body.lpwpg-pswp-open .pswp__ui--idle .pswp__top-bar,
    body.lpwpg-pswp-open .pswp__ui--idle .pswp__button--arrow--left,
    body.lpwpg-pswp-open .pswp__ui--idle .pswp__button--arrow--right {
        opacity: 1 !important;
    }
}

/* jQuery Zoom adds a second image layer. Hide only that generated layer on
 * phones and touch layouts so the gallery does not magnify on accidental hover. */
@media (max-width: 768px), (hover: none) and (pointer: coarse) {
    .woocommerce-product-gallery.lpwpg-enhanced.lpwpg-mobile-no-hover-zoom .zoomImg {
        display: none !important;
        opacity: 0 !important;
        visibility: hidden !important;
        pointer-events: none !important;
    }
}

@media (prefers-reduced-motion: reduce) {
    .woocommerce-product-gallery.lpwpg-enhanced *,
    .woocommerce-product-gallery.lpwpg-enhanced *::before,
    .woocommerce-product-gallery.lpwpg-enhanced *::after {
        scroll-behavior: auto !important;
        transition-duration: 0.001ms !important;
        animation-duration: 0.001ms !important;
    }
}
