/* ═══════════════════════════════════════════════════════════════
   Product Image Gallery
   Transforms product-image-block into swipeable multi-image galleries.
   Works alongside existing product-image styles.
   ═══════════════════════════════════════════════════════════════ */

/* Gallery container — replaces the static product-image-block */
.product-gallery {
    width: 220px;
    min-width: 220px;
    flex-shrink: 0;
    position: relative;
    user-select: none;
    -webkit-user-select: none;
}

.product-gallery .gallery-main {
    width: 100%;
    height: 220px;
    border-radius: 12px;
    overflow: hidden;
    position: relative;
    border: 1px solid var(--border, rgba(255,255,255,0.07));
    background: linear-gradient(135deg, #1a0000 0%, #111 50%, #0a0a0a 100%);
    cursor: pointer;
}

.product-gallery .gallery-main img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 0.75rem;
    position: absolute;
    inset: 0;
    opacity: 0;
    transition: opacity 0.35s ease;
    filter: drop-shadow(0 4px 16px rgba(255,0,0,0.15));
    -webkit-user-drag: none;
}

.product-gallery .gallery-main img.active {
    opacity: 1;
}

/* Navigation arrows */
.product-gallery .gallery-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(0,0,0,0.65);
    border: 1px solid rgba(255,255,255,0.12);
    color: #fff;
    font-size: 0.85rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3;
    opacity: 0;
    transition: opacity 0.2s, background 0.2s;
    line-height: 1;
    padding: 0;
}

.product-gallery:hover .gallery-nav {
    opacity: 1;
}

.product-gallery .gallery-nav:hover {
    background: rgba(255,0,0,0.7);
    border-color: rgba(255,0,0,0.4);
}

.product-gallery .gallery-prev {
    left: 6px;
}

.product-gallery .gallery-next {
    right: 6px;
}

/* Dot indicators */
.product-gallery .gallery-dots {
    display: flex;
    justify-content: center;
    gap: 5px;
    margin-top: 8px;
    padding: 0 4px;
}

.product-gallery .gallery-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-dim, #555);
    cursor: pointer;
    transition: background 0.2s, transform 0.2s;
    border: none;
    padding: 0;
    flex-shrink: 0;
}

