:root {
    --utd-red: #C00021; /* Slightly deeper red */
    --utd-dark-red: #A0001B;
    --utd-black: #1A1A1A; /* Softer black */
    --utd-gold: #FFD700; /* Classic gold */
    --white: #F8F9FA; /* Very light gray for backgrounds */
    --light-gray: #E9ECEF; /* Light background for cards/sections */
    --medium-gray: #6C757D; /* Standard text/border gray */
    --dark-gray: #343A40; /* Darker text/icon gray */
    --text-primary: #212529; /* Primary text color (darker for contrast) */
    --text-secondary: var(--medium-gray); /* Secondary text color */
    --border-color: #DEE2E6; /* Light border for subtle separation */
    --shadow: 0 6px 15px rgba(0,0,0,0.08); /* Softer, wider shadow */
    --shadow-hover: 0 10px 25px rgba(0,0,0,0.12);
    --border-radius: 10px; /* Slightly smaller radius for sleekness */
    --transition: all 0.3s ease-in-out; /* Smoother transitions */

    /* Article Reading Specifics (refined) */
    --article-line-height: 1.8; /* Increased for readability */
    --article-font-size: 1.15rem; /* Slightly larger base font */
    --article-heading-color: var(--utd-black);
    --article-text-color: var(--text-primary);
}

/* Deep Black Dark Theme */
[data-theme="dark"] {
    --white: #0A0A0A; /* Very dark background */
    --light-gray: #1A1A1A; /* Darker background for cards/sections */
    --dark-gray: #E0E0E0; /* Light text for dark mode */
    --medium-gray: #A0A0A0; /* Medium text for dark mode */
    --text-primary: #F0F0F0; /* Primary text color in dark mode (lighter for contrast) */
    --text-secondary: var(--medium-gray); /* Secondary text color in dark mode */
    --border-color: #333333; /* Darker border */
    --shadow: 0 6px 15px rgba(0,0,0,0.2); /* More prominent shadow in dark mode */
    --shadow-hover: 0 10px 25px rgba(0,0,0,0.3);

    --article-heading-color: var(--text-primary);
    --article-text-color: var(--text-secondary);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Newsreader', serif; /* Set Newsreader as the default for the entire body */
    background: var(--white);
    color: var(--text-primary); /* Ensures body text uses theme variable */
    line-height: 1.6;
    transition: background var(--transition), color var(--transition);
}

/* New class for when modal is open */
body.modal-open {
    overflow: hidden; /* Prevent background scrolling */
}

/* Header */
.header {
    background: var(--white);
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 1000;
    border-bottom: 3px solid var(--utd-red);
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    align-items: center;
    justify-content: space-between; /* Space out logo, brand text, and nav links */
    height: 70px;
}

.logo { /* This is the @UtdPaper_ with icon */
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 800; /* Newsreader's 800 weight will be used */
    font-size: 1.5rem;
    color: var(--utd-red);
    text-decoration: none;
}

.logo-img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
}

.logo-icon {
    font-size: 2rem;
    color: var(--utd-red);
}

.main-brand-text { /* New style for UTDPAPER text in nav container */
    font-family: 'Newsreader', serif; /* Use Newsreader */
    font-size: 1.8rem; /* Adjusted size */
    font-weight: 900; /* Make it bold (or 700 if 900 is too much) */
    color: var(--text-primary); /* Ensures brand text uses theme variable */
    margin-left: 20px; /* Space from the main logo */
    margin-right: auto; /* Push nav links to the right */
}

/* Responsive adjustment for main-brand-text */
@media (max-width: 768px) {
    .main-brand-text {
        display: none; /* Hide on smaller screens if too crowded */
    }
    .nav-container {
        justify-content: space-between; /* Adjust spacing if brand text is hidden */
    }
}


.nav-links {
    display: flex;
    gap: 2rem;
    list-style: none;
    align-items: center;
}

.nav-links a {
    text-decoration: none;
    color: var(--text-primary); /* Ensures nav links use theme variable */
    font-weight: 500;
    transition: var(--transition);
    padding: 8px 16px;
    border-radius: 8px;
}

.nav-links a:hover, .nav-links a.active {
    background: var(--utd-red);
    color: var(--white);
}

