/* ==========================================================================
   G'day Coffee – Single product gallery + lightbox
   Mobile first. Uploaded images of different sizes are unified in a square
   frame without cropping the source image:
     --gday-gallery-ratio : 1 / 1 on every viewport
     --gday-gallery-fit   : contain keeps every full product image visible
   ========================================================================== */

.gday-gallery {
    --gday-gallery-ratio: 1 / 1;
    --gday-gallery-fit: contain;
    --gday-gallery-bg: #f4f1ec;
    --gday-green: #1c583f;
    --gday-orange: #E87722;
}

/* Reset WooCommerce / theme defaults that break the slider layout */
.woocommerce div.product div.images.gday-gallery {
    position: relative;
    float: none;
    width: 100%;
    margin: 0;
    overflow: visible;
    border: 0;
    box-shadow: none;
    background: transparent;
}

.woocommerce div.product div.images.gday-gallery .woocommerce-product-gallery__wrapper {
    margin: 0;
    padding: 0;
}

.gday-gallery__stage {
    position: relative;
}

/* ---- Main slider ---- */
.gday-gallery__main.swiper {
    position: relative;
    width: 100%;
    aspect-ratio: var(--gday-gallery-ratio);
    background: var(--gday-gallery-bg);
    overflow: hidden;
    touch-action: pan-y;
    -webkit-tap-highlight-color: transparent;
}

.woocommerce div.product div.images.gday-gallery .gday-gallery__main .swiper-wrapper,
.gday-gallery__thumbs .swiper-wrapper,
.gday-lightbox__swiper .swiper-wrapper {
    display: flex;
    position: relative;
    box-sizing: content-box;
    transition-property: transform;
}

.gday-gallery__main .swiper-wrapper {
    height: 100%;
}

.woocommerce div.product div.images.gday-gallery .gday-gallery__slide {
    width: 100%;
    height: 100%;
    flex-shrink: 0;
    display: block;
    margin: 0;
}

.gday-gallery__link {
    display: block;
    width: 100%;
    height: 100%;
    cursor: zoom-in;
    -webkit-tap-highlight-color: transparent;
}

.woocommerce div.product div.images.gday-gallery .gday-gallery__img {
    display: block;
    width: 100%;
    height: 100%;
    max-height: none;
    object-fit: var(--gday-gallery-fit);
    object-position: center;
    border-radius: 0 !important;
    box-shadow: none;
    user-select: none;
    -webkit-user-drag: none;
}

/* Sale badge */
.gday-gallery__badge {
    position: absolute;
    top: 1rem;
    left: 1rem;
    z-index: 5;
    background: var(--gday-orange);
    color: #fff;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    padding: 0.25rem 0.75rem;
    border-radius: 999px;
    pointer-events: none;
}

/* Counter pill "1 / 3" */
.gday-gallery__counter {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    z-index: 4;
    padding: 0.2rem 0.65rem;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.45);
    color: #fff;
    font-size: 0.75rem;
    line-height: 1.4;
    font-variant-numeric: tabular-nums;
    pointer-events: none;
}

/* Dots */
.gday-gallery .gday-gallery__dots {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0.75rem;
    top: auto;
    z-index: 4;
    display: flex;
    justify-content: center;
    gap: 6px;
    pointer-events: none;
}

.gday-gallery__dots .swiper-pagination-bullet {
    width: 7px;
    height: 7px;
    margin: 0 !important;
    background: #fff;
    opacity: 0.6;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.12);
    transition: width 0.25s ease, opacity 0.25s ease, background 0.25s ease;
    pointer-events: auto;
}

.gday-gallery__dots .swiper-pagination-bullet-active {
    width: 20px;
    border-radius: 999px;
    opacity: 1;
    background: var(--gday-orange);
}

/* Zoom (fullscreen) button */
.gday-gallery__zoom {
    position: absolute;
    right: 0.75rem;
    bottom: 0.75rem;
    z-index: 4;
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.9);
    color: var(--gday-green);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
    cursor: pointer;
}

