/* ================================================================
   Gallery component — carousel + thumbnails + lightbox
   Used by: project_detail, stores (via _gallery.html partial)
   ================================================================ */

.gallery-viewport {
    position: relative;
    overflow: hidden;
    border-radius: 8px;
    background: var(--bg-placeholder);
    width: 100%;
    max-height: calc(100vh - 25rem);
    cursor: zoom-in;
    touch-action: pan-y pinch-zoom;
}

.gallery-track {
    display: flex;
    gap: 4px;
    width: 100%;
    height: 100%;
    will-change: transform;
}

.gallery-track.snap {
    transition: transform 0.3s ease;
}

.gallery-slide {
    flex: none;
    width: 100%;
    height: 100%;
}

.gallery-slide img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    user-select: none;
    -webkit-user-select: none;
    -webkit-user-drag: none;
    pointer-events: none;
}

/* Carousel prev/next buttons — desktop only */
.gallery-nav-btn {
    display: none;
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 2;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: rgba(0, 0, 0, 0.45);
    color: #fff;
    padding: 0;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, opacity 0.15s;
    user-select: none;
}

.gallery-nav-btn svg {
    width: 22px;
    height: 22px;
}

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

.gallery-nav-prev { left: 0.75rem; }
.gallery-nav-next { right: 0.75rem; }

.gallery-nav-btn.hidden { display: none !important; }

@media (hover: hover) {
    .gallery-viewport:hover .gallery-nav-btn:not(.hidden) {
        display: flex;
    }
}

.gallery-main-placeholder {
    width: 100%;
    border-radius: 8px;
    background: var(--bg-placeholder);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-faint);
    font-size: 0.95rem;
}

/* ── Thumbnail strip ── */

.gallery-thumbs-wrapper {
    position: relative;
    margin-top: 0.75rem;
}

.gallery-thumbs {
    display: flex;
    gap: 0.6rem;
    overflow-x: auto;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 4px;
}

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

.gallery-thumbs img {
    width: 80px;
    height: 60px;
    flex-shrink: 0;
    object-fit: cover;
    border-radius: 5px;
    cursor: pointer;
    border: 2px solid transparent;
    transition: border-color 0.15s, opacity 0.15s;
    opacity: 0.75;
}

.gallery-thumbs img:hover,
.gallery-thumbs img.active {
    border-color: var(--brand-blue);
    opacity: 1;
}

/* Scroll fade indicators */
.gallery-thumbs-wrapper::before,
.gallery-thumbs-wrapper::after {
    content: '';
    position: absolute;
    top: 0;
    bottom: 4px;
    width: 40px;
    pointer-events: none;
    z-index: 1;
    opacity: 0;
    transition: opacity 0.2s;
}

.gallery-thumbs-wrapper::before {
    left: 0;
    background: linear-gradient(to right, var(--gradient-fade) 10%, transparent);
}

.gallery-thumbs-wrapper::after {
    right: 0;
    background: linear-gradient(to left, var(--gradient-fade) 10%, transparent);
}

.gallery-thumbs-wrapper.can-scroll-left::before {
    opacity: 1;
}

.gallery-thumbs-wrapper.can-scroll-right::after {
    opacity: 1;
}

/* Thumb arrow buttons */
.thumb-scroll-btn {
    position: absolute;
    top: 50%;
    transform: translateY(calc(-50% - 2px));
    z-index: 2;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: none;
    background: rgba(0, 0, 0, 0.5);
    touch-action: manipulation;
    color: #fff;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}

.thumb-scroll-btn svg {
    width: 14px;
    height: 14px;
}

.thumb-scroll-btn:hover {
    background: rgba(0, 0, 0, 0.7);
}

.gallery-thumbs-wrapper.can-scroll-left .thumb-scroll-left {
    display: flex;
}

.gallery-thumbs-wrapper.can-scroll-right .thumb-scroll-right {
    display: flex;
}

.thumb-scroll-left { left: 4px; }
.thumb-scroll-right { right: 4px; }

/* ── Lightbox ── */

.lightbox {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.92);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.lightbox.open {
    display: flex;
}

.lightbox-img {
    max-width: 90vw;
    max-height: 90vh;
    object-fit: contain;
    border-radius: 4px;
    user-select: none;
    -webkit-user-select: none;
    -webkit-user-drag: none;
    touch-action: pan-y pinch-zoom;
}

.lightbox-img.snap {
    transition: transform 0.3s ease;
}

.lightbox-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.12);
    border: none;
    color: #fff;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    touch-action: manipulation;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
    user-select: none;
}

.lightbox-btn svg {
    width: 28px;
    height: 28px;
}

.lightbox-btn:hover {
    background: rgba(255, 255, 255, 0.25);
}

.lightbox-prev { left: 1.25rem; }
.lightbox-next { right: 1.25rem; }

.lightbox-close {
    position: absolute;
    top: 1rem;
    right: 1.25rem;
    background: none;
    border: none;
    color: rgba(255,255,255,0.7);
    cursor: pointer;
    touch-action: manipulation;
    padding: 0.25rem;
    transition: color 0.15s;
}

.lightbox-close svg { width: 28px; height: 28px; }

.lightbox-close:hover { color: #fff; }

.lightbox-counter {
    position: absolute;
    bottom: 1.25rem;
    left: 50%;
    transform: translateX(-50%);
    color: rgba(255,255,255,0.55);
    font-size: 0.85rem;
    user-select: none;
}
