/* Wrapper container (not a grid) */
.reg-foto {
    display: flex;
    /* use flex instead of grid */
    flex-wrap: wrap;
    /* wrap images to next line */
    gap: 10px;
    padding: 20px;
    position: relative;
    /* needed for overlay inside it */
}

/* Make images square and cover the container */
.reg-foto img {
    width: calc(20% - 8px);
    /* roughly 5 per row, adjust for gap */
    aspect-ratio: 1 / 1;
    object-fit: cover;
    transition: transform 0.3s ease;
    cursor: pointer;
    display: block;
}

/* Zoom effect on hover */
.reg-foto img:hover {
    transform: scale(1.05);
}


/* overlay should apply globally */
.overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    justify-content: center;
    align-items: center;
    z-index: 9999;
    overflow: auto;
    padding: 20px;
}

.overlay.active {
    display: flex;
}


.overlay .close-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    font-size: 24px;
    color: white;
    background-color: transparent;
    border: none;
    cursor: pointer;
    z-index: 1001;
}


.overlay-content {
    position: relative;
    display: block;
    /* remove inline-block / flex */
    margin: 0 auto;
    /* center horizontally if needed */
}

.overlay-content img {
    max-width: 90vw;
    max-height: 90vh;
    border-radius: 10px;
    pointer-events: none;
}

.overlay-content .close-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    font-size: 36px;
    color: white;
    background: rgba(0, 0, 0, 0.4);
    border: none;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
}

.overlay-content .close-btn:hover {
    background: rgba(0, 0, 0, 0.7);
}

/* Mobile-specific overlay centering */
@media (max-width: 1000px) {
    .foto {
        grid-template-columns: repeat(2, 1fr);
    }

    /* Ensure the flexbox truly centers the content */
    .overlay {
        padding: 0;               /* remove side padding that was pushing right */
        justify-content: center;
        align-items: center;
    }

    .overlay-content {
        width: auto;              /* don’t force 100% width */
        max-width: 95vw;
        margin: 0;                /* kill any accidental margins */
    }

    .overlay-content img {
        max-width: 95vw;
        max-height: 80vh;
    }

    /* keep buttons inside */
    .overlay .arrow-left  { left: 10px; }
    .overlay .arrow-right { right: 10px; }
    .overlay-content .close-btn { right: 10px; }
}
