/*
 * JW Gallery — frontend styles
 * Visual values are driven by CSS custom properties so the settings page can
 * override them via wp_add_inline_style without editing this file.
 */

:root {
    --jwg-thumb-gap:              4px;
    --jwg-thumb-margin-top:       4px;
    --jwg-thumb-cols:             4;
    --jwg-active-outline:         #333333;
    --jwg-thumb-inactive-opacity: 1;
    --jwg-thumb-hover-opacity:    1;
    --jwg-pswp-sidebar-bg:        rgba(255, 255, 255, 0.9);
    --jwg-pswp-sidebar-scrollbar: rgba(0, 0, 0, 0.2);
    --jwg-pswp-sidebar-outline:   rgba(0, 0, 0, 0.6);
}

/* Hide WooCommerce's native gallery children — the plugin renders its own */
.woocommerce-product-gallery > *:not(#jwgallery-container) {
    display: none !important;
}

/* ── Container ─────────────────────────────────────────────────────────── */

#jwgallery-container {
    width: 100%;
    box-sizing: border-box;
}

/* ── Main image ─────────────────────────────────────────────────────────── */

.jwg-main {
    position: relative;
    line-height: 0;
    background: #f5f5f5;
    cursor: zoom-in;
}

.jwg-main-img {
    width: 100%;
    height: auto;
    display: block;
}

/* ── Zoom trigger (top-right corner of main image) ──────────────────────── */

.jwg-trigger {
    position: absolute;
    top: 0.75em;
    right: 0.75em;
    width: 2.25em;
    height: 2.25em;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.85);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}

.jwg-trigger:hover {
    background: #fff;
}

.jwg-trigger svg {
    width: 1em;
    height: 1em;
    fill: #333;
    display: block;
    pointer-events: none;
}

/* ── Thumbnail strip ────────────────────────────────────────────────────── */

.jwg-thumbs {
    display: grid;
    grid-template-columns: repeat(var(--jwg-thumb-cols), 1fr);
    gap: var(--jwg-thumb-gap);
    margin-top: var(--jwg-thumb-margin-top);
}

.jwg-thumb {
    cursor: pointer;
    line-height: 0;
    opacity: var(--jwg-thumb-inactive-opacity);
    outline: 2px solid transparent;
    outline-offset: 2px;
    transition: opacity 0.15s, outline-color 0.15s;
}

.jwg-thumb:hover {
    opacity: var(--jwg-thumb-hover-opacity);
}

.jwg-thumb.active {
    opacity: 1;
    outline-color: var(--jwg-active-outline);
}

.jwg-thumb img {
    width: 100%;
    height: auto;
    display: block;
}

/* ── PhotoSwipe caption ─────────────────────────────────────────────────── */

.jwg-pswp-caption-wrap {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    text-align: center;
    padding: 0 60px 24px;
    pointer-events: none;
}

.jwg-pswp-caption {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    margin: 0;
    color: var(--pswp-icon-color, #fff);
    opacity: 0.75;
    font-size: 0.8em;
    line-height: 1.5;
}

.jwg-pswp-caption::before {
    content: '';
    display: block;
    width: 28px;
    height: 1px;
    background: currentColor;
    flex-shrink: 0;
}

/* ── PhotoSwipe lightbox thumbnail strip (left panel) ───────────────────── */

.jwg-pswp-thumbstrip {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 72px;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 8px 6px;
    background: var(--jwg-pswp-sidebar-bg);
    z-index: 1;
    scrollbar-width: thin;
    scrollbar-color: var(--jwg-pswp-sidebar-scrollbar) transparent;
}

.jwg-pswp-thumb-item {
    flex-shrink: 0;
    cursor: pointer;
    opacity: 0.45;
    outline: 2px solid transparent;
    outline-offset: -2px;
    transition: opacity 0.15s, outline-color 0.15s;
}

.jwg-pswp-thumb-item:hover {
    opacity: 0.8;
}

.jwg-pswp-thumb-item.active {
    opacity: 1;
    outline-color: var(--jwg-pswp-sidebar-outline);
}

.jwg-pswp-thumb-item img {
    display: block;
    width: 100%;
    height: auto;
}

/* Shift PS5's prev arrow so it doesn't sit on top of the thumbstrip.
   Double class needed: photoswipe.min.css loads after this file, so equal
   specificity would lose. .pswp prefix gives (0,2,0) vs PS5's (0,1,0). */
.pswp .pswp__button--arrow--prev {
    left: 72px;
}
