/**
 * Post Image Lightbox Styles
 * Provides styling for both dark and light themes
 * Responsive design for desktop and mobile devices
 */

/* ============================================================================
   LIGHTBOX CONTAINER
   Main container that holds the overlay and content
   ============================================================================ */
.pil-lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 999999;
    opacity: 0;
    transition: opacity 0.3s ease;
}

/* Show lightbox when active */
.pil-lightbox.pil-active {
    opacity: 1;
}

/* ============================================================================
   OVERLAY
   Semi-transparent background that covers the page
   Clicking this closes the lightbox
   ============================================================================ */
.pil-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
}

/* Dark theme overlay */
.pil-theme-dark .pil-overlay {
    background-color: rgba(0, 0, 0, 0.95);
}

/* Light theme overlay */
.pil-theme-light .pil-overlay {
    background-color: rgba(255, 255, 255, 0.95);
}

/* ============================================================================
   CONTENT CONTAINER
   Contains the image, navigation buttons, and close button
   ============================================================================ */
.pil-content {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
}

/* ============================================================================
   IMAGE CONTAINER
   Wrapper for the main image with size constraints
   ============================================================================ */
.pil-image-container {
    position: relative;
    max-width: 1000px;
    max-height: 90vh;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Main lightbox image */
.pil-image {
    max-width: 100%;
    max-height: 90vh;
    width: auto;
    height: auto;
    display: block;
    object-fit: contain;
    pointer-events: none;
    user-select: none;
}

/* ============================================================================
   CLOSE BUTTON
   X button in top-right corner to close the lightbox
   ============================================================================ */
.pil-close {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    border: none;
    background: transparent;
    font-size: 50px;
    line-height: 1;
    cursor: pointer;
    z-index: 1000;
    padding: 0;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

/* Close button hover effect */
.pil-close:hover {
    transform: scale(1.2);
    opacity: 0.8;
}

/* Dark theme close button */
.pil-theme-dark .pil-close {
    color: #ffffff;
}

/* Light theme close button */
.pil-theme-light .pil-close {
    color: #000000;
}

/* ============================================================================
   NAVIGATION BUTTONS (Previous/Next)
   Arrow buttons on left and right sides for desktop navigation
   Hidden on mobile devices
   ============================================================================ */
.pil-prev,
.pil-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 60px;
    height: 60px;
    border: none;
    background: transparent;
    font-size: 60px;
    line-height: 1;
    cursor: pointer;
    z-index: 1000;
    padding: 0;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

/* Previous button positioning */
.pil-prev {
    left: 20px;
}

/* Next button positioning */
.pil-next {
    right: 20px;
}

/* Navigation button hover effect */
.pil-prev:hover,
.pil-next:hover {
    transform: translateY(-50%) scale(1.2);
    opacity: 0.8;
}

/* Dark theme navigation buttons */
.pil-theme-dark .pil-prev,
.pil-theme-dark .pil-next {
    color: #ffffff;
}

/* Light theme navigation buttons */
.pil-theme-light .pil-prev,
.pil-theme-light .pil-next {
    color: #000000;
}

/* Hide navigation buttons when only one image */
.pil-lightbox[data-single-image="true"] .pil-prev,
.pil-lightbox[data-single-image="true"] .pil-next {
    display: none;
}

/* ============================================================================
   IMAGE COUNTER
   Displays current image number and total (e.g., "1 / 5")
   ============================================================================ */
.pil-counter {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    z-index: 1000;
    pointer-events: none;
}

/* Dark theme counter */
.pil-theme-dark .pil-counter {
    background-color: rgba(0, 0, 0, 0.7);
    color: #ffffff;
}

/* Light theme counter */
.pil-theme-light .pil-counter {
    background-color: rgba(255, 255, 255, 0.7);
    color: #000000;
}

/* Hide counter when only one image */
.pil-lightbox[data-single-image="true"] .pil-counter {
    display: none;
}

/* ============================================================================
   MOBILE RESPONSIVENESS
   Adjustments for mobile devices (768px and below)
   ============================================================================ */
@media screen and (max-width: 768px) {
    /* Full screen on mobile */
    .pil-content {
        padding: 0;
    }
    
    /* Full screen image container on mobile */
    .pil-image-container {
        max-width: 100%;
        max-height: 100vh;
        width: 100%;
        height: 100%;
    }
    
    /* Full screen image on mobile */
    .pil-image {
        max-width: 100vw;
        max-height: 100vh;
        width: 100%;
        height: 100%;
    }
    
    /* Hide navigation buttons on mobile (swipe gestures used instead) */
    .pil-prev,
    .pil-next {
        display: none;
    }
    
    /* Adjust close button position for mobile */
    .pil-close {
        top: 10px;
        right: 10px;
        width: 50px;
        height: 50px;
        font-size: 50px;
        background-color: rgba(0, 0, 0, 0.5);
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    /* Force white color for close button on mobile for visibility */
    .pil-close {
        color: #ffffff;
    }
    
    /* Adjust counter position for mobile */
    .pil-counter {
        bottom: 10px;
        font-size: 12px;
        padding: 6px 12px;
    }
}

/* ============================================================================
   LOADING STATE
   Optional: Add loading animation while image loads
   ============================================================================ */
.pil-image-container::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: pil-spin 0.8s linear infinite;
    opacity: 0;
    transition: opacity 0.3s ease;
}

/* Show loading animation when image is loading */
.pil-image-container.pil-loading::before {
    opacity: 1;
}

/* Spin animation for loader */
@keyframes pil-spin {
    to {
        transform: translate(-50%, -50%) rotate(360deg);
    }
}

/* Hide image while loading */
.pil-image-container.pil-loading .pil-image {
    opacity: 0;
}

/* ============================================================================
   ACCESSIBILITY
   Ensure focus states are visible for keyboard navigation
   ============================================================================ */
.pil-close:focus,
.pil-prev:focus,
.pil-next:focus {
    outline: 2px solid #4a9eff;
    outline-offset: 2px;
}

/* ============================================================================
   ANIMATIONS
   Smooth transitions for opening and closing
   ============================================================================ */
.pil-image {
    transition: opacity 0.3s ease;
}

/* Fade in animation for images */
.pil-image.pil-loaded {
    opacity: 1;
}