/**
 * Figure Gallery Styles (Arrow-based Image Viewer)
 * WCAG 2.1 AA compliant
 * Uses design system variables from theme-consolidated.css
 */

/* Gallery container */
.figure-gallery {
    margin: 2rem auto;
    max-width: 100%;
    background: var(--bg-secondary);
    border-radius: 8px;
    overflow: hidden;
    position: relative;
    padding: 1.5rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    /* Fix sub-pixel rendering artifacts at rounded corners */
    transform: translateZ(0);
    backface-visibility: hidden;
}

/* Main image viewer */
.figure-gallery-main {
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    padding: 1rem;
    border-radius: 4px;
    margin-bottom: 0.5rem;
    /* Fix sub-pixel rendering artifacts at rounded corners */
    transform: translateZ(0);
    backface-visibility: hidden;
}

.figure-gallery-main img {
    max-width: 100%;
    max-height: 500px;
    height: auto;
    width: auto;
    object-fit: contain;
    border-radius: 4px;
}

/* Caption block */
.figure-gallery-caption {
    padding: 0.5rem 0 0;
    color: var(--text-secondary);
}

.figure-gallery-caption .figure-number {
    font-weight: 600;
    color: var(--text-primary);
    margin-right: 0.25rem;
}

.figure-gallery-caption .figure-caption {
    display: inline;
    color: var(--text-secondary);
}

.figure-gallery-caption .figure-caption p {
    display: inline;
    margin: 0;
    padding: 0;
    color: var(--text-secondary) !important;
}

.figure-gallery-caption .figure-caption p + p {
    display: block;
    margin-top: 0.5rem;
}

/* Ensure all nested elements inherit the caption color */
.figure-gallery-caption .figure-caption * {
    color: inherit !important;
}

.figure-gallery-caption .figure-credit {
    display: block;
    margin-top: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-muted);
    font-style: italic;
}

/* Navigation arrows */
.figure-gallery-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%) translateZ(0);
    width: 48px;
    height: 48px;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid var(--border-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0.8;
    transition: all 0.2s ease;
    z-index: 10;
    color: var(--text-primary);
    /* Fix sub-pixel rendering artifacts at rounded corners */
    backface-visibility: hidden;
}

.figure-gallery-nav:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.figure-gallery-nav:focus {
    opacity: 1;
    outline: 3px solid var(--ucb-gold);
    outline-offset: 2px;
}

.figure-gallery-nav-prev {
    left: 1rem;
}

.figure-gallery-nav-next {
    right: 1rem;
}

/* Dark mode styles */
[data-theme="dark"] .figure-gallery {
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .figure-gallery-nav {
    background: rgba(42, 42, 42, 0.9);
    border-color: var(--border-color);
    color: var(--text-primary);
}

[data-theme="dark"] .figure-gallery-nav:hover {
    background: rgba(42, 42, 42, 1);
}

/* Hidden by default - shown via JS */
.figure-gallery-item {
    display: none;
}

.figure-gallery-item.active {
    display: block;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .figure-gallery-main {
        padding: 1rem;
    }

    .figure-gallery-main img {
        max-height: 400px;
    }

    .figure-gallery-caption {
        padding: 0.75rem 1rem 0;
        font-size: 0.85rem;
    }

    .figure-gallery-nav {
        width: 40px;
        height: 40px;
    }

    .figure-gallery-nav-prev {
        left: 0.5rem;
    }

    .figure-gallery-nav-next {
        right: 0.5rem;
    }
}

/* Print styles */
@media print {
    .figure-gallery-nav {
        display: none !important;
    }

    .figure-gallery-item {
        display: block !important;
        page-break-inside: avoid;
        margin-bottom: 1rem;
    }

    .figure-gallery-main img {
        max-height: none;
    }
}
