#lightbox {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.82);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

#lightbox.active {
    display: flex;
}

.lightbox-content {
    position: relative;
    max-width: 96%;
    max-height: 96%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

#lightbox img {
    max-width: min(94vw, 1700px);
    max-height: 90vh;
    object-fit: contain;
    border-radius: 4px;
    touch-action: pan-y;
}

#lightbox img.portrait-image {
    max-width: min(94vw, 1150px);
    max-height: 94vh;
}

.lightbox-caption {
    color: white;
    font-size: 14px;
    text-align: center;
    margin-top: 10px;
    max-width: 80%;
}

#lightbox .close,
#lightbox .prev,
#lightbox .next {
    position: absolute;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    border: none;
    padding: 10px;
    cursor: pointer;
    font-size: 24px;
    border-radius: 4px;
    transition: background 0.2s;
}

#lightbox .close:hover,
#lightbox .prev:hover,
#lightbox .next:hover {
    background: rgba(0, 0, 0, 0.9);
}

#lightbox .close {
    position: fixed;
    top: 20px;
    right: 20px;
}

#lightbox .prev {
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
}

#lightbox .next {
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
}
/* -----------------------------------------------
   Small screens: swipe replaces the arrows, and
   the photo goes edge to edge
   ----------------------------------------------- */

/* max-width covers a narrow desktop window; the pointer query catches a
   phone or tablet in ANY orientation - a phone held landscape is ~812px wide */
@media screen and (max-width: 800px), (hover: none) and (pointer: coarse) {

    #lightbox .prev,
    #lightbox .next {
        display: none;          /* swipe left/right instead */
    }

    .lightbox-content {
        max-width: 100%;
        max-height: 100%;
    }

    #lightbox img {
        max-width: 100vw;
        max-height: 92vh;
        max-height: 92dvh;
        border-radius: 0;
    }

    #lightbox img.portrait-image {
        max-width: 100vw;
        max-height: 96vh;
        max-height: 96dvh;
    }

    .lightbox-caption {
        max-width: 92%;
    }
}