.theme-toggle {
    background: var(--light-gray);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    width: 60px;
    height: 30px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 5px;
    position: relative;
    overflow: hidden;
    transition: background var(--transition), border-color var(--transition);
}

.theme-toggle:hover {
    border-color: var(--utd-red);
}

.theme-toggle i {
    font-size: 1.2rem;
    color: var(--text-primary); /* Ensures toggle icon uses theme variable */
    position: absolute;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform var(--transition), background var(--transition), color var(--transition);
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

body[data-theme="dark"] .theme-toggle i {
    transform: translateX(30px);
    background: var(--utd-red);
    color: var(--white);
}

body[data-theme="dark"] .theme-toggle {
    background: var(--utd-dark-red);
    border-color: var(--utd-dark-red);
}

/* Breaking News Banner */
.breaking-banner {
    background: linear-gradient(135deg, var(--utd-red), var(--utd-dark-red));
    color: var(--white);
    padding: 12px 0;
    text-align: center;
    font-weight: 600;
    animation: pulse 2s infinite;
}

.breaking-banner-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
    text-align: center;
}

#breakingBannerLogo {
    height: 30px;
    width: 30px;
    object-fit: cover;
    border-radius: 50%;
    flex-shrink: 0;
}

#breakingBannerText {
    font-weight: 700;
    font-size: 1rem;
    white-space: nowrap;
}


/* Main Content Container Blur */
#pageWrapper.blurred-background {
    filter: blur(5px);
    pointer-events: none;
    user-select: none;
}


/* Main Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 25px;
}

/* Hero Section */
.hero {
    padding: 40px 0;
    background: linear-gradient(135deg, var(--light-gray) 0%, var(--white) 100%);
}

.hero-content {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 40px;
    align-items: start;
}

.featured-story {
    background: var(--white);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    transition: var(--transition);
}

.featured-story:hover {
    box-shadow: var(--shadow-hover);
    transform: translateY(-2px);
}

.featured-image {
    width: 100%;
    height: 300px;
    background: linear-gradient(45deg, var(--utd-red), var(--utd-dark-red));
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--white);
    font-size: 4rem;
    overflow: hidden;
}

.featured-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.featured-content {
    padding: 30px;
}

.tier-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--utd-red);
    color: var(--white);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 15px;
}

.featured-title {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 15px;
    line-height: 1.3;
    color: var(--text-primary); /* Ensures title uses theme variable */
}

.featured-excerpt {
    color: var(--text-secondary); /* Ensures excerpt uses theme variable */
    margin-bottom: 20px;
}

.read-more {
    background: var(--utd-red);
    color: var(--white);
    padding: 12px 24px;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 500;
    display: inline-block;
    transition: var(--transition);
}

.read-more:hover {
    background: var(--utd-dark-red);
    transform: translateY(-1px);
}

/* Pinned Posts */
.pinned-posts {
    background: var(--white);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    padding: 30px;
}

.section-title {
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 20px;
    color: var(--utd-red);
    display: flex;
    align-items: center;
    gap: 10px;
}

.pinned-item {
    padding: 15px 0;
    border-bottom: 1px solid var(--light-gray);
    transition: var(--transition);
    cursor: pointer;
    color: var(--text-primary); /* Ensures pinned item text uses theme variable */
    text-decoration: none; /* Ensure no underline on link */
}

.pinned-item:hover {
    background: var(--light-gray);
    margin: 0 -15px;
    padding: 15px;
    border-radius: 8px;
}

.pinned-item:last-child {
    border-bottom: none;
}

.pinned-title {
    font-weight: 600;
    margin-bottom: 8px;
    line-height: 1.4;
}

.pinned-meta {
    font-size: 0.85rem;
    color: var(--text-secondary); /* Ensures meta text uses theme variable */
    display: flex;
    align-items: center;
    gap: 15px;
}

/* Content Sections */
.content-grid {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 40px;
    margin: 40px 0;
}

