/* Gallery page classes */
.gallery * {
    box-sizing: border-box;
}

.gallery {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    grid-auto-rows: 1fr;
    gap: 1rem;
    margin-left: 2rem;
    margin-right: 2rem;
}

.gallery-item {
    position: relative;
    overflow: hidden;
    object-fit: contain;
    border: 6px solid white;
    background-color: white;
    cursor: pointer;
    transition: box-shadow 0.2s cubic-bezier(0.25, 0.1, 0.25, 1);
}

.gallery-item:hover {
    box-shadow: 0 0 5px 5px rgba(0, 0, 0, 0.5);
}

.gallery-item>img {
    aspect-ratio: 1/1;
    width: 100%;
    height: auto;
    object-fit: cover;
}

.gallery-item-caption {
    color: black;
    font-size: .75rem;
    text-align: center;
    /* Remove the default margin of p */
    margin: 0;
}

/* Gallery modal classes */
.gallery-modal {
    transition: opacity 0.5s ease-in-out;
}

.gallery-modal-closed {
    display: none;
    opacity: 0;
}

.gallery-modal-opened {
    display: flex;
    position: fixed;
    background-color: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(64px);

    z-index: 100001;
    left: 0;
    right: 0;
    bottom: 0;
    top: 0;
    height: 100vh;

    flex-direction: column;
    justify-content: center;
    align-items: center;
    opacity: 0;
}

.gallery-modal-content {
    height: 100%;
    width: 100%;
}

.gallery-modal-image-container {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;
    position: relative;
}

.gallery-modal-image {
    height: 100%;
    max-height: calc(100vh - 8rem);
    object-fit: contain;
    /* box-shadow: 10px 10px 10px rgba(0, 0, 0, 0.4); */
    transition: opacity 0.5s ease-in-out;
}

.gallery-modal-topbar {
    height: 8rem;
    width: 100%;
    background-color: rgb(76, 98, 102, 0.7);
    backdrop-filter: blur(100px);

    display: flex;
    flex-direction: row;
    justify-content: space-between;
    gap: 20px;
    align-items: center;
    padding: 0 2rem;
    border-bottom: 5px solid rgb(76, 98, 102, 1);
}

.gallery-modal-topbar-spacer {
    width: 2rem;
    height: 1px;
}

.gallery-modal-close {
    cursor: pointer;
    text-decoration: underline;
}

.gallery-modal-close:hover {
    color: rgba(255, 255, 255, 0.8);
}

.gallery-modal-caption {
    font-weight: bold;
    width: 100%;
}

.gallery-modal-image-bg {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    object-fit: cover;
    background-repeat: no-repeat;
    background-size: cover;
    background-position: center center;
    background-color: white;
    filter: blur(64px) brightness(70%);
    /* box-shadow: 0px 0px 19px 18px rgba(0, 0, 0, 0.1); */
    z-index: -1;
}

.gallery-modal-image-loader {
    position: absolute;
    width: 128px;
    height: 128px;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center center;
    z-index: 1;
    transition: opacity 0.2s ease-in-out;
}

.gallery-modal-image-wrapper {
    position: relative;
    border: 10px white;
}

@media screen and (max-width: 768px) {
    .gallery {
        grid-template-columns: repeat(1, 1fr);
    }


    .gallery-modal-image {
        max-width: 100vw;
        max-height: 80vh;
        aspect-ratio: 16/9;
        object-fit: contain;
        box-shadow: none;
    }

    .gallery-modal-content {
        padding-bottom: env(safe-area-inset-bottom, 50px);
    }
}

@media screen and (min-width: 768px) and (max-width: 1200px) {
    .gallery {
        grid-template-columns: repeat(3, 1fr);
    }

    .gallery-modal-content {
        padding-bottom: env(safe-area-inset-bottom, 50px);
    }
}