/* ==========================================================================
   GALLERY — SHOWCASE + LIGHTBOX
   A deliberately different register from the rest of the site: the grid
   sits inside a dark, cinematic "viewing room" so photos read like they're
   lit on a screen, not sitting on a white page.
   ========================================================================== */

.gallery-showcase {
    background: #0b1220;
    background-image:
        radial-gradient(circle at 15% 10%, rgba(30,144,255,0.16), transparent 45%),
        radial-gradient(circle at 85% 90%, rgba(37,99,235,0.14), transparent 45%);
    padding: var(--spacing-lg) 0;
    position: relative;
    overflow: hidden;
}

.gallery-showcase::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image: linear-gradient(rgba(255,255,255,0.035) 1px, transparent 1px),
                       linear-gradient(90deg, rgba(255,255,255,0.035) 1px, transparent 1px);
    background-size: 42px 42px;
    pointer-events: none;
    mask-image: radial-gradient(ellipse at center, black 40%, transparent 78%);
}

.gallery-toolbar {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1.5rem;
    margin-bottom: 2.2rem;
    padding-bottom: 1.6rem;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.gallery-stat { display: flex; align-items: baseline; gap: 0.6rem; }
.gallery-stat-number {
    font-family: var(--font-heading);
    font-size: 2.6rem;
    font-weight: 700;
    color: #fff;
    line-height: 1;
    background: linear-gradient(120deg, #ffffff, var(--color-accent-light));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}
.gallery-stat-label {
    font-family: var(--font-heading);
    font-size: 0.85rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(255,255,255,0.55);
}

.gallery-controls { display: flex; align-items: center; gap: 0.9rem; flex-wrap: wrap; }

.view-toggle {
    display: inline-flex;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: var(--radius-pill);
    padding: 4px;
    gap: 2px;
}
.view-toggle-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px; height: 34px;
    border: none;
    background: transparent;
    color: rgba(255,255,255,0.55);
    border-radius: var(--radius-pill);
    cursor: pointer;
    transition: all 0.2s ease;
}
.view-toggle-btn svg { width: 17px; height: 17px; }
.view-toggle-btn:hover { color: #fff; }
.view-toggle-btn.active { background: var(--color-accent); color: #fff; box-shadow: 0 2px 10px rgba(30,144,255,0.5); }

.gallery-filters {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.gallery-filter-select {
    appearance: none;
    -webkit-appearance: none;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.12);
    color: rgba(255,255,255,0.85);
    padding: 0 2rem 0 1rem;
    height: 34px;
    border-radius: var(--radius-pill);
    font-family: var(--font-heading);
    font-weight: 500;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
    background-repeat: no-repeat;
    background-position: right 0.6rem center;
    background-size: 14px;
}
.gallery-filter-select:hover { background-color: rgba(255,255,255,0.14); color: #fff; }
.gallery-filter-select:focus { outline: none; border-color: var(--color-accent); }
.gallery-filter-select option { background: #0b1220; color: #fff; }

.gallery-empty-msg {
    color: rgba(255,255,255,0.6);
    font-family: var(--font-heading);
    padding: 3rem 0;
    text-align: center;
    width: 100%;
}

.shuffle-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.12);
    color: rgba(255,255,255,0.8);
    padding: 0 1rem;
    height: 34px;
    border-radius: var(--radius-pill);
    font-family: var(--font-heading);
    font-weight: 500;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
}
.shuffle-btn svg { width: 15px; height: 15px; }
.shuffle-btn:hover { background: rgba(255,255,255,0.14); color: #fff; }
.shuffle-btn.spinning svg { animation: shuffleSpin 0.5s ease; }
@keyframes shuffleSpin { to { transform: rotate(180deg); } }

/* ---- The wall of photos ---- */

.gallery-wall {
    position: relative;
    z-index: 1;
    column-gap: 1rem;
}
.gallery-wall.masonry-view { column-count: 4; }
.gallery-wall.grid-view {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
}

.gallery-tile {
    display: block;
    width: 100%;
    border: none;
    padding: 0;
    margin: 0 0 1rem;
    break-inside: avoid;
    position: relative;
    border-radius: 14px;
    overflow: hidden;
    cursor: pointer;
    background: #111c30;
    box-shadow: 0 6px 24px rgba(0,0,0,0.35);
    opacity: 0;
    transform: translateY(18px);
    animation: tileIn 0.6s ease forwards;
}
@keyframes tileIn { to { opacity: 1; transform: translateY(0); } }

.gallery-wall.grid-view .gallery-tile { margin-bottom: 0; aspect-ratio: 1 / 1; }
.gallery-wall.grid-view .gallery-tile img { width: 100%; height: 100%; object-fit: cover; }

.gallery-tile img {
    display: block;
    width: 100%;
    height: auto;
    transition: transform 0.55s cubic-bezier(.2,.8,.2,1), filter 0.4s ease;
}
.gallery-tile:hover img { transform: scale(1.08); filter: brightness(0.72); }

.tile-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    padding: 0.9rem;
    opacity: 0;
    transition: opacity 0.35s ease;
    background: linear-gradient(180deg, transparent 40%, rgba(0,0,0,0.55) 100%);
}
.gallery-tile:hover .tile-overlay { opacity: 1; }

.tile-index {
    font-family: var(--font-heading);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    color: rgba(255,255,255,0.85);
}
.tile-expand-icon {
    width: 34px; height: 34px;
    border-radius: 50%;
    background: rgba(255,255,255,0.16);
    backdrop-filter: blur(6px);
    display: flex; align-items: center; justify-content: center;
    color: #fff;
    transform: scale(0.7);
    transition: transform 0.3s ease;
}
.gallery-tile:hover .tile-expand-icon { transform: scale(1); }
.tile-expand-icon svg { width: 16px; height: 16px; }

/* ---- Lightbox ---- */

.lightbox {
    position: fixed;
    inset: 0;
    z-index: 2000;
    background: rgba(4, 8, 18, 0.97);
    backdrop-filter: blur(6px);
    display: flex;
    flex-direction: column;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.3s ease, visibility 0s linear 0.3s;
}
.lightbox.open { opacity: 1; visibility: visible; pointer-events: auto; transition: opacity 0.3s ease, visibility 0s linear 0s; }

.lightbox-topbar {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.4rem;
    color: #fff;
    z-index: 2;
}
.lightbox-counter { font-family: var(--font-heading); font-weight: 500; letter-spacing: 0.04em; color: rgba(255,255,255,0.75); font-size: 0.95rem; }

.lightbox-zoom-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: var(--radius-pill);
    padding: 4px 6px;
}
.lightbox-zoom-controls button {
    width: 30px; height: 30px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: #fff;
    font-size: 1.1rem;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: background 0.2s ease;
}
.lightbox-zoom-controls button:hover { background: rgba(255,255,255,0.14); }
#zoomLevel { font-family: var(--font-heading); font-size: 0.8rem; color: rgba(255,255,255,0.8); min-width: 42px; text-align: center; }
.zoom-reset-btn { font-size: 0.72rem !important; width: auto !important; padding: 0 0.7rem; border-radius: var(--radius-pill) !important; }

.lightbox-icon-btn {
    width: 38px; height: 38px;
    border-radius: 50%;
    border: 1px solid rgba(255,255,255,0.14);
    background: rgba(255,255,255,0.06);
    color: #fff;
    font-size: 1.3rem;
    line-height: 1;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: background 0.2s ease;
}
.lightbox-icon-btn:hover { background: rgba(255,255,255,0.18); }
.lightbox-icon-btn svg { width: 17px; height: 17px; }

.lightbox-stage {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
    touch-action: none;
}
.lightbox-stage img {
    max-width: 88vw;
    max-height: 72vh;
    border-radius: 6px;
    box-shadow: 0 20px 70px rgba(0,0,0,0.6);
    user-select: none;
    -webkit-user-drag: none;
    transform-origin: center center;
    transition: transform 0.15s ease-out;
    cursor: grab;
}
.lightbox-stage img.dragging { cursor: grabbing; transition: none; }
.lightbox-stage img.zoomed { cursor: grab; }

.lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 3;
    width: 48px; height: 48px;
    border-radius: 50%;
    border: 1px solid rgba(255,255,255,0.14);
    background: rgba(255,255,255,0.06);
    color: #fff;
    font-size: 1.6rem;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: background 0.2s ease, transform 0.2s ease;
}
.lightbox-nav:hover { background: rgba(255,255,255,0.2); transform: translateY(-50%) scale(1.08); }
.lightbox-prev { left: 1.2rem; }
.lightbox-next { right: 1.2rem; }

.lightbox-filmstrip {
    flex-shrink: 0;
    display: flex;
    gap: 0.6rem;
    padding: 0.9rem 1.4rem 1.3rem;
    overflow-x: auto;
    scrollbar-width: thin;
}
.lightbox-filmstrip::-webkit-scrollbar { height: 5px; }
.lightbox-filmstrip::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.25); border-radius: 5px; }

