/* ==========================================================================
   Gallery Component Styles
   ========================================================================== */

/* Gallery Item */
.gallery-item {
    position: relative;
    overflow: hidden;
    border-radius: 0.75rem;
    background: rgba(255, 255, 255, 0.05);
    cursor: pointer;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.gallery-item.visible {
    opacity: 1;
    transform: translateY(0);
}

.gallery-item:hover {
    transform: translateY(-4px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
}

.gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.gallery-item:hover img {
    transform: scale(1.1);
}

.gallery-item.loaded img {
    animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* Gallery Overlay */
.gallery-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(to bottom,
        rgba(0,0,0,0) 0%,
        rgba(0,0,0,0.7) 100%);
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: 1.5rem;
    opacity: 0;
    transition: opacity 0.3s ease;
}

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

.gallery-caption {
    font-size: 0.875rem;
    color: #fff;
    margin-bottom: 0.5rem;
}

.gallery-expand {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    transform: scale(0);
    transition: transform 0.3s ease;
}

.gallery-item:hover .gallery-expand {
    transform: scale(1);
}

/* Masonry Layout */
.gallery-masonry {
    column-count: 1;
    column-gap: 1rem;
}

.gallery-masonry .gallery-item {
    break-inside: avoid;
    margin-bottom: 1rem;
}

/* Different sizes for masonry */
.gallery-item-small {
    grid-row: span 1;
}

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

.gallery-item-large {
    grid-row: span 3;
}

/* When using masonry layout */
.gallery-masonry .gallery-item-small img {
    height: 200px;
}

.gallery-masonry .gallery-item-medium img {
    height: 350px;
}

.gallery-masonry .gallery-item-large img {
    height: 500px;
}

/* Loading state for images */
.gallery-item img.loading {
    background: linear-gradient(90deg,
        rgba(255,255,255,0.1) 0%,
        rgba(255,255,255,0.2) 50%,
        rgba(255,255,255,0.1) 100%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% {
        background-position: -200% center;
    }
    100% {
        background-position: 200% center;
    }
}

/* Touch feedback for mobile */
@media (hover: none) {
    .gallery-overlay {
        opacity: 1;
        background: linear-gradient(to bottom,
            rgba(0,0,0,0.3) 0%,
            rgba(0,0,0,0.8) 100%);
    }

    .gallery-expand {
        transform: scale(1);
        background: rgba(37, 99, 235, 0.9);
        border-color: #2563eb;
    }

    .gallery-item:active {
        transform: scale(0.98);
    }
}

/* Responsive adjustments */
@media (min-width: 768px) {
    .gallery-masonry {
        column-count: 2;
    }

    .gallery-caption {
        font-size: 1rem;
    }
}

@media (min-width: 1024px) {
    .gallery-masonry {
        column-count: 3;
    }
}

@media (min-width: 1280px) {
    .gallery-masonry {
        column-count: 4;
    }
}

/* Accessibility */
.gallery-item:focus {
    outline: 2px solid #2563eb;
    outline-offset: 2px;
}

.gallery-item:focus:not(:focus-visible) {
    outline: none;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .gallery-item,
    .gallery-item img,
    .gallery-overlay,
    .gallery-expand {
        transition-duration: 0.01ms !important;
    }

    .gallery-item.loaded img {
        animation: none;
    }
}