/* Google Fonts Import */
@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;500;700;900&family=Barlow:wght@300;400;500&display=swap');

:root {
    /* NASA / Space Palette */
    --bg-space: #05070d;
    --accent-blue: #4da3ff;
    --accent-glow: rgba(77, 163, 255, 0.6);
    --text-primary: #ffffff;
    --text-secondary: #a0aab5;

    --sidebar-bg: rgba(5, 7, 13, 0.95);
    --sidebar-border: rgba(77, 163, 255, 0.2);

    --font-heading: 'Orbitron', sans-serif;
    --font-body: 'Barlow', sans-serif;

    --sidebar-width: 250px;

    /* Spaziature / Space Scale */
    --space-1: 0.5rem;
    --space-2: 1rem;
    --space-3: 1.5rem;
    --space-4: 2rem;
    --space-5: 3rem;
    --space-6: 4rem;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    scrollbar-width: thin;
    scrollbar-color: var(--accent-blue) var(--bg-space);
}

body {
    background-color: var(--bg-space);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 16px;
    line-height: 1.6;
    overflow-x: hidden;
    min-height: 100vh;
    display: flex;
    /* Flex layout for Sidebar + Content */
}

/* Scrollbar Customization */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-space);
}

::-webkit-scrollbar-thumb {
    background: var(--accent-blue);
    border-radius: 4px;
}

/* =========================================
   SIDEBAR STYLES
   ========================================= */
.cosmos-sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--sidebar-border);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    backdrop-filter: blur(10px);
    box-shadow: 5px 0 30px rgba(0, 0, 0, 0.5);
}

.sidebar-header {
    padding: 2rem;
    display: flex;
    justify-content: center;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.logo-ring {
    width: 20px;
    height: 20px;
    border: 2px solid var(--accent-blue);
    border-radius: 50%;
    box-shadow: 0 0 10px var(--accent-blue);
}

.logo-text {
    font-family: var(--font-heading);
    font-weight: 900;
    font-size: 1.5rem;
    letter-spacing: 2px;
    color: white;
    text-shadow: 0 0 10px rgba(77, 163, 255, 0.5);
}

.sidebar-nav {
    flex: 1;
    padding: 2rem 0;
    overflow-y: auto;
}

.sidebar-nav ul {
    list-style: none;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    padding: 1rem 2rem;
    color: var(--text-secondary);
    text-decoration: none;
    font-family: var(--font-heading);
    font-size: 0.9rem;
    letter-spacing: 1px;
    transition: all 0.3s ease;
    border-left: 3px solid transparent;
}

.sidebar-nav .nav-icon {
    margin-right: 1rem;
    filter: grayscale(1);
    transition: filter 0.3s ease;
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
    color: white;
    background: linear-gradient(90deg, rgba(77, 163, 255, 0.1), transparent);
    border-left-color: var(--accent-blue);
    text-shadow: 0 0 8px var(--accent-glow);
}

.sidebar-nav a:hover .nav-icon,
.sidebar-nav a.active .nav-icon {
    filter: grayscale(0);
}

.sidebar-footer {
    padding: 1.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    background: rgba(0, 0, 0, 0.2);
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-family: var(--font-heading);
    font-size: 0.7rem;
    color: var(--accent-blue);
    letter-spacing: 2px;
}

.status-dot {
    width: 8px;
    height: 8px;
    background: var(--accent-blue);
    border-radius: 50%;
    box-shadow: 0 0 5px var(--accent-blue);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }

    100% {
        opacity: 1;
    }
}

/* =========================================
   MAIN CONTENT STYLES
   ========================================= */
main.grid-container,
main {
    flex: 1;
    margin-left: var(--sidebar-width);
    /* Push content right */
    padding: var(--space-5) 2rem;
    width: calc(100% - var(--sidebar-width));
    position: relative;
    z-index: 1;
    /* Above background */
}

main.grid-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: var(--space-5);
    align-content: start;
}

/* Typography Overrides */
h1,
h2,
h3,
h4,
h5 {
    font-family: var(--font-heading);
    text-transform: uppercase;
}

h1 {
    font-size: 5rem;
    margin-bottom: var(--space-4);
    text-shadow: 0 0 20px rgba(77, 163, 255, 0.3);
}

h2 {
    font-size: 3rem;
    color: var(--accent-blue);
    margin-top: var(--space-5);
    margin-bottom: var(--space-3);
}

section {
    margin-bottom: var(--space-6);
}

p,
.description {
    font-family: var(--font-body);
    font-weight: 300;
    color: #cbd5e1;
    line-height: 1.8;
    max-width: 65ch;
    margin-bottom: var(--space-3);
}

/* Buttons */
.explore-btn {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    width: auto;
    height: auto;
    padding: 1.5rem 3rem;
    border: 1px solid var(--accent-blue);
    border-radius: 0;
    background: rgba(77, 163, 255, 0.1);
    color: white;
    font-family: var(--font-heading);
    font-size: 1.2rem;
    letter-spacing: 4px;
    text-decoration: none;
    text-transform: uppercase;
    transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    position: relative;
    overflow: hidden;
    z-index: 1;
}

.explore-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 0%;
    height: 100%;
    background: var(--accent-blue);
    transition: width 0.4s ease;
    z-index: -1;
}

