/* ==========================================================
   Gallery Page — AstroBin-inspired dark astronomy gallery
   ========================================================== */

*, *::before, *::after { box-sizing: border-box; }

body {
    background: url('../photo/background.jpg') center/cover no-repeat fixed;
    background-color: #0a0a0a;
    color: #e0e0e0;
    font-family: -apple-system, 'Helvetica Neue', Arial, sans-serif;
    font-weight: 300;
    margin: 0;
    padding: 0;
    min-height: 100vh;
}

/* Dark overlay */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.68);
    z-index: 0;
    pointer-events: none;
}







.gallery-header {
    text-align: center;
    margin-bottom: 56px;
}

.gallery-title {
    font-size: clamp(2rem, 4vw, 3rem);
    font-weight: 200;
    letter-spacing: 8px;
    text-transform: uppercase;
    color: #fff;
    margin: 0 0 10px;
}

.gallery-subtitle {
    font-size: 0.88rem;
    color: rgba(255,255,255,0.45);
    margin: 0;
    letter-spacing: 1px;
}

/* ============================================================
   Page layout
   ============================================================ */
.gallery-page {
    position: relative;
    z-index: 1;
    padding: 32px 48px 48px;
    max-width: 1600px;
    margin: 0 auto;
}

/* ============================================================
   Masonry grid
   ============================================================ */
.gallery-grid {
    columns: 4;
    column-gap: 16px;
}

.gallery-card {
    break-inside: avoid;
    margin-bottom: 16px;
    background: #161616;
    border-radius: 10px;
    overflow: hidden;
    cursor: pointer;
    border: 1px solid rgba(255,255,255,0.06);
    transition: transform 0.28s ease, box-shadow 0.28s ease, border-color 0.28s ease;
}

.gallery-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 16px 48px rgba(0,0,0,0.7);
    border-color: rgba(197,160,89,0.35);
}

.gallery-thumb-wrap {
    width: 100%;
    overflow: hidden;
    background: #111;
}

.gallery-thumb {
    width: 100%;
    height: auto;
    display: block;
    transition: transform 0.4s ease, opacity 0.3s ease;
    opacity: 0;
}

.gallery-thumb.loaded {
    opacity: 1;
}

.gallery-card:hover .gallery-thumb {
    transform: scale(1.04);
}

.gallery-card-body {
    padding: 14px 16px 16px;
}

.gallery-card-title {
    font-size: 0.88rem;
    font-weight: 500;
    color: #C5A059;
    margin: 0 0 5px;
    letter-spacing: 0.3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.gallery-card-caption {
    font-size: 0.78rem;
    color: rgba(255,255,255,0.6);
    margin: 0 0 8px;
    line-height: 1.45;
    font-style: italic;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.gallery-card-author {
    font-size: 0.72rem;
    color: rgba(255,255,255,0.35);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 5px;
}

/* Skeleton loading */
.gallery-skeleton {
    break-inside: avoid;
    margin-bottom: 16px;
    background: #161616;
    border-radius: 10px;
    height: 240px;
    animation: skeleton-pulse 1.6s ease-in-out infinite;
}

@keyframes skeleton-pulse {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 0.7; }
}

/* ============================================================
   Lightbox
   ============================================================ */
.lightbox-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.92);
    z-index: 900;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.lightbox-backdrop.visible {
    opacity: 1;
    pointer-events: all;
}

.lightbox {
    position: fixed;
    inset: 0;
    z-index: 901;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.lightbox.visible {
    opacity: 1;
    pointer-events: all;
}

.lightbox[hidden] {
    display: none;
}

.lightbox-inner {
    display: flex;
    flex-direction: row;
    gap: 32px;
    max-width: 1200px;
    width: 100%;
    max-height: calc(100vh - 80px);
    align-items: center;
}

.lightbox-img-wrap {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
    max-height: calc(100vh - 80px);
}

.lightbox-img {
    max-width: 100%;
    max-height: calc(100vh - 80px);
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 24px 80px rgba(0,0,0,0.8);
    transition: opacity 0.25s ease;
}

.lightbox-img.fading {
    opacity: 0;
}

.lightbox-info {
    width: 280px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.lightbox-title {
    font-size: 1.25rem;
    font-weight: 400;
    color: #C5A059;
    margin: 0;
    letter-spacing: 0.5px;
}

.lightbox-caption {
    font-size: 0.88rem;
    color: rgba(255,255,255,0.75);
    font-style: italic;
    line-height: 1.6;
    margin: 0;
}

.lightbox-author {
    font-size: 0.78rem;
    color: rgba(255,255,255,0.4);
    margin: 0;
}

/* Close button */
.lightbox-close {
    position: fixed;
    top: 20px;
    right: 24px;
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 50%;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: rgba(255,255,255,0.8);
    z-index: 902;
    transition: background 0.2s, color 0.2s;
}

.lightbox-close:hover {
    background: rgba(255,255,255,0.18);
    color: #fff;
}

/* Nav arrows */
.lightbox-nav {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255,255,255,0.07);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 50%;
    width: 52px;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: rgba(255,255,255,0.75);
    z-index: 902;
    transition: background 0.2s, color 0.2s, transform 0.2s;
}

.lightbox-nav:hover {
    background: rgba(255,255,255,0.16);
    color: #fff;
}

.lightbox-prev { left: 16px; }
.lightbox-prev:hover { transform: translateY(-50%) translateX(-2px); }
.lightbox-next { right: 16px; }
.lightbox-next:hover { transform: translateY(-50%) translateX(2px); }

/* ============================================================
   Responsive
   ============================================================ */
@media screen and (max-width: 1400px) {
    .gallery-grid { columns: 3; }
}

@media screen and (max-width: 1024px) {
    .gallery-page { padding: 24px 32px 40px; }
    .gallery-grid { columns: 3; }
}

@media screen and (max-width: 768px) {
    .gallery-page { padding: 20px 20px 36px; }
    .gallery-grid { columns: 2; }

    .lightbox-inner {
        flex-direction: column;
        gap: 16px;
        max-height: none;
        overflow-y: auto;
        padding: 60px 8px 20px;
        align-items: flex-start;
    }

    .lightbox-img-wrap {
        max-height: 60vh;
        width: 100%;
    }

    .lightbox-info {
        width: 100%;
    }

    .lightbox-nav { display: none; }
}

@media screen and (max-width: 480px) {
    .gallery-grid { columns: 1; }
    .gallery-title { letter-spacing: 4px; }
}
