/* ============================================
   Gallery Page
   ============================================ */

.gallery-header {
    padding: var(--space-3xl) 0 var(--space-xl);
    text-align: center;
}

.gallery-header h1 {
    margin-bottom: var(--space-sm);
}

.gallery-header p {
    font-family: var(--font-accent);
    font-size: var(--fs-sm);
    max-width: 36rem;
    margin: 0 auto;
}

/* ---- Filters ---- */

.gallery-filters {
    padding: var(--space-lg) 0;
    border-bottom: 0.0625rem solid var(--bone-faint);
    margin-bottom: var(--space-2xl);
}

.filter-row {
    display: flex;
    align-items: center;
    gap: var(--space-lg);
    flex-wrap: wrap;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.filter-label {
    font-family: var(--font-accent);
    font-size: var(--fs-xs);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--bone-dim);
    opacity: 0.7;
    white-space: nowrap;
}

.filter-tags {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-xs);
}

.filter-btn {
    font-family: var(--font-accent);
    font-size: var(--fs-xs);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 0.3125rem 0.75rem;
    border: 0.0625rem solid var(--bone-faint);
    border-radius: var(--radius-sm);
    color: var(--bone-dim);
    background: transparent;
    cursor: pointer;
    transition: all var(--transition-fast);
    min-height: 2.75rem;
    min-width: 2.75rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.filter-btn:hover {
    color: var(--jaundice);
    border-color: var(--jaundice);
}

.filter-btn.active {
    background: var(--jaundice);
    color: var(--void);
    border-color: var(--jaundice);
}

.filter-select-mobile {
    display: none;
}

/* ---- Gallery Grid ---- */

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr));
    gap: var(--space-lg);
    padding-bottom: var(--space-3xl);
}

.gallery-item {
    position: relative;
    overflow: hidden;
    border-radius: var(--radius-md);
    border: 0.0625rem solid var(--bone-faint);
    background: var(--void-deeper);
    cursor: pointer;
    transition: transform var(--transition-normal), box-shadow var(--transition-normal);
}

.gallery-item:hover {
    transform: translateY(-0.25rem);
    box-shadow: var(--shadow-lg);
}

.gallery-item--featured {
    grid-row: span 2;
    grid-column: span 2;
}

.gallery-item-image {
    aspect-ratio: 1;
    overflow: hidden;
}

.gallery-item-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform var(--transition-slow), filter var(--transition-slow);
    filter: saturate(0.85);
}

.gallery-item:hover .gallery-item-image img {
    transform: scale(1.08);
    filter: saturate(1.1);
}

.gallery-item-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(10, 8, 5, 0.9) 0%, transparent 60%);
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: var(--space-lg);
    opacity: 0;
    transition: opacity var(--transition-normal);
}

.gallery-item:hover .gallery-item-overlay {
    opacity: 1;
}

.gallery-item-title {
    font-family: var(--font-display);
    font-size: var(--fs-md);
    color: var(--bone);
    margin-bottom: var(--space-xs);
}

.gallery-item-meta {
    font-family: var(--font-accent);
    font-size: var(--fs-xs);
    color: var(--bone-dim);
}

.gallery-item-badge {
    position: absolute;
    top: var(--space-sm);
    right: var(--space-sm);
    z-index: 2;
}

.gallery-empty {
    grid-column: 1 / -1;
    text-align: center;
    padding: var(--space-4xl) 0;
    color: var(--bone-dim);
    font-family: var(--font-accent);
}

/* ---- Load More ---- */

.gallery-load-more {
    text-align: center;
    padding: var(--space-2xl) 0 var(--space-4xl);
}

/* ---- Lightbox ---- */

.lightbox {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: rgba(6, 4, 3, 0.95);
    backdrop-filter: blur(0.5rem);
}

