/**
 * Amazon-style product image gallery
 * Desktop: vertical thumbs | main image | zoom panel
 * Mobile: main image + horizontal thumbs, fullscreen viewer on tap
 */

/* ── Root container ── */
.pg-product-gallery {
    position: relative;
    max-width: 100%;
    width: 100%;
}

.pg-gallery-layout {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    max-width: 100%;
    width: 100%;
}

/* ── Thumbnail column (desktop: vertical) ── */
.pg-thumbnails {
    flex-shrink: 0;
    width: 72px;
    max-height: 430px;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
}

.pg-thumbnails::-webkit-scrollbar {
    width: 4px;
}

.pg-thumbnails::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 2px;
}

.pg-thumbnail-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    list-style: none;
    margin: 0;
    padding: 0;
}

.pg-thumbnail-btn {
    display: block;
    width: 72px;
    height: 72px;
    padding: 0;
    border: 2px solid transparent;
    background: #f5f5f5;
    cursor: pointer;
    transition: border-color 0.2s ease;
    overflow: hidden;
    position: relative;
}

.pg-thumbnail-btn img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    pointer-events: none;
}

.pg-thumbnail-btn:hover,
.pg-thumbnail-btn.pg-active,
.pg-thumbnail-btn:focus-visible {
    border-color: #1a1a2e;
    outline: none;
}

.pg-thumbnail-btn:focus-visible {
    box-shadow: 0 0 0 2px #fff, 0 0 0 4px #1a1a2e;
}

/* ── Stage: main image + zoom panel ── */
.pg-stage {
    position: relative;
    flex: 1;
    min-width: 0;
    max-width: 100%;
    width: 100%;
}

.pg-main-image-wrap {
    position: relative;
    width: 100%;
    max-width: 100%;
    background: #f5f5f5;
    overflow: hidden;
}

.pg-main-image {
    width: 100%;
    height: 430px;
    object-fit: contain;
    display: block;
    user-select: none;
    -webkit-user-drag: none;
}

.pg-main-image-wrap.pg-zoom-enabled {
    cursor: crosshair;
}

.pg-main-image-wrap.pg-mobile-tap {
    cursor: pointer;
}

/* Lens overlay on main image */
.pg-zoom-lens {
    position: absolute;
    border: 1px solid rgba(0, 0, 0, 0.15);
    background: rgba(255, 255, 255, 0.35);
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.12s ease;
    z-index: 3;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.5);
}

.pg-gallery-is-zooming .pg-zoom-lens {
    opacity: 1;
    visibility: visible;
    z-index: 8;
}

/* Zoom panel (magnified view) — mounted to body on hover, above all page content */
.pg-zoom-viewer {
    display: none;
    width: 400px;
    height: 430px;
    background-color: #fff;
    background-repeat: no-repeat;
    border: 1px solid #ddd;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
    pointer-events: none;
    will-change: background-position;
    z-index: 10050;
}

.pg-zoom-viewer.pg-zoom-viewer--active,
.pg-gallery-is-zooming .pg-zoom-viewer {
    display: block;
}

@media (min-width: 992px) {
    .pg-zoom-viewer.pg-zoom-viewer--active,
    .pg-gallery-is-zooming .pg-zoom-viewer {
        position: fixed;
    }

    /* Allow zoom panel to extend beside the gallery on desktop only */
    #product .psg-product-row > .col-md-5:first-child,
    #product .pg-product-gallery,
    #product .pg-gallery-layout,
    #product .pg-stage {
        overflow: visible;
    }
}

/* Badge & overlays */
.pg-gallery-badge {
    position: absolute;
    top: 12px;
    left: 12px;
    background: #1a1a2e;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    padding: 4px 12px;
    z-index: 5;
    pointer-events: none;
}

.pg-nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 38px;
    height: 38px;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid #ddd;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 6;
    color: #444;
    font-size: 14px;
    transition: background 0.2s, box-shadow 0.2s;
    padding: 0;
}

.pg-nav-btn:hover {
    background: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.pg-nav-btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px #fff, 0 0 0 4px #1a1a2e;
}

.pg-nav-prev {
    left: 10px;
}

.pg-nav-next {
    right: 10px;
}

