/* ================================================================
   WGW – Product Gallery Widget for Elementor
   Description: Styles for all gallery layouts and components
   Author:      The Salt
   Updated:     2026-05
================================================================ */

/* ── CSS custom properties (only for thumb sizing now) */
.wgw-gallery {
    --wgw-thumb-size:      80px;
    --wgw-thumb-gap:       8px;
    --wgw-thumb-main-gap:  12px;
    --wgw-transition:      0.22s ease;

    position: relative;
    width: 100%;
    line-height: 0;
}

/* ── Editor placeholder */
.wgw-notice {
    padding: 16px;
    background: #f5f5f5;
    border: 1px dashed #ccc;
    color: #888;
    font-size: 13px;
    line-height: 1.5;
    text-align: center;
}


/* ================================================================
   LAYOUT VARIANTS
================================================================ */

/* Bottom (default) */
.wgw-gallery--thumbs-bottom {
    display: flex;
    flex-direction: column;
    gap: var(--wgw-thumb-main-gap);
}

/* Top */
.wgw-gallery--thumbs-top {
    display: flex;
    flex-direction: column-reverse;
    gap: var(--wgw-thumb-main-gap);
}

/* Left */
.wgw-gallery--thumbs-left {
    display: flex;
    flex-direction: row;
    gap: var(--wgw-thumb-main-gap);
    align-items: flex-start;
}

/* Right */
.wgw-gallery--thumbs-right {
    display: flex;
    flex-direction: row-reverse;
    gap: var(--wgw-thumb-main-gap);
    align-items: flex-start;
}

/* Left / Right: main grows, thumbs are fixed column width */
.wgw-gallery--thumbs-left  .wgw-main,
.wgw-gallery--thumbs-right .wgw-main {
    flex: 1 1 0;
    min-width: 0;
}

.wgw-gallery--thumbs-left  .wgw-thumbs,
.wgw-gallery--thumbs-right .wgw-thumbs {
    width: var(--wgw-thumb-size);
    flex-shrink: 0;
}

/* None / Inside: no external thumbs row */
.wgw-gallery--thumbs-none .wgw-main,
.wgw-gallery--thumbs-inside .wgw-main {
    width: 100%;
}


/* ================================================================
   MAIN IMAGE AREA
================================================================ */

.wgw-main {
    position: relative;
    width: 100%;
    flex-shrink: 0;
}

.wgw-main__img-wrap {
    position: relative;  /* anchor for inside thumbs + arrows if needed */
    display: block;
    width: 100%;
    overflow: hidden;    /* clips image overflow AND inside thumbs to border-radius */
    line-height: 0;
}

/* When has-ratio class is set, img must fill the fixed-ratio box */
.wgw-main__img-wrap.has-ratio .wgw-main__img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.wgw-main__img {
    display: block;
    width: 100%;
    height: auto;           /* natural ratio by default */
    object-fit: contain;    /* overridden by Elementor control */
    transition: opacity var(--wgw-transition);
    max-width: 100%;
}

.wgw-main__img.is-transitioning {
    opacity: 0;
}


/* ================================================================
   VIDEO
================================================================ */

.wgw-video {
    line-height: 0;
}

.wgw-video--iframe {
    position: relative;
    width: 100%;
    padding-bottom: 56.25%; /* 16:9 default */
}

.wgw-video--iframe iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 0;
}

.wgw-video--native video {
    display: block;
    width: 100%;
    height: auto;
}


/* ================================================================
   MAIN ARROWS
================================================================ */

.wgw-arrow {
    position: absolute;
    top: 50%;
    z-index: 2;
    transform: translateY(-50%);

    display: flex;
    align-items: center;
    justify-content: center;

    /* Size set directly by Elementor selector, default 40px */
    width:  40px;
    height: 40px;
    padding: 0;
    border: none;
    cursor: pointer;

    background-color: rgba(255, 255, 255, 0.85);
    color: #1a1a1a;
    border-radius: 50%;

    transition:
        background-color var(--wgw-transition),
        color            var(--wgw-transition),
        opacity          var(--wgw-transition);

    line-height: 1;
    flex-shrink: 0;
}

.wgw-arrow:hover {
    background-color: #fff;
}

/* Offset set directly by Elementor selector, default 12px */
.wgw-arrow--prev { left:  12px; }
.wgw-arrow--next { right: 12px; }

.wgw-arrow svg {
    display: block;
    width:  16px;
    height: 16px;
    pointer-events: none;
    flex-shrink: 0;
}

/* ── Custom icon wrapper – flip for "prev" direction */
.wgw-arrow-icon-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.wgw-arrow-icon-wrap--flip {
    transform: scaleX(-1);
}

.wgw-arrow-icon-wrap i,
.wgw-arrow-icon-wrap svg,
.wgw-arrow-icon-wrap img {
    display: block;
    width:  16px;
    height: 16px;
    pointer-events: none;
    flex-shrink: 0;
}


/* ================================================================
   DOTS
================================================================ */

.wgw-dots {
    position: absolute;
    bottom: 12px;
    left: 50%;
    z-index: 2;
    transform: translateX(-50%);

    display: flex;
    align-items: center;
    gap: 6px;
    line-height: 0;
}

.wgw-dot {
    display: block;
    width: 8px;
    height: 8px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    transition:
        background-color var(--wgw-transition),
        transform        var(--wgw-transition);
}