.lightbox.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.lightbox-content {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lightbox-image {
    max-width: 100%;
    max-height: 75vh;
    object-fit: contain;
    border-radius: var(--radius-md);
}

.lightbox-info {
    text-align: center;
    padding: var(--space-lg) 0;
    max-width: 36rem;
}

.lightbox-title {
    font-family: var(--font-display);
    font-size: var(--fs-xl);
    color: var(--jaundice);
    margin-bottom: var(--space-xs);
}

.lightbox-meta {
    font-family: var(--font-accent);
    font-size: var(--fs-sm);
    color: var(--bone-dim);
    margin-bottom: var(--space-sm);
}

.lightbox-desc {
    font-style: italic;
    color: var(--bone-dim);
    font-size: var(--fs-sm);
}

.lightbox-close {
    position: fixed;
    top: var(--space-lg);
    right: var(--space-xl);
    font-size: var(--fs-3xl);
    color: var(--bone);
    cursor: pointer;
    z-index: 10001;
    min-width: 2.75rem;
    min-height: 2.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color var(--transition-fast), transform var(--transition-fast);
}

.lightbox-close:hover {
    color: var(--lurch);
    transform: rotate(90deg);
}

.lightbox-nav {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    font-size: var(--fs-2xl);
    color: var(--bone);
    cursor: pointer;
    padding: var(--space-lg);
    min-width: 2.75rem;
    min-height: 2.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color var(--transition-fast), opacity var(--transition-fast);
    opacity: 0.6;
    z-index: 10001;
}

.lightbox-nav:hover {
    color: var(--jaundice);
    opacity: 1;
}

.lightbox-prev {
    left: var(--space-md);
}

.lightbox-next {
    right: var(--space-md);
}

/* ---- Responsive ---- */

@media (max-width: 64rem) {
    .gallery-item--featured {
        grid-row: span 1;
        grid-column: span 1;
    }
}

@media (max-width: 48rem) {
    .gallery-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--space-md);
    }

    .gallery-item-overlay {
        opacity: 1;
        background: linear-gradient(to top, rgba(10, 8, 5, 0.8) 0%, transparent 50%);
    }

    .filter-row {
        flex-direction: column;
        align-items: stretch;
    }

    .filter-tags {
        display: none;
    }

    .filter-select-mobile {
        display: block;
    }

    .lightbox-nav {
        display: none;
    }
}

@media (max-width: 30rem) {
    .gallery-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--space-sm);
    }

    .gallery-item-overlay {
        padding: var(--space-sm);
    }

    .gallery-item-title {
        font-size: var(--fs-sm);
    }
}

/* ---- Image Count Badge ---- */

.gallery-item-count {
    position: absolute;
    bottom: var(--space-sm);
    right: var(--space-sm);
    display: flex;
    align-items: center;
    gap: 0.3125rem;
    padding: 0.5rem 0.75rem;
    background: rgba(0, 0, 0, 0.8);
    border: 0.0625rem solid var(--bone-faint);
    color: var(--bone);
    font-family: var(--font-body);
    font-size: var(--fs-sm);
    z-index: 2;
    pointer-events: none;
}

.gallery-item-count svg {
    width: 1rem;
    height: 1rem;
}

/* ---- Loading Overlay ---- */

.loading-overlay {
    visibility: hidden;
    position: fixed;
    inset: 0;
    z-index: 100000;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
}

.loader {
    width: 3rem;
    height: 3rem;
    border: 0.3125rem solid var(--bone);
    border-bottom-color: transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* ---- Lightbox Image Wrapper (single image, viewport-fit) ---- */

.lightbox-image-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

.lightbox-image-wrapper img {
    max-width: 90vw;
    max-height: 88vh;
    object-fit: contain;
    border-radius: var(--radius-md);
}

.lightbox-counter {
    position: fixed;
    bottom: var(--space-lg);
    left: 50%;
    transform: translateX(-50%);
    font-family: var(--font-accent);
    font-size: var(--fs-sm);
    color: var(--bone-dim);
    background: rgba(0, 0, 0, 0.6);
    padding: 0.375rem 1rem;
    border-radius: var(--radius-sm);
    z-index: 10001;
    pointer-events: none;
}

@media (max-width: 48rem) {
    .lightbox-image-wrapper img {
        max-width: 100%;
        max-height: 85vh;
        border-radius: 0;
    }
}

/* ---- Gallery Item as non-link (div) ---- */

.gallery-item[data-post-id] {
    cursor: pointer;
}

.gallery-item[data-post-id]:hover .gallery-item-image img {
    transform: scale(1.08);
    filter: saturate(1.1);
}

.gallery-item[data-post-id] .gallery-item-image {
    aspect-ratio: 1;
}

.gallery-item[data-post-id] .gallery-item-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
