/* =========================================
   GALLERY VIEW - CSS MASONRY & LIGHTBOX
========================================= */

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background-color: var(--view-bg);
    font-family: 'Space Grotesk', sans-serif;
    color: var(--view-text-main);
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
}

.gallery-view-main {
    max-width: 1400px;
    margin: 0 auto;
    padding: max(120px, 12vh) 4vw 80px;
}

.gallery-view-header {
    text-align: left;
    margin-bottom: 4rem;
}

.gallery-view-back-link {
    display: inline-block;
    margin-bottom: 2rem;
    text-decoration: none;
    color: var(--view-back-link);
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    transition: color 0.3s ease;
}

.gallery-view-back-link:hover {
    color: var(--view-back-link-hover);
}

.gallery-view-title {
    font-size: clamp(3rem, 6vw, 5rem);
    font-weight: 700;
    text-transform: uppercase;
    line-height: 1;
    margin: 0 0 1rem 0;
    letter-spacing: -0.03em;
}

.gallery-view-desc {
    color: var(--view-desc);
    max-width: 600px;
    font-size: clamp(1rem, 1.5vw, 1.15rem);
    line-height: 1.6;
    margin: 0;
}

/* =========================================
   JUSTIFIED PHOTO GRID (FLICKR STYLE)
========================================= */
.gal-view-maso-cont {
    display: flex;
    flex-wrap: wrap;
    gap: 6px; /* Ultra-tight gap matching reference picture */
    width: 100%;
}

.masonry-item {
    flex: 1 1 auto;
    height: 250px; /* Small, equal row height */
    margin: 0;
    display: block;
    cursor: pointer;
    overflow: hidden;
    background-color: var(--view-maso-item-bg);
    /* Dropped border-radius to match sharp corners in reference */
}

/* Prevent last row from wildly stretching */
.gal-view-maso-cont::after {
    content: '';
    flex-grow: 999999999;
    min-width: 250px;
}

@media (max-width: 600px) {
    .masonry-item { height: 150px; }
}

@media (min-width: 1200px) {
    .masonry-item { height: 320px; }
}

.masonry-item img {
    width: auto;
    min-width: 100%;
    height: 100%;
    object-fit: cover; /* Fills height uniformly while maintaining shape scale */
    display: block;
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.4s ease;
    opacity: 0.85;
}

.masonry-item:hover img {
    transform: scale(1.03);
    opacity: 1;
}

/* =========================================
   LIGHTBOX STYLES
========================================= */
.lightbox {
    position: fixed;
    inset: 0;
    z-index: 99999;
    background: var(--lightbox-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    backdrop-filter: blur(5px);
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.lightbox.active {
    opacity: 1;
    visibility: visible;
}

.lightbox-content {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

#lightbox-img {
    max-width: 100%;
    max-height: 90vh;
    object-fit: contain;
    border-radius: 4px;
    box-shadow: 0 10px 40px var(--lightbox-shadow);
    /* Transition for source change */
    animation: fadeIn 0.3s ease forwards;
}

@keyframes fadeIn {
    from { opacity: 0; transform: scale(0.98); }
    to { opacity: 1; transform: scale(1); }
}

/* Base Lightbox Buttons */
.lightbox-btn {
    position: absolute;
    background: transparent;
    border: none;
    color: var(--lightbox-btn);
    font-size: 2.5rem;
    cursor: pointer;
    z-index: 1000;
    padding: 1rem;
    transition: color 0.2s ease, transform 0.2s ease;
}

.lightbox-btn:hover {
    color: var(--lightbox-btn-hover);
    transform: scale(1.1);
}

.lightbox-close {
    top: 20px;
    right: 30px;
    font-size: 3rem;
    line-height: 1;
}

.lightbox-prev {
    left: 2vw;
}

.lightbox-next {
    right: 2vw;
}

@media (max-width: 768px) {
    .lightbox-prev { left: 0; }
    .lightbox-next { right: 0; }
    .lightbox-close { top: 10px; right: 10px; }
}