.gday-gallery__zoom svg,
.gday-gallery__nav svg,
.gday-lightbox__btn svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* Prev / next arrows – hidden on touch, shown on hover for desktop */
.gday-gallery__nav {
    position: absolute;
    top: 50%;
    z-index: 4;
    width: 40px;
    height: 40px;
    margin-top: -20px;
    display: none;
    place-items: center;
    border: 0;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.92);
    color: var(--gday-green);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.12);
    cursor: pointer;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.gday-gallery__nav--prev { left: 0.75rem; }
.gday-gallery__nav--next { right: 0.75rem; }

.gday-gallery__nav.swiper-button-disabled {
    opacity: 0 !important;
    pointer-events: none;
}

@media (hover: hover) and (pointer: fine) {
    .gday-gallery__nav {
        display: grid;
        opacity: 0;
    }

    .gday-gallery__main:hover .gday-gallery__nav,
    .gday-gallery__nav:focus-visible {
        opacity: 1;
    }

    .gday-gallery__nav:hover {
        transform: scale(1.06);
    }
}

/* ---- Thumbnails ---- */
.gday-gallery__thumbs.swiper {
    margin-top: 0.625rem;
    padding: 0 1rem;
    overflow: hidden;
}

.woocommerce div.product div.images.gday-gallery .gday-gallery__thumb {
    width: 72px;
    height: 72px;
    flex-shrink: 0;
    border-radius: 10px;
    overflow: hidden;
    cursor: pointer;
    opacity: 0.55;
    border: 2px solid transparent;
    background: var(--gday-gallery-bg);
    transition: opacity 0.2s ease, border-color 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

.woocommerce div.product div.images.gday-gallery .gday-gallery__thumb.swiper-slide-thumb-active {
    opacity: 1;
    border-color: var(--gday-green);
}

.woocommerce div.product div.images.gday-gallery .gday-gallery__thumb:focus-visible {
    outline: 2px solid var(--gday-orange);
    outline-offset: 2px;
}

.woocommerce div.product div.images.gday-gallery .gday-gallery__thumb img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 0;
    box-shadow: none;
}

/* ---- Tablet / desktop ---- */
@media (min-width: 768px) {
    .gday-gallery__main.swiper {
        border-radius: 16px;
    }

    .gday-gallery__thumbs.swiper {
        margin-top: 0.875rem;
        padding: 0;
    }

    .woocommerce div.product div.images.gday-gallery .gday-gallery__thumb {
        width: 80px;
        height: 80px;
    }

    .gday-gallery__counter {
        display: none;
    }
}

/* Native scroll-snap fallback keeps touch browsing available if Swiper's CDN is unavailable. */
.gday-gallery__main.gday-gallery__main--native {
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
    touch-action: pan-x pan-y;
    -webkit-overflow-scrolling: touch;
}

.gday-gallery__main.gday-gallery__main--native::-webkit-scrollbar,
.gday-gallery__thumbs.gday-gallery__thumbs--native::-webkit-scrollbar,
.gday-lightbox__swiper--native::-webkit-scrollbar {
    display: none;
}

.gday-gallery__main--native .swiper-wrapper {
    display: flex;
    width: 100%;
    height: 100%;
    transform: none !important;
    transition: none !important;
}

.woocommerce div.product div.images.gday-gallery .gday-gallery__main--native .gday-gallery__slide {
    flex: 0 0 100%;
    scroll-snap-align: start;
    scroll-snap-stop: always;
}

.gday-gallery__thumbs.gday-gallery__thumbs--native {
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}

.gday-gallery__thumbs--native .swiper-wrapper {
    display: flex;
    width: max-content;
    transform: none !important;
    transition: none !important;
}

.woocommerce div.product div.images.gday-gallery .gday-gallery__thumbs--native .gday-gallery__thumb {
    flex: 0 0 auto;
    scroll-snap-align: start;
}

