/* =============================================================
   GALLERY PAGE STYLES
   Premium masonry grid with lightbox - inherits from style.css
   ============================================================= */

/* --- Gallery Grid Container --- */
.gag-gallery {
    padding: var(--space-4) var(--space-4) var(--space-8);
    max-width: 1400px;
    margin: 0 auto;
}

@media (max-width: 768px) {
    .gag-gallery {
        padding-left: 5px;
        padding-right: 5px;
    }
}

/* --- Masonry Grid --- */
.gag-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-auto-rows: 220px;
    gap: var(--space-2);
}

@media (max-width: 1024px) {
    .gag-grid {
        grid-template-columns: repeat(3, 1fr);
        grid-auto-rows: 200px;
    }
}

@media (max-width: 768px) {
    .gag-grid {
        grid-template-columns: repeat(2, 1fr);
        grid-auto-rows: 180px;
    }
}

@media (max-width: 480px) {
    .gag-grid {
        grid-template-columns: 1fr 1fr;
        grid-auto-rows: auto;
    }
    .gag-cell {
        aspect-ratio: 1 / 1;
    }
}

/* --- Grid Cell --- */
.gag-cell {
    position: relative;
    overflow: hidden;
    border-radius: var(--radius-md);
    cursor: pointer;
    background: var(--bg-secondary);
}

.gag-cell.wide {
    grid-column: span 2;
}

.gag-cell.tall {
    grid-row: span 2;
}

@media (max-width: 480px) {
    .gag-cell.wide,
    .gag-cell.tall {
        grid-column: span 1;
        grid-row: span 1;
    }
}

/* --- Cell Image --- */
.gag-cell img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform var(--transition-slow), filter var(--transition-normal);
}

.gag-cell:hover img {
    transform: scale(1.08);
    filter: brightness(0.7);
}

/* --- Cell Label Overlay --- */
@keyframes gagImgPulse {
    0%   { transform: scale(1.0);   filter: brightness(1); }
    45%  { transform: scale(1.05);  filter: brightness(0.8); }
    100% { transform: scale(1.0);   filter: brightness(1); }
}

.gag-cell.gag-pulse img {
    animation: gagImgPulse 0.65s ease;
}

.gag-label {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 6px var(--space-2);
    background: linear-gradient(to top, rgba(15, 23, 42, 0.88) 0%, transparent 100%);
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 400;
    text-transform: none;
    letter-spacing: 0;
    transform: translateY(100%);
    opacity: 0;
    transition: transform 0.4s ease, opacity 0.4s ease;
}

.gag-cell:hover .gag-label,
.gag-cell.gag-alive .gag-label {
    transform: translateY(0);
    opacity: 1;
}

/* --- Lightbox Overlay --- */
.gag-lightbox {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition-normal), visibility var(--transition-normal);
}

.gag-lightbox.active {
    opacity: 1;
    visibility: visible;
}

/* --- Lightbox Image Wrapper --- */
.gag-lb-img-wrap {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    max-width: 90vw;
    max-height: 85vh;
}

/* --- Lightbox Image --- */
.gag-lb-img {
    display: block;
    max-width: 90vw;
    max-height: 85vh;
    object-fit: contain;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    transform: scale(0.9);
    opacity: 0;
    transition: transform var(--transition-normal), opacity var(--transition-normal);
}

.gag-lightbox.active .gag-lb-img {
    transform: scale(1);
    opacity: 1;
}

/* --- Lightbox Close Button --- */
.gag-lb-close {
    position: absolute;
    top: var(--space-3);
    right: var(--space-3);
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 50%;
    color: var(--text-primary);
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
    z-index: 10;
    transition: var(--transition-fast);
}

.gag-lb-close:hover {
    background: rgba(100, 145, 158, 0.2);
    border-color: var(--accent-muted);
    color: var(--accent-light);
}

/* --- Lightbox Navigation Arrows --- */
.gag-lb-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 50%;
    color: var(--text-primary);
    font-size: 32px;
    line-height: 1;
    cursor: pointer;
    z-index: 5;
    transition: var(--transition-fast);
}

.gag-lb-arrow:hover {
    background: rgba(100, 145, 158, 0.2);
    border-color: var(--accent-muted);
    color: var(--accent-light);
}

.gag-lb-prev {
    left: var(--space-3);
}

.gag-lb-next {
    right: var(--space-3);
}


@media (max-width: 768px) {
    .gag-lb-img-wrap {
        max-width: 100vw;
        max-height: 80vh;
        width: 100vw;
    }

    .gag-lb-img {
        max-width: 100vw;
        max-height: 80vh;
        border-radius: 0;
    }

    .gag-lb-arrow {
        width: 40px;
        height: 40px;
        font-size: 22px;
        background: rgba(15, 23, 42, 0.6);
        border-color: rgba(148, 163, 184, 0.25);
    }

    .gag-lb-prev {
        left: var(--space-1);
    }

    .gag-lb-next {
        right: var(--space-1);
    }
}

/* --- Lightbox Counter --- */
.gag-lb-counter {
    position: absolute;
    bottom: var(--space-3);
    left: 50%;
    transform: translateX(-50%);
    padding: var(--space-1) var(--space-2);
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
}

/* --- Touch scroll lock for lightbox (mobile) --- */
.gag-lightbox {
    touch-action: none;
    overscroll-behavior: contain;
}

.gag-lb-img-wrap {
    touch-action: pan-x;
}
#fh5co-gallery .fh5co-heading p {
    color: var(--text-secondary);
    line-height: 1.7;
    margin-bottom: var(--space-2);
}

#fh5co-gallery .fh5co-heading p a {
    color: var(--accent-light);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: border-color var(--transition-fast);
}

#fh5co-gallery .fh5co-heading p a:hover {
    border-bottom-color: var(--accent-light);
}
