/* ============================================================
   FP STN Gallery — styles
   ============================================================ */

/* ---------- Container: main left, thumbs right (desktop) ---------- */
.fp-stn-gallery {
    display: grid;
    grid-template-columns: 1fr 88px;
    grid-template-areas: "main thumbs";
    gap: 12px;
    width: 100%;
    max-width: 100%;
    opacity: 1;
    /* Neutralize any leftover Woo styles */
    float: none;
}

.fp-stn-gallery__main {
    grid-area: main;
    position: relative;
    overflow: hidden;
    background: #f7f7f5;
    /* Height is set by JS to match active slide; smooth transition. */
    transition: height 0.3s ease;
}

.fp-stn-gallery__thumbs {
    grid-area: thumbs;
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow-y: auto;
    max-height: 100%;
    scrollbar-width: thin;
}

.fp-stn-gallery__thumbs::-webkit-scrollbar {
    width: 4px;
}
.fp-stn-gallery__thumbs::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.15);
    border-radius: 2px;
}

/* ---------- Thumbs ---------- */
.fp-stn-gallery__thumb {
    position: relative;
    display: block;
    width: 80px;
    height: 80px;
    padding: 0;
    border: 2px solid transparent;
    background: #fff;
    cursor: pointer;
    overflow: hidden;
    flex-shrink: 0;
    transition: border-color 0.15s ease;
}

.fp-stn-gallery__thumb:hover,
.fp-stn-gallery__thumb:focus-visible {
    border-color: #f9c89d;
    outline: none;
}

.fp-stn-gallery__thumb.is-active {
    border-color: #000;
}

.fp-stn-gallery__thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Play overlay on video thumbs */
.fp-stn-gallery__thumb-play {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

/* ---------- Slide track ---------- */
.fp-stn-gallery__track {
    position: relative;
    width: 100%;
    height: 100%;
}

.fp-stn-gallery__slide {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease;
    /* Non-active slides stay in the DOM for SEO but don't block layout */
}

.fp-stn-gallery__slide.is-active {
    opacity: 1;
    visibility: visible;
    z-index: 1;
}

.fp-stn-gallery__image,
.fp-stn-gallery__video,
.fp-stn-gallery__video-poster {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #f7f7f5;
}

.fp-stn-gallery__image {
    cursor: zoom-in;
}

.fp-stn-gallery__slide--video {
    cursor: zoom-in;
}

.fp-stn-gallery__video-poster {
    position: absolute;
    inset: 0;
    z-index: 1;
    transition: opacity 0.2s ease;
}

.fp-stn-gallery__slide.is-video-ready .fp-stn-gallery__video-poster {
    opacity: 0;
    pointer-events: none;
}

/* ---------- Spinner (while media loads) ---------- */
.fp-stn-gallery__spinner {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 32px;
    height: 32px;
    margin: -16px 0 0 -16px;
    border: 3px solid rgba(0, 0, 0, 0.1);
    border-top-color: #000;
    border-radius: 50%;
    animation: fp-stn-spin 0.8s linear infinite;
    opacity: 0;
    pointer-events: none;
    z-index: 2;
    transition: opacity 0.15s ease;
}

.fp-stn-gallery__slide.is-loading .fp-stn-gallery__spinner {
    opacity: 1;
}

@keyframes fp-stn-spin {
    to { transform: rotate(360deg); }
}

/* ---------- Screen reader helper ---------- */
.fp-stn-gallery .screen-reader-text {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ============================================================
   Lightbox
   ============================================================ */
.fp-stn-lightbox {
    position: fixed;
    inset: 0;
    z-index: 99999;
    background: rgba(0, 0, 0, 0.92);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.fp-stn-lightbox.is-open {
    opacity: 1;
}

.fp-stn-lightbox[hidden] {
    display: none;
}

.fp-stn-lightbox__stage {
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.fp-stn-lightbox__stage img,
.fp-stn-lightbox__stage video {
    max-width: 90vw;
    max-height: 90vh;
    width: auto;
    height: auto;
    object-fit: contain;
    display: block;
}

.fp-stn-lightbox__close,
.fp-stn-lightbox__nav {
    position: absolute;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: #fff;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease;
}

.fp-stn-lightbox__close:hover,
.fp-stn-lightbox__nav:hover {
    background: rgba(255, 255, 255, 0.2);
}

.fp-stn-lightbox__close {
    top: 20px;
    right: 20px;
}

.fp-stn-lightbox__nav--prev { left: 20px; top: 50%; transform: translateY(-50%); }
.fp-stn-lightbox__nav--next { right: 20px; top: 50%; transform: translateY(-50%); }

/* ============================================================
   Mobile (< 900px): thumbs move BELOW main, in a horizontal row
   ============================================================ */
@media (max-width: 899px) {
    .fp-stn-gallery {
        grid-template-columns: 1fr;
        grid-template-areas:
            "main"
            "thumbs";
        gap: 8px;
    }

    .fp-stn-gallery__thumbs {
        flex-direction: row;
        overflow-x: auto;
        overflow-y: hidden;
        scroll-snap-type: x mandatory;
        max-height: none;
        padding: 4px 0;
        -webkit-overflow-scrolling: touch;
    }

    .fp-stn-gallery__thumb {
        width: 64px;
        height: 64px;
        scroll-snap-align: start;
    }

    .fp-stn-gallery__main {
        touch-action: pan-y pinch-zoom;
    }

    .fp-stn-lightbox__close,
    .fp-stn-lightbox__nav {
        width: 40px;
        height: 40px;
    }

    .fp-stn-lightbox__close { top: 12px; right: 12px; }
    .fp-stn-lightbox__nav--prev { left: 8px; }
    .fp-stn-lightbox__nav--next { right: 8px; }
}
