/* Lightbox / Modal Overlay */
.lightbox-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.lightbox-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.lightbox-content {
    position: relative;
    max-width: 95vw;
    max-height: 95vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
}

.lightbox-image-wrapper {
    display: grid;
    place-items: center;
    width: 100%;
    /* Ensure the wrapper doesn't grow beyond viewport expectations if images are huge */
    max-height: 90vh;
}

.lightbox-image {
    grid-area: 1 / 1;
    max-width: 100%;
    max-height: 90vh;
    object-fit: contain;
    box-shadow: 0 5px 25px rgba(0, 0, 0, 0.5);
    user-select: none;
    transition: opacity 0.5s ease;
    opacity: 0;
    z-index: 1;
}

.lightbox-image.active {
    opacity: 1;
    z-index: 2;
}

.lightbox-info {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1010;
    color: #fff;
    text-align: center;
    max-width: 60%;
    pointer-events: none;
}

/* Background for readability */
.lightbox-title,
.lightbox-date {
    background-color: transparent;
    padding: 0;
    border-radius: 0;
    pointer-events: auto;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
    /* Add drop shadow for readability instead */
}

.lightbox-title {
    display: inline-block;
    font-size: 1.2rem;
    font-weight: 300;
    letter-spacing: 0.05em;
    margin-bottom: 4px;
    line-height: 1.2;
}

.lightbox-date {
    display: inline-block;
    font-size: 0.9rem;
    color: #ddd;
    margin-top: 0;
    line-height: 1.2;
}

.lightbox-controls {
    position: absolute;
    top: 20px;
    right: 20px;
    display: flex;
    align-items: center;
    gap: 5px;
    /* Spacing between buttons */
    z-index: 1010;
    opacity: 1;
    transition: opacity 0.2s;
}

.lightbox-close {
    position: relative;
    top: auto;
    right: auto;
    color: #fff;
    font-size: 2rem;
    cursor: pointer;
    background: transparent;
    border: none;
    padding: 0;
    /* Remove padding as we use flex centering */
    line-height: 1;
    opacity: 0.7;
    transition: opacity 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    /* Match play button */
    height: 48px;
}

.lightbox-close:hover {
    opacity: 1;
}

.lightbox-fullscreen {
    position: relative;
    top: auto;
    right: auto;
    color: #fff;
    font-size: 1.5rem;
    cursor: pointer;
    background: transparent;
    border: none;
    padding: 0;
    line-height: 1;
    opacity: 0.7;
    transition: opacity 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
}

.lightbox-fullscreen:hover {
    opacity: 1;
}

/* 
   We removed the media query for individual button positioning 
   since flexbox handles the layout now.
*/

.lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    color: #fff;
    font-size: 2rem;
    cursor: pointer;
    padding: 20px;
    z-index: 1010;
    opacity: 0.6;
    transition: opacity 0.2s, background-color 0.2s;
    background-color: rgba(0, 0, 0, 0);
    border: none;
    border-radius: 50%;
}

.lightbox-nav:hover {
    opacity: 1;
    background-color: rgba(255, 255, 255, 0.1);
}

.lightbox-prev {
    left: 20px;
}

.lightbox-next {
    right: 20px;
}

@media (max-width: 768px) {
    .lightbox-nav {
        font-size: 1.5rem;
        padding: 15px;
    }

    .lightbox-prev {
        left: 10px;
    }

    .lightbox-next {
        right: 10px;
    }

    .lightbox-image {
        max-height: 80vh;
    }
}

.lightbox-play-pause {
    position: relative;
    top: auto;
    right: auto;
    left: auto;
    bottom: auto;
    transform: none;
    color: #fff;
    font-size: 1.5rem;
    cursor: pointer;
    background: transparent;
    border: none;
    padding: 0;
    width: 48px;
    height: 48px;
    display: flex;
    justify-content: center;
    align-items: center;
    line-height: 1;
    opacity: 0.9;
    transition: opacity 0.2s, background-color 0.2s;
    border-radius: 50%;
}

.lightbox-play-pause i {
    position: relative;
    z-index: 2;
    /* Optical adjustment for play triangle */
    margin-left: 2px;
}

.lightbox-play-pause i.fa-pause {
    margin-left: 0;
}

.progress-ring {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1;
    transform: rotate(-90deg);
}

.progress-ring__circle {
    stroke-dasharray: 132;
    stroke-dashoffset: 132;
    transition: stroke-dashoffset 0.1s;
}

.lightbox-play-pause.playing .progress-ring__circle {
    /* 3s matches the JS interval */
    animation: progress-fill 3s linear infinite;
}

@keyframes progress-fill {
    from {
        stroke-dashoffset: 132;
    }

    to {
        stroke-dashoffset: 0;
    }
}

/* User Idle State - Fade out controls */
/* Specificity needs to be high to override default and hover states */

/* Hide cursor on the overlay itself */
.lightbox-overlay.active.user-idle {
    cursor: none;
}

.lightbox-overlay.active.user-idle .lightbox-controls,
.lightbox-overlay.active.user-idle .lightbox-nav {
    opacity: 0 !important;
    pointer-events: none !important;
    transition: opacity 0.5s ease;
}

.lightbox-play-pause:hover {
    opacity: 1;
    background-color: rgba(255, 255, 255, 0.1);
}

@media (max-width: 768px) {

    /* Adjust controls container for mobile */
    .lightbox-controls {
        top: auto;
        /* Remove top positioning */
        bottom: 30px;
        /* Stick to bottom */
        right: 50%;
        /* Center horizontally */
        transform: translateX(50%);
        /* Offset for true center */
        gap: 15px;
        /* Keep spacing */
        background-color: rgba(0, 0, 0, 0.5);
        /* Optional: distinct background for better visibility */
        border-radius: 30px;
        padding: 5px 15px;
    }

    .lightbox-image-wrapper {
        /* Reduce max-height to make room for controls at bottom and text at top */
        max-height: 75vh;
    }

    .lightbox-image {
        max-height: 75vh;
    }
}

/* Mobile Landscape Fix to prevent text overlap */
@media (max-width: 950px) and (orientation: landscape) and (max-height: 600px) {
    .lightbox-overlay {
        flex-direction: column;
        padding-top: 5px;
    }

    .lightbox-info {
        position: relative;
        top: auto;
        left: auto;
        transform: none;
        margin-bottom: 5px;
        background: transparent;
        width: 80%;
        max-width: none;
        pointer-events: none;
        order: 0;
    }

    .lightbox-content {
        flex: 1;
        overflow: hidden;
        max-height: none;
        height: auto;
        /* Allow flex to determine height */
        min-height: 0;
        padding-bottom: 0;
        order: 1;
        width: 100%;
        /* Ensure full width */
        display: flex;
        /* Make this a flex container too so wrapper can fill it */
        flex-direction: column;
    }

    .lightbox-image-wrapper {
        flex: 1;
        width: 100%;
        height: 100%;
        min-height: 0;
        min-width: 0;
        /* Important for preventing grid overflow */
        display: grid;
        place-items: center;
    }

    .lightbox-image {
        /* Force image to fit completely within the wrapper */
        max-width: 100%;
        max-height: 100%;
        /* Revert to auto to allow proper aspect ratio fitting without stretching */
        width: auto;
        height: auto;
        object-fit: contain;
    }
}