:root {
    --primary-color: rgb(21, 21, 27);
    --border-color: rgb(85, 85, 85);
    --accent-color: rgb(140, 140, 255);
    --text-gray: rgb(180, 180, 180);
    --card-bg: rgb(30, 30, 36);
    --card-border: rgb(60, 60, 70);
}

html {
    box-sizing: border-box;
    overflow-x: hidden;
    width: 100%;
    height: 100%;
}

body {
    background-color: var(--primary-color);
    color: white;
    margin: 0;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    font-family:'Courier New', Courier, monospace;
    overflow-x: hidden;
}

main {
    flex: 1;
    display: flex;
    width: 100%;
    flex-direction: column;
    align-items: center;
    overflow-y: auto;
    overflow-x: hidden;
    padding-bottom: 2rem;
    position: relative;
    z-index: 1; /* Lower z-index for main content */
    justify-content: center;
}

nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 2rem;
    max-width: 100vw;
}

.nav-logo {
    margin: 0.5rem 0;
}

.nav-logo img {
    max-height: 50px;
    width: auto;
}

.nav-buttons {
    display: flex;
    gap: 3rem;
    font-size: 1.1rem;
    align-items: center;
    font-family:'Courier New', Courier, monospace;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.nav-buttons a {
    color: white;
    text-decoration: none;
    padding: 0.5rem 0;
}

.nav-buttons a:hover {
    text-decoration: underline;
}

.fontawesome {
    font-size: 1.6rem;
}

header {
    position: sticky;
    top: 0;
    z-index: 1000; /* Higher z-index for header */
    padding: 0.5rem;
    background-color: var(--primary-color);
    border-bottom: 1px solid var(--border-color);
    width: 100%;
}

footer {
    margin-top: auto;
    width: 100%;
    position: relative;
    z-index: 1000; /* Higher z-index for footer */
    box-sizing: border-box;
}

.footer-text {
    text-align: center;
    border-top: 1px solid var(--border-color);
    color: var(--text-gray);
    margin: 0;
    padding: 0.8rem;
    font-family:'Courier New', Courier, monospace;
    width: 100%;
}


/* Article Page Specific Styles */
.article-page {
    max-width: 900px;
    margin: 0 auto;
    padding: 2rem;
}

.article-header {
    text-align: center;
    margin-bottom: 2rem;
}

.article-header h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    line-height: 1.2;
}

.article-meta {
    color: var(--text-gray);
    font-size: 1rem;
    display: flex;
    justify-content: center;
    gap: 1.5rem;
}

.article-hero {
    margin-bottom: 2rem;
    border-radius: 8px;
    overflow: hidden;
    height: 500px;
    border: 1px solid var(--card-border);
}

.article-hero img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    max-width: 100%;
    transform-style: preserve-3d;
    backface-visibility: hidden;
    will-change: transform;
}

.article-content {
    font-size: 1.1rem;
    line-height: 1.8;
}

.article-content p {
    margin-bottom: 1.5rem;
}

.article-content h2 {
    margin-top: 2.5rem;
    margin-bottom: 1rem;
    font-size: 1.8rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.5rem;
    line-height: 1.2;
}

.article-image-container {
    margin: 2rem 0;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--card-border);
    height: 400px;
}

.article-image-container img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
    max-width: 100%;
    max-height: 100%;
    transform-style: preserve-3d;
    backface-visibility: hidden;
    will-change: transform;
}

.image-caption {
    font-size: 0.9rem;
    color: var(--text-gray);
    text-align: center;
    padding: 0.8rem;
    margin: 0;
    background-color: var(--card-bg);
}

.article-content ul, .article-content ol {
    margin-bottom: 1.5rem;
    padding-left: 1.5rem;
}

.article-content li {
    margin-bottom: 0.5rem;
}

.full-width {
    margin-left: -2rem;
    margin-right: -2rem;
    width: calc(100% + 4rem);
    height: 500px;
}

.article-closing {
    margin-top: 3rem;
    padding: 1.5rem;
    background-color: var(--card-bg);
    border-radius: 8px;
    border: 1px solid var(--card-border);
}

.article-closing a {
    color: var(--accent-color);
    text-decoration: none;
}

.article-closing a:hover {
    text-decoration: underline;
}

.article-navigation {
    display: flex;
    justify-content: space-between;
    margin: 3rem 0;
    padding-top: 2rem;
    border-top: 1px solid var(--border-color);
}

.nav-previous, .nav-next {
    max-width: 45%;
}

.nav-label {
    display: block;
    font-size: 0.9rem;
    color: var(--text-gray);
    margin-bottom: 0.5rem;
}

.article-navigation a {
    color: var(--accent-color);
    text-decoration: none;
    font-weight: bold;
}

.article-navigation a:hover {
    text-decoration: underline;
}

/* Related Articles */
.related-articles {
    /*margin-top: 4rem;*/
    padding-top: 2rem;
    /*border-top: 1px solid var(--border-color);*/
}

.related-articles h3 {
    text-align: center;
    margin-bottom: 2rem;
}

.related-container {
    display: flex;
    gap: 2rem;
    justify-content: center;
}

.related-article-link {
    width: 45%;
    text-decoration: none;
    color: inherit;
    display: block;
    transition: transform 0.3s ease;
}

.related-article-link:hover {
    transform: translateY(-5px);
    text-decoration: none;
}

.related-article {
    background-color: var(--card-bg);
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--card-border);
    height: 100%;
    display: flex;
    flex-direction: column;
    transition: border-color 0.3s ease;
}

.related-article-link:hover .related-article {
    border-color: var(--accent-color);
}