.main-content {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

.content-section {
    background: var(--white);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    padding: 30px;
}

.tabs {
    display: flex;
    border-bottom: 2px solid var(--light-gray);
    margin-bottom: 25px;
}

.tab {
    padding: 12px 24px;
    background: none;
    border: none;
    cursor: pointer;
    font-weight: 500;
    color: var(--text-secondary); /* Ensures tab text uses theme variable */
    transition: var(--transition);
    border-bottom: 3px solid transparent;
}

.tab.active {
    color: var(--utd-red);
    border-bottom-color: var(--utd-red);
}

/* Match Centre Tab Content Styling */
.tab-content-group {
    display: none;/* This wrapper helps manage the display of individual tab contents */
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}


.news-item {
    display: flex;
    gap: 20px;
    padding: 20px 0;
    border-bottom: 1px solid var(--light-gray);
    transition: var(--transition);
    cursor: pointer;
    color: var(--text-primary); /* Ensures news item text uses theme variable */
    text-decoration: none; /* Ensure no underline on link */
}

.news-item:hover {
    background: var(--light-gray);
    margin: 0 -20px;
    padding: 20px;
    border-radius: 8px;
}

.news-item:last-child {
    border-bottom: none;
}

.news-image {
    width: 100px;
    height: 80px;
    background: linear-gradient(45deg, var(--utd-red), var(--utd-dark-red));
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--white);
    font-size: 4rem;
    overflow: hidden;
}

.news-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.news-content h3 {
    font-weight: 600;
    margin-bottom: 8px;
    line-height: 1.4;
}

.news-meta {
    font-size: 0.85rem;
    color: var(--text-secondary); /* Ensures meta text uses theme variable */
    margin-bottom: 8px;
}

.news-excerpt {
    font-size: 0.9rem;
    color: var(--text-secondary); /* Ensures excerpt text uses theme variable */
    line-height: 1.5;
}

/* Sidebar */
.sidebar {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

.widget {
    background: var(--white);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    padding: 25px;
}

.twitter-feed {
    height: 400px;
    background: var(--light-gray);
    border-radius: 8px;
    overflow: hidden;
    padding: 10px;
}

.newsletter {
    text-align: center;
}

.newsletter-input {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--border-color); /* Ensures border uses theme variable */
    border-radius: 8px;
    margin: 15px 0;
    font-size: 1rem;
    transition: var(--transition);
    background: var(--white); /* Ensures input background uses theme variable */
    color: var(--text-primary); /* Ensures input text uses theme variable */
}

.newsletter-input:focus {
    outline: none;
    border-color: var(--utd-red);
}
/* Placeholder color for newsletter input */
.newsletter-input::placeholder {
    color: var(--medium-gray);
    opacity: 1; /* Firefox default opacity can make it lighter */
}


.newsletter-btn {
    width: 100%;
    background: var(--utd-red);
    color: var(--white);
    padding: 12px;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.newsletter-btn:hover {
    background: var(--utd-dark-red);
}

/* Mobile Menu */
.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--dark-gray); /* Ensures mobile menu icon uses theme variable */
    cursor: pointer;
}

/* Responsive */
@media (max-width: 768px) {
    .nav-links {
        display: none;
    }
    
    .mobile-menu-btn {
        display: block;
    }
    
    .hero-content {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .content-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .tabs {
        overflow-x: auto;
        white-space: nowrap;
    }
    
    .news-item {
        flex-direction: column;
        gap: 15px;
    }
    
    .news-image {
        width: 100%;
        height: 200px;
    }
    
    .container {
        padding: 0 15px;
    }
    .main-brand-text {
        font-size: 1.5rem;
        margin-left: 10px;
    }
    .breaking-banner-content {
        flex-direction: column;
        gap: 5px;
    }
}

/* Footer */
.footer {
    background: var(--utd-black);
    color: var(--white);
    padding: 40px 0 20px;
    margin-top: 60px;
}

.footer-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 30px;
    margin-bottom: 30px;
}

.footer-section h3 {
    margin-bottom: 15px;
    color: var(--utd-red);
}

.footer-section a {
    color: var(--white); /* Ensures footer links use theme variable */
    text-decoration: none;
    display: block;
    margin-bottom: 8px;
    transition: var(--transition);
}

.footer-section a:hover {
    color: var(--utd-red);
}

