/* Post photo gallery (resources/views/Frontend/Posts/partials/gallery.blade.php).
   Every rule is scoped to .pg so nothing leaks into the rest of the site.
   The stage has a fixed aspect ratio, so photos of different sizes never move the page. */

.pg {
    --pg-accent: #008eff;
    margin: 0 0 28px;
}

.pg-stage {
    position: relative;
    width: 100%;
    aspect-ratio: 3 / 2;
    max-height: 72vh;
    overflow: hidden;
    border-radius: 8px;
    background: #10161d;
    isolation: isolate;
}

/* Blurred copy of the current photo fills the empty sides of portrait or narrow photos. */
.pg-backdrop {
    position: absolute;
    inset: -40px;
    z-index: -1;
    background: center / cover no-repeat;
    filter: blur(28px) brightness(0.5) saturate(1.1);
    transform: scale(1.08);
    transition: opacity 0.35s ease;
}

.pg-track {
    display: flex;
    height: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}

.pg-track::-webkit-scrollbar {
    display: none;
}

.pg-track:focus-visible {
    outline: 3px solid var(--pg-accent);
    outline-offset: -3px;
}

.pg .pg-slide {
    flex: 0 0 100%;
    height: 100%;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    scroll-snap-align: center;
    scroll-snap-stop: always;
    cursor: zoom-in;
}

.pg .pg-slide img {
    display: block;
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    user-select: none;
    -webkit-user-drag: none;
}

/* Round buttons (also used inside the lightbox) */
.pg .pg-nav,
.pg .pg-zoom {
    position: absolute;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.92);
    color: #111;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.25);
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.2s ease, opacity 0.2s ease;
}

.pg .pg-nav svg,
.pg .pg-zoom svg {
    width: 22px;
    height: 22px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.4;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.pg .pg-nav:hover,
.pg .pg-zoom:hover {
    background: #fff;
}

.pg .pg-nav:active {
    transform: scale(0.94);
}

.pg .pg-prev:active,
.pg .pg-next:active {
    transform: translateY(-50%) scale(0.94);
}

.pg .pg-nav:focus-visible,
.pg .pg-zoom:focus-visible,
.pg .pg-thumb:focus-visible {
    outline: 3px solid var(--pg-accent);
    outline-offset: 2px;
}

.pg .pg-prev,
.pg .pg-next {
    top: 50%;
    transform: translateY(-50%);
}

.pg .pg-prev {
    left: 14px;
}

.pg .pg-next {
    right: 14px;
}

.pg .pg-zoom {
    top: 14px;
    right: 14px;
    width: 38px;
    height: 38px;
    opacity: 0.85;
}

.pg .pg-zoom svg {
    width: 18px;
    height: 18px;
}

.pg .pg-zoom:active {
    transform: scale(0.94);
}

.pg-count {
    position: absolute;
    right: 14px;
    bottom: 14px;
    z-index: 2;
    padding: 4px 11px;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    font-size: 13px;
    line-height: 1.4;
    font-variant-numeric: tabular-nums;
    pointer-events: none;
}

/* Thumbnails */
.pg-thumbs {
    /* width 0 + min-width 100%: the strip never widens the page column (bootstrap .row is flex). */
    width: 0;
    min-width: 100%;
    box-sizing: border-box;
    display: flex;
    gap: 8px;
    margin-top: 10px;
    padding: 3px;
    overflow-x: auto;
    scrollbar-width: thin;
}

.pg .pg-thumb {
    flex: 0 0 92px;
    height: 62px;
    padding: 0;
    border: 2px solid transparent;
    border-radius: 6px;
    overflow: hidden;
    background: #e9edf1;
    opacity: 0.55;
    cursor: pointer;
    transition: opacity 0.2s ease, border-color 0.2s ease;
}

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

.pg .pg-thumb:hover,
.pg .pg-thumb.is-active {
    opacity: 1;
}

.pg .pg-thumb.is-active {
    border-color: var(--pg-accent);
}

/* Full-screen lightbox */
.pg .pg-lightbox {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
    margin: 0;
    padding: 0;
    border: 0;
    background: rgba(8, 10, 14, 0.96);
    color: #fff;
    overflow: hidden;
}

/* The theme's old normalize.css sets dialog { display: block }, so hide it explicitly when closed. */
.pg .pg-lightbox:not([open]) {
    display: none;
}

.pg .pg-lightbox::backdrop {
    background: rgba(0, 0, 0, 0.7);
}

.pg-lb-stage {
    position: absolute;
    inset: 64px 76px;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: pan-y pinch-zoom;
}

.pg .pg-lb-img {
    display: block;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    user-select: none;
    -webkit-user-drag: none;
}

.pg-lb-count {
    position: absolute;
    top: 22px;
    left: 24px;
    font-size: 15px;
    font-variant-numeric: tabular-nums;
    opacity: 0.85;
}

.pg .pg-lb-close {
    top: 14px;
    right: 14px;
}

html.pg-lock {
    overflow: hidden;
}

@media (hover: none) {
    .pg .pg-zoom {
        display: none;
    }
}

@media (max-width: 576px) {
    .pg-stage {
        border-radius: 0;
    }

    .pg .pg-nav {
        width: 36px;
        height: 36px;
    }

    .pg .pg-nav svg {
        width: 18px;
        height: 18px;
    }

    .pg .pg-prev {
        left: 8px;
    }

    .pg .pg-next {
        right: 8px;
    }

    .pg .pg-thumb {
        flex-basis: 66px;
        height: 46px;
    }

    .pg-lb-stage {
        inset: 64px 6px;
    }

    .pg .pg-lb-prev,
    .pg .pg-lb-next {
        top: auto;
        bottom: 18px;
        transform: none;
    }

    .pg .pg-lb-prev:active,
    .pg .pg-lb-next:active {
        transform: scale(0.94);
    }
}

@media (prefers-reduced-motion: reduce) {
    .pg *,
    .pg-track {
        scroll-behavior: auto !important;
        transition: none !important;
    }
}
