/* Gallery page specific styles */
#news.gallery-page .gallery-grid {
    display: grid;
    gap: 10px;
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    grid-auto-rows: 200px;
    grid-auto-flow: dense;
    margin: 24px auto 0;
    width: 100%;
}

#news.gallery-page .gallery-grid img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.24);
    cursor: pointer;
    transform: none !important;
    transition: filter 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

#news.gallery-page .gallery-grid img:hover,
#news.gallery-page .gallery-grid img:focus-visible {
    transform: none !important;
    filter: brightness(1.06);
    border-color: rgba(255, 255, 255, 0.32);
    box-shadow: 0 14px 24px rgba(0, 0, 0, 0.3);
}

#expandedImageContainer {
    display: flex;
    justify-content: center;
    align-items: center;
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    padding-top: 80px;
    box-sizing: border-box;
    z-index: 4000;
    opacity: 0;
    transition: opacity 0.22s ease;
    pointer-events: none;
}

#expandedImageContainer:focus,
#expandedImageContainer:focus-visible {
    outline: none !important;
}

#expandedImageContainer::before {
    content: "";
    position: absolute;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.84);
    z-index: 0;
}

#expandedImage {
    position: relative;
    z-index: 1;
    width: auto;
    max-width: 80vw;
    max-height: 80vh;
    height: auto;
    opacity: 0;
    transform: scale(0.97);
    transform-origin: center;
    transition: transform 0.22s ease, opacity 0.22s ease;
    border-radius: 10px;
    border: 0;
    box-shadow: none;
    outline: none !important;
}

#expandedImage:focus,
#expandedImage:focus-visible {
    outline: none !important;
}

#expandedImage.expanded {
    opacity: 1;
    transform: scale(1);
}

@media (hover: none) {
    #news.gallery-page .gallery-grid img:hover {
        filter: none;
        border-color: rgba(255, 255, 255, 0.12);
        box-shadow: 0 10px 20px rgba(0, 0, 0, 0.24);
    }
}

@media (max-width: 768px) {
    #news.gallery-page .gallery-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        grid-auto-rows: 150px;
        gap: 8px;
        margin-top: 24px;
    }

    #expandedImageContainer {
        padding-top: 78px;
        padding-bottom: calc(16px + env(safe-area-inset-bottom));
    }

    #expandedImage {
        max-width: calc(100vw - 20px);
        max-height: calc(100dvh - 110px - env(safe-area-inset-bottom));
    }
}
