/* Explain: Styles for the photo gallery grid and lightbox viewer. */
.gallery-tile {
    position: relative;
    display: block;
    overflow: hidden;
    width: 100%;
    aspect-ratio: 4 / 3;
    padding: 0;
    border: 1px solid var(--border-color);
    border-radius: 1.6rem;
    background: var(--surface-color);
    box-shadow: var(--shadow-soft);
    text-align: left;
    transition: transform 300ms ease, border-color 300ms ease, box-shadow 300ms ease;
}

.gallery-tile:hover {
    border-color: var(--glass-border);
    box-shadow: 0 22px 60px rgba(0, 0, 0, 0.6);
    transform: translateY(-4px);
}

.gallery-tile:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 3px;
}

.gallery-tile img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 600ms ease;
}

.gallery-tile:hover img {
    transform: scale(1.06);
}

.gallery-tile img.is-rotated {
    transform: rotate(90deg) scale(1.34);
}

.gallery-tile:hover img.is-rotated,
.gallery-tile:focus-visible img.is-rotated {
    transform: rotate(90deg) scale(1.42);
}

.gallery-tile-overlay {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    background: rgba(3, 6, 9, 0.5);
    color: var(--text-color);
    opacity: 0;
    transition: opacity 300ms ease;
}

.gallery-tile-overlay i {
    display: grid;
    width: 3rem;
    height: 3rem;
    place-items: center;
    border: 1px solid var(--glass-border);
    border-radius: 999px;
    background: rgba(5, 8, 12, 0.72);
    font-size: 1rem;
}

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

.gallery-tile-caption {
    position: absolute;
    right: 0.85rem;
    bottom: 0.85rem;
    left: 0.85rem;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    padding: 0.6rem 0.8rem;
    border: 1px solid var(--glass-border);
    border-radius: 0.95rem;
    background: rgba(5, 8, 12, 0.8);
    backdrop-filter: blur(8px);
}

.gallery-tile-title {
    color: var(--text-color);
    font-size: 0.82rem;
    font-weight: 600;
    line-height: 1.3;
}

.gallery-tile-label {
    color: var(--text-muted);
    font-size: 0.68rem;
    line-height: 1.4;
}

.gallery-lightbox {
    position: fixed;
    inset: 0;
    z-index: 90;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: rgba(3, 6, 9, 0.95);
    backdrop-filter: blur(8px);
}

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

.gallery-lightbox-panel {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    width: min(100%, 64rem);
    max-height: 100%;
    padding: 0.9rem;
}

.gallery-lightbox-stage {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 12rem;
    overflow: hidden;
    border: 1px solid var(--glass-border);
    border-radius: 1.4rem;
    background: var(--surface-color);
}

.gallery-lightbox-image {
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 72vh;
    object-fit: contain;
    transition: opacity 250ms ease;
}

.gallery-lightbox-image.is-loading {
    opacity: 0;
}

.gallery-lightbox-stage.is-rotated {
    min-height: min(68vh, 86vw);
}

.gallery-lightbox-image.is-rotated {
    max-width: min(68vh, 86vw);
    max-height: none;
    transform: rotate(90deg);
}

.gallery-lightbox-loader {
    position: absolute;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.gallery-lightbox-loader.is-visible {
    display: flex;
}

.gallery-lightbox-bar {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    align-items: flex-start;
    justify-content: space-between;
}

.gallery-lightbox-caption {
    margin: 0;
    color: var(--text-color);
    font-size: 0.85rem;
    line-height: 1.5;
}

.gallery-lightbox-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.gallery-lightbox-counter {
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.1em;
}

.gallery-lightbox-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.75rem;
    height: 2.75rem;
    border: 1px solid var(--glass-border);
    border-radius: 999px;
    background: rgba(11, 17, 23, 0.86);
    color: var(--text-color);
    transition: background 250ms ease, border-color 250ms ease;
}

.gallery-lightbox-button:hover {
    border-color: var(--primary-color);
    background: var(--surface-color);
}

.gallery-lightbox-button:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 3px;
}

.gallery-lightbox-close {
    position: absolute;
    top: 0.2rem;
    right: 0.2rem;
    z-index: 2;
}

@media (min-width: 640px) {
    .gallery-lightbox-bar {
        flex-direction: row;
        align-items: center;
    }

    .gallery-lightbox-close {
        top: -0.4rem;
        right: -0.4rem;
    }
}