/**
 * Gallery: masonry columns, hover effects, full-screen lightbox
 */

/* ----- Masonry columns: 4 → 3 → 2 → 1 ----- */
.gallery-grid {
    display: block;
    columns: 4;
    column-gap: 12px;
    transition: opacity 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
    will-change: opacity;
}
.gallery-grid.gallery-loading {
    opacity: 0.72;
    pointer-events: none;
    filter: saturate(0.95) blur(0.3px);
}

#gallery-container.gallery-container--busy {
    pointer-events: none;
}

.gallery-area.gallery-area--fetching,
.gallery-area.gallery-area--skeleton {
    position: relative;
}
.gallery-area.gallery-area--switching {
    transition: transform 0.28s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.28s ease;
}
.gallery-area.gallery-area--fetching::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    width: 2.25rem;
    height: 2.25rem;
    margin: -1.125rem 0 0 -1.125rem;
    border: 2px solid rgba(200, 154, 90, 0.25);
    border-top-color: rgba(200, 154, 90, 0.95);
    border-radius: 50%;
    animation: gallery-fetch-spin 0.8s linear infinite;
    pointer-events: none;
    z-index: 3;
    opacity: 0.92;
}
.gallery-area.gallery-area--skeleton {
    min-height: 12rem;
}
.gallery-area.gallery-area--skeleton::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background:
        linear-gradient(
            90deg,
            rgba(255, 255, 255, 0.02) 0%,
            rgba(200, 154, 90, 0.1) 50%,
            rgba(255, 255, 255, 0.02) 100%
        ),
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent 11px,
            rgba(200, 154, 90, 0.04) 11px,
            rgba(200, 154, 90, 0.04) 12px
        ),
        repeating-linear-gradient(
            90deg,
            transparent,
            transparent 11px,
            rgba(200, 154, 90, 0.04) 11px,
            rgba(200, 154, 90, 0.04) 12px
        );
    background-size: 200% 100%, 100% 100%, 100% 100%;
    animation: gallery-skeleton-shimmer 1.35s ease-in-out infinite;
    pointer-events: none;
    z-index: 2;
}
@keyframes gallery-skeleton-shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}
@keyframes gallery-fetch-spin {
    to { transform: rotate(360deg); }
}

@media (min-width: 2400px) {
    .gallery-grid { columns: 6; }
}
@media (min-width: 1800px) and (max-width: 2399px) {
    .gallery-grid { columns: 5; }
}
@media (max-width: 1200px) {
    .gallery-grid { columns: 3; column-gap: 10px; }
}
@media (max-width: 768px) {
    .gallery-grid { columns: 2; column-gap: 8px; }
    .gallery-item .caption {
        opacity: 1;
        transform: translateY(0);
        padding: 1rem;
        font-size: 0.9375rem;
    }
}
@media (max-width: 480px) {
    .gallery-grid { columns: 1; }
}

/* Touch feedback */
@media (hover: none) and (pointer: coarse) {
    .gallery-item:active {
        transform: scale(0.98);
        box-shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
    }
    .gallery-item:active::after { opacity: 0.6; }
}

/* ----- Gallery item ----- */
.gallery-item {
    break-inside: avoid;
    display: inline-block;
    width: 100%;
    margin-bottom: 12px;
    aspect-ratio: unset;
    position: relative;
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: var(--color-bg-card);
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(200, 154, 90, 0.15);
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.38s ease, transform 0.38s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.25s ease;
}
.gallery-item.visible {
    opacity: 1;
    transform: none;
}
.gallery-item:hover {
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.35);
}

.gallery-item img {
    width: 100%;
    height: auto;
    object-fit: unset;
    display: block;
    transition: transform 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}
.gallery-item:hover img {
    transform: scale(1.03);
}

/* Gold overlay on hover */
.gallery-item::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(10, 61, 59, 0.88) 0%, rgba(10, 61, 59, 0.2) 45%, transparent 70%);
    opacity: 0;
    transition: opacity var(--transition);
}
.gallery-item:hover::after { opacity: 1; }

