/* Gallery Layout */
.gallery-container {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2rem;
    padding-top: 2rem;
    padding-bottom: 2rem;
}

@media (min-width: 768px) {
    .gallery-container {
        grid-template-columns: 200px 1fr;
        align-items: start;
    }
    
    .gallery-sidebar {
        position: sticky;
        top: 100px; /* Adjust based on navbar height */
        align-self: start;
        z-index: 10;
    }
}

/* Sidebar */
.gallery-sidebar {
    background-color: white;
    padding: 1.5rem;
    border: 1px solid var(--color-border);
}
.filter-btn {
    display: block;
    width: 100%;
    text-align: left;
    padding: 0.5rem 0;
    margin-bottom: 0.5rem;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    color: var(--color-text-light);
    transition: color 0.3s;
}
.filter-btn:hover, .filter-btn.active {
    color: var(--color-accent);
    font-weight: 700;
}

/* Image Grid */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(1, 1fr);
    gap: 1.5rem;
}
.gallery-empty-state {
    grid-column: 1 / -1;
    text-align: center;
    color: var(--color-text-light);
}

@media (min-width: 768px) {
    .gallery-grid {
        /* Large screens: 3 columns */
        grid-template-columns: repeat(3, 1fr);
    }
}

/* User asked for "two rows on large screens". 
   If we have 3 columns, 2 rows = 6 items visible. 
   We can control this via JS pagination or just simple scrolling.
   Here I ensure the cards are sized well. 
*/

.gallery-item {
    background-color: white;
    border: 1px solid var(--color-border);
    overflow: hidden;
    position: relative;
    aspect-ratio: 1 / 1; /* Square images */
    cursor: pointer;
    transition: transform 0.3s ease;
}

.gallery-item:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1);
}

/* Real Images */
.gallery-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.5s ease;
}
.gallery-item:hover .gallery-img {
    transform: scale(1.1);
}

.item-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    background: linear-gradient(to top, rgba(0,0,0,0.8), rgba(0,0,0,0));
    color: white;
    padding: 1rem;
    padding-top: 3rem;
    transform: translateY(100%);
    transition: transform 0.3s ease;
}

.gallery-item:hover .item-overlay {
    transform: translateY(0);
}

.item-title {
    font-size: 1rem;
    font-weight: 700;
}
.item-category {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #d1cdc7;
}

/* Skeleton Loader */
@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.skeleton {
  background: #f0f0f0;
  background-image: linear-gradient(
    90deg,
    #f0f0f0 25%,
    #e0e0e0 50%,
    #f0f0f0 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 4px;
}

.skeleton-card {
  aspect-ratio: 1;
  width: 100%;
  display: block;
}

/* Image Loading State */
.gallery-img {
    opacity: 0;
    transition: opacity 0.5s ease, transform 0.5s ease;
}
.gallery-img.loaded {
    opacity: 1;
}

/* Lightbox */
.lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.95);
    z-index: 1000;
    display: flex;
    flex-direction: column; /* Stack image and caption */
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.lightbox.active {
    opacity: 1;
    pointer-events: all;
}

.lightbox-img {
    max-width: 90%;
    max-height: 80vh; /* Reserve space for caption */
    object-fit: contain;
    border: 2px solid white;
    box-shadow: 0 0 20px rgba(0,0,0,0.5);
    transform: scale(0.9);
    transition: transform 0.3s ease;
    margin-bottom: 1rem; /* Space between image and caption */
}

.lightbox.active .lightbox-img {
    transform: scale(1);
}

.lightbox-close {
    position: absolute;
    top: 2rem;
    right: 2rem;
    background: none;
    border: none;
    color: white;
    font-size: 3rem;
    cursor: pointer;
    z-index: 1001;
    line-height: 1;
    transition: color 0.3s, transform 0.3s;
}

.lightbox-close:hover {
    color: var(--color-accent);
    transform: rotate(90deg);
}
.lightbox-caption {
    position: relative; /* Return to flow */
    bottom: auto;
    color: white;
    font-size: 1.25rem;
    font-family: "Playfair Display", serif;
    text-align: center;
    max-width: 80%;
}

.lightbox-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: white;
    font-size: 4rem;
    cursor: pointer;
    z-index: 1002;
    padding: 0 1rem;
    transition: color 0.3s ease;
    user-select: none;
}
.lightbox-arrow:hover {
    color: var(--color-accent);
}
.lightbox-prev { left: 1rem; }
.lightbox-next { right: 1rem; }
