/*
    The destination gallery ("Visual Experience") and its lightbox, ported from the <style> block of the old
    includes/components/destination_gallery.php (#174).

    Two deliberate differences from the old file: a tile is a <button> (so it takes focus and the keyboard),
    and the lightbox is shown by a class (`.is-open`) and the page behind it is locked by a class on <body>
    (`.lightbox-open`) instead of by inline style attributes written by the script.
*/

.gallery-subtitle {
    text-align: center;
    color: var(--color-text-gray);
    margin-bottom: 2rem;
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1.5rem;
}

.gallery-item {
    position: relative;
    display: block;
    width: 100%;
    padding: 0;
    border: none;
    background: none;
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    aspect-ratio: 4 / 3;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.gallery-item:hover,
.gallery-item:focus-visible {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
}

.gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}

.gallery-item:hover img {
    transform: scale(1.1);
}

.gallery-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 2;
}

.gallery-item:hover .gallery-overlay,
.gallery-item:focus-visible .gallery-overlay {
    opacity: 1;
}

.gallery-overlay i {
    color: white;
    font-size: 2rem;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

/* ----------  Lightbox  ---------- */

.lightbox {
    display: none;
    position: fixed;
    /* Above the cookie banner (2000), which comes later in the page and would otherwise sit on top of it. */
    z-index: 2100;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.95);
    backdrop-filter: blur(5px);
    align-items: center;
    justify-content: center;
}

.lightbox.is-open {
    display: flex;
}

body.lightbox-open {
    overflow: hidden;
}

.lightbox-loader {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-top: 4px solid var(--color-gold);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: lightbox-spin 1s linear infinite;
    z-index: 2005;
    display: none;
}

@keyframes lightbox-spin {
    0% {
        transform: translate(-50%, -50%) rotate(0deg);
    }

    100% {
        transform: translate(-50%, -50%) rotate(360deg);
    }
}

.lightbox-content {
    margin: auto;
    display: block;
    max-width: 90%;
    max-height: 85vh;
    border-radius: 4px;
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.5);
    object-fit: contain;
    animation: lightbox-zoom-in 0.3s ease;
    transition: opacity 0.2s ease;
}

.lightbox-close {
    position: absolute;
    top: 15px;
    right: 35px;
    background: transparent;
    border: none;
    padding: 0;
    color: #f1f1f1;
    font-size: 40px;
    font-weight: bold;
    line-height: 1;
    transition: 0.3s;
    cursor: pointer;
    z-index: 2001;
}

.lightbox-close:hover,
.lightbox-close:focus {
    color: var(--color-gold);
}

.lightbox-play-pause {
    position: absolute;
    top: 25px;
    left: 35px;
    background: transparent;
    border: none;
    color: #f1f1f1;
    font-size: 24px;
    cursor: pointer;
    z-index: 2001;
    transition: 0.3s;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lightbox-play-pause:hover,
.lightbox-play-pause:focus {
    color: var(--color-gold);
    transform: scale(1.1);
}

.lightbox-progress-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    z-index: 2002;
}

.lightbox-progress-bar {
    height: 100%;
    width: 0%;
    background-color: var(--color-gold);
    transition: width 0.1s linear;
}

.lightbox-prev,
.lightbox-next {
    cursor: pointer;
    position: absolute;
    top: 50%;
    width: auto;
    padding: 16px;
    margin-top: -50px;
    background: transparent;
    border: none;
    color: white;
    font-weight: bold;
    font-size: 20px;
    transition: 0.6s ease;
    user-select: none;
    -webkit-user-select: none;
}

.lightbox-next {
    right: 0;
    border-radius: 3px 0 0 3px;
}

.lightbox-prev {
    left: 0;
    border-radius: 0 3px 3px 0;
}

.lightbox-prev:hover,
.lightbox-next:hover,
.lightbox-prev:focus,
.lightbox-next:focus {
    background-color: rgba(212, 175, 55, 0.8);
}

@keyframes lightbox-zoom-in {
    from {
        transform: scale(0);
    }

    to {
        transform: scale(1);
    }
}

@media only screen and (max-width: 700px) {
    .lightbox-content {
        width: 100%;
    }
}