.gallery-item .caption {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 1.5rem 1.25rem;
    font-family: var(--font-display);
    font-size: 1rem;
    font-weight: 500;
    letter-spacing: 0.02em;
    color: var(--text-light);
    z-index: 1;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity var(--transition), transform var(--transition);
}
.gallery-item:hover .caption {
    opacity: 1;
    transform: translateY(0);
}

.gallery-empty,
.gallery-loading-msg {
    column-span: all;
    text-align: center;
    padding: 4rem 2rem;
    color: rgba(255, 255, 255, 0.75);
    font-size: 1rem;
    letter-spacing: 0.03em;
    font-weight: 400;
    line-height: 1.6;
}

/* ----- New lightbox: full-screen, elegant ----- */
.lb-overlay {
    position: fixed;
    inset: 0;
    z-index: 2000;
    background: rgba(5, 18, 18, 0.97);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    animation: lb-fade-in 0.22s ease forwards;
}
@keyframes lb-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.lb-top {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    z-index: 1;
}
.lb-close {
    width: 44px;
    height: 44px;
    background: transparent;
    border: 1px solid rgba(200, 154, 90, 0.4);
    border-radius: 50%;
    color: rgba(255, 255, 255, 0.85);
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: border-color 0.2s ease, color 0.2s ease, background 0.2s ease;
}
.lb-close:hover {
    border-color: var(--brand-gold);
    color: var(--brand-gold-light);
    background: rgba(200, 154, 90, 0.1);
}
.lb-counter {
    font-family: var(--font-display);
    font-size: 0.875rem;
    letter-spacing: 0.06em;
    color: rgba(255, 255, 255, 0.5);
}

.lb-body {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    position: relative;
    padding: 4rem 5rem;
    box-sizing: border-box;
}
.lb-img {
    max-width: 85vw;
    max-height: 82vh;
    object-fit: contain;
    border-radius: var(--radius-sm);
    box-shadow: 0 32px 96px rgba(0, 0, 0, 0.6);
    animation: lb-img-in 0.28s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
    display: block;
}
@keyframes lb-img-in {
    from { opacity: 0; transform: scale(0.93); }
    to   { opacity: 1; transform: scale(1); }
}

.lb-prev,
.lb-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 52px;
    height: 52px;
    background: rgba(10, 61, 59, 0.75);
    border: 1px solid rgba(200, 154, 90, 0.35);
    border-radius: 50%;
    color: rgba(255, 255, 255, 0.85);
    font-size: 1.6rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s ease, background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
    z-index: 2;
}
.lb-prev { left: 1.5rem; }
.lb-next { right: 1.5rem; }
.lb-overlay:hover .lb-prev,
.lb-overlay:hover .lb-next { opacity: 1; }
.lb-prev:hover,
.lb-next:hover {
    background: rgba(10, 61, 59, 0.95);
    border-color: var(--brand-gold);
    color: var(--brand-gold-light);
}

.lb-bottom {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    text-align: center;
    padding: 1.25rem 2rem;
}
.lb-title {
    font-family: 'Playfair Display', var(--font-display), Georgia, serif;
    font-size: 1rem;
    font-weight: 500;
    letter-spacing: 0.04em;
    color: rgba(255, 255, 255, 0.72);
    margin: 0;
}

@media (max-width: 768px) {
    .lb-body { padding: 3.5rem 0.5rem; }
    .lb-img { max-width: 96vw; max-height: 72vh; }
    .lb-prev { left: 0.5rem; }
    .lb-next { right: 0.5rem; }
    .lb-prev,
    .lb-next { opacity: 0.75; width: 44px; height: 44px; font-size: 1.3rem; }
}

@media (prefers-reduced-motion: reduce) {
    .gallery-grid,
    .gallery-grid.gallery-loading,
    .gallery-area.gallery-area--switching { transition: none !important; }
    .gallery-item { transition: none !important; opacity: 1 !important; transform: none !important; }
    .gallery-item.visible { opacity: 1 !important; transform: none !important; }
    .gallery-area.gallery-area--fetching::after,
    .gallery-area.gallery-area--skeleton::before { animation: none !important; }
    .lb-overlay,
    .lb-img { animation: none !important; }
}
