/* Post gallery + lightbox - shared by post_view, post_snippet, and anywhere snippets appear */

.pv-gallery {
    display: grid;
    margin: 16px 0;
    border-radius: 20px;
    overflow: hidden;
    border: none;
    outline: none;
    transition: 0.1s;
}

.pv-gallery__item {
    position: relative;
    margin: 0;
    padding: 0;
    border: none;
    background: none;
    cursor: pointer;
    overflow: hidden;
    transition: 0.1s;
}

.pv-gallery__img-wrap {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: var(--uw-white-2);
}

.pv-gallery__img-wrap::before {
    content: '';
    position: absolute;
    inset: -20%;
    background-image: var(--bg-url);
    background-size: cover;
    background-position: center;
    filter: blur(40px);
    transform: scale(1.2);
    z-index: 0;
}

.pv-gallery__img {
    position: relative;
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    z-index: 1;
}

.pv-gallery--1 {
    grid-template-columns: 1fr;
}

.pv-gallery--1 .pv-gallery__img-wrap {
    min-height: 280px;
}

.pv-gallery--1 .pv-gallery__img {
    max-height: 520px;
    max-width: 100%;
    width: auto;
}

.pv-gallery--2 {
    grid-template-columns: 1fr 1fr;
}

.pv-gallery--2 .pv-gallery__img-wrap {
    aspect-ratio: 1;
    min-height: 200px;
}

.pv-gallery--3 {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 200px 200px;
}

.pv-gallery--3 .pv-gallery__item:first-child {
    grid-row: span 2;
}

.pv-gallery--3 .pv-gallery__img-wrap {
    min-height: 100%;
}

.pv-gallery--4 {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 220px 220px;
}

.pv-gallery--4 .pv-gallery__img-wrap {
    min-height: 100%;
}

.pv-gallery--many {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 220px 220px;
}

.pv-gallery--many .pv-gallery__img-wrap {
    min-height: 100%;
}

.pv-gallery__more {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.5);
    color: #fff;
    font-size: 1.5rem;
    font-weight: 600;
    z-index: 2;
}

.pv-gallery__img-wrap:hover {
    border-color: var(--uw-blurple-1);
}

.pv-gallery__item:hover .pv-gallery__img {
    transform: scale(1.03);
}

.pv-gallery__item .pv-gallery__img {
    transition: transform 0.2s ease;
}

/* Lightbox - fullscreen viewer (minimal UniWave; image uses native aspect, max-fit in area) */
.lightbox {
    --lb-track: rgba(255, 255, 255, 0.22);
    --lb-accent: var(--uw-blurple-1, #0866ff);
    --lb-text: rgba(255, 255, 255, 0.88);
    --lb-text-muted: rgba(255, 255, 255, 0.5);
    --lb-thumb: var(--uw-white-1, #ffffff);
    --lb-ui-bg: rgba(255, 255, 255, 0.06);

    display: none;
    position: fixed;
    inset: 0;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.92);
    backdrop-filter: blur(8px);
    z-index: 10000;
    opacity: 0;
    transition: opacity 0.25s ease;
}

.lightbox.active {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    opacity: 1;
}

.lightbox-content {
    flex: 1;
    align-self: stretch;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: stretch;
    min-height: 0;
    padding: 52px 16px 12px;
    box-sizing: border-box;
    overflow: hidden;
}

/*
 * Viewport: takes remaining height, capped width. Pan layer fills viewport via flex
 * (not position:absolute) so % max-width/max-height on the img resolve correctly.
 */
.lightbox-viewport {
    flex: 1;
    min-height: 120px;
    width: 100%;
    max-width: min(96vw, 1400px);
    margin: 0 auto;
    position: relative;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-radius: 16px;
    /* Stacking context helps border-radius clip transformed children */
    isolation: isolate;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
    touch-action: none;
    cursor: grab;
    user-select: none;
    -webkit-user-select: none;
}

.lightbox-viewport.is-grabbing {
    cursor: grabbing;
}

.lightbox-pan-layer {
    flex: 1;
    min-height: 0;
    min-width: 0;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    will-change: transform;
    transform-origin: center center;
}

#lightbox-img {
    display: block;
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    /* Receive clicks so letterbox hits .lightbox-pan-layer and closes; image click does not */
    pointer-events: auto;
    cursor: grab;
    border-radius: 4px;
}

