/* ========================================
   GALLERY PAGE
   ======================================== */

/* Reset & base */
body {
    font-family: 'DM Sans', sans-serif;
    margin: 0;
    padding: 0;
    overflow-y: auto;
    overflow-x: hidden;
    background-color: #fff;
}

/* Layout */
.container {
    display: flex;
    flex-direction: row;
    width: 100%;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 240px;
    min-width: 240px;
    padding: 30px 24px;
    background-color: #f7f7f7;
    box-sizing: border-box;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    border-right: 1px solid #eee;
    display: flex;
    flex-direction: column;
}

.sidebar h1 {
    margin: 0 0 30px 0;
    font-size: 22px;
    font-weight: 700;
    line-height: 1.2;
}

.sidebar h1 a {
    text-decoration: none;
    color: #111;
    transition: color 0.3s;
}

.sidebar h1 a:hover {
    color: #ffbc47;
}

.categories {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.categories a {
    text-decoration: none;
    color: #666;
    font-size: 15px;
    font-weight: 500;
    padding: 6px 0;
    transition: color 0.2s ease;
    position: relative;
}

.categories a:hover {
    color: #111;
}

.categories a.active {
    color: #111;
    font-weight: 700;
}

.categories a.active::before {
    content: '';
    position: absolute;
    left: -24px;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 20px;
    background-color: #ffbc47;
    border-radius: 0 2px 2px 0;
}

/* Sidebar footer nav */
.sidebar-nav {
    margin-top: auto;
    padding-top: 24px;
    border-top: 1px solid #eee;
}

.sidebar-nav a {
    text-decoration: none;
    color: #999;
    font-size: 14px;
    font-weight: 500;
    transition: color 0.2s;
}

.sidebar-nav a:hover {
    color: #111;
}

/* Gallery grid */
.gallery {
    flex: 1;
    padding: 12px;
    column-count: 4;
    column-gap: 8px;
    background-color: #fff;
    overflow: hidden;
}

/* picture wrapper — ensure masonry layout applies correctly */
.gallery picture {
    display: block;
    break-inside: avoid;
    margin-bottom: 8px;
}

.gallery picture img {
    width: 100%;
    height: auto;
    object-fit: cover;
    display: block;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.4s ease, transform 0.3s ease;
}

.gallery picture img.lazy-loaded {
    opacity: 1;
}

.gallery picture img:hover {
    transform: scale(1.03);
    position: relative;
    z-index: 1;
}

/* Lightbox */
.lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.92);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.lightbox-content {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

#lightbox-img {
    max-width: 90vw;
    max-height: 90vh;
    width: auto;
    height: auto;
    display: none;
    object-fit: contain;
    opacity: 0;
    transition: opacity 0.3s ease;
    cursor: default;
}

#lightbox-img.loaded {
    opacity: 1;
}

.lightbox-close {
    position: fixed;
    top: 16px;
    right: 24px;
    font-size: 36px;
    color: #fff;
    cursor: pointer;
    z-index: 1002;
    background: none;
    border: none;
    font-family: inherit;
    line-height: 1;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.lightbox-close:hover {
    opacity: 1;
}

/* Lightbox prev / next */
.lightbox-nav {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.35);
    border: none;
    color: #fff;
    font-size: 32px;
    line-height: 1;
    width: 52px;
    height: 80px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background 0.2s, opacity 0.2s;
    z-index: 1002;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.lightbox-nav:hover {
    background: rgba(0, 0, 0, 0.65);
}

.lightbox-nav:disabled {
    opacity: 0.2;
    cursor: default;
}

.lightbox-prev { left: 12px; }
.lightbox-next { right: 12px; }

/* Spinner */
.spinner {
    border: 3px solid rgba(255, 255, 255, 0.15);
    border-top: 3px solid #fff;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 0.8s linear infinite;
    display: none;
}

.lightbox.loading .spinner {
    display: block;
}

.lightbox.loading #lightbox-img {
    display: none !important;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ========================================
   RESPONSIVE
   ======================================== */

@media (max-width: 1200px) {
    .gallery {
        column-count: 3;
    }
}

@media (max-width: 900px) {
    .gallery {
        column-count: 2;
    }
}

@media (max-width: 768px) {
    .container {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        min-width: 100%;
        height: auto;
        position: relative;
        padding: 16px 20px;
        border-right: none;
        border-bottom: 1px solid #eee;
        flex-direction: row;
        align-items: center;
        flex-wrap: wrap;
        gap: 12px;
    }

    .sidebar h1 {
        margin: 0;
        font-size: 18px;
        flex-shrink: 0;
    }

    .categories {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 8px;
    }

    .categories a {
        padding: 6px 14px;
        font-size: 14px;
        background-color: #eee;
        border-radius: 20px;
    }

    .categories a.active {
        background-color: #111;
        color: #fff;
    }

    .categories a.active::before {
        display: none;
    }

    .sidebar-nav {
        margin-top: 0;
        padding-top: 0;
        border-top: none;
        margin-left: auto;
    }

    .sidebar-nav a {
        padding: 6px 14px;
        background-color: #eee;
        border-radius: 20px;
        font-size: 14px;
    }

    .gallery {
        column-count: 2;
        padding: 8px;
    }

    .lightbox-nav {
        width: 44px;
        height: 64px;
        font-size: 26px;
    }

    .lightbox-prev { left: 4px; }
    .lightbox-next { right: 4px; }
}

@media (max-width: 480px) {
    .gallery {
        column-count: 2;
        padding: 4px;
        column-gap: 4px;
    }

    .gallery picture {
        margin-bottom: 4px;
    }

    .sidebar h1 {
        font-size: 16px;
    }
}