.gday-gallery__dots .gday-gallery__dot {
    width: 8px;
    height: 8px;
    padding: 0;
    border: 0;
    border-radius: 999px;
    background: #fff;
    opacity: 0.65;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.12);
    cursor: pointer;
}

.gday-gallery__dots .gday-gallery__dot.is-active {
    width: 20px;
    background: var(--gday-orange);
    opacity: 1;
}

.gday-gallery__main--native .gday-gallery__dots {
    pointer-events: auto;
}

@media (min-width: 1024px) {
    .product-gallery-wrapper {
        position: sticky;
        top: 6rem;
    }
}

/* ==========================================================================
   Lightbox
   ========================================================================== */
html.gday-lightbox-open,
html.gday-lightbox-open body {
    overflow: hidden !important;
}

.gday-lightbox {
    position: fixed;
    inset: 0;
    z-index: 100000;
    display: flex;
    flex-direction: column;
    color: #fff;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.22s ease, visibility 0s linear 0.22s;
}

.gday-lightbox.is-open {
    opacity: 1;
    visibility: visible;
    transition: opacity 0.22s ease;
}

.gday-lightbox__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 15, 15, 0.94);
    transition: opacity 0.2s ease;
}

.gday-lightbox__bar {
    position: relative;
    z-index: 3;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: calc(env(safe-area-inset-top, 0px) + 0.75rem) 1rem 0.75rem;
}

.gday-lightbox__counter {
    font-size: 0.9rem;
    font-variant-numeric: tabular-nums;
    opacity: 0.85;
}

.gday-lightbox__btn {
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.14);
    color: #fff;
    cursor: pointer;
    transition: background 0.2s ease;
}

.gday-lightbox__btn:hover,
.gday-lightbox__btn:focus-visible {
    background: rgba(255, 255, 255, 0.28);
    outline: none;
}

.gday-lightbox__btn svg {
    width: 22px;
    height: 22px;
}

.gday-lightbox__swiper.swiper {
    position: relative;
    z-index: 2;
    flex: 1;
    width: 100%;
    min-height: 0;
    transition: transform 0.2s ease;
}

.gday-lightbox__swiper .swiper-slide {
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.gday-lightbox__swiper .swiper-zoom-container {
    padding: 0 0.5rem;
}

.gday-lightbox__swiper img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    user-select: none;
    -webkit-user-drag: none;
}

/* Native lightbox fallback for touch devices when the Swiper script is unavailable. */
.gday-lightbox__swiper--native {
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
    touch-action: pan-x;
    -webkit-overflow-scrolling: touch;
}

.gday-lightbox__swiper--native .swiper-wrapper {
    display: flex;
    width: 100%;
    height: 100%;
    transform: none !important;
    transition: none !important;
}

.gday-lightbox__swiper--native .swiper-slide {
    flex: 0 0 100%;
    width: 100%;
    height: 100%;
    scroll-snap-align: center;
}

.gday-lightbox--native .gday-lightbox__nav {
    display: grid;
}

.gday-lightbox--native .gday-lightbox__nav[hidden] {
    display: none;
}

.gday-lightbox__nav {
    position: absolute;
    top: 50%;
    z-index: 3;
    margin-top: -22px;
    display: none;
}

.gday-lightbox__nav--prev { left: 1rem; }
.gday-lightbox__nav--next { right: 1rem; }

.gday-lightbox__nav.swiper-button-disabled {
    opacity: 0.25;
    pointer-events: none;
}

.gday-lightbox__hint {
    position: relative;
    z-index: 3;
    margin: 0;
    padding: 0.75rem 1rem calc(env(safe-area-inset-bottom, 0px) + 1rem);
    text-align: center;
    font-size: 0.8rem;
    opacity: 0.65;
    pointer-events: none;
}

@media (hover: hover) and (pointer: fine) {
    .gday-lightbox__nav {
        display: grid;
    }
}

@media (prefers-reduced-motion: reduce) {
    .gday-lightbox,
    .gday-lightbox.is-open,
    .gday-gallery__dots .swiper-pagination-bullet {
        transition: none;
    }
}
