/* Gallery page — masonry + lightbox (app-like) */

.gallery-page {
    padding-top: 28px;
}

.gallery-empty {
    text-align: center;
    color: var(--color-text-light);
    padding: 40px 16px;
}

.gallery-empty code {
    font-size: 0.85em;
    background: var(--color-warm);
    padding: 2px 8px;
    border-radius: 6px;
}

.gallery-masonry {
    column-count: 3;
    column-gap: 14px;
}

.gallery-item {
    display: block;
    width: 100%;
    break-inside: avoid;
    margin: 0 0 14px;
    padding: 0;
    border: none;
    background: var(--color-white);
    border-radius: 14px;
    overflow: hidden;
    cursor: zoom-in;
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.06);
    transition: transform 0.25s ease, box-shadow 0.25s ease;
    -webkit-tap-highlight-color: transparent;
}

.gallery-item:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.1);
}

.gallery-item:active {
    transform: scale(0.98);
}

.gallery-item img {
    width: 100%;
    height: auto;
    display: block;
    vertical-align: top;
    object-fit: contain;
    background: #f3ede3;
}

/* Lightbox */
.gallery-lightbox {
    position: fixed;
    inset: 0;
    z-index: 3000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
}

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

.gallery-lightbox[hidden] {
    display: none !important;
}

.gallery-lightbox.is-open[hidden] {
    display: flex !important;
}

.gallery-lightbox__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(10, 10, 10, 0.92);
}

.gallery-lightbox__stage {
    position: relative;
    z-index: 1;
    max-width: min(1100px, 100%);
    max-height: 90dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.gallery-lightbox__stage img {
    max-width: 100%;
    max-height: calc(90dvh - 40px);
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 10px;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.4);
    background: #111;
}

.gallery-lightbox__counter {
    color: rgba(255, 255, 255, 0.75);
    font-size: 0.85rem;
    letter-spacing: 0.06em;
}

.gallery-lightbox__close,
.gallery-lightbox__nav {
    position: absolute;
    z-index: 2;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    backdrop-filter: blur(8px);
    transition: background 0.2s ease;
}

.gallery-lightbox__close:hover,
.gallery-lightbox__nav:hover {
    background: rgba(255, 255, 255, 0.22);
}

.gallery-lightbox__close {
    top: max(12px, env(safe-area-inset-top));
    right: max(12px, env(safe-area-inset-right));
}

.gallery-lightbox__nav--prev {
    left: max(10px, env(safe-area-inset-left));
    top: 50%;
    transform: translateY(-50%);
}

.gallery-lightbox__nav--next {
    right: max(10px, env(safe-area-inset-right));
    top: 50%;
    transform: translateY(-50%);
}

@media (max-width: 900px) {
    .gallery-masonry {
        column-count: 2;
        column-gap: 10px;
    }
    .gallery-item {
        margin-bottom: 10px;
        border-radius: 12px;
    }
}

@media (max-width: 560px) {
    .gallery-page {
        padding-top: 12px;
    }

    .gallery-masonry {
        column-count: 2;
        column-gap: 8px;
    }

    .gallery-item {
        margin-bottom: 8px;
        border-radius: 10px;
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    }

    .gallery-lightbox {
        padding: 8px;
    }

    .gallery-lightbox__nav {
        width: 40px;
        height: 40px;
    }

    .gallery-lightbox__stage img {
        max-height: calc(88dvh - 36px);
        border-radius: 8px;
    }
}
