/**
 * Image Lightbox CSS
 * Styles for the image lightbox/zoom functionality for article images
 */

/* Lightbox container */
.image-lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--color-overlay-dark);
    z-index: 9999;
    display: none;
    justify-content: center;
    align-items: center;
    padding: 20px;
    box-sizing: border-box; /* Ensure padding is included in width calculation */
    opacity: 0;
    transition: opacity 0.3s ease;
}

.image-lightbox.active {
    opacity: 1;
    display: flex;
}

/* Lightbox content */
.lightbox-content {
    position: relative;
    max-width: 90%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    animation: lightboxFadeIn 0.3s ease forwards;
    margin: 0 auto; /* Ensure centering */
}

@keyframes lightboxFadeIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Lightbox image */
.lightbox-image {
    max-width: 100%;
    max-height: 80vh;
    object-fit: contain;
    box-shadow: 0 5px 20px var(--color-shadow-medium);
    cursor: zoom-in;
    transition: transform 0.3s ease;
    opacity: 1;
    transition: opacity 0.3s ease;
}

/* Loading spinner for lightbox */
.lightbox-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 50px;
    height: 50px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: lightbox-spin 1s ease-in-out infinite;
    display: none;
}

@keyframes lightbox-spin {
    to { transform: translate(-50%, -50%) rotate(360deg); }
}

.lightbox-image.loading {
    opacity: 0.2;
}

.lightbox-loading.active {
    display: block;
}

/* Zoomed image */
.lightbox-image.zoomed {
    max-width: none;
    max-height: none;
    transform: scale(1.75);
    cursor: zoom-out;
}

/* Lightbox navigation buttons */
.lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 40px;
    height: 40px;
    background-color: rgba(0, 0, 0, 0.5);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #fff;
    font-size: 24px;
    z-index: 10;
    transition: background-color 0.2s ease;
}

.lightbox-nav:hover {
    background-color: rgba(0, 0, 0, 0.8);
}

.lightbox-prev {
    left: -50px;
}

.lightbox-next {
    right: -50px;
}

/* Close button */
.lightbox-close {
    position: absolute;
    top: -40px;
    right: 0;
    width: 40px;
    height: 40px;
    background-color: rgba(0, 0, 0, 0.7);
    border: 2px solid white;
    border-radius: 50%;
    color: white;
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.lightbox-close:hover {
    background-color: rgba(0, 0, 0, 0.9);
}

/* Caption area */
.lightbox-caption {
    color: white;
    padding: 15px 0;
    text-align: center;
    max-width: 800px;
    margin: 0 auto;
    font-size: 14px;
    line-height: 1.5;
}

/* Zoom cursors for article images */
.article-content img {
    cursor: zoom-in;
}

/* Dark mode adjustments */
.dark-mode .lightbox-content {
    /* Add a subtle border in dark mode for better visibility */
    box-shadow: 0 0 0 1px var(--color-border-light);
}

/* Screen reader only class */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .lightbox-content {
        max-width: 95%;
        max-height: 95vh;
    }
    
    .lightbox-image {
        max-height: 70vh; /* Smaller max-height on mobile */
    }
    
    .lightbox-caption {
        padding: 8px;
        font-size: 14px;
    }
    
    .lightbox-nav-button {
        width: 36px;
        height: 36px;
    }
}

/* Further adjustments for very small screens */
@media (max-width: 480px) {
    .image-lightbox {
        padding: 10px;
    }
    
    .lightbox-image {
        max-height: 60vh;
    }
    
    .lightbox-caption {
        font-size: 12px;
        padding: 6px;
    }
}

/* Image Lightbox Component */

.lightbox-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.lightbox-overlay.active {
    opacity: 1;
    visibility: visible;
}

.lightbox-container {
    position: relative;
    max-width: 90%;
    max-height: 90%;
    margin: auto;
    overflow: hidden;
}

.lightbox-image {
    max-width: 100%;
    max-height: 90vh;
    display: block;
    margin: 0 auto;
    transition: transform 0.3s ease;
    cursor: zoom-in;
}

.lightbox-image.zoomed {
    transform: scale(1.5);
    cursor: zoom-out;
}

.lightbox-caption {
    color: #fff;
    text-align: center;
    padding: 10px;
    font-size: 14px;
    max-width: 80%;
    margin: 10px auto 0;
}

.lightbox-close {
    position: absolute;
    top: 20px;
    right: 20px;
    color: #fff;
    font-size: 30px;
    cursor: pointer;
    background: rgba(0, 0, 0, 0.5);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.3s ease;
}

.lightbox-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Navigation buttons - circle style */
.lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 50px;
    height: 50px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 24px;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.lightbox-nav:hover {
    background: rgba(255, 255, 255, 0.2);
}

.lightbox-prev {
    left: 20px;
}

.lightbox-next {
    right: 20px;
}

/* Counter for images */
.lightbox-counter {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    color: #fff;
    font-size: 12px;
    background: rgba(0, 0, 0, 0.5);
    padding: 5px 10px;
    border-radius: 15px;
}

/* Loading spinner */
.lightbox-spinner {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top: 4px solid #fff;
    animation: spin 1s linear infinite;
    display: none;
}

@keyframes spin {
    0% { transform: translate(-50%, -50%) rotate(0deg); }
    100% { transform: translate(-50%, -50%) rotate(360deg); }
}

/* Make lightbox accessible */
.lightbox-overlay:focus {
    outline: none;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .lightbox-nav {
        width: 40px;
        height: 40px;
        font-size: 20px;
    }
    
    .lightbox-close {
        width: 35px;
        height: 35px;
        font-size: 24px;
    }
    
    .lightbox-prev {
        left: 10px;
    }
    
    .lightbox-next {
        right: 10px;
    }
} 