.footer-bottom {
    text-align: center;
    padding-top: 20px;
    border-top: 1px solid var(--medium-gray); /* Ensures border uses theme variable */
    color: var(--medium-gray); /* Ensures copyright text uses theme variable */
}

/* Modal Styles */
.modal {
    display: none; /* Hidden by default */
    position: fixed; /* Stay in place */
    z-index: 2000; /* Sit on top */
    left: 0;
    top: 0;
    width: 100%; /* Full width */
    height: 100%; /* Full height */
    overflow: auto; /* Enable scroll if needed */
    background-color: rgba(0,0,0,0.7); /* Black w/ opacity */
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background-color: var(--white);
    margin: auto;
    padding: 40px;
    border-radius: var(--border-radius);
    width: 90%;
    max-width: 800px;
    box-shadow: var(--shadow-hover);
    position: relative;
    max-height: 90vh; /* Limit height for scrolling */
    overflow-y: auto; /* Enable scrolling within modal */
    animation: fadeInScale 0.3s ease-out;
}

@keyframes fadeInScale {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

.close-button {
    color: var(--text-primary); /* Ensures close button uses theme variable */
    font-size: 2.5rem;
    font-weight: bold;
    position: absolute;
    top: 10px;
    right: 20px;
    cursor: pointer;
    transition: color 0.2s ease;
}

.close-button:hover,
.close-button:focus {
    color: var(--utd-red);
    text-decoration: none;
}

.modal-title {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 1rem;
    color: var(--text-primary); /* Ensures title uses theme variable */
    line-height: 1.3;
}

.modal-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    font-size: 0.9rem;
    color: var(--text-secondary); /* Ensures meta text uses theme variable */
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--light-gray); /* Ensures border uses theme variable */
}

.modal-meta-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.modal-meta-item .tier-badge {
    margin-bottom: 0;
}

.modal-body {
    color: var(--article-text-color);
    line-height: var(--article-line-height);
    font-size: var(--article-font-size);
}

/* Styling for content within modal-body */
.modal-body p {
    margin-bottom: 1.25rem;
}

.modal-body h1,
.modal-body h2,
.modal-body h3,
.modal-body h4,
.modal-body h5,
.modal-body h6 {
    color: var(--article-heading-color);
    margin-top: 1.5rem;
    margin-bottom: 1rem;
    font-weight: 700;
    line-height: 1.2;
}

.modal-body h1 { font-size: 2.2rem; }
.modal-body h2 { font-size: 1.8rem; }
.modal-body h3 { font-size: 1.5rem; }
.modal-body h4 { font-size: 1.3rem; }
.modal-body h5 { font-size: 1.1rem; }
.modal-body h6 { font-size: 1rem; }


.modal-body img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 1rem auto;
    display: block;
}

.modal-body blockquote {
    border-left: 4px solid var(--utd-red);
    padding-left: 1.5rem;
    margin: 1.5rem 0;
    font-style: italic;
    color: var(--medium-gray); /* Ensures blockquote text uses theme variable */
    background-color: var(--light-gray); /* Ensures blockquote background uses theme variable */
    padding: 1rem 1.5rem;
    border-radius: 8px;
}

.modal-body ul, .modal-body ol {
    margin-left: 2rem;
    margin-bottom: 1.25rem;
    list-style-position: outside;
}

.modal-body li {
    margin-bottom: 0.5rem;
}

.modal-body a {
    color: var(--utd-red);
    text-decoration: underline;
}

/* Responsive adjustments for modal */
@media (max-width: 768px) {
    .modal-content {
        width: 95%;
        padding: 20px;
    }
    .modal-title {
        font-size: 1.5rem;
    }
    .close-button {
        font-size: 2rem;
        top: 5px;
        right: 10px;
    }
    .modal-body {
        font-size: 1rem;
    }
}

/* Article Page Specific Styles */
.article-page-container {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 40px;
    margin-top: 40px;
    margin-bottom: 60px;
}

.article-content-main {
    background: var(--white);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    padding: 2.5rem;
}

.article-detail-title {
    font-size: 2.5rem;
    font-weight: 800;
    line-height: 1.2;
    color: var(--article-heading-color);
    margin-bottom: 1rem;
}

