/* Theatre Gallery Lightbox - #359 section 3 (show Photos viewer) - Version 2.0 */

/* Seating plan thumbnail (theatre-gallery-grid) */
.theatre-gallery-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem;
}

.theatre-gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

/* No fixed aspect-ratio: the plan keeps its own shape (#359 no-crop rule). */
.gallery-thumbnail {
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.gallery-thumbnail:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.gallery-thumbnail img {
    display: block;
    width: 100%;
    height: auto;
    object-fit: contain;
    background: var(--htt-sand);
    transition: transform 0.3s ease;
}

.gallery-thumbnail:hover img {
    transform: scale(1.05);
}

/* Viewer: full screen, dark, one photo at a time */
.theatre-lightbox {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: none;
    background: #000;
    opacity: 0;
    transition: opacity 0.3s ease;
}

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

.lightbox-content {
    position: relative;
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    min-height: 0;
    color: #fff;
}

/*
 * issue 354: class-name collision guard. public/css/show-tab-about.css (loaded
 * on every show page) still carries an old About-tab lightbox that uses the
 * same class names as this viewer: .lightbox-content, .lightbox-close,
 * .lightbox-image-container, .lightbox-image and .lightbox-caption. Its rules
 * are the same specificity as the ones below, so whichever loaded last won, and
 * its `align-items: center` shrank .lightbox-stage to 0px wide (all its children
 * are absolutely positioned), leaving a black stage with no photo. Every
 * colliding property is reset here under .theatre-lightbox, which outranks a
 * bare class selector regardless of load order.
 */
.theatre-lightbox .lightbox-content {
    align-items: stretch;
    justify-content: flex-start;
    padding: 0;
    animation: none;
}

.theatre-lightbox .lightbox-stage {
    width: 100%;
    align-self: stretch;
}

.theatre-lightbox .lightbox-image-container {
    display: block;
    max-width: none;
    max-height: none;
}

.theatre-lightbox .lightbox-image {
    max-width: none;
    max-height: none;
    border-radius: 0;
    box-shadow: none;
}

.theatre-lightbox .lightbox-close {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    z-index: 20;
}

.theatre-lightbox .lightbox-close:hover {
    background: #fff;
    transform: scale(1.1);
}

.theatre-lightbox .lightbox-caption {
    margin-top: 0;
    font-size: 1rem;
    font-weight: 400;
}

/* The stage holds the photo, its blurred frame and the controls. */
.lightbox-stage {
    position: relative;
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
}

/* Blurred, darkened copy of the same photo behind it (#359 rule 6). Decorative. */
.lightbox-backdrop {
    position: absolute;
    inset: -2rem;
    background-size: cover;
    background-position: center;
    filter: blur(28px) brightness(0.45);
    transform: scale(1.05);
    z-index: 0;
}

.lightbox-image-container {
    position: absolute;
    inset: 0;
    z-index: 1;
}

/* The photo sits in a frame inside the stage. object-fit: contain, never cropped. */
.lightbox-image {
    position: absolute;
    top: 3.5rem;
    bottom: 1rem;
    left: 3.5rem;
    right: 3.5rem;
    width: calc(100% - 7rem);
    height: calc(100% - 4.5rem);
    object-fit: contain;
    display: block;
    transform-origin: center center;
    transition: transform 0.3s ease;
    cursor: grab;
}

.lightbox-image.zoomed {
    cursor: grabbing;
}

.lightbox-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #fff;
    font-size: 1.125rem;
    text-align: center;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top: 3px solid #fff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

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

/* Caption and credit under the photo */
.lightbox-caption {
    padding: 0.75rem 1.25rem 0.5rem;
    text-align: center;
    background: #000;
}

.lightbox-caption[hidden],
.lightbox-caption [hidden] {
    display: none;
}

.lightbox-caption .caption-text {
    margin: 0;
    font-size: 1rem;
    line-height: 1.5;
    color: #fff;
}

.lightbox-caption .credit-text {
    margin: 0.25rem 0 0;
    font-size: 0.8125rem;
    line-height: 1.4;
    color: rgba(255, 255, 255, 0.75);
}

/* Thumbnail row: desktop only */
.lightbox-thumbs {
    display: none;
    gap: 0.5rem;
    justify-content: center;
    padding: 0.5rem 1.25rem 1rem;
    overflow-x: auto;
    background: #000;
}

.lightbox-thumbs[hidden] {
    display: none !important;
}

.lightbox-thumb {
    flex: 0 0 auto;
    width: 72px;
    height: 54px;
    padding: 0;
    border: 2px solid transparent;
    border-radius: 4px;
    overflow: hidden;
    background: #111;
    cursor: pointer;
    opacity: 0.55;
    transition: opacity 0.2s ease, border-color 0.2s ease;
}

.lightbox-thumb img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.lightbox-thumb:hover,
.lightbox-thumb.is-current {
    opacity: 1;
}

.lightbox-thumb.is-current {
    border-color: #fff;
}

.lightbox-thumb:focus-visible {
    outline: 2px solid var(--htt-accent, #fff);
    outline-offset: 2px;
}

@media (min-width: 768px) {
    .lightbox-thumbs {
        display: flex;
    }
}

/* Navigation Controls */
.lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 50px;
    height: 50px;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    z-index: 10;
}

.lightbox-nav:hover {
    background: #fff;
    transform: translateY(-50%) scale(1.1);
}

.lightbox-nav-prev {
    left: 1rem;
}

.lightbox-nav-next {
    right: 1rem;
}

.lightbox-nav svg {
    width: 24px;
    height: 24px;
    color: #333;
}

/* Close Button */
.lightbox-close {
    position: absolute;
    top: 0.75rem;
    right: 1rem;
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    z-index: 20;
}

.lightbox-close:hover {
    background: #fff;
    transform: scale(1.1);
}

.lightbox-close svg {
    width: 20px;
    height: 20px;
    color: #333;
}

/* Zoom Controls */
.lightbox-zoom-controls {
    position: absolute;
    bottom: 1rem;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 0.5rem;
    z-index: 10;
}

.zoom-btn {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.zoom-btn:hover {
    background: #fff;
    transform: scale(1.05);
}

.zoom-btn svg {
    width: 18px;
    height: 18px;
    color: #333;
}

/* Progress Indicator ("3 of 8") */
.lightbox-progress {
    position: absolute;
    top: 0.75rem;
    left: 50%;
    transform: translateX(-50%);
    color: #fff;
    background: rgba(0, 0, 0, 0.6);
    padding: 0.375rem 0.875rem;
    border-radius: 20px;
    font-size: 0.875rem;
    white-space: nowrap;
    z-index: 20;
}

/* Mobile Responsive */
@media (max-width: 767px) {
    /* issue 354: show-tab-about.css sets .lightbox-content padding: 1rem here. */
    .theatre-lightbox .lightbox-content {
        padding: 0;
    }

    .theatre-lightbox .lightbox-close {
        top: 0.5rem;
        right: 0.5rem;
    }

    .theatre-gallery-grid {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
        gap: 0.75rem;
    }

    .lightbox-image {
        top: 3rem;
        bottom: 0.5rem;
        left: 0.5rem;
        right: 0.5rem;
        width: calc(100% - 1rem);
        height: calc(100% - 3.5rem);
    }

    .lightbox-nav {
        width: 44px;
        height: 44px;
    }

    .lightbox-nav-prev {
        left: 0.5rem;
    }

    .lightbox-nav-next {
        right: 0.5rem;
    }

    .lightbox-close {
        top: 0.5rem;
        right: 0.5rem;
    }

    .lightbox-zoom-controls {
        bottom: 0.5rem;
    }
}

/* Accessibility */
.lightbox-nav:focus,
.lightbox-close:focus,
.zoom-btn:focus {
    outline: 2px solid var(--htt-accent, #fff);
    outline-offset: 2px;
}

.gallery-thumbnail:focus {
    outline: 2px solid var(--htt-accent);
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .lightbox-nav,
    .lightbox-close,
    .zoom-btn {
        background: #fff;
        border: 2px solid #000;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .gallery-thumbnail,
    .gallery-thumbnail img,
    .theatre-lightbox,
    .lightbox-image,
    .lightbox-nav,
    .lightbox-close,
    .zoom-btn,
    .lightbox-thumb {
        transition: none;
    }

    .loading-spinner {
        animation: none;
    }
}
