/* Gallery Styles */
.gallery-section {
    padding: 80px 0;
    background: linear-gradient(180deg, var(--sky-gradient-start, #E8F4FF) 0%, var(--cream-white, #F8FBFF) 100%);
}

.gallery-section h2 {
    text-align: center;
    color: var(--kanata-blue, #2894FF);
    margin-bottom: 50px;
    font-size: 2.2em;
    font-weight: 300;
    letter-spacing: 0.05em;
}

#gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 25px;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

.gallery-item {
    position: relative;
    border-radius: 16px;
    overflow: hidden;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(40, 148, 255, 0.15);
    transition: transform 0.4s ease, box-shadow 0.4s ease;
    aspect-ratio: 16 / 9;
    background: linear-gradient(135deg, #E8F4FF 0%, #F0F8FF 100%);
    opacity: 0;
    animation: galleryFadeIn 0.6s ease-out both;
}

.gallery-item:nth-child(1) { animation-delay: 0s; }
.gallery-item:nth-child(2) { animation-delay: 0.08s; }
.gallery-item:nth-child(3) { animation-delay: 0.16s; }
.gallery-item:nth-child(4) { animation-delay: 0.24s; }
.gallery-item:nth-child(5) { animation-delay: 0.32s; }
.gallery-item:nth-child(6) { animation-delay: 0.40s; }
.gallery-item:nth-child(7) { animation-delay: 0.48s; }
.gallery-item:nth-child(8) { animation-delay: 0.56s; }
.gallery-item:nth-child(9) { animation-delay: 0.64s; }

@keyframes galleryFadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.gallery-item::before {
    content: '';
    position: absolute;
    top: -3px;
    right: -3px;
    bottom: -3px;
    left: -3px;
    background: linear-gradient(45deg, var(--kanata-blue, #2894FF), var(--gold, #FFD700), var(--kanata-blue-light, #5AAFFF));
    border-radius: 18px;
    z-index: -1;
    opacity: 0;
    transition: opacity 0.4s ease;
}

.gallery-item:hover {
    transform: translateY(-8px);
    box-shadow: 0 15px 40px rgba(40, 148, 255, 0.3);
}

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

.gallery-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease, filter 0.4s ease, opacity 0.5s ease;
}

.gallery-image.lazy {
    opacity: 0;
}

.gallery-image:not(.lazy) {
    opacity: 1;
}

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

.gallery-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 20px;
    background: linear-gradient(transparent, rgba(45, 45, 68, 0.9));
    color: white;
    transform: translateY(100%);
    transition: transform 0.4s ease;
}

.gallery-item:hover .gallery-overlay {
    transform: translateY(0);
}

.gallery-caption {
    font-size: 0.9em;
    opacity: 0.85;
    font-style: italic;
}

.gallery-empty {
    text-align: center;
    color: #888;
    grid-column: 1 / -1;
    padding: 60px 20px;
    font-size: 1.1em;
}

.gallery-empty a {
    color: var(--kanata-blue, #2894FF);
    text-decoration: underline;
}

/* Skeleton Loading */
.gallery-skeleton {
    position: relative;
    border-radius: 16px;
    overflow: hidden;
    aspect-ratio: 16 / 9;
    background: linear-gradient(135deg, #E8F4FF 0%, #F0F8FF 100%);
}

.gallery-skeleton::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, rgba(255,255,255,0) 0%, rgba(255,255,255,0.4) 50%, rgba(255,255,255,0) 100%);
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* Lightbox */
.lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(26, 26, 46, 0.98);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.4s ease, visibility 0.4s ease;
}

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

.lightbox-content {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    align-items: center;
}

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

.lightbox-image img {
    max-width: 100%;
    max-height: 70vh;
    object-fit: contain;
    border-radius: 12px;
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.5);
}

.lightbox-info {
    color: white;
    text-align: center;
    padding: 25px;
    max-width: 650px;
}

.lightbox-caption {
    font-size: 1.05em;
    opacity: 0.9;
    font-style: italic;
}

.lightbox-close {
    position: absolute;
    top: -50px;
    right: 0;
    background: none;
    border: none;
    color: white;
    font-size: 2.5em;
    cursor: pointer;
    padding: 10px;
    line-height: 1;
    opacity: 0.6;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.lightbox-close:hover {
    opacity: 1;
    transform: rotate(90deg);
}

.lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(40, 148, 255, 0.2);
    border: none;
    color: white;
    font-size: 2em;
    cursor: pointer;
    padding: 20px 15px;
    opacity: 0.7;
    transition: opacity 0.3s ease, background 0.3s ease;
    border-radius: 8px;
}

.lightbox-nav:hover {
    opacity: 1;
    background: rgba(40, 148, 255, 0.4);
}

.lightbox-prev { left: 20px; }
.lightbox-next { right: 20px; }

/* Responsive */
@media (max-width: 768px) {
    .gallery-section {
        padding: 50px 0;
    }

    .gallery-section h2 {
        font-size: 1.8em;
        margin-bottom: 35px;
    }

    #gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
        gap: 18px;
    }

    .gallery-item {
        border-radius: 12px;
    }

    .gallery-overlay {
        transform: translateY(0);
        background: linear-gradient(transparent 40%, rgba(45, 45, 68, 0.9));
        padding: 15px;
    }

    .lightbox-nav {
        padding: 15px 10px;
        font-size: 1.5em;
    }

    .lightbox-prev { left: 10px; }
    .lightbox-next { right: 10px; }
}

@media (max-width: 480px) {
    #gallery-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .gallery-item {
        aspect-ratio: 4 / 3;
    }

    .lightbox-close {
        top: -40px;
        font-size: 2em;
    }
}
