.gallery {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    padding: 10px;
}

.thumbnail {
    flex: 1 1 calc(22% - 10px);
    box-sizing: border-box;
    max-width: calc(22% - 10px);
}

.thumbnail img {
    width: auto;
    height: 220px;
    cursor: pointer;
    transition: transform 0.4s;
}

.thumbnail img:hover {
    transform: scale(1.05);
}

.lightbox {
    display: none;
    position:fixed;
    z-index: 9999;
    left: 0;
    top: 0;
    width: 100% !important;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 0;
    margin: 0;
    box-sizing: border-box;
}

.lightbox-img {
    max-width: 100%;
    max-height: 100%;
    margin: auto;
    opacity: 0;
    transition: opacity 0.6s ease-in-out;
}

.lightbox-img.visible {
    opacity: 1;
}

.lightbox-img.slide-in {
    animation: slide-in 0.6s forwards;
}

.lightbox-img.slide-out {
    animation: slide-out 0.6s forwards;
}


.caption {
    color: #fff;
    margin: 0;
    max-width: 60%;
    width: initial;
    position: absolute;
    z-index: 1100;
    bottom: 50px;
    background: #000;
    padding: 3px 10px 3px 10px;
}

.close, .prev, .next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    font-size: 40px;
    color: #fff;
    cursor: pointer;
    transition: color 0.3s;
    touch-action: manipulation;
    user-select: none;
    padding: 10px;
}

.close:hover, .prev:hover, .next:hover {
    color: #bbb;
}

.close {
    top: 20px;
    right: 30px;
    transform: none;
    font-family: arial;
}

.prev {
    left: 20px;
}

.next {
    right: 25px;
}

@media only screen and (max-width: 890px) {
    article {
        width: initial;
    }

    .main-container {
        width: 95%;
    }

    .caption {
        bottom: 20px;
    }

}
@media only screen and (max-width: 860px) and (orientation: landscape) {

.lightbox {
    position: fixed;
    z-index: 999;
    left: 0;
    top: 0;
    width: 100% !important;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    padding: 0;
    margin: 0;
    right: 0;
}

}
@media (max-width: 768px) {
    .thumbnail {
        flex: 1 1 calc(50% - 10px);
        max-width: calc(50% - 10px);
    }
}

@media (max-width: 480px) {
    .lightbox {
        width: 99%;
        flex-direction: column;
    }

    .lightbox-img {
        max-height: 80%;
        margin: 5% 0% 0;
    }

    .thumbnail {
        flex: 1 1 100%;
        max-width: 100%;
    }

    .close {
        top: 10px;
        right: 20px;
        font-size: 30px;
    }

    .prev, .next {
        font-size: 30px;
        padding: 15px;
    }

    .next {
        right: 25px;
    }

    .caption {
        margin-top: 10px;
        bottom: 28%;
    }
}
@keyframes slide-in-right {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slide-out-left {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(-100%);
        opacity: 0;
    }
}

@keyframes slide-in-left {
    from {
        transform: translateX(-100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slide-out-right {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

@keyframes slide-in {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slide-out {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(-100%);
        opacity: 0;
    }
}

.lightbox-img.slide-in-right {
    animation: slide-in-right 0.5s forwards;
}

.lightbox-img.slide-out-left {
    animation: slide-out-left 0.5s forwards;
}

.lightbox-img.slide-in-left {
    animation: slide-in-left 0.5s forwards;
}

.lightbox-img.slide-out-right {
    animation: slide-out-right 0.5s forwards;
}
