/* =======================================================================
   Exist Green Swiper Gallery Layout
   -----------------------------------------------------------------------
   Neutral base styles powered by CSS custom properties so each layout mode
   (picture-first, action-first, info-first) can define its own proportions
   without fighting global !important overrides.
   ======================================================================= */

body.single-product {
    /* Shared gallery defaults */
    --eg-thumb-width: 72px;
    --eg-thumb-height: 72px;
    --eg-thumb-radius: 4%;
    --eg-thumb-gap: 0.75rem;
    --eg-thumb-direction: row;
    --eg-thumb-justify: flex-start;
    --eg-thumb-overflow-x: hidden;
    --eg-thumb-overflow-y: hidden;
    --eg-swiper-main-max-height: none;
    --eg-swiper-main-object-fit: contain;
    --eg-swiper-main-object-position: top center;
    --eg-swiper-main-radius: 6px;
    --eg-nav-color: #6b8e8c;
    --eg-nav-background: linear-gradient(135deg, #d4e5d3, #d0e8e6);
    --eg-nav-size: 32px;
    --eg-nav-icon-size: 16px;
}

body.single-product .eg-swiper-container {
    /* Ensure gallery is visible and clickable before variation is selected (variable products) */
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
}

/* Picture-first: gallery fills its grid column */
body.single-product.eg-layout-picture .eg-swiper-container {
    width: 100%;
}

body.single-product .eg-swiper-main {
    width: 100%;
    border-radius: var(--eg-swiper-main-radius);
    overflow: hidden;
    background-color: transparent;
    max-height: var(--eg-swiper-main-max-height);
}

body.single-product .eg-swiper-main .swiper-slide {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    height: auto;
    min-height: 0;
    background-color: transparent;
}

body.single-product .eg-swiper-main .swiper-slide img {
    width: 100%;
    height: auto;
    max-height: 100%;
    object-fit: var(--eg-swiper-main-object-fit);
    object-position: var(--eg-swiper-main-object-position, top center);
    background-color: transparent;
}

body.single-product .eg-swiper-thumbs {
    display: block;
    overflow-x: var(--eg-thumb-overflow-x);
    overflow-y: var(--eg-thumb-overflow-y);
    padding: 0;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

body.single-product .eg-swiper-thumbs.has-overflow {
    cursor: grab;
}

body.single-product .eg-swiper-thumbs.has-overflow:active {
    cursor: grabbing;
}

body.single-product .eg-swiper-thumbs .swiper-wrapper {
    display: flex;
    flex-wrap: nowrap;
    flex-direction: var(--eg-thumb-direction);
    gap: var(--eg-thumb-gap);
    justify-content: var(--eg-thumb-justify);
    align-items: flex-start;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

body.single-product .eg-swiper-thumbs .swiper-slide {
    width: var(--eg-thumb-width);
    height: var(--eg-thumb-height);
    opacity: 0.5;
    flex: 0 0 auto;
}

body.single-product .eg-swiper-thumbs .swiper-slide img {
    border: 0;
    border-radius: var(--eg-thumb-radius);
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

body.single-product .eg-swiper-thumbs .swiper-slide:hover img {
    opacity: 0.85;
    transform: scale(1.03);
}

body.single-product .eg-swiper-thumbs .swiper-slide-thumb-active {
    opacity: 1;
    background-color: var(--eg-thumb-active-background, #cbd8c2);
}

body.single-product .eg-swiper-main .swiper-button-next,
body.single-product .eg-swiper-main .swiper-button-prev {
    color: var(--eg-nav-color);
    margin-top: 0;
    background: var(--eg-nav-background);
    border-radius: 50%;
    width: var(--eg-nav-size);
    height: var(--eg-nav-size);
    --swiper-navigation-size: var(--eg-nav-icon-size);
}

@media (max-width: 768px) {
    body.single-product .eg-swiper-main .swiper-button-next,
    body.single-product .eg-swiper-main .swiper-button-prev {
        display: none;
    }
}

/* Pagination dots: hidden by default, shown on picture-first mobile only */
body.single-product .eg-swiper-main .swiper-pagination {
    display: none;
}

/* -----------------------------------------------------------------------
   Picture-first: two-column sticky gallery hero layout
   ----------------------------------------------------------------------- */
body.single-product.eg-layout-picture {
    --eg-layout-max-width: min(100%, 1440px);
    --eg-layout-padding: clamp(1.5rem, 3vw, 2.5rem);
    --eg-layout-gap: clamp(2rem, 5vw, 4rem);
    --eg-layout-columns: minmax(0, 1fr) minmax(0, 1fr);
    --eg-gallery-position: sticky;
    --eg-gallery-top: var(--eg-sticky-top, 96px);
    --eg-gallery-align: flex-start;
    --eg-gallery-margin-inline: 0;
    --eg-gallery-max-width: 100%;
    --eg-gallery-max-height: calc(100vh - var(--eg-sticky-top, 96px) - 2rem);
    --eg-gallery-overflow: hidden;
    --eg-info-min-height: calc(100vh - var(--eg-sticky-top, 96px));
    --eg-swiper-main-max-height: calc(100vh - var(--eg-sticky-top, 96px) - var(--eg-thumb-height, 72px) - 3rem);
    --eg-thumb-direction: row;
    --eg-thumb-justify: flex-start;
    --eg-thumb-overflow-x: hidden;
    --eg-thumb-overflow-y: hidden;
}

body.single-product.eg-layout-picture .eg-product-wrapper {
    max-width: var(--eg-layout-max-width);
    margin: 0 auto;
    padding: clamp(0.5rem, 1.5vw, 1rem) 3%;
    position: relative;
    box-sizing: border-box;
}

body.single-product.eg-layout-picture .eg-product-layout {
    display: grid;
    grid-template-columns: var(--eg-layout-columns);
    gap: var(--eg-layout-gap);
    align-items: flex-start;
    padding-bottom: 2rem;
}

body.single-product.eg-layout-picture .eg-gallery-column {
    position: var(--eg-gallery-position);
    top: var(--eg-gallery-top);
    width: 100%;
    max-width: var(--eg-gallery-max-width);
    max-height: var(--eg-gallery-max-height);
    overflow: var(--eg-gallery-overflow);
    align-self: var(--eg-gallery-align);
    margin-inline: var(--eg-gallery-margin-inline);
}

body.single-product.eg-layout-picture .eg-gallery-column,
body.single-product.eg-layout-picture .eg-swiper-container,
body.single-product.eg-layout-picture .eg-swiper-main,
body.single-product.eg-layout-picture .eg-swiper-thumbs {
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
}

body.single-product.eg-layout-picture .eg-info-column {
    min-height: var(--eg-info-min-height);
    padding-left: clamp(1rem, 2vw, 2rem);
}

body.single-product.eg-layout-picture .eg-swiper-container {
    display: block;
    gap: 1rem;
    align-items: flex-start;
}

body.single-product.eg-layout-picture .eg-swiper-thumbs {
    max-height: none;
    margin-top: 0.75rem;
    overflow: hidden;
}

body.single-product.eg-layout-picture .eg-swiper-thumbs .swiper-wrapper {
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 0.6rem;
}

body.single-product.eg-layout-picture .eg-swiper-thumbs .swiper-slide {
    width: calc(25% - 0.45rem);
    height: auto;
    aspect-ratio: 1 / 1;
}

/* Fill more horizontal space: 5–6 thumbnails per row on wide screens */
@media (min-width: 1400px) {
    body.single-product.eg-layout-picture .eg-swiper-thumbs .swiper-slide {
        width: calc(16.666% - 0.5rem); /* 6 per row */
    }
}

@media (min-width: 1200px) and (max-width: 1399px) {
    body.single-product.eg-layout-picture .eg-swiper-thumbs .swiper-slide {
        width: calc(20% - 0.5rem); /* 5 per row */
    }
}

/* Mid-to-large screens: keep cleaner stacked gallery with wrapped thumbs.
   This avoids the abrupt side-thumbs jump and large dead space under gallery. */
@media (max-width: 1199px) and (min-width: 481px) {
    body.single-product.eg-layout-picture {
        --eg-gallery-position: relative;
        --eg-gallery-top: auto;
        --eg-gallery-max-height: none;
        --eg-gallery-overflow: visible;
        --eg-info-min-height: auto;
        --eg-thumb-direction: row;
        --eg-thumb-overflow-x: hidden;
        --eg-thumb-overflow-y: visible;
        --eg-thumb-width: 88px;
        --eg-thumb-height: 88px;
    }

    body.single-product.eg-layout-picture .eg-gallery-column {
        position: sticky;
        top: var(--eg-sticky-top, 96px);
        max-height: calc(100vh - var(--eg-sticky-top, 96px) - 1rem);
        overflow: hidden;
    }

    body.single-product.eg-layout-picture .eg-info-column {
        min-height: auto;
    }

    body.single-product.eg-layout-picture .eg-swiper-container {
        display: block;
    }

    body.single-product.eg-layout-picture .eg-swiper-thumbs {
        margin-top: 0.75rem;
        max-height: none;
        overflow: hidden;
    }

    body.single-product.eg-layout-picture .eg-swiper-thumbs .swiper-wrapper {
        flex-wrap: wrap;
        justify-content: flex-start;
        gap: 0.6rem;
    }

    body.single-product.eg-layout-picture .eg-swiper-thumbs .swiper-slide {
        width: calc(25% - 0.45rem);
        height: auto;
        aspect-ratio: 1 / 1;
    }
}

/* Wide desktop: sticky gallery with below-image thumb grid. */
@media (min-width: 1200px) {
    body.single-product.eg-layout-picture {
        --eg-gallery-position: sticky;
        --eg-gallery-top: var(--eg-sticky-top, 96px);
        --eg-gallery-max-height: calc(100vh - var(--eg-sticky-top, 96px) - 1rem);
        --eg-gallery-overflow: hidden;
        --eg-info-min-height: auto;
        --eg-thumb-direction: row;
        --eg-thumb-overflow-x: hidden;
        --eg-thumb-overflow-y: hidden;
        --eg-thumb-width: 88px;
        --eg-thumb-height: 88px;
    }

    body.single-product.eg-layout-picture .eg-swiper-container {
        display: block;
    }

    body.single-product.eg-layout-picture .eg-swiper-thumbs .swiper-wrapper {
        flex-wrap: wrap;
    }

    body.single-product.eg-layout-picture .eg-swiper-thumbs .swiper-slide {
        width: calc(25% - 0.45rem);
        height: auto;
        aspect-ratio: 1 / 1;
    }
}

/* Tablet adjustments (860px-1023px): picture-first shows a compact thumb grid below image */
@media (max-width: 1023px) and (min-width: 481px) {
    body.single-product.eg-layout-picture {
        --eg-thumb-direction: row;
        --eg-thumb-overflow-x: hidden;
        --eg-thumb-overflow-y: hidden;
        --eg-thumb-width: 88px;
        --eg-thumb-height: 88px;
        --eg-swiper-main-max-height: calc(100vh - var(--eg-sticky-top, 96px) - var(--eg-thumb-height, 88px) - 3rem);
    }

    body.single-product.eg-layout-picture .eg-product-wrapper {
        padding: clamp(0.75rem, 2vw, 1rem) 0;
    }

    body.single-product.eg-layout-picture .eg-swiper-container {
        display: block;
        gap: 0.75rem;
    }

    body.single-product.eg-layout-picture .eg-swiper-thumbs {
        margin-top: 0.75rem;
        max-height: none;
        overflow: hidden;
    }

    body.single-product.eg-layout-picture .eg-swiper-thumbs .swiper-wrapper {
        flex-wrap: wrap;
        justify-content: flex-start;
        gap: 0.6rem;
    }

    body.single-product.eg-layout-picture .eg-swiper-thumbs .swiper-slide {
        width: calc(25% - 0.45rem);
        height: auto;
        aspect-ratio: 1 / 1;
    }
}

@media (max-width: 1023px) and (max-width: 859px) {
    body.single-product.eg-layout-picture .eg-product-wrapper {
        padding: clamp(1rem, 4vw, 1.75rem) 1.5rem;
    }
}

/* Stack picture-first layout below tablet — swipe + dots, no thumbnails */
@media (max-width: 859px) {
    body.single-product.eg-layout-picture {
        --eg-swiper-main-max-height: clamp(280px, 55vh, 480px);
    }

    body.single-product.eg-layout-picture .eg-product-layout {
        display: block;
    }

    body.single-product.eg-layout-picture .eg-gallery-column {
        position: relative;
        top: auto;
        margin-bottom: 1.5rem;
        max-width: 100%;
        overflow-x: hidden;
        overflow-y: visible;
    }

    /* Contain image within capped height instead of cropping */
    body.single-product.eg-layout-picture .eg-swiper-main .swiper-slide img {
        max-height: var(--eg-swiper-main-max-height);
        object-fit: contain;
    }

    body.single-product.eg-layout-picture .eg-info-column {
        min-height: auto;
    }

    /* Full-width swipe gallery, no grid needed */
    body.single-product.eg-layout-picture .eg-swiper-container {
        display: block;
        max-width: 100%;
    }

    /* Hide thumbnails entirely on mobile — use dots instead */
    body.single-product.eg-layout-picture .eg-swiper-thumbs {
        display: none !important;
    }

    /* Pagination dots — position below image, let Swiper handle bullet layout */
    body.single-product.eg-layout-picture .eg-swiper-main .swiper-pagination {
        display: block;
        position: relative;
        bottom: auto;
        padding: 0.75rem 0 0.25rem;
        text-align: center;
        width: 100%;
    }

    body.single-product.eg-layout-picture .eg-swiper-main .swiper-pagination-bullet {
        width: 7px;
        height: 7px;
        border-radius: 50%;
        background: #c5c5c5;
        opacity: 1;
        margin: 0 3px;
        transition: background 0.2s ease, transform 0.2s ease;
    }

    body.single-product.eg-layout-picture .eg-swiper-main .swiper-pagination-bullet-active {
        background: #6b8e8c;
    }
}


/* -----------------------------------------------------------------------
   Float-based layouts: action-first & info-first
   ----------------------------------------------------------------------- */
body.single-product.eg-layout-action,
body.single-product.eg-layout-info {
    --eg-thumb-width: 48px;
    --eg-thumb-height: 48px;
    --eg-thumb-gap: 0.5rem;
    --eg-thumb-direction: row;
    --eg-thumb-overflow-x: hidden;
    --eg-thumb-overflow-y: hidden;
    --eg-gallery-margin-right: clamp(1.25rem, 3vw, 2rem);
    --eg-gallery-margin-bottom: clamp(1.5rem, 4vw, 2.25rem);
}

body.single-product.eg-layout-action {
    --eg-gallery-width-desktop: clamp(200px, 30%, 280px);
    --eg-gallery-width-tablet: clamp(240px, 45%, 320px);
    --eg-gallery-width-mobile: clamp(180px, 40%, 200px);
    --eg-swiper-main-max-height: clamp(260px, 38vh, 420px);
}

body.single-product.eg-layout-info {
    --eg-gallery-width-desktop: clamp(180px, 28%, 260px);
    --eg-gallery-width-tablet: clamp(220px, 42%, 300px);
    --eg-gallery-width-mobile: clamp(160px, 35%, 180px);
    --eg-swiper-main-max-height: clamp(220px, 34vh, 380px);
}

/* Action/info: float + sizing handled by eg-layout-modes.css (gallery inside card) */
body.single-product.eg-layout-action .eg-swiper-container,
body.single-product.eg-layout-info .eg-swiper-container {
    display: block;
}

body.single-product.eg-layout-action .eg-swiper-main,
body.single-product.eg-layout-info .eg-swiper-main {
    max-height: var(--eg-swiper-main-max-height);
}

body.single-product.eg-layout-action .eg-swiper-thumbs,
body.single-product.eg-layout-info .eg-swiper-thumbs {
    margin-top: 0.75rem;
    justify-content: flex-start;
}

body.single-product.eg-layout-action .eg-swiper-thumbs .swiper-wrapper,
body.single-product.eg-layout-info .eg-swiper-thumbs .swiper-wrapper {
    justify-content: flex-start;
}

body.single-product.eg-layout-action .eg-info-column,
body.single-product.eg-layout-info .eg-info-column {
    display: contents;
}

@supports not (display: contents) {
    body.single-product.eg-layout-action .eg-info-column,
    body.single-product.eg-layout-info .eg-info-column {
        display: block;
    }
}

/* Action/info responsive gallery widths handled by eg-layout-modes.css */

@media (max-width: 480px) {
    /* Action/info gallery floats inside card — sizing handled by eg-layout-modes.css */
    body.single-product.eg-layout-action .eg-swiper-container,
    body.single-product.eg-layout-info .eg-swiper-container {
        margin: 0;
    }

    body.single-product.eg-layout-action,
    body.single-product.eg-layout-info {
        --eg-thumb-width: 56px;
        --eg-thumb-height: 56px;
        --eg-thumb-gap: 0.5rem;
        --eg-thumb-direction: row;
        --eg-thumb-justify: center;
    }
}

@media (max-width: 599px) {
    body.single-product.eg-layout-picture {
        --eg-thumb-width: 56px;
        --eg-thumb-height: 56px;
        --eg-thumb-gap: 0.5rem;
    }
}

/* Photoswipe overlay adjustments */
.pswp {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    z-index: 9999;
}

.pswp__bg {
    background: rgba(0, 0, 0, 0.85);
}

/* -----------------------------------------------------------------------
   Gallery Lightbox — fullscreen overlay using Swiper
   ----------------------------------------------------------------------- */

/* Hint that images are clickable */
.eg-swiper-main .swiper-slide img {
    cursor: zoom-in;
}

.eg-swiper-main .swiper-button-disabled {
    pointer-events: auto;
}

.eg-gallery-lightbox {
    position: fixed;
    inset: 0;
    z-index: 999999;
    background: rgba(15, 76, 58, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.25s ease;
}

.eg-gallery-lightbox.eg-lightbox-visible {
    opacity: 1;
}

.eg-gallery-lightbox .eg-lightbox-swiper {
    width: 90vw;
    height: 90vh;
    max-width: 1400px;
}

.eg-gallery-lightbox .swiper-slide {
    display: flex;
    align-items: center;
    justify-content: center;
}

.eg-gallery-lightbox .swiper-slide img {
    max-width: 100%;
    max-height: 88vh;
    object-fit: contain;
    cursor: default;
    user-select: none;
    -webkit-user-select: none;
}

.eg-gallery-lightbox .swiper-button-prev,
.eg-gallery-lightbox .swiper-button-next {
    color: #fff;
    opacity: 0.8;
    transition: opacity 0.2s ease;
}

.eg-gallery-lightbox .swiper-button-prev:hover,
.eg-gallery-lightbox .swiper-button-next:hover {
    opacity: 1;
}

.eg-lightbox-close {
    position: absolute;
    top: 1rem;
    right: 1.25rem;
    z-index: 10;
    width: 40px;
    height: 40px;
    border: none;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 50%;
    color: #fff;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
}

.eg-lightbox-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Counter (e.g., "2 / 5") */
.eg-lightbox-counter {
    position: absolute;
    bottom: 1rem;
    left: 50%;
    transform: translateX(-50%);
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.85rem;
    letter-spacing: 0.05em;
}
