* {
    box-sizing: border-box;
}

.thumbnail:hover {
    background-color: transparent;
}

.thumbnail:hover img {
    max-height: 100%;
    max-width: 100%;
}

.thumbnail span {
    /*CSS for enlarged image*/
    background-color: transparent;
    position: fixed;
    visibility: hidden;
    text-decoration: none;
    z-index: 5;
    display: flex;
    flex-direction: column;
    justify-content: center;
    /* this transition doesn't work?*/
}

.thumbnail span img {
    /*CSS for enlarged image*/
    border-width: 0;
}

.thumbnail:hover span {
    /*CSS for enlarged image*/
    visibility: visible;
    left: 30%;
    right: 30%;
    top: 20vh;
    bottom: 20vh;
    margin: 0;
    display: block;
    max-height: 80vh;
    max-width: 100%;
    height: auto;
}

.thumbnail cap,
.thumbnail img {
    box-shadow: 1px 1px 7px rgb(0, 0, 0);
    margin-bottom: 1em;
}

.thumbnail img {
    border-radius: 10px;
    object-fit: cover;
    width: 100%;
}

.thumbnail span .cap {
    background-color: #0000ff;
    color: whitesmoke;
    width: 40ch;
    height: fit-content;
    line-height: 2em;
    padding: 1em;
    border-radius: 25px;
}

@media screen and (max-width: 786px) {
    .thumbnail span {
        visibility: visible;
        position: relative;
    }
    .thumbnail:hover span {
        left: 0;
        right: 0;
        top: 0;
        bottom: 0;
        display: flex;
        max-height: 100%;
        max-width: 100%;
        height: auto;
        margin-bottom: 1em;
    }
    .thumbnail span .cap {
        width: 100%;
    }
}