.article-detail-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    font-size: 0.95rem;
    color: var(--text-secondary); /* Ensures meta text uses theme variable */
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--light-gray); /* Ensures border uses theme variable */
}

.article-detail-meta .meta-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.article-detail-meta .tier-badge {
    margin-bottom: 0;
}

.article-detail-thumbnail {
    width: 100%;
    height: auto;
    max-height: 450px;
    object-fit: cover;
    border-radius: var(--border-radius);
    margin-bottom: 2rem;
}

.article-detail-excerpt {
    font-size: 1.25rem;
    font-weight: 500;
    line-height: 1.6;
    color: var(--text-primary); /* Ensures excerpt text uses theme variable */
    margin-bottom: 2rem;
}

.article-detail-body {
    color: var(--article-text-color);
    line-height: var(--article-line-height);
    font-size: var(--article-font-size);
}

/* Styling for content within article-detail-body (similar to modal-body) */
.article-detail-body p {
    margin-bottom: 1.5rem;
}

.article-detail-body h1,
.article-detail-body h2,
.article-detail-body h3,
.article-detail-body h4,
.article-detail-body h5,
.article-detail-body h6 {
    color: var(--article-heading-color);
    margin-top: 2rem;
    margin-bottom: 1rem;
    font-weight: 700;
    line-height: 1.2;
}

.article-detail-body h1 { font-size: 2.2rem; }
.article-detail-body h2 { font-size: 1.8rem; }
.article-detail-body h3 { font-size: 1.5rem; }
.article-detail-body h4 { font-size: 1.3rem; }
.article-detail-body h5 { font-size: 1.1rem; }
.article-detail-body h6 { font-size: 1rem; }

.article-detail-body img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 1.5rem auto;
    display: block;
}

.article-detail-body blockquote {
    border-left: 4px solid var(--utd-red);
    padding-left: 1.5rem;
    margin: 1.5rem 0;
    font-style: italic;
    color: var(--medium-gray); /* Ensures blockquote text uses theme variable */
    background-color: var(--light-gray); /* Ensures blockquote background uses theme variable */
    padding: 1rem 1.5rem;
    border-radius: 8px;
}

.article-detail-body ul, .article-detail-body ol {
    margin-left: 2rem;
    margin-bottom: 1.5rem;
    list-style-position: outside;
}

.article-detail-body li {
    margin-bottom: 0.5rem;
}

.article-detail-body a {
    color: var(--utd-red);
    text-decoration: underline;
}


/* Suggested Articles Section */
.suggested-articles-section {
    background: var(--white);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    padding: 2.5rem;
    margin-top: 40px;
}

.suggested-articles-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 25px;
    margin-top: 20px;
}

.suggested-article-card {
    display: block;
    text-decoration: none;
    color: inherit;
    background: var(--background);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    transition: var(--transition);
}

.suggested-article-card:hover {
    box-shadow: var(--shadow-hover);
    transform: translateY(-3px);
}

.suggested-article-image {
    width: 100%;
    height: 160px;
    background: linear-gradient(45deg, var(--utd-red), var(--utd-dark-red));
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--white);
    font-size: 3rem;
    overflow: hidden;
}

.suggested-article-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.suggested-article-content {
    padding: 1rem;
}

.suggested-article-title {
    font-size: 1.1rem;
    font-weight: 600;
    line-height: 1.4;
    margin-bottom: 0.5rem;
    color: var(--text-primary); /* Ensures title uses theme variable */
}

.suggested-article-meta {
    font-size: 0.8rem;
    color: var(--text-secondary); /* Ensures meta text uses theme variable */
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
}

/* Responsive for Article Page */
@media (max-width: 768px) {
    .article-page-container {
        grid-template-columns: 1fr;
        padding: 0 15px;
    }

    .article-content-main {
        padding: 1.5rem;
    }

    .article-detail-title {
        font-size: 2rem;
    }

    .article-detail-excerpt {
        font-size: 1.1rem;
    }

    .article-detail-body {
        font-size: 1rem;
    }

    .suggested-articles-section {
        padding: 1.5rem;
    }

    .suggested-articles-grid {
        grid-template-columns: 1fr;
    }
}
