/* =======================================================
   LIGHTBOX.CSS
   -------------------------------------------------------
   - Overlay
   - Vollbildbildanzeige
   - Navigation
   - Controls
   - Position Info
   - Touch-Optimierungen
   - GRID CONTROL ARCHITECTURE (NEU)
   ======================================================= */


/* =======================================================
   LIGHTBOX OVERLAY
   ======================================================= */

#lightbox {
    position: fixed;
    inset: 0;

    height: 100vh;
    height: 100dvh;
    height: -webkit-fill-available;

    display: none;

    justify-content: center;
    align-items: center;

    background: var(--lightbox-bg);

    z-index: 999;
    touch-action: none;
}


/* =======================================================
   LIGHTBOX BILD
   ======================================================= */

#lightbox-img {
    max-width: 98vw;
    max-height: 95dvh;

    width: auto;
    height: auto;

    object-fit: contain;

    touch-action: pan-x;

    -webkit-user-select: none;
    -webkit-touch-callout: none;
    user-select: none;

    transition: opacity 0.25s ease;

    border-radius: 0;
}


/* =======================================================
   DYNAMISCHE BILDAUSRICHTUNG
   ======================================================= */

#lightbox-img.landscape {
    width: 98vw;
    height: auto;
}

#lightbox-img.portrait {
    width: auto;
    height: 95dvh;
    max-height: 95dvh;
}


/* =======================================================
   LIGHTBOX CONTROLS (BASIS)
   ======================================================= */

.control {
    position: absolute; 

    display: flex;
    align-items: center;
    justify-content: center;    

    background: var(--control-bg);
    color: var(--control-color);

    cursor: pointer;
    user-select: none;

    opacity: 0.6;

    transition:
        background 0.3s ease,
        transform 0.2s ease;

    /* =======================================================
       GRID CONTROL FIX (NEU)
       -------------------------------------------------------
       Ziel:
       - alle Controls nutzen identische Referenzbasis
       - verhindert optische „top drift“ Unterschiede
       - stabilisiert Box-Rendering zwischen Text & Icon
       ======================================================= */
    line-height: 0;
}

.control svg {
    width: 22px;
    height: 22px;

    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;

    display: block;
    margin: auto;
}

/* =======================================================
   NAVIGATION
   ======================================================= */

#prev {
    
    min-height: 35px;
    min-width: 35px;

    border-radius: 50%;

    left: 55px;
    top: 50%;
    transform: translateY(-50%);

    
}

#next {
    
    min-height: 35px;
    min-width: 35px;

    border-radius: 50%;
        
    right: 55px;
    top: 50%;

    transform: translateY(-50%);
}


/* =======================================================
   CLOSE BUTTON
   ======================================================= */

#close {
    /* gleiche Top-Basis wie Position-Info */
    top: calc(clamp(14px, 3vw, 34px) + env(safe-area-inset-top));
    right: clamp(14px, 4vw, 55px);
   
    
    width: 32px;
    height: 32px;
    padding: 0;

    border-radius: 50%;
    
    /* =======================================================
       FIX: optische Zentrierung des Icons
       ======================================================= */
    display: flex;
    align-items: center;
    justify-content: center;
}


/* =======================================================
   POSITION INFO
   ======================================================= */

#position-info {
    position: absolute;

    /* gleiche Top-Basis wie Close Button */
    top: calc(clamp(14px, 3vw, 34px) + env(safe-area-inset-top));
    left: clamp(14px, 4vw, 55px);

    min-height: 28px;
        
    padding: 3px 6px;

    border-radius: 6px;
    
    display: flex;
    align-items: center;
    justify-content: flex-end;

    font-size: 1rem;
    font-family: 'Inter', sans-serif;
    
    font-variant-numeric: tabular-nums;

    background: var(--control-bg);
    color: var(--control-color);
}

#position-info .current {
    font-weight: bold;
}

#position-info .total {
    font-weight: normal;
}


/* =======================================================
   LIGHTBOX BODY LOCK
   ======================================================= */

body.lightbox-open {
    overflow: hidden !important;
}

body.lightbox-open main {
    overflow: hidden !important;
}

body.lightbox-open::-webkit-scrollbar {
    display: none;
}


/* =======================================================
   HOVER (NUR DESKTOP)
   ======================================================= */

@media (hover: hover) {

    .control:hover {
        color: var(--control-hover-color);
        opacity: 1;
        transform: scale(1.05);
    }
}


/* =======================================================
   TOUCH ACTIVE STATE
   ======================================================= */

.control:active {
    opacity: 0.6 !important;
    transform: scale(1);
}


/* =======================================================
   RESPONSIVE / TOUCH
   ======================================================= */

@media (hover: none) and (pointer: coarse) {

    #prev,
    #next {
        display: none;
    }
}


/* Kleine Displays */
@media (max-width: 600px) {

    .control {
        width: 32px;
        height: 32px;
    }
    #position-info {
        left: 8px;
    }
}


/* Landscape auf mobilen Geräten */
@media (max-width: 900px) and (orientation: landscape) {

    #lightbox {
        height: 100dvh;
    }
    #position-info {
        left: 8px;
    }
}

/* Landscape auf mobilen Geräten */
@media (max-width: 900px) and (orientation: portrait) {

    #position-info {
        top: 30px;
    }
    #close {top: 30px;
    }
}
