/* Clickable Figure Styling */
.clickable-figure {
    position: relative;
    overflow: visible;
}

.clickable-figure img {
    cursor: zoom-in;
    transition: filter 0.2s ease;
}

.clickable-figure:hover img {
    filter: brightness(1.05);
}

/* Zoom indicator */
.zoom-indicator {
    position: absolute;
    top: 10px;
    right: 10px;
    background-color: rgba(0, 0, 0, 0.6);
    color: white;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transform: translateY(-5px);
    transition: all 0.2s ease;
    pointer-events: none;
    z-index: 5;
}

.clickable-figure:hover .zoom-indicator {
    opacity: 1;
    transform: translateY(0);
}

/* Lightbox styling - WITH SEMI-TRANSPARENT BACKGROUND */
.clickable-figure-lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.75); /* MORE TRANSPARENT BACKGROUND */
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    opacity: 0;
}

/* When active, show immediately without transition */
.clickable-figure-lightbox.active {
    opacity: 1;
}

/* Theme support for lightbox */
.clickable-figure-lightbox[data-theme="dark"] {
    background-color: rgba(0, 0, 0, 1); /* MORE TRANSPARENT FOR DARK MODE */
}

.clickable-figure-lightbox[data-theme="light"] {
    background-color: rgba(0, 0, 0, 0.7); /* MORE TRANSPARENT FOR LIGHT MODE */
}

.lightbox-image-container {
    position: relative;
    max-width: 90%;
    max-height: 80vh;
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 0 auto;
}

.lightbox-image-container img {
    max-width: 100%;
    max-height: 80vh;
    object-fit: contain;
    display: block;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.3);
    background-color: white;
    padding: 5px;
    border-radius: 4px;
}

[data-mode="dark"] .lightbox-image-container img {
    background-color: white !important;
}

[data-mode="auto"] .lightbox-image-container img {
    background-color: white !important;
}


/* Adaptive image support for light/dark mode */
.lightbox-image-container img.adaptive-figure {
    transition: filter 0.3s ease, background-color 0.3s ease;
}

.clickable-figure-lightbox[data-theme="dark"] .lightbox-image-container img.adaptive-figure {
    background-color: #333;
    filter: brightness(0.85);
}

/* IMPROVED CLOSE BUTTON */
.lightbox-close {
    position: absolute;
    top: 20px;
    right: 30px;
    background: transparent;
    border: none;
    color: white;
    font-size: 40px;
    cursor: pointer;
    z-index: 10001;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border-radius: 50%;
    background-color: rgba(0, 0, 0, 0.3); /* Slightly visible background */
}

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

.lightbox-caption {
    color: white;
    max-width: 80%;
    margin: 20px auto 0;
    padding: 10px 20px;
    text-align: center;
    background-color: rgba(0, 0, 0, 0.5);
    border-radius: 4px;
    font-style: italic;
}

/* Theme support for captions */
.clickable-figure-lightbox[data-theme="dark"] .lightbox-caption {
    background-color: rgba(50, 50, 50, 0.8);
}

/* Math styling in lightbox */
.lightbox-caption .katex {
    color: white;
    font-size: 1.1em;
}

.lightbox-caption .katex-display {
    margin: 0.5em 0;
}

.lightbox-caption .katex-html {
    color: white;
}

/* Dark mode support for zoom indicator */
@media (prefers-color-scheme: dark) {
    [data-mode="auto"] .zoom-indicator {
        background-color: rgba(255, 255, 255, 0.2);
    }
    
    [data-mode="auto"] .adaptive-figure {
        filter: brightness(0.9);
    }
}

[data-mode="dark"] .zoom-indicator {
    background-color: rgba(255, 255, 255, 0.2);
}

[data-mode="dark"] .adaptive-figure {
    filter: brightness(0.9);
}