/* ==========================================================================
   Accessible LightBox - CSS Styles
   ========================================================================== */

/* Container Grid Layout */
.accessibleLightBox {
    display: grid;
    gap: 1rem;
    /* Mobile first: 1 column */
    grid-template-columns: 1fr;
}

/* Tablet: 2 columns */
@media (min-width: 768px) {
    .accessibleLightBox {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Desktop: alternating 2-3 pattern using subgrid fallback */
@media (min-width: 992px) {
    .accessibleLightBox {
        grid-template-columns: repeat(6, 1fr);
    }

    .accessibleLightBox .item {
        grid-column: span 3; /* Default: 2 per row (6/3 = 2) */
    }

    /* Pattern: 2, 3, 2, 3... */
    /* Row 1 (items 1-2): 2 per row */
    .accessibleLightBox .item:nth-child(5n + 1),
    .accessibleLightBox .item:nth-child(5n + 2) {
        grid-column: span 3;
    }

    /* Row 2 (items 3-5): 3 per row */
    .accessibleLightBox .item:nth-child(5n + 3),
    .accessibleLightBox .item:nth-child(5n + 4),
    .accessibleLightBox .item:nth-child(5n + 5) {
        grid-column: span 2;
    }
}

/* Item Styles */
.accessibleLightBox .item {
    position: relative;
    overflow: hidden;
    border-radius: 0.25rem;
    aspect-ratio: 5/4;
}

.accessibleLightBox .item picture {
    display: block;
    width: 100%;
    height: 100%;
}

.accessibleLightBox .item picture:focus-within{
    padding: 10px!important;
    background: transparent!important;
    border: 2px solid var(--etg-primary)!important;
}

.accessibleLightBox .item picture:focus-within img:focus-visible {
    outline: none!important;
    box-shadow: none!important;
}

.accessibleLightBox .item img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    cursor: zoom-in;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.accessibleLightBox .item img:hover,
.accessibleLightBox .item img:focus {
    transform: scale(1.02);
    opacity: 0.9;
}

/* Make images focusable for keyboard navigation */
.accessibleLightBox .item img[tabindex] {
/*
    outline-offset: 2px;

 */
}

.accessibleLightBox .item img[tabindex]:focus-visible {
    /*
        outline: 3px solid #0d6efd;
        outline-offset: 2px;

     */
}



/* ==========================================================================
   Lightbox Overlay
   ========================================================================== */

.accessibleLightBox-overlay {
    position: fixed;
    inset: 0;
    z-index: 10500;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: rgba(0, 0, 0, 0.92);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.accessibleLightBox-overlay.is-open {
    opacity: 1;
    visibility: visible;
}

.accessibleLightBox-overlay.is-open .accessibleLightBox-content {
    transform: scale(1);
}

/* ==========================================================================
   Lightbox Content
   ========================================================================== */

.accessibleLightBox-content {
    position: relative;
    display: flex;
    flex-direction: column-reverse;
    align-items: center;
    justify-content: center;
    max-width: 90vw;
    max-height: 90vh;
    transform: scale(0.95);
    transition: transform 0.3s ease;
    /* Enable horizontal swipe, prevent vertical scroll */
    touch-action: pan-y pinch-zoom;
    user-select: none;
    -webkit-user-select: none;
    cursor: grab;
}

.accessibleLightBox-content:active {
    cursor: grabbing;
}

.accessibleLightBox-image-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    max-width: 100%;
    max-height: calc(90vh - 4rem);
}

.accessibleLightBox-image {
    display: block;
    max-width: 100%;
    max-height: calc(90vh - 4rem);
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 0.25rem;
    /* Prevent image drag on swipe */
    pointer-events: none;
    -webkit-user-drag: none;
}

/* Caption / Alt Text */
.accessibleLightBox-caption {
    margin-top: 1rem;
    margin-top: -4rem;
    padding: 0.75rem 1.5rem;
    max-width: 100%;
    color: #fff;
    font-size: 1rem;
    text-align: center;
    background-color: rgba(0, 0, 0, 0.6);
    border-radius: 0.25rem;
}

/* ==========================================================================
   Navigation Buttons
   ========================================================================== */

.accessibleLightBox-btn {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 3rem;
    height: 3rem;
    padding: 0;
    border: 2px solid transparent;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.15);
    color: #fff;
    font-size: 1.5rem;
    cursor: pointer;
    transition: background-color 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.accessibleLightBox-btn:hover {
    background-color: rgba(255, 255, 255, 0.3);
}

.accessibleLightBox-btn:focus {
    outline: none;
    border-color: #0d6efd;
    box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.5);
}

.accessibleLightBox-btn:focus-visible {
    outline: none;
    border-color: #0d6efd;
    box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.5);
}

.accessibleLightBox-btn:active {
    transform: scale(0.95);
}

/* Close Button */
.accessibleLightBox-close {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 1051;
}

/* Previous Button */
.accessibleLightBox-prev {
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
}

.accessibleLightBox-prev:active {
    transform: translateY(-50%) scale(0.95);
}

/* Next Button */
.accessibleLightBox-next {
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
}

.accessibleLightBox-next:active {
    transform: translateY(-50%) scale(0.95);
}

/* Button Icons (SVG) */
.accessibleLightBox-btn svg {
    width: 1.5rem;
    height: 1.5rem;
    fill: currentColor;
}

/* ==========================================================================
   Responsive Adjustments
   ========================================================================== */

@media (max-width: 767.98px) {
    .accessibleLightBox-btn {
        width: 2.5rem;
        height: 2.5rem;
        font-size: 1.25rem;
    }

    .accessibleLightBox-btn svg {
        width: 1.25rem;
        height: 1.25rem;
    }

    .accessibleLightBox-prev {
        left: 0.5rem;
    }

    .accessibleLightBox-next {
        right: 0.5rem;
    }

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

    .accessibleLightBox-caption {
        font-size: 0.875rem;
        padding: 0.5rem 1rem;
    }
}

/* ==========================================================================
   Screen Reader Only (Visually Hidden)
   ========================================================================== */

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

/* ==========================================================================
   Reduced Motion
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
    .accessibleLightBox .item img,
    .accessibleLightBox-overlay,
    .accessibleLightBox-content,
    .accessibleLightBox-btn {
        transition: none;
    }
}

/* ==========================================================================
   High Contrast Mode Support
   ========================================================================== */

@media (forced-colors: active) {
    .accessibleLightBox-btn {
        border: 2px solid currentColor;
    }

    .accessibleLightBox .item img:focus-visible {
        outline: 3px solid currentColor;
    }
}