.wgw-dot.is-active {
    background-color: #fff;
    transform: scale(1.3);
}


/* ================================================================
   THUMBNAIL STRIP
================================================================ */

/* ── Outer wrapper */
.wgw-thumbs {
    display: flex;
    align-items: center;
    gap: 4px;
    min-width: 0;
    line-height: 0;
}

/* ── Scrollable track */
.wgw-thumbs__track {
    flex: 1 1 0;
    display: flex;
    gap: var(--wgw-thumb-gap);
    overflow: hidden;          /* JS handles scroll */
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    min-width: 0;
}

/* Horizontal tracks (bottom / top) */
.wgw-gallery--thumbs-bottom .wgw-thumbs__track,
.wgw-gallery--thumbs-top    .wgw-thumbs__track {
    flex-direction: row;
    overflow-x: auto;
    overflow-y: hidden;
}

/* Vertical tracks (left / right) */
.wgw-gallery--thumbs-left  .wgw-thumbs,
.wgw-gallery--thumbs-right .wgw-thumbs {
    flex-direction: column;
    width: var(--wgw-thumb-size);
}

.wgw-gallery--thumbs-left  .wgw-thumbs__track,
.wgw-gallery--thumbs-right .wgw-thumbs__track {
    flex-direction: column;
    overflow-x: hidden;
    overflow-y: auto;
    /* max-height is set by JS to match main image height */
}

/* Hide scrollbar visually (JS arrows handle it) */
.wgw-thumbs__track {
    scrollbar-width: none;
    -ms-overflow-style: none;
}
.wgw-thumbs__track::-webkit-scrollbar {
    display: none;
}

/* ── Thumbnail button */
.wgw-thumb {
    flex-shrink: 0;
    flex-grow: 0;
    position: relative;                     /* anchor for absolute img */
    display: block;
    width:     var(--wgw-thumb-size, 80px);
    min-width: var(--wgw-thumb-size, 80px);
    height:    var(--wgw-thumb-size, 80px);
    padding: 0;
    border: 2px solid transparent;
    cursor: pointer;
    overflow: hidden;
    background: none;

    transition:
        opacity      var(--wgw-transition),
        border-color var(--wgw-transition);
}

.wgw-thumb:not(.is-active) {
    opacity: 0.5;
}

.wgw-thumb.is-active {
    opacity: 1;
    border-color: currentColor;
}

.wgw-thumb img {
    /* position:absolute + inset:0 fills the button completely,
       regardless of border, box-sizing or flex context */
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    pointer-events: none;
}

/* Video thumbnail play icon */
.wgw-thumb__play {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: block;
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 7px 0 7px 14px;
    border-color: transparent transparent transparent rgba(255,255,255,0.9);
    pointer-events: none;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,0.4));
}

/* ── Thumbnail nav arrows */
.wgw-thumbs__arrow {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: none;
    background: none;
    cursor: pointer;
    color: #555;
    line-height: 1;

    transition:
        color   var(--wgw-transition),
        opacity var(--wgw-transition);
}

.wgw-thumbs__arrow:hover { color: #000; }

.wgw-thumbs__arrow[disabled] {
    opacity: 0.25;
    cursor: default;
    pointer-events: none;
}

.wgw-thumbs__arrow svg {
    display: block;
    width: 20px;
    height: 20px;
    pointer-events: none;
}

/* For horizontal layouts, arrows are vertical chevrons (pointing left/right)
   For vertical layouts, we rotate them to point up/down */
.wgw-gallery--thumbs-left  .wgw-thumbs__arrow,
.wgw-gallery--thumbs-right .wgw-thumbs__arrow {
    width: 100%;
    height: 24px;
}

.wgw-gallery--thumbs-left  .wgw-thumbs__arrow--prev svg,
.wgw-gallery--thumbs-right .wgw-thumbs__arrow--prev svg {
    transform: rotate(90deg);
}

.wgw-gallery--thumbs-left  .wgw-thumbs__arrow--next svg,
.wgw-gallery--thumbs-right .wgw-thumbs__arrow--next svg {
    transform: rotate(-90deg);
}


/* ================================================================
   INSIDE OVERLAY THUMBNAILS
   Nested inside .wgw-main__img-wrap so overflow:hidden + border-radius
   automatically clips the overlay to the image shape.
================================================================ */

.wgw-thumbs--inside {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 3;
    padding: 8px;
    background: rgba(0, 0, 0, 0.35);
    /* border-radius inherited/clipped by parent overflow:hidden */
}

.wgw-thumbs--inside .wgw-thumbs__track {
    flex-direction: row;
    overflow-x: auto;
    overflow-y: hidden;
}


/* ================================================================
   LIGHTBOX GROUP – visually hidden, JS-clickable
================================================================ */

.wgw-lightbox-group {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    pointer-events: none;
    z-index: -1;
    top: 0;
    left: 0;
}

/* Temporarily revealed by JS before .click() to ensure event fires */
.wgw-lightbox-group.is-triggering {
    pointer-events: auto;
    position: static;
    width: auto;
    height: auto;
    clip: auto;
}


/* ================================================================
   CURSOR / LIGHTBOX AFFORDANCE
================================================================ */

.wgw-gallery[data-lightbox="yes"] .wgw-main__img-wrap {
    cursor: zoom-in;
}
