:root {
    --grid-cell-size: 15rem;
    --grid-gap: 0.5rem;
    --img-btn-gap: 1rem;
}


/* IMAGE GALLERY */

#img-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, var(--grid-cell-size));
    gap: var(--grid-gap);
    justify-content: center;
    max-width: 1000px;
    margin: 0 auto;
    padding: 2rem var(--grid-gap);
}

/* Make grid cell square by making the height the same as the width */
#img-gallery div {
    aspect-ratio: 1 / 1;
}

#img-gallery img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* On small screens, force two columns that are sized to fill the width of the screen */
@media (max-width: 520px) {
    #img-gallery {
        grid-template-columns: 1fr 1fr;
        padding: 1rem;
    }
}


/* IMAGE MODAL */

/* Prevent page scroll when modal is open */
body:has(dialog[open]) {
    overflow: hidden;
}

#img-modal {
    width: 100dvw;
    height: 100dvh;
    max-width: 100dvw;
    max-height: 100dvh;
    padding: 0;
    margin: 0;
    border: none;
    outline: none;
    background-color: transparent;
}

#img-modal::backdrop {
    background-color: rgba(0, 0, 0, 0.85);
}

#img-modal > div {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100dvw;
    height: 100dvh;
}

#img-modal img {
    display: block;
    max-width: 90dvw;
    max-height: 95dvh;
    padding: 1rem;
    border-radius: 1rem;
    background-color: white;
    box-sizing: border-box;
}

#img-container {
    position: relative;
}

#img-details {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background-color: rgba(255, 255, 255, 0.9);
    margin: 1rem;
    padding: 1rem;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

#img-title {
    margin: 0;
    font-size: 1rem;
}

#img-desc {
    margin: 0;
    font-size: 0.9rem;
}

#img-left-btn, #img-right-btn, #img-close-btn {
    position: fixed;
    background-color: transparent;
    color: white;
    border: none;
    outline: none;
}

#img-left-btn:hover, #img-right-btn:hover, #img-close-btn:hover {
    cursor: pointer;
}

#img-left-btn {
    top: 50%;
    left: var(--img-btn-gap);
    transform: translateY(-50%);
    font-size: 2rem;
}

#img-right-btn {
    top: 50%;
    right: var(--img-btn-gap);
    transform: translateY(-50%);
    font-size: 2rem;
}

#img-close-btn {
    top: var(--img-btn-gap);
    right: var(--img-btn-gap);
    font-size: 1.5rem;
}

@media (max-width: 768px) {
    #img-modal::backdrop {
        background-color: rgba(0, 0, 0, 1);
    }

    #img-modal img {
        max-width: 85dvw;
        max-height: 60dvh;
        padding: 0.8rem;
    }

    #img-container {
        display: flex;
        flex-direction: column;
        align-items: center;
    }

    #img-details {
        position: static;
        margin: 0;
        padding: 2rem;
        background: transparent;
        color: white;
    }

    #img-title {
        font-size: 0.9rem;
    }

    #img-desc {
        color: rgb(161, 161, 161);
        font-size: 0.8rem;
    }

    #img-left-btn, #img-right-btn {
        display: none;
    }

    #img-close-btn {
        right: calc(var(--img-btn-gap) / 2);
        font-size: 1rem;
    }
}