.product-gallery .gallery-dot.active {
    background: var(--red, #FF0000);
    transform: scale(1.3);
}

.product-gallery .gallery-dot:hover {
    background: var(--red, #FF0000);
}

/* Image counter badge */
.product-gallery .gallery-counter {
    position: absolute;
    bottom: 8px;
    right: 8px;
    font-family: var(--font-accent, 'Barlow Condensed', sans-serif);
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: rgba(255,255,255,0.8);
    background: rgba(0,0,0,0.6);
    padding: 2px 7px;
    border-radius: 4px;
    z-index: 2;
    pointer-events: none;
}

/* ── Lightbox (fullscreen view) ── */
.gallery-lightbox {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: rgba(0,0,0,0.92);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.gallery-lightbox.open {
    opacity: 1;
    visibility: visible;
}

.gallery-lightbox .lightbox-inner {
    position: relative;
    max-width: 90vw;
    max-height: 85vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.gallery-lightbox .lightbox-inner img {
    max-width: 90vw;
    max-height: 80vh;
    object-fit: contain;
    border-radius: 8px;
    filter: drop-shadow(0 8px 40px rgba(0,0,0,0.6));
}

.gallery-lightbox .lightbox-close {
    position: absolute;
    top: -40px;
    right: 0;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    color: #fff;
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.gallery-lightbox .lightbox-close:hover {
    background: rgba(255,0,0,0.6);
}

.gallery-lightbox .lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.15);
    color: #fff;
    font-size: 1.3rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.gallery-lightbox .lightbox-nav:hover {
    background: rgba(255,0,0,0.5);
}

.gallery-lightbox .lightbox-prev {
    left: -60px;
}

.gallery-lightbox .lightbox-next {
    right: -60px;
}

.gallery-lightbox .lightbox-counter {
    position: absolute;
    bottom: -35px;
    left: 50%;
    transform: translateX(-50%);
    font-family: var(--font-accent, 'Barlow Condensed', sans-serif);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    color: rgba(255,255,255,0.6);
}

/* ── Plugin-style gallery (full-width) ── */
.plugin-gallery {
    width: 100%;
    position: relative;
    margin-bottom: 2rem;
    user-select: none;
    -webkit-user-select: none;
}

.plugin-gallery .gallery-main {
    width: 100%;
    height: 220px;
    border-radius: 12px;
    overflow: hidden;
    position: relative;
    border: 1px solid var(--border, rgba(255,255,255,0.07));
    background: linear-gradient(135deg, #0a001a 0%, #111 60%, #0d0d0d 100%);
    cursor: pointer;
}

.plugin-gallery .gallery-main img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    position: absolute;
    inset: 0;
    padding: 0.5rem;
    opacity: 0;
    transition: opacity 0.35s ease;
    filter: drop-shadow(0 4px 24px rgba(255,0,0,0.25));
    -webkit-user-drag: none;
}

.plugin-gallery .gallery-main img.active {
    opacity: 1;
}

.plugin-gallery .gallery-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(0,0,0,0.65);
    border: 1px solid rgba(255,255,255,0.12);
    color: #fff;
    font-size: 0.95rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3;
    opacity: 0;
    transition: opacity 0.2s, background 0.2s;
    line-height: 1;
    padding: 0;
}

.plugin-gallery:hover .gallery-nav {
    opacity: 1;
}

.plugin-gallery .gallery-nav:hover {
    background: rgba(255,0,0,0.7);
}

.plugin-gallery .gallery-prev { left: 10px; }
.plugin-gallery .gallery-next { right: 10px; }

.plugin-gallery .gallery-dots {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin-top: 10px;
}

.plugin-gallery .gallery-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--text-dim, #555);
    cursor: pointer;
    transition: background 0.2s, transform 0.2s;
    border: none;
    padding: 0;
}

.plugin-gallery .gallery-dot.active {
    background: var(--red, #FF0000);
    transform: scale(1.3);
}

.plugin-gallery .gallery-counter {
    position: absolute;
    bottom: 8px;
    right: 10px;
    font-family: var(--font-accent, 'Barlow Condensed', sans-serif);
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: rgba(255,255,255,0.8);
    background: rgba(0,0,0,0.6);
    padding: 2px 7px;
    border-radius: 4px;
    z-index: 2;
    pointer-events: none;
}

/* ── Thumbnail strip (for both gallery types) ── */
.gallery-thumbs {
    display: flex;
    gap: 4px;
    margin-top: 6px;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    -webkit-overflow-scrolling: touch;
    padding: 2px 0;
}

.gallery-thumbs::-webkit-scrollbar { display: none; }

.gallery-thumb {
    width: 40px;
    height: 40px;
    min-width: 40px;
    border-radius: 6px;
    overflow: hidden;
    cursor: pointer;
    border: 2px solid transparent;
    transition: border-color 0.2s, opacity 0.2s;
    background: var(--surface, #111);
    padding: 0;
}

.gallery-thumb img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 2px;
}

.gallery-thumb.active {
    border-color: var(--red, #FF0000);
}

.gallery-thumb:hover {
    border-color: rgba(255,0,0,0.4);
}

/* ── Responsive ── */
@media (max-width: 768px) {
    .product-gallery {
        width: 100%;
        min-width: 0;
    }

    .product-gallery .gallery-main {
        height: 240px;
    }

    .product-gallery .gallery-nav {
        opacity: 0.7;
    }

    .gallery-lightbox .lightbox-prev { left: 8px; }
    .gallery-lightbox .lightbox-next { right: 8px; }
    .gallery-lightbox .lightbox-nav { width: 38px; height: 38px; }

    .gallery-thumbs {
        gap: 3px;
    }

    .gallery-thumb {
        width: 36px;
        height: 36px;
        min-width: 36px;
    }
}

@media (max-width: 480px) {
    .product-gallery .gallery-main {
        height: 200px;
    }

    .product-gallery .gallery-nav {
        width: 24px;
        height: 24px;
        font-size: 0.75rem;
    }

    .gallery-lightbox .lightbox-inner img {
        max-width: 95vw;
        max-height: 75vh;
    }
}
