/* Gallery styles */
.gallery-section {
    padding: 4rem 0;
}

.gallery-section .container {
    max-width: 1400px;
    margin: 0 auto;
}

.gallery-grid {
    display: grid;
    /* smaller minimum column to keep thumbnails compact on wide screens */
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 10px;
    justify-items: center;
}

.gallery-item {
    width: 100%;
    position: relative; /* for caption overlay */
    overflow: hidden;
    border-radius: 12px;
    background: var(--soft-white);
    /* make thumbnails square and consistent */
    aspect-ratio: 1 / 1;
}

.gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover; /* center-crop to fill the square */
    display: block;
    transition: transform 0.35s ease, filter 0.35s ease;
}

/* caption overlay that appears on hover/focus */
.gallery-caption {
    position: absolute;
    inset: 0; /* top:0; right:0; bottom:0; left:0 */
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    background: linear-gradient(to bottom, rgba(0,0,0,0.0), rgba(0,0,0,0.45));
    opacity: 0;
    transition: opacity 200ms ease, transform 200ms ease;
    transform: translateY(6px);
    text-align: center;
    padding: 0.75rem 1rem;
    font-weight: 600;
    pointer-events: none; /* allow image hover to still trigger */
}

.gallery-item:focus .gallery-caption,
.gallery-item:hover .gallery-caption {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

/* small caption text on very small screens */
@media (max-width: 480px) {
    .gallery-caption { font-size: 0.9rem; padding: 0.5rem; }
}

/* Responsive Design */
@media (max-width: 768px) {
    .section-title {
        font-size: 2.2rem;
    }
    
    .projects-gallery {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    
    .initiatives-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    


}

/* Mobile-friendly card adjustments: make cards full-width, reduce gaps and padding */
@media (max-width: 600px) {
    .container { padding: 0 1rem; }

    /* Project cards: stack, remove side margins that caused overflow */
    .projects-gallery {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .project-card {
        margin: 0;
        width: 100%;
        border-radius: 14px;
        box-shadow: 0 12px 30px rgba(0,0,0,0.08);
        overflow: hidden;
    }

    .project-image {
        height: auto; /* let image determine height on small screens */
    }

    .project-image img {
        width: 100%;
        height: auto;
        object-fit: cover;
    }

    .project-info { padding: 1rem; }

    /* Initiative cards: slightly smaller padding and icon size */
    .initiative-card { padding: 1.25rem; }
    .initiative-icon { width: 56px; height: 56px; margin-bottom: 1rem; }

    /* Gallery items: reduce gap and radius for denser mobile layout */
    .gallery-grid { gap: 8px; }
    .gallery-item { border-radius: 10px; }

    /* Make sure buttons and links don't overflow */
    .action-buttons .btn { width: 100%; max-width: none; }
}

.gallery-item:hover img {
    transform: scale(1.05);
    filter: brightness(1.02);
}


/* On narrow screens keep the square ratio but reduce grid column min size */
@media (max-width: 768px) {
    .gallery-grid { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
}

@media (max-width: 480px) {
    .gallery-grid { grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); }
}

/* Optional: make gallery images focusable for keyboard users */
.gallery-item img:focus {
    outline: 3px solid rgba(107,70,193,0.16);
}

/* Global image defaults to avoid oversized images leaking layout */
img {
    max-width: 100%;
    height: auto;
    display: block;
}
.initiative-stats {
    gap: 1rem;
}

.project-card {
    margin: 0; /* remove side margins so grid spacing (gap) controls gutters and prevents overflow */
}

/* Ensure galleries use border-box sizing so item widths include padding/borders and align with .container */
.projects-gallery, .gallery-grid {
    box-sizing: border-box;
}

/* Lightbox / Modal styles */
.lightbox {
    position: fixed;
    inset: 0;
    background: rgba(10, 10, 15, 0.75);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 200ms ease, visibility 200ms ease;
}
.lightbox.open {
    opacity: 1;
    visibility: visible;
}
.lightbox-inner {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    width: min(1000px, 95%);
}
.lightbox-inner {
    display: flex;
    flex-direction: column; /* stack controls/content vertically */
    align-items: center;
}
.lightbox-content {
    display: flex;
    flex-direction: column; /* stack image and caption vertically */
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    background: transparent;
}
.lightbox-content {
    width: 100%;
    box-sizing: border-box;
}
.lightbox-content img {
    width: auto;
    max-width: 100%;
    max-height: 80vh;
    border-radius: 10px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.6);
}
.lightbox-caption {
    margin: 0;
    color: #fff;
    text-align: center;
    font-size: 0.95rem;
    line-height: 1.3;
    max-width: 90%;
    word-break: break-word;
}
.lightbox-close,
.lightbox-prev,
.lightbox-next {
    position: absolute;
    background: rgba(0,0,0,0.45);
    color: white;
    border: none;
    padding: 0.5rem 0.9rem;
    font-size: 1.6rem;
    border-radius: 8px;
    cursor: pointer;
}
.lightbox-close { top: -10px; right: -10px; }
.lightbox-prev { left: -40px; top: 50%; transform: translateY(-50%); }
.lightbox-next { right: -40px; top: 50%; transform: translateY(-50%); }
.lightbox-close:focus, .lightbox-prev:focus, .lightbox-next:focus { outline: 2px solid rgba(107,70,193,0.3); }

@media (max-width: 680px) {
    .lightbox-prev, .lightbox-next { left: 8px; right: 8px; top: auto; bottom: -48px; transform: none; }
    .lightbox-close { right: 8px; top: 8px; }

/* Mobile: stack card content and place logo above title in normal flow */
@media (max-width: 600px) {
    .initiative-card {
        display: block;
        padding: 1.25rem;
    }
    .initiative-icon {
        width: 56px;
        height: 56px;
        grid-column: auto;
        grid-row: auto;
        justify-self: start;
        margin-bottom: 0.75rem;
    }
    .initiative-content { padding-right: 0; }
}
}
