/* =========================================
   1. RESET & BASE STYLES
   ========================================= */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background: linear-gradient(135deg, #050b1a 0%, #0a1227 100%);
    color: #ffffff;
    font-family: 'Segoe UI', 'Poppins', 'Roboto', system-ui, -apple-system, sans-serif;
    line-height: 1.6;
    min-height: 100vh;
}

::-webkit-scrollbar {
    width: 8px;
}
::-webkit-scrollbar-track {
    background: #0f1a2e;
    border-radius: 10px;
}
::-webkit-scrollbar-thumb {
    background: #f5c542;
    border-radius: 10px;
}

/* =========================================
   2. NAVIGATION BAR
   ========================================= */
.navbar {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.55rem;
    background: rgba(6, 12, 26, 0.92);
    backdrop-filter: blur(14px);
    padding: 1rem 1.5rem;
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 1px solid rgba(245, 197, 66, 0.33);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.5);
}

.navbar a {
    color: #f0eef7;
    text-decoration: none;
    font-weight: 500;
    padding: 0.45rem 1rem;
    border-radius: 40px;
    transition: all 0.25s;
    font-size: 0.9rem;
    background: rgba(30, 45, 85, 0.5);
    backdrop-filter: blur(4px);
}

.navbar a:hover {
    background: #f5c542;
    color: #0a0f1f;
    transform: translateY(-2px);
    box-shadow: 0 6px 14px rgba(245, 197, 66, 0.3);
}

/* =========================================
   3. LAYOUT & CONTAINERS
   ========================================= */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 40px 20px;
}

/* =========================================
   4. PAGE HEADERS
   ========================================= */
.page-header {
    text-align: center;
    margin-bottom: 50px;
}

.page-header h1 {
    font-size: 48px;
    color: #ffaa00;
    margin-bottom: 15px;
    text-shadow: 0 0 30px rgba(255, 170, 0, 0.1);
}

.page-header p {
    font-size: 18px;
    color: #aaa;
}

/* Optional gradient headline style — add class="gradient-text" to a page-header h1
   if you want the softer gold/blue gradient look instead of solid orange */
.page-header h1.gradient-text {
    background: linear-gradient(135deg, #ffe6b0, #b0c4ff);
    background-clip: text;
    -webkit-background-clip: text;
    color: transparent;
    text-shadow: none;
}

/* Live item-count line under a page title, e.g. "46 galaxies captured" */
.gallery-counter {
    color: #ffaa00;
    font-size: 18px;
    margin-top: 8px;
    font-weight: bold;
}

/* =========================================
   5. GALLERY GRID
   ========================================= */
.gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 25px;
}

.photo-card {
    background: rgba(20, 20, 40, 0.8);
    border-radius: 15px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.3s, box-shadow 0.3s, border-color 0.3s;
    border: 1px solid #333;
}

.photo-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    border-color: #ffaa00;
}

.photo-card img {
    width: 100%;
    aspect-ratio: 16 / 10; /* Keeps thumbnails uniform without cropping */
    object-fit: contain;   /* Shows the whole image */
    background-color: #000;
    display: block;
    transition: transform 0.4s ease;
}

.photo-card:hover img {
    transform: scale(1.03);
}

.photo-info {
    padding: 15px;
}

.photo-title {
    font-size: 18px;
    font-weight: bold;
    color: #ffaa00;
    margin-bottom: 8px;
}

.photo-details {
    font-size: 13px;
    color: #aaa;
    margin-bottom: 8px;
}

.photo-description {
    font-size: 14px;
    color: #ccc;
}

/* =========================================
   6. ARTICLE STYLES
   ========================================= */
.article-content {
    background: rgba(20, 20, 40, 0.8);
    border-radius: 15px;
    padding: 40px;
    line-height: 1.8;
    max-width: 1000px;
    margin: 2rem auto;
    border: 1px solid rgba(255, 170, 0, 0.1);
}

.article-content h1 {
    color: #ffaa00;
    margin-bottom: 20px;
    font-size: 36px;
}

.article-content h2 {
    color: #ffaa00;
    margin-top: 40px;
    margin-bottom: 10px;
    font-size: 28px;
    border-bottom: 1px solid rgba(245, 197, 66, 0.2);
    padding-bottom: 8px;
}

.article-content h3 {
    color: #ffaa00;
    margin-top: 25px;
    margin-bottom: 10px;
    font-size: 24px;
}

.article-content p {
    margin-bottom: 20px;
    color: #ddd;
    font-size: 18px;
}

/* Article Images - Shows full image without cropping */
.featured-image,
.object-image {
    width: 100%;
    max-height: 400px;
    object-fit: contain;
    border-radius: 12px;
    margin: 15px 0;
    background: #0f1a2e;
    border: 1px solid rgba(245, 197, 66, 0.2);
}

.fact-box {
    background: rgba(0, 0, 0, 0.4);
    border-left: 4px solid #ffaa00;
    padding: 15px 20px;
    margin: 25px 0;
    border-radius: 10px;
}

.fact-box strong {
    color: #ffaa00;
}

.object-details {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 10px;
    padding: 15px 20px;
    margin: 10px 0 20px 0;
    display: flex;
    flex-wrap: wrap;
    gap: 10px 30px;
    font-size: 17px;
    border-left: 3px solid #ffaa00;
}

.object-details strong {
    color: #ffaa00;
}

.back-link {
    display: inline-block;
    margin-top: 30px;
    color: #ffaa00;
    text-decoration: none;
    font-weight: bold;
    font-size: 18px;
}

.back-link:hover {
    text-decoration: underline;
}

/* =========================================
   7. LIGHTBOX (Universal iOS Scroll Fix)
   -----------------------------------------
   This is the ONLY lightbox style block the
   whole site should use. Do not paste a second,
   separate <style> lightbox block into any page
   — that duplication is what caused the iPhone/
   iPad scroll + clipped-content bug. Every gallery
   page should link this file and reuse the same
   #lightbox / .lightbox markup.
   ========================================= */
/* Locks the background page in place while the lightbox is open.
   Pages whose JS sets scrollY and toggles this class (e.g. comets.html)
   get a smoother iOS scroll-lock; pages that don't reference it are
   unaffected — the base .lightbox overflow rules below still work either way. */
body.lightbox-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
}

.lightbox {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh; /* Adapts to iOS Safari's dynamic browser bars */
    background: rgba(0, 0, 0, 0.95);
    backdrop-filter: blur(10px);
    z-index: 9999;
    cursor: pointer;

    /* Enable vertical touch scrolling on mobile — this is the critical fix */
    overflow-y: scroll;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;

    padding: 60px 16px 60px;
    box-sizing: border-box;
}

.lightbox.active {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start; /* Keeps the top of tall content visible & scrollable */
}

/* Optional wrapper div some pages use around the image — safe to keep even
   if a page's markup doesn't include it. */
.lightbox-img-container {
    max-width: 100%;
    text-align: center;
    flex-shrink: 0;
}

#lightbox-img,
.lightbox-img-container img {
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 75vh;
    max-height: 75dvh; /* Bigger images, with room still left for the caption below */
    border-radius: 12px;
    border: 2px solid #ffaa00;
    object-fit: contain;
    flex-shrink: 0; /* Prevents image squishing */
    cursor: default;
    display: block;
    margin: 0 auto;
}

.lightbox-caption,
#lightbox-caption {
    color: #ffffff;
    text-align: center;
    background: rgba(15, 26, 46, 0.85);
    border: 1px solid rgba(245, 197, 66, 0.2);
    padding: 16px 20px;
    margin-top: 16px;
    border-radius: 10px;
    width: 100%;
    max-width: 650px;
    font-size: 14px;
    line-height: 1.6;
    box-sizing: border-box;
    cursor: default;

    /* Forces long descriptions to wrap and trigger scrolling instead of being cut off */
    word-wrap: break-word;
    overflow-wrap: break-word;
    white-space: normal;
    flex-shrink: 0;
}

.close-btn {
    position: fixed;
    top: 12px;
    right: 16px;
    font-size: 36px;
    color: #ffffff;
    cursor: pointer;
    z-index: 10000;
    padding: 8px 12px;
    line-height: 1;
    background: rgba(0, 0, 0, 0.6);
    border-radius: 50%;
    backdrop-filter: blur(4px);
}

/* =========================================
   8. FOOTER
   ========================================= */
footer {
    text-align: center;
    padding: 40px;
    color: #888;
    border-top: 1px solid #333;
    margin-top: 50px;
    font-size: 0.9rem;
}

/* =========================================
   9. RESPONSIVE DESIGN
   ========================================= */
@media (max-width: 700px) {
    .navbar a {
        font-size: 0.75rem;
        padding: 0.35rem 0.7rem;
    }

    .page-header h1 {
        font-size: 32px;
    }

    .gallery {
        grid-template-columns: 1fr;
    }

    .article-content {
        padding: 25px;
    }

    .article-content h1 {
        font-size: 28px;
    }

    .article-content p {
        font-size: 16px;
    }

    .featured-image,
    .object-image {
        max-height: 250px;
    }

    .object-details {
        flex-direction: column;
        gap: 5px;
    }

    #lightbox-img,
    .lightbox-img-container img {
        max-height: 70vh;
        max-height: 70dvh; /* still bigger than before, but leaves room for the caption on small screens */
    }
}
