/* ==========================================================================
   Komponente: Lightbox
   Gemeinsame Lightbox für Drawings (page-drawings.php, Bilder) und
   Animations (page-animations.php, Bilder + Videos). Konsolidiert aus den
   vormals duplizierten Blöcken in drawings.css und animations.css; bei
   mehrfach definierten Regeln wurden die effektiv gewinnenden Werte
   übernommen.
   ========================================================================== */

.lightbox {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        radial-gradient(circle at center,
            rgba(0, 0, 0, 0) 50%,
            rgba(0, 0, 0, 0.02) 70%,
            rgba(0, 0, 0, 0.1) 100%
        ),
        url("../../images/paper_gray_mid_light.jpg") repeat,
        #aaa;
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.lightbox-content {
    position: relative;
    max-width: calc(90% - 3rem);
    width: calc(100% - 3rem);
    margin: 0 4rem;
    padding: 2rem;
    box-sizing: border-box;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: transparent;
}

#lightbox-image,
#lightbox-video {
    display: block;
    max-width: 100%;
    max-height: calc(90vh - 8rem);
    object-fit: contain;
    border-radius: var(--radius-sm);
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
}

#lightbox-media {
    display: flex;
    justify-content: center;
    align-items: center;
}

.lightbox-caption {
    text-align: center;
    padding: 10px 0 0 0;
    color: #666;
    max-width: 100%;
}

/* Buttons: gemeinsame Basis */
#lightbox-close,
#lightbox-prev,
#lightbox-next {
    background: transparent;
    border: 1.5px solid rgba(0, 0, 0, 0.6);
    border-radius: 50%;
    width: 3rem;
    height: 3rem;
    padding: 0;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.15);
    cursor: pointer;
    transition: all 0.1s ease;
    z-index: 1001;
    display: flex;
    justify-content: center;
    align-items: center;
}

#lightbox-close {
    position: fixed;
    top: 3rem;
    right: 20px;
}

#lightbox-prev,
#lightbox-next {
    position: fixed;
    top: 50%;
    margin-top: -1.5rem;
    text-align: center;
}

#lightbox-prev {
    left: 20px;
}

#lightbox-next {
    right: 20px;
}

.close-icon,
.nav-icon {
    width: 1.5rem;
    height: 1.5rem;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.2));
}

.close-icon path {
    stroke: rgba(0, 0, 0, 0.7);
    stroke-width: 2;
}

.nav-icon path {
    stroke: rgba(0, 0, 0, 0.6);
    stroke-width: 2;
}

#lightbox-close:hover,
#lightbox-prev:hover,
#lightbox-next:hover {
    background-color: rgba(255, 255, 255, 0.7);
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.2);
    transition: all 0.2s ease;
}

#lightbox-close:active,
#lightbox-prev:active,
#lightbox-next:active {
    transform: translateY(1px);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: all 0.1s ease;
}

/* Ein-/Ausblenden */
.lightbox.fade-in {
    display: flex;
    opacity: 0;
    animation: lightboxFadeIn 0.3s ease-in-out forwards;
}

.lightbox.fade-out {
    animation: lightboxFadeOut 0.3s ease-in-out forwards;
}

@keyframes lightboxFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes lightboxFadeOut {
    from { opacity: 1; }
    to { opacity: 0; display: none; }
}

/* Mobile: Buttons in Daumenreichweite, Bild mit Touch-Gesten */
@media (max-width: 480px) {
    .lightbox {
        justify-content: center;
        align-items: center;
    }

    .lightbox-content {
        position: relative;
        display: block;
        width: fit-content;
        max-width: calc(100% - 1rem);
        margin: 0 auto;
        padding: 0;
    }

    #lightbox-image {
        display: block;
        width: auto;
        max-width: calc(100% - 1rem);
        max-height: calc(80vh - 10rem);
        margin: 0 auto;
        vertical-align: top;
        touch-action: pan-x pinch-zoom;
        -webkit-user-select: none;
        -webkit-touch-callout: none;
    }

    #lightbox-prev,
    #lightbox-next {
        position: fixed;
        top: auto;
        bottom: 2rem;
        margin-top: 0;
        touch-action: none;
        -webkit-user-select: none;
        -webkit-touch-callout: none;
    }

    #lightbox-prev {
        left: 2rem;
    }

    #lightbox-next {
        right: 2rem;
    }

    #lightbox-close {
        right: 1.5rem;
        top: 1.5rem;
        touch-action: none;
        -webkit-user-select: none;
        -webkit-touch-callout: none;
    }

    .lightbox-caption {
        display: block;
        width: calc(100% - 1rem);
        margin: 0 auto;
        padding-top: 1rem;
        text-align: center;
        box-sizing: border-box;
    }
}