.related-article img {
    width: 100%;
    height: 200px;
    object-fit: cover;
    max-width: 100%;
    max-height: 100%;
    transform-style: preserve-3d;
    backface-visibility: hidden;
    will-change: transform;
}

.related-article h4 {
    padding: 1rem 1rem 0.5rem;
    margin: 0;
}

.read-link {
    display: block;
    padding: 0 1rem 1rem;
    color: var(--accent-color);
    font-weight: bold;
    margin-top: auto;
}

.related-article-link:hover .read-link {
    text-decoration: underline;
}


/* Mobile menu toggle button */
.menu-toggle {
    display: none;
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
}



/* Core fixes to apply to all screen sizes */
.article-page {
    box-sizing: border-box;
    width: 100%;
}

.article-content {
    box-sizing: border-box;
    width: 100%;
}



/* Extra large screens */
@media screen and (min-width: 1921px) {
    .articles-container {
        max-width: 1800px;
    }
    
    .article-image {
        height: 400px;
    }
}

@media screen and (max-width: 1400px) {
    .nav-logo img {
        width: 80%;
    }
    
    .nav-buttons {
        gap: 2rem;
    }
}

/* Medium-sized screens */
@media screen and (max-width: 1200px) {
    .articles-container {
        max-width: 1000px;
    }
    
    .article-title {
        font-size: 1.6rem;
    }
    
    .article-excerpt {
        font-size: 1rem;
    }
    
    .article-hero {
        height: 450px;
    }
    
    .full-width {
        height: 450px;
    }

    .article-content {
        padding: 1.5rem;
        width: 100%;
        max-width: 100%;
    }
    
    .article-page {
        width: 100%; /* Ensure it uses full width */
        max-width: 100%; /* Override the max-width temporarily */
        padding: 2rem;
        margin: 0 auto;
    }
}

/* Responsive breakpoints */
@media screen and (max-width: 1024px) {
    .nav-buttons {
        gap: 1.5rem;
    }
    
    nav {
        padding: 0 1rem;
    }
}

/* Tablet and smaller screens */
@media screen and (max-width: 900px) {
    .articles-container {
        width: 95%;
        max-width: 800px;
    }
    
    .article-card {
        flex-direction: column;
    }
    
    .article-image, .article-content {
        width: 100%;
    }
    
    .article-image {
        height: 300px;
    }
    
    .article-content {
        padding: 1.5rem;
        width: 100%;
        max-width: 100%;
    }
    
    .article-page {
        width: 100%; /* Ensure it uses full width */
        max-width: 100%; /* Override the max-width temporarily */
        padding: 1rem;
        margin: 0 auto;
    }
    
    .article-header h1 {
        font-size: 2rem;
    }
    
    .article-hero {
        height: 350px;
    }
    
    .article-image-container {
        height: 300px;
    }
    
    .full-width {
        margin-left: -1rem;
        margin-right: -1rem;
        width: calc(100% + 2rem);
        height: 350px;
    }
    
    .article-navigation {
        flex-direction: column;
        gap: 1.5rem;
    }
    
    .nav-previous, .nav-next {
        max-width: 100%;
    }
    
    .related-article-link {
        width: 48%;
    }
}

/* Threshold for menu toggle button */
@media screen and (max-width: 840px) {
    /* Menu toggle button becomes visible */
    .menu-toggle {
        display: block;
    }
    
    /* Navigation buttons become a dropdown */
    .nav-buttons {
        position: fixed;
        top: var(--header-height, 0); /* Use CSS variable for header height */
        left: 0;
        right: 0;
        background-color: var(--primary-color);
        flex-direction: column;
        align-items: center;
        padding: 1rem 0;
        gap: 1rem;
        border-bottom: 1px solid var(--border-color);
        transform: translateY(-100%);
        opacity: 0;
        transition: transform 0.3s ease, opacity 0.3s ease;
        pointer-events: none;
    }
    
    .nav-buttons.active {
        transform: translateY(0);
        opacity: 1;
        pointer-events: all;
    }
    
    .nav-buttons a {
        width: 100%;
        text-align: center;
        padding: 0.5rem 0;
    }
}

/* Mobile phones */
@media screen and (max-width: 600px) {
    nav {
        padding-left: 1rem;
        padding-right: 1rem;
    }
    
    .article-title {
        font-size: 1.3rem;
    }
    
    .article-excerpt {
        font-size: 0.95rem;
    }
    
    .article-image {
        height: 220px;
    }
    
    .article-header h1 {
        font-size: 1.8rem;
    }
    
    .article-meta {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .article-hero {
        height: 250px;
    }
    
    .article-page {
        max-width: 100%;
        padding-left: 1rem;
        padding-right: 1rem;
        margin: 0 auto;
    }
    
    .article-content {
        font-size: 1rem;
        padding: 1rem;
        max-width: 100%;
    }
    
    .article-content h2 {
        font-size: 1.5rem;
    }
    
    .article-image-container {
        height: 200px;
    }
    
    .full-width {
        height: 250px;
    }
    
    .related-container {
        flex-direction: column;
    }
    
    .related-article-link {
        width: 100%;
        margin-bottom: 1.5rem;
    }

    footer {
        width: 100%; /* Explicit full width */
        left: 0;
        right: 0;
        padding: 0.8rem 0; /* Maintain vertical padding only */
    }
}

@media screen and (max-width: 480px) {
    .nav-logo img {
        width: 60%;
    }
    
    .nav-logo {
        margin: 0.25rem 0;
    }
    
    nav {
        padding: 0 0.5rem;
    }
    
    .text-overlay {
        padding: 0.5rem;
        width: 90%;
        font-size: 0.9rem;
    }
    
    .footer-text {
        font-size: 0.8rem;
    }
}