/* ================================================
   Gallery page — /gallery
   Masonry column layout, fully responsive
   CSS-only shimmer — no JS needed for loading effect
   ================================================ */

/* ── Shimmer animation ── */
@keyframes shimmer {
    0%   { background-position: -200% 0; }
    100% { background-position:  200% 0; }
}

/* ── Zoom-in on image load ── */
@keyframes imgZoomIn {
    from { transform: scale(1.12); opacity: 0; }
    to   { transform: scale(1);    opacity: 1; }
}

.image-container.loaded .gallery-image {
    animation: imgZoomIn 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

/* ── Slide-in-up entrance per column (4-col) ── */
@keyframes slideInUp {
    from { opacity: 0; transform: translateY(28px); }
    to   { opacity: 1; transform: translateY(0); }
}

.gallery-item {
    animation: slideInUp 0.5s ease both;
}

/* 4 columns — stagger by column position */
.gallery-masonry .gallery-item:nth-child(4n+1) { animation-delay: 0ms; }
.gallery-masonry .gallery-item:nth-child(4n+2) { animation-delay: 80ms; }
.gallery-masonry .gallery-item:nth-child(4n+3) { animation-delay: 160ms; }
.gallery-masonry .gallery-item:nth-child(4n+4) { animation-delay: 240ms; }

@media (max-width: 1199.98px) {
    /* 3 columns */
    .gallery-masonry .gallery-item:nth-child(4n+1),
    .gallery-masonry .gallery-item:nth-child(4n+2),
    .gallery-masonry .gallery-item:nth-child(4n+3),
    .gallery-masonry .gallery-item:nth-child(4n+4) { animation-delay: 0ms; }

    .gallery-masonry .gallery-item:nth-child(3n+1) { animation-delay: 0ms; }
    .gallery-masonry .gallery-item:nth-child(3n+2) { animation-delay: 80ms; }
    .gallery-masonry .gallery-item:nth-child(3n+3) { animation-delay: 160ms; }
}

@media (max-width: 767.98px) {
    /* 2 columns */
    .gallery-masonry .gallery-item:nth-child(3n+1),
    .gallery-masonry .gallery-item:nth-child(3n+2),
    .gallery-masonry .gallery-item:nth-child(3n+3) { animation-delay: 0ms; }

    .gallery-masonry .gallery-item:nth-child(2n+1) { animation-delay: 0ms; }
    .gallery-masonry .gallery-item:nth-child(2n+2) { animation-delay: 80ms; }
}

@media (max-width: 479.98px) {
    /* 1 column — no stagger needed */
    .gallery-masonry .gallery-item:nth-child(2n+1),
    .gallery-masonry .gallery-item:nth-child(2n+2) { animation-delay: 0ms; }
}

/* ── Masonry grid ── */
.gallery-masonry {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.5rem;
    padding: 0.75rem 0.5rem;
}

@media (max-width: 1199.98px) {
    .gallery-masonry { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 767.98px) {
    .gallery-masonry { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 479.98px) {
    .gallery-masonry { grid-template-columns: repeat(1, 1fr); }
}

/* ── Individual card ── */
.gallery-item {
    margin-bottom: 0;
}

.gallery-item a {
    display: block;
    text-decoration: none;
}

/* ── Image container ── */
.image-container {
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    background: linear-gradient(90deg, #e0e0e0 25%, #ececec 50%, #e0e0e0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.6s ease-in-out infinite;
    min-height: 0;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.12);
    transition: box-shadow 0.3s ease, transform 0.3s ease;
}

/* Stop shimmer once image has loaded */
.image-container.loaded {
    animation: none;
    background: none;
}

.image-container:hover {
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.22);
    transform: translateY(-2px);
}

/* ── Image — fills container width, fixed height ── */
.gallery-image {
    display: block;
    width: 100%;
    height: 220px;
    object-fit: cover;
    object-position: center;
    transition: transform 0.3s ease;
}

.gallery-item a:hover .gallery-image {
    transform: scale(1.03);
}

/* ── Title overlay at bottom of image ── */
.gallery-item__title {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    margin: 0;
    padding: 0.5rem 0.6rem 0.45rem;
    font-size: 0.78rem;
    font-weight: 600;
    line-height: 1.3;
    text-align: center;
    color: #fff;
    background: linear-gradient(to top, rgba(0,0,0,0.65) 0%, rgba(0,0,0,0) 100%);
    opacity: 0;
    transform: translateY(4px);
    transition: opacity 0.3s ease, transform 0.3s ease;
    pointer-events: none;
}

.image-container:hover .gallery-item__title {
    opacity: 1;
    transform: translateY(0);
}

/* ── Loading indicator (infinite scroll) ── */
#loading-indicator {
    background: rgba(255, 255, 255, 0.9);
    border-radius: 12px;
    padding: 1.25rem;
    margin: 1rem 0;
}

/* ── Scroll trigger (invisible element) ── */
.gallery-scroll-trigger {
    height: 1px;
}

/* ── End of results message ── */
.gallery-end-alert {
    border: 2px solid #F2DDCC;
    box-shadow: 0 4px 20px rgba(236, 118, 22, 0.18);
    background: linear-gradient(135deg, #e3f2fd 0%, #f3e5f5 100%);
    border-radius: 12px;
    padding: 1rem 1.5rem;
}
/* ── Individual card ── */
.gallery-item {
    margin-bottom: 0;
}

.gallery-item a {
    display: block;
    text-decoration: none;
}

/* Title inside image container as bottom overlay */
.gallery-item__title {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    margin: 0;
    padding: 0.5rem 0.6rem 0.45rem;
    font-size: 0.78rem;
    font-weight: 600;
    line-height: 1.3;
    text-align: center;
    color: #fff;
    background: linear-gradient(to top, rgba(0,0,0,0.62) 0%, rgba(0,0,0,0) 100%);
    opacity: 0;
    transform: translateY(4px);
    transition: opacity 0.3s ease, transform 0.3s ease;
    pointer-events: none;
}

.image-container:hover .gallery-item__title {
    opacity: 1;
    transform: translateY(0);
}

/* ── Image container ── */
.image-container {
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    background: #e4e4e4;
    border: 2px solid #fff;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.12);
    transition: box-shadow 0.3s ease, transform 0.3s ease;
}

.image-container:hover {
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.22);
    transform: translateY(-2px);
}

/* ── Image ── */
.gallery-image {
    display: block;
    width: 100%;
    height: 100%;
    transition: transform 0.3s ease;
}

.gallery-item a:hover .gallery-image {
    transform: scale(1.03);
}

/* ── Skeleton shimmer overlay ── */
.loading-skeleton {
    position: absolute;
    inset: 0;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    background: linear-gradient(90deg, #e0e0e0 25%, #efefef 50%, #e0e0e0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.6s ease-in-out infinite;
    transition: opacity 0.4s ease;
    pointer-events: none;
}

/* Icon inside skeleton */
.loading-skeleton i {
    font-size: 2rem;
    color: #aaa;
    animation: skeleton-pulse 1.6s ease-in-out infinite;
}

/* Fake progress bar at bottom of skeleton */
.loading-skeleton::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    width: 40%;
    border-radius: 0 2px 2px 0;
    background: linear-gradient(90deg, transparent, #c0c0c0, transparent);
    animation: shimmer 1.6s ease-in-out infinite;
    background-size: 200% 100%;
}

.image-container.loaded .loading-skeleton {
    opacity: 0;
}

/* ── Loading indicator (infinite scroll) ── */
#loading-indicator {
    background: rgba(255, 255, 255, 0.9);
    border-radius: 12px;
    padding: 1.25rem;
    margin: 1.5rem 0;
}

/* ── End of results message ── */
#end-message .alert {
    border: 2px solid #F2DDCC;
    box-shadow: 0 4px 20px rgba(236, 118, 22, 0.18);
    background: linear-gradient(135deg, #e3f2fd 0%, #f3e5f5 100%);
    border-radius: 12px;
}

.image-container.loaded .loading-skeleton {
    opacity: 0;
    pointer-events: none;
}

/* ── Loading indicator (infinite scroll) ── */
#loading-indicator {
    background: rgba(255, 255, 255, 0.9);
    border-radius: 12px;
    padding: 1.25rem;
    margin: 1.5rem 0;
}

/* ── End of results message ── */
#end-message .alert {
    border: 2px solid #F2DDCC;
    box-shadow: 0 4px 20px rgba(236, 118, 22, 0.18);
    background: linear-gradient(135deg, #e3f2fd 0%, #f3e5f5 100%);
    border-radius: 12px;
}