.pg-fullscreen-trigger {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 34px;
    height: 34px;
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid #ddd;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 5;
    color: #555;
    font-size: 14px;
    padding: 0;
}

.pg-fullscreen-trigger:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px #fff, 0 0 0 4px #1a1a2e;
}

/* Sold-out ribbon (shared with legacy styles) */
.pg-product-gallery a.sold_out {
    top: 2em;
    left: 0;
    color: #fff;
    display: block;
    position: absolute;
    text-align: center;
    text-decoration: none;
    letter-spacing: 0.06em;
    background-color: #a00;
    padding: 0.5em 3em 0.4em;
    text-shadow: 0 0 0.75em #444;
    box-shadow: 0 0 0.5em rgba(0, 0, 0, 0.5);
    font: bold 16px/1.2em Arial, sans-serif;
    transform: rotate(-45deg) scale(0.75, 1);
    z-index: 10;
}

.pg-product-gallery a.sold_out::before {
    content: '';
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    position: absolute;
    margin: -0.3em -1em;
    transform: scale(0.7);
    border: 2px rgba(255, 255, 255, 0.7) dashed;
}

/* ── Fullscreen gallery (mobile / tap) ── */
.pg-fullscreen {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(0, 0, 0, 0.95);
    display: none;
    flex-direction: column;
    touch-action: none;
}

.pg-fullscreen.pg-open {
    display: flex;
}

.pg-fullscreen-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    color: #fff;
    flex-shrink: 0;
}

.pg-fullscreen-counter {
    font-size: 14px;
    opacity: 0.85;
}

.pg-fullscreen-close {
    width: 44px;
    height: 44px;
    border: none;
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    border-radius: 50%;
    font-size: 22px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.pg-fullscreen-close:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

.pg-fullscreen-viewport {
    flex: 1;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pg-fullscreen-track {
    display: flex;
    height: 100%;
    width: 100%;
    transition: transform 0.3s ease;
    will-change: transform;
}

.pg-fullscreen-slide {
    flex: 0 0 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.pg-fullscreen-slide img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    transform-origin: center center;
    will-change: transform;
    user-select: none;
    -webkit-user-drag: none;
}

.pg-fullscreen-thumbs {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    overflow-x: auto;
    flex-shrink: 0;
    justify-content: center;
}

.pg-fullscreen-thumbs button {
    width: 56px;
    height: 56px;
    padding: 0;
    border: 2px solid transparent;
    background: #333;
    cursor: pointer;
    flex-shrink: 0;
}

.pg-fullscreen-thumbs button.pg-active {
    border-color: #fff;
}

.pg-fullscreen-thumbs button:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

.pg-fullscreen-thumbs img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Screen-reader only */
.pg-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ── Tablet & mobile (≤ 991px) ── */
@media (max-width: 991px) {
    .pg-gallery-layout {
        flex-direction: column;
        gap: 10px;
    }

    .pg-thumbnails {
        width: 100%;
        max-height: none;
        order: 2;
    }

    .pg-thumbnail-list {
        flex-direction: row;
        flex-wrap: nowrap;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 4px;
        gap: 8px;
    }

    .pg-thumbnail-btn {
        flex-shrink: 0;
    }

    .pg-stage {
        order: 1;
        width: 100%;
    }

    .pg-main-image {
        height: 360px;
    }

    /* Hover zoom disabled — use tap-to-fullscreen instead */
    .pg-zoom-viewer,
    .pg-zoom-viewer.pg-zoom-viewer--active,
    .pg-gallery-is-zooming .pg-zoom-viewer {
        display: none !important;
    }

    .pg-zoom-lens,
    .pg-gallery-is-zooming .pg-zoom-lens {
        display: none !important;
    }

    .pg-main-image-wrap.pg-zoom-enabled {
        cursor: pointer;
    }
}

/* ── Mobile (< 768px) ── */
@media (max-width: 767px) {
    .pg-main-image {
        height: 280px;
    }

    .pg-nav-btn {
        width: 32px;
        height: 32px;
        font-size: 12px;
    }

    .pg-thumbnail-btn {
        width: 64px;
        height: 64px;
    }

    .pg-thumbnails {
        width: 100%;
    }
}
