.gallery-page {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, 150px);
    gap: 10px;
    justify-content: center;
}

.gallery-thumb {
    width: 150px;
    height: 100px;
    cursor: pointer;
    overflow: hidden;
    border-radius: 4px;
    transition: transform 0.2s, box-shadow 0.2s;
}

.gallery-thumb:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.gallery-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Overlays */
.gallery-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.3s ease, visibility 0.3s;
}

.gallery-overlay.is-active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.gallery-overlay--medium {
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
}

/* Crossfade image container */
.gallery-crossfade {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    max-width: 90vw;
    max-height: 90vh;
}

.gallery-crossfade img {
    max-width: 90vw;
    max-height: 90vh;
    object-fit: contain;
    cursor: default;
    opacity: 0;
    transition: opacity 0.35s ease;
}

.gallery-crossfade img:not(:first-child) {
    position: absolute;
}

.gallery-crossfade img.is-visible {
    opacity: 1;
}

/* Close button */
.gallery-close {
    position: absolute;
    top: 15px;
    right: 20px;
    background: none;
    border: none;
    color: white;
    font-size: 36px;
    cursor: pointer;
    z-index: 10001;
    line-height: 1;
    padding: 5px 10px;
}

.gallery-close:hover {
    color: #ccc;
}

/* Navigation arrows */
.gallery-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: white;
    font-size: 48px;
    cursor: pointer;
    padding: 10px 20px;
    z-index: 10001;
    border-radius: 4px;
    line-height: 1;
}

.gallery-nav:hover {
    background: rgba(255, 255, 255, 0.3);
}

.gallery-nav--prev {
    left: 15px;
}

.gallery-nav--next {
    right: 15px;
}

/* Gallery cards (gallery list page) */
.gallery-card {
    display: block;
    width: 150px;
    text-align: center;
    text-decoration: none;
    color: inherit;
}

.gallery-card:hover {
    text-decoration: none;
    color: inherit;
}

.gallery-card-name {
    margin-top: 6px;
    font-size: 13px;
    line-height: 1.3;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.gallery-thumb-placeholder {
    background: #e0e0e0;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Accessibility: disable animations for users who prefer reduced motion */
@media (prefers-reduced-motion: reduce) {
    .gallery-overlay,
    .gallery-crossfade img {
        transition: none;
    }
}
