/* 1. Locks the background page so it cannot scroll or zoom */
body.salpz-open {
    overflow: hidden !important;
    touch-action: none !important; 
}

/* 2. The dark overlay background */
#salpz-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 999999;
    opacity: 0;
    transition: opacity 0.3s ease;
    touch-action: none; 
    
    /* CRITICAL FIX: Ensures the invisible overlay never blocks clicks on your page */
    pointer-events: none; 
}

/* 3. When the lightbox is open and visible */
#salpz-overlay.salpz-visible {
    opacity: 1;
    /* Turns clicks back on so you can interact with the zoomed image and close button */
    pointer-events: auto; 
}

/* --- NEW: The Virtual Filmstrip Slides --- */
.salpz-slide {
    position: absolute; 
    top: 0; 
    left: 0; 
    width: 100vw; 
    height: 100vh;
    display: flex; 
    justify-content: center; 
    align-items: center;
    will-change: transform;
    overflow: hidden; /* <--- THIS IS THE MAGIC FIX for magnification of adjacent images*/
}

/* 4. The zoomed image inside the lightbox slides */
.salpz-slide img {
    max-width: 90%;
    max-height: 90%;
    transform-origin: center center;
    /* Only transition transform for zoom snapping. Sliding is handled by the parent slide */
    transition: transform 0.05s ease-out; 
    cursor: grab;
    
    /* Prevents the annoying blue highlight when dragging/tapping */
    user-select: none; 
    -webkit-user-drag: none; 
}

/* 5. The highly visible Close Button */
#salpz-overlay .salpz-close {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 40px;
    height: 40px;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    font-size: 30px;
    line-height: 40px;
    text-align: center;
    border-radius: 50%;
    font-weight: bold;
    cursor: pointer;
    z-index: 1000001;
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
}

/* 6. Removes the native blue tap flash on mobile devices when you click an image */
img {
    -webkit-tap-highlight-color: transparent; 
}

/* --- Image Counter (e.g., "1 of 5") --- */
.salpz-counter {
    position: absolute; 
    top: 25px; 
    left: 50%; 
    transform: translateX(-50%);
    color: white; 
    font-size: 14px; 
    font-family: sans-serif; 
    letter-spacing: 1px;
    background: rgba(0, 0, 0, 0.6); 
    padding: 5px 15px; 
    border-radius: 20px; 
    z-index: 1000001;
}

/* --- Controls Wrapper (Slider + 1:1 Reset Button) --- */
.salpz-controls-wrapper {
    position: fixed; 
    bottom: 30px; 
    left: 50%; 
    transform: translateX(-50%);
    display: flex; 
    align-items: center; 
    gap: 15px; 
    background: rgba(0, 0, 0, 0.6);
    padding: 10px 20px; 
    border-radius: 30px; 
    z-index: 1000001;
    box-shadow: 0 4px 15px rgba(0,0,0,0.4);
}

.salpz-zoom-slider { 
    width: 150px; 
    margin: 0;
    cursor: pointer; 
    /* Optional: custom accent color for modern browsers */
    accent-color: #ffffff; 
}

.salpz-reset-btn {
    background: transparent; 
    border: 1px solid rgba(255,255,255,0.5);
    color: white; 
    border-radius: 5px; 
    padding: 4px 10px; 
    cursor: pointer;
    font-size: 13px; 
    font-weight: bold; 
    transition: background 0.2s;
}

.salpz-reset-btn:hover { 
    background: rgba(255,255,255,0.2); 
}

/* --- Scrollable Caption Box --- */
.salpz-caption {
    position: fixed;
    bottom: 90px; /* Sits nicely right above the slider */
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 600px;
    max-height: 120px; /* Limits the height so it doesn't cover the whole image */
    overflow-y: auto; /* Makes it scrollable! */
    background: rgba(0, 0, 0, 0.75);
    color: #ffffff;
    padding: 12px 20px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.5;
    text-align: center;
    z-index: 1000000;
    pointer-events: auto; /* Allows the user to click and scroll the text */
    display: none; /* Hidden by default if there is no caption */
    box-shadow: 0 4px 15px rgba(0,0,0,0.4);
}

/* Custom Scrollbar for the caption so it looks elegant */
.salpz-caption::-webkit-scrollbar { width: 6px; }
.salpz-caption::-webkit-scrollbar-track { background: transparent; }
.salpz-caption::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.5); border-radius: 3px; }

/* --- Next & Previous Arrows --- */
.salpz-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    color: white;
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
    padding: 15px;
    user-select: none;
    z-index: 1000001;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 5px;
    transition: background 0.3s;
}
.salpz-nav:hover {
    background: rgba(0, 0, 0, 0.8);
}
.salpz-prev { left: 15px; }
.salpz-next { right: 15px; }

/* Hide arrows on very small screens to avoid clutter, allowing swipe to take over */
/* --- Mobile Adjustments --- */
@media (max-width: 600px) {
    /* Bring back the arrows, make them small, and put them at the top! */
    .salpz-nav { 
        display: block !important; 
        top: 20px; 
        transform: none; /* Removes the vertical centering */
        font-size: 16px; 
        padding: 6px 14px; 
        border-radius: 20px;
        background: rgba(0, 0, 0, 0.6);
    }
    
    /* Position them neatly alongside the counter and close button */
    .salpz-prev { left: 15px; }
    .salpz-next { right: 75px; /* Sits just to the left of the close button */ }
    
    /* Adjust caption to fit above mobile browser bars */
    .salpz-caption { bottom: 75px; font-size: 13px; }
}