/* SPDX-FileCopyrightText: 2026 RiftWii contributors */
/* SPDX-License-Identifier: GPL-3.0-or-later */
/* The picture preview (java/lightbox.js): shared by the home page, the
   Themes page and the tutorials. */

.grid-image img,
img.tutorial-image,
.theme-preview img {
    cursor: zoom-in;
}

.grid-image img:focus-visible,
img.tutorial-image:focus-visible,
.theme-preview img:focus-visible {
    outline: 3px solid #78d3ff;
    outline-offset: 3px;
}

html.lightbox-open {
    overflow: hidden;
}

.lightbox {
    position: fixed;
    inset: 0;
    /* Above the navigation bar and its slim phone bar. */
    z-index: 2147483000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(2, 4, 20, 0.88);
    opacity: 0;
    transition: opacity 0.18s ease;
}

.lightbox[hidden] {
    display: none;
}

.lightbox.lightbox-visible {
    opacity: 1;
}

.lightbox-stage {
    margin: 0;
    max-width: 92vw;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    transform: scale(0.96);
    transition: transform 0.18s ease;
}

.lightbox.lightbox-visible .lightbox-stage {
    transform: none;
}

.lightbox-image {
    display: block;
    max-width: 92vw;
    max-height: 80vh;
    max-height: 80dvh;
    width: auto;
    height: auto;
    border-radius: 10px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.6);
    /* Swiping sideways changes picture; pinching is left to the browser. */
    touch-action: pan-y pinch-zoom;
    user-select: none;
    -webkit-user-drag: none;
}

.lightbox-caption {
    max-width: min(92vw, 720px);
    color: #e8efff;
    font-family: Arial, sans-serif;
    font-size: 0.95rem;
    line-height: 1.35;
    text-align: center;
}

.lightbox-counter {
    position: absolute;
    top: max(16px, env(safe-area-inset-top));
    left: max(16px, env(safe-area-inset-left));
    padding: 6px 12px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.12);
    color: #e8efff;
    font-family: Arial, sans-serif;
    font-size: 0.9rem;
}

.lightbox-button {
    position: absolute;
    width: 48px;
    height: 48px;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.28);
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.14);
    color: #fff;
    font-family: Arial, sans-serif;
    font-size: 2rem;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lightbox-button:hover {
    background: rgba(255, 255, 255, 0.28);
}

.lightbox-button:focus-visible {
    outline: 3px solid #78d3ff;
    outline-offset: 2px;
}

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

.lightbox-close {
    top: max(12px, env(safe-area-inset-top));
    right: max(12px, env(safe-area-inset-right));
}

.lightbox-prev,
.lightbox-next {
    top: 50%;
    margin-top: -24px;
    padding-bottom: 4px;
}

.lightbox-prev {
    left: max(12px, env(safe-area-inset-left));
}

.lightbox-next {
    right: max(12px, env(safe-area-inset-right));
}

@media (max-width: 650px) {
    /* On a phone the arrows sit under the picture's corners so they don't
       cover it; swiping works as well. */
    .lightbox-prev,
    .lightbox-next {
        top: auto;
        bottom: max(16px, env(safe-area-inset-bottom));
        margin-top: 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    .lightbox,
    .lightbox-stage {
        transition: none;
        transform: none;
    }
}