.filmstrip-thumb {
    flex-shrink: 0;
    width: 62px; height: 62px;
    border-radius: 8px;
    overflow: hidden;
    border: 2px solid transparent;
    opacity: 0.5;
    cursor: pointer;
    transition: all 0.2s ease;
}
.filmstrip-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.filmstrip-thumb:hover { opacity: 0.85; }
.filmstrip-thumb.active { opacity: 1; border-color: var(--color-accent); }

/* ---- Responsive ---- */

@media (max-width: 1100px) {
    .gallery-wall.masonry-view { column-count: 3; }
    .gallery-wall.grid-view { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 720px) {
    .gallery-wall.masonry-view { column-count: 2; }
    .gallery-wall.grid-view { grid-template-columns: repeat(2, 1fr); }
    .gallery-toolbar { flex-direction: column; align-items: flex-start; }
    .gallery-controls { width: 100%; }
    .gallery-filters { width: 100%; }
    .gallery-filter-select { flex: 1; }
    .lightbox-stage img { max-height: 60vh; }
    .lightbox-nav { width: 40px; height: 40px; font-size: 1.3rem; }
    .lightbox-prev { left: 0.5rem; }
    .lightbox-next { right: 0.5rem; }
    .filmstrip-thumb { width: 48px; height: 48px; }
}