.explore-btn:hover::before {
    width: 100%;
}

.explore-btn:hover {
    box-shadow: 0 0 30px var(--accent-glow);
    color: #000;
    /* Contrast on hover */
}

.explore-btn::after {
    display: none;
    /* Remove old circle effect */
}


/* Cards & Glassmorphism */
.card,
.detail-card,
.deep-read-section,
.full-article {
    background: rgba(10, 15, 30, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(12px);
    border-radius: 4px;
    /* More angular, tech feel */
    transition: all 0.3s ease;
    padding: var(--space-4);
}

.card:hover,
.detail-card:hover {
    border-color: var(--accent-blue);
    box-shadow: 0 0 20px rgba(77, 163, 255, 0.2);
    transform: translateY(-5px);
}

/* Animations */
.animate-fade-in {
    opacity: 0;
    animation: fadeIn 1s ease-out forwards;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Hide Old Navigation if present in HTML */
.primary-header {
    display: none !important;
}

/* Mobile Responsive */
@media (max-width: 1024px) {
    body {
        flex-direction: column;
    }

    .cosmos-sidebar {
        width: 100%;
        height: auto;
        position: relative;
        border-right: none;
        border-bottom: 1px solid var(--sidebar-border);
    }

    .sidebar-nav {
        display: none;
        /* Add JS toggle for mobile later */
    }

    .sidebar-header {
        justify-content: space-between;
    }

    main.grid-container,
    main {
        margin-left: 0;
        width: 100%;
        padding: var(--space-4) 2rem;
    }
}

@media (max-width: 767px) {

    main.grid-container,
    main {
        padding: var(--space-4) 1rem;
    }

    main.grid-container {
        gap: var(--space-3);
    }

    .card,
    .detail-card,
    .deep-read-section,
    .full-article {
        padding: var(--space-4);
    }
}

/* =========================================================================
   WIKIPEDIA-STYLE CONCEPT PREVIEW MODAL
   ========================================================================= */
.concept-preview-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.concept-preview-modal.open {
    opacity: 1;
    visibility: visible;
}

.concept-preview-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(5, 8, 16, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.concept-preview-content {
    position: relative;
    background: rgba(12, 18, 33, 0.95);
    border: 1px solid rgba(0, 198, 255, 0.25);
    box-shadow: 0 15px 50px rgba(0, 0, 0, 0.8), 0 0 20px rgba(0, 198, 255, 0.15);
    border-radius: 16px;
    width: 90%;
    max-width: 650px;
    max-height: 90vh;
    overflow-y: auto;
    z-index: 100001;
    transform: scale(0.95) translateY(20px);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    flex-direction: column;
}

.concept-preview-modal.open .concept-preview-content {
    transform: scale(1) translateY(0);
}

.concept-preview-content::-webkit-scrollbar {
    width: 8px;
}

.concept-preview-content::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 0 16px 16px 0;
}

.concept-preview-content::-webkit-scrollbar-thumb {
    background: rgba(0, 198, 255, 0.3);
    border-radius: 4px;
}

.concept-preview-close {
    position: absolute;
    top: 15px;
    right: 15px;
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #fff;
    font-size: 1.5rem;
    cursor: pointer;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    z-index: 2;
}

.concept-preview-close:hover {
    background: rgba(0, 198, 255, 0.8);
    transform: rotate(90deg);
}

.concept-preview-body img {
    width: 100%;
    height: 280px;
    object-fit: cover;
    border-bottom: 2px solid rgba(0, 198, 255, 0.4);
    border-radius: 16px 16px 0 0;
    pointer-events: none;
}

.concept-preview-text {
    padding: 2.2rem;
}

.concept-preview-text h3 {
    margin: 0 0 1rem 0;
    color: #fff;
    font-family: 'Orbitron', sans-serif;
    font-size: 1.8rem;
    text-shadow: 0 2px 10px rgba(0, 198, 255, 0.3);
}

.concept-preview-text p {
    color: #d1d5db;
    line-height: 1.7;
    margin-bottom: 2rem;
    font-size: 1.05rem;
    text-align: left;
}

.concept-preview-btn {
    display: block;
    font-family: 'Orbitron', sans-serif;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #fff;
    background: linear-gradient(90deg, #00c6ff 0%, #0072ff 100%);
    padding: 1rem 1.5rem;
    border-radius: 8px;
    text-decoration: none;
    transition: opacity 0.3s, transform 0.2s, box-shadow 0.3s;
    text-align: center;
    box-shadow: 0 5px 15px rgba(0, 114, 255, 0.3);
}

.concept-preview-btn:hover {
    opacity: 0.95;
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 114, 255, 0.5);
}

/* Concept Link Styles for Inline Text */
.concept-link {
    color: #4facfe;
    text-decoration: none;
    border-bottom: 1px dashed rgba(79, 172, 254, 0.6);
    transition: all 0.2s ease;
    cursor: pointer;
    background-color: rgba(79, 172, 254, 0.08);
    padding: 0 4px;
    border-radius: 3px;
    font-weight: 500;
}

.concept-link:hover {
    color: #00c6ff;
    border-bottom: 1px solid #00c6ff;
    background-color: rgba(79, 172, 254, 0.18);
    text-shadow: 0 0 8px rgba(0, 198, 255, 0.4);
}