/* Bottom bar — minimal: no heavy gradients */
.lightbox-footer {
    align-self: stretch;
    width: 100%;
    box-sizing: border-box;
    flex-shrink: 0;
    position: relative;
    z-index: 10001;
    padding: 16px 20px 22px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.lightbox-zoom-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    max-width: 360px;
    margin: 0 auto 10px;
    padding: 0;
    box-sizing: border-box;
}

.lightbox-zoom-label {
    color: var(--lb-text-muted);
    font-size: 13px;
    font-weight: 400;
    font-family: "Roboto", sans-serif;
    flex-shrink: 0;
}

.lightbox-zoom-input {
    flex: 1;
    min-width: 100px;
    width: 100%;
    height: 22px;
    margin: 0;
    padding: 0;
    cursor: pointer;
    background: transparent;
    -webkit-appearance: none;
    appearance: none;
}

.lightbox-zoom-input:focus {
    outline: none;
}

.lightbox-zoom-input:focus-visible {
    outline: 1px solid var(--lb-accent);
    outline-offset: 6px;
    border-radius: 4px;
}

.lightbox-zoom-input::-webkit-slider-runnable-track {
    height: 3px;
    border-radius: 999px;
    background: var(--lb-track);
}

.lightbox-zoom-input::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    margin-top: -5.5px;
    border-radius: 50%;
    background: var(--lb-thumb);
    border: none;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.2);
    transition: transform 0.12s ease;
}

.lightbox-zoom-input:hover::-webkit-slider-thumb {
    transform: scale(1.08);
    box-shadow: 0 0 0 2px var(--lb-accent);
}

.lightbox-zoom-input::-moz-range-track {
    height: 3px;
    border-radius: 999px;
    background: var(--lb-track);
}

.lightbox-zoom-input::-moz-range-progress {
    height: 3px;
    border-radius: 999px;
    background: var(--lb-accent);
}

.lightbox-zoom-input::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--lb-thumb);
    border: none;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.25);
    cursor: pointer;
}

.lightbox-zoom-pct {
    color: var(--lb-text-muted);
    font-size: 13px;
    font-weight: 500;
    font-family: "Roboto", sans-serif, system-ui;
    font-variant-numeric: tabular-nums;
    min-width: 42px;
    text-align: right;
    flex-shrink: 0;
}

.lightbox-close,
.lightbox-prev,
.lightbox-next {
    position: absolute;
    z-index: 10002;
    background: var(--lb-ui-bg);
    color: var(--lb-text);
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    transition: background 0.15s ease;
}

.lightbox-close:hover,
.lightbox-prev:hover,
.lightbox-next:hover {
    background: rgba(255, 255, 255, 0.12);
}

.lightbox-close {
    top: 16px;
    right: 16px;
}

.lightbox-prev {
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
}

.lightbox-next {
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
}

.lightbox-counter {
    position: static;
    transform: none;
    text-align: center;
    color: var(--lb-text-muted);
    background: none;
    border: none;
    padding: 0;
    border-radius: 0;
    font-size: 12px;
    font-weight: 400;
    display: block;
    width: fit-content;
    max-width: 100%;
    margin: 0 auto;
    font-family: "Roboto", sans-serif;
}

@media (max-width: 768px) {
    .pv-gallery {
        gap: 6px;
        margin: 12px 0;
    }

    .pv-gallery--1 .pv-gallery__img {
        max-height: 360px;
    }

    .pv-gallery--2 .pv-gallery__img-wrap {
        min-height: 160px;
    }

    .pv-gallery--3,
    .pv-gallery--4,
    .pv-gallery--many {
        grid-template-rows: 160px 160px;
    }

    .lightbox-content {
        padding: 48px 12px 8px;
    }

    .lightbox-footer {
        padding: 12px 14px 18px;
    }

    .lightbox-zoom-row {
        gap: 10px;
        max-width: 100%;
    }

    .lightbox-viewport {
        max-width: 100%;
        border-radius: 14px;
    }

    .lightbox-close,
    .lightbox-prev,
    .lightbox-next {
        width: 40px;
        height: 40px;
        font-size: 18px;
    }

    .lightbox-close {
        top: 12px;
        right: 12px;
    }

    .lightbox-prev {
        left: 12px;
    }

    .lightbox-next {
        right: 12px;
    }
}
