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

:root {
    --primary-color: #003d82;
    --secondary-color: #e30613;
    --text-color: #333;
    --light-bg: #f5f5f5;
    --border-color: #ddd;
    --bg-color: #fff;
    --card-bg: #fff;
    --header-bg: #003d82;
    --meta-color: #666;
    --preview-color: #555;
}

@media (prefers-color-scheme: dark) {
    :root {
        --primary-color: #5eb3ff;
        --text-color: #ffffff;
        --light-bg: #2a2a2a;
        --border-color: #444;
        --bg-color: #1a1a1a;
        --card-bg: #242424;
        --header-bg: #1a1a1a;
        --meta-color: #aaa;
        --preview-color: #ccc;
    }
}

* {
    box-sizing: border-box;
}

html {
    overflow-x: hidden;
    width: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: var(--text-color);
    background-color: var(--bg-color);
    overflow-x: hidden;
    width: 100%;
    max-width: 100vw;
    margin: 0;
    padding: 0;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header */
header {
    background-color: transparent;
    color: var(--text-color);
    padding: 1rem 0;
    box-shadow: none;
    border-bottom: 1px solid var(--border-color);
}

header h1 {
    font-size: 1.8rem;
    margin-bottom: 0.3rem;
}

header h1 a {
    color: inherit;
    text-decoration: none;
}

/* Desktop Navigation */
#desktop-nav {
    display: flex;
    gap: 1rem;
    margin-top: 0.5rem;
    flex-wrap: wrap;
    align-items: center;
    line-height: 1.4;
}

#desktop-nav a {
    color: #666;
    text-decoration: none;
    padding: 0.3rem 0;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
    white-space: nowrap;
    font-size: 0.9rem;
}

#desktop-nav a:hover,
#desktop-nav a.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

/* Mobile Menu Button */
#mobile-menu-btn-show {
    display: none;
    background: none;
    border: none;
    color: var(--text-color);
    font-size: 1.8rem;
    cursor: pointer;
    padding: 0.5rem;
    margin-top: 0.5rem;
    transition: transform 0.2s ease;
}

#mobile-menu-btn-show:hover {
    transform: scale(1.1);
}

#mobile-menu-btn-show:active {
    transform: scale(0.95);
}

/* Mobile Navigation Popover */
#mobile-nav {
    display: none;
    flex-direction: column;
    flex-wrap: nowrap;
    gap: 0;
    position: fixed;
    top: 0;
    right: 0;
    height: 100vh;
    width: 85%;
    max-width: 320px;
    background: var(--card-bg);
    border: none;
    padding: 0;
    margin: 0;
    inset: unset;
    overflow-y: auto;
    overflow-x: hidden;
    box-shadow: -2px 0 20px rgba(0, 0, 0, 0.5);
    -webkit-overflow-scrolling: touch;
}

#mobile-nav:popover-open {
    display: flex;
}

#mobile-nav::backdrop {
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
}

.mobile-nav-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 1.5rem 1rem 1.5rem;
    background: var(--primary-color);
    color: white;
    border-bottom: 3px solid var(--secondary-color);
}

.mobile-nav-header h2 {
    font-size: 1.5rem;
    margin: 0;
}

#mobile-menu-btn-close {
    background: none;
    border: none;
    color: white;
    font-size: 2rem;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    line-height: 1;
    transition: transform 0.2s ease;
}

#mobile-menu-btn-close:hover {
    transform: scale(1.1);
}

#mobile-menu-btn-close:active {
    transform: scale(0.95);
}

#mobile-nav a {
    color: var(--text-color);
    text-decoration: none;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #e0e0e0;
    font-size: 1rem;
    transition: background-color 0.2s ease;
    display: block;
    width: 100%;
    box-sizing: border-box;
    flex-shrink: 0;
}

#mobile-nav a:hover {
    background-color: #f5f5f5;
}

#mobile-nav a:active {
    background-color: #e8e8e8;
}

#mobile-nav a.active {
    background-color: #f0f7ff;
    color: var(--primary-color);
    font-weight: 600;
}

#mobile-nav a:last-child {
    border-bottom: none;
}

/* Responsive Behavior */
@media (max-width: 1024px) {
    #desktop-nav {
        display: none;
    }
    
    #mobile-menu-btn-show {
        display: block;
    }
}

/* Main */
main {
    padding: 3rem 0;
    min-height: 70vh;
}

#homeView {
    padding-top: 1rem;
}

@media (max-width: 768px) {
    main {
        padding: 1rem 1rem;
    }
    
    #homeView {
        padding-top: 0.5rem;
    }
}

/* Loading */
.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 0;
}

.loading.hidden {
    display: none;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Articles Grid */
.articles-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 2rem;
    margin-top: 2rem;
}

.article-card {
    background: transparent;
    border: none;
    border-bottom: 1px solid #e8e8e8;
    border-right: 1px solid #e8e8e8;
    border-radius: 0;
    overflow: visible;
    transition: opacity 0.2s;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    padding-bottom: 1.5rem;
    padding-right: 1.5rem;
}

.article-card:hover {
    opacity: 0.85;
}

.article-image {
    width: 100%;
    aspect-ratio: 16 / 9;
    background-color: var(--light-bg);
    display: flex;
    align-items: flex-end;
    justify-content: flex-start;
    color: #999;
    font-size: 3rem;
    position: relative;
    overflow: hidden;
    margin-bottom: 1rem;
}

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

.article-content {
    padding: 0;
}

.article-meta {
    display: flex;
    align-items: center;
    gap: 0;
    font-size: 0.85rem;
    color: var(--meta-color);
    margin-bottom: 0.75rem;
}

.article-type {
    background-color: var(--primary-color);
    color: white;
    font-size: 0.75rem;
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 0.8px;
    padding: 0.4rem 0.8rem;
    display: inline-block;
}

/* Only position absolutely when inside article-image */
.article-image .article-type {
    position: absolute;
    bottom: 0.75rem;
    left: 0.75rem;
    z-index: 2;
}

/* Category above title on desktop */
.article-category {
    font-size: 0.75rem;
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 0.8px;
    color: var(--primary-color);
    margin-bottom: 0.3rem;
}

/* Show/hide category based on context */
.mobile-only {
    display: none !important;
}

.desktop-only {
    display: block;
}

.image-badge {
    display: inline-block;
}

.live-badge {
    background-color: #e74c3c;
    color: white;
    padding: 0.3rem 0.7rem;
    border-radius: 0;
    font-size: 0.4rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    position: absolute;
    top: 0.4rem;
    left: 0.4rem;
    z-index: 2;
}

.article-badge {
    position: absolute;
    top: 0.5rem;
    left: 0.5rem;
    z-index: 2;
}

@keyframes pulse-red {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}

.liveblog-card {
    /* Red border removed for cleaner design */
}

.article-title {
    font-size: 1.4rem;
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 0.75rem;
    line-height: 1.4;
}

.article-title a {
    color: inherit;
    text-decoration: none;
}

.article-title a:hover {
    color: inherit;
}

.article-preview {
    font-size: 0.95rem;
    color: var(--preview-color);
    line-height: 1.6;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.article-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.article-author {
    font-size: 0.85rem;
    color: #666;
    font-style: italic;
}

.article-source {
    font-size: 0.85rem;
    color: #999;
}

.article-date {
    font-size: 0.85rem;
    color: #666;
}

/* Load More Button */
.load-more-container {
    text-align: center;
    margin: 3rem 0;
}

.load-more-btn {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 1rem 2rem;
    font-size: 1rem;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s;
}

.load-more-btn:hover {
    background-color: #002d5f;
}

.load-more-btn:disabled {
    background-color: #ccc;
    cursor: not-allowed;
}

.load-more-btn.hidden {
    display: none;
}

/* Footer */
footer {
    background-color: var(--light-bg);
    border-top: 1px solid var(--border-color);
    padding: 2rem 0;
    text-align: center;
    color: #666;
}

/* Responsive */
@media (max-width: 768px) {
    .articles-grid {
        grid-template-columns: 1fr;
        gap: 0;
    }

    nav {
        flex-wrap: wrap;
        gap: 1rem;
    }

    header h1 {
        font-size: 1.5rem;
    }
    
    .article-card {
        display: flex;
        flex-direction: row;
        border: none;
        border-bottom: 1px solid var(--border-color);
        border-radius: 0;
        background: transparent;
        padding: 1rem 0;
        align-items: flex-start;
    }
    
    .article-card:hover {
        transform: none;
        box-shadow: none;
    }
    
    .article-image {
        width: 25%;
        min-width: 25%;
        aspect-ratio: 320 / 200;
        border-radius: 0;
        margin-right: 1rem;
        flex-shrink: 0;
        overflow: hidden;
        position: relative;
    }
    
    .article-image img {
        border-radius: 0;
        object-fit: cover;
        width: 100%;
        height: 100%;
    }
    
    .article-content {
        padding: 0;
        flex: 1;
        display: flex;
        flex-direction: column;
        justify-content: flex-start;
        min-width: 0;
    }
    
    .article-meta {
        display: flex;
        flex-wrap: wrap;
        gap: 0;
        row-gap: 0.4rem;
        margin-bottom: 0.4rem;
        order: -1;
    }
    
    .article-badge {
        position: absolute;
        top: 0.4rem;
        left: 0.4rem;
        font-size: 0.65rem;
        padding: 0.2rem 0.5rem;
        text-transform: uppercase;
        font-weight: 700;
        letter-spacing: 0.3px;
        white-space: nowrap;
        z-index: 1;
    }
    
    .article-type {
        font-size: 0.7rem;
        text-transform: uppercase;
        font-weight: 700;
        letter-spacing: 0.5px;
        color: var(--primary-color);
        margin-bottom: 0;
        display: inline-block;
        vertical-align: middle;
        line-height: 1;
        background: none;
        padding: 0;
    }
    
    .article-type::after {
        content: "•";
        color: var(--primary-color);
        margin: 0 0.4rem;
        font-size: 0.6rem;
        vertical-align: middle;
        position: relative;
        top: -0.1em;
    }
    
    /* Show mobile category, hide desktop category */
    .mobile-only {
        display: inline-block !important;
    }
    
    .desktop-only {
        display: none !important;
    }
    
    .article-card h2 {
        font-size: 1rem;
        line-height: 1.35;
        margin: 0.3rem 0 0.4rem 0;
        font-weight: 400;
    }
    
    .article-preview {
        display: none;
    }
    
    .article-author {
        display: none;
    }
    
    .article-meta-info {
        display: none;
    }
    
    .article-source {
        display: none;
    }
    
    .article-time {
        font-size: 0.7rem;
        color: var(--meta-color);
        display: inline-block;
        vertical-align: middle;
        line-height: 1;
    }
    
    .article-meta {
        margin-bottom: 0.3rem;
    }
    
    .liveblog-entry {
        padding: 0.75rem;
    }
}

/* Error Message */
.error-message {
    background-color: #fee;
    border: 1px solid #fcc;
    border-radius: 5px;
    padding: 1rem;
    margin: 2rem 0;
    color: #c33;
}

/* Article View */
#articleView {
    max-width: 800px;
    margin: 0 auto;
    padding: 2rem 0;
}

.back-btn {
    background-color: var(--light-bg);
    border: 1px solid var(--border-color);
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    border-radius: 5px;
    cursor: pointer;
    margin-bottom: 2rem;
    transition: background-color 0.3s;
}

.back-btn:hover {
    background-color: #e5e5e5;
}

.article-full {
    background: transparent;
    padding: 0;
    border-radius: 0;
    margin-top: 1rem;
    margin-bottom: 5rem;
}

.article-full a,
.article-full a:link,
.article-full a:visited {
    color: inherit !important;
    text-decoration: underline !important;
}

.article-header {
    margin-bottom: 2rem;
    margin-left: auto;
    margin-right: auto;
    padding: 0 0.5rem;
    max-width: 800px;
}

.article-category {
    color: var(--primary-color);
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.5rem;
}

.article-full-title {
    font-size: 2.8rem;
    line-height: 1.15;
    margin-bottom: 1.25rem;
    color: var(--text-color);
    font-weight: 600;
}

.article-lead {
    font-size: 1.25rem;
    line-height: 1.6;
    color: #666;
    margin-bottom: 1.25rem;
    font-weight: 400;
}

.article-meta-info {
    display: flex;
    flex-wrap: wrap;
    gap: 0;
    align-items: center;
    font-size: 0.85rem;
    color: #666;
    padding-bottom: 1.5rem;
    border-bottom: none;
    margin-bottom: 2rem;
    line-height: 1.4;
}

.article-meta-info > * {
    margin-right: 0.5rem;
}

.article-meta-info > *:not(:last-child)::after {
    content: "";
    display: inline-block;
    width: 3px;
    height: 3px;
    background-color: #999;
    border-radius: 50%;
    margin-left: 0.5rem;
    vertical-align: middle;
}

.article-full-image {
    width: 100%;
    max-width: 800px;
    margin: 0 auto 1.5rem auto;
    display: block;
}

.article-full-image img {
    width: 100%;
    max-width: 100%;
    max-height: 600px;
    height: auto;
    border-radius: 0;
    display: block;
    object-fit: cover;
}

.article-full-image figcaption {
    font-size: 0.85rem;
    color: #666;
    margin-top: 0.5rem;
    font-style: italic;
}

.article-body {
    font-size: 1.1rem;
    line-height: 1.8;
    color: var(--text-color);
    padding: 0 0.5rem 3rem 0.5rem;
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
}

.article-body:empty {
    display: none;
}

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

.article-body p {
    margin-bottom: 1.5rem;
    line-height: 1.7;
}

.article-body p:last-child {
    margin-bottom: 0;
}

.article-body a,
.article-body a:link,
.article-body a:visited,
.entry-content a,
.entry-content a:link,
.entry-content a:visited {
    color: inherit !important;
    text-decoration: underline !important;
}

.article-body a:hover,
.entry-content a:hover {
    opacity: 0.7;
}

.article-body blockquote {
    border-left: 4px solid var(--primary-color);
    padding-left: 1.5rem;
    margin: 2rem 0;
    font-style: italic;
    color: #555;
}

.hidden {
    display: none;
}

/* Responsive Article View */
@media (max-width: 768px) {
    .article-full {
        padding: 0.25rem;
        margin-top: 0.5rem;
    }
    
    .article-header {
        max-width: 100%;
        padding: 0 1rem;
        margin-bottom: 1.5rem;
        margin-left: 0;
        margin-right: 0;
    }
    
    .article-category {
        font-size: 0.75rem;
        margin-bottom: 0.75rem;
    }

    .article-full-title {
        font-size: 1.85rem;
        line-height: 1.25;
        margin-bottom: 1rem;
    }

    .article-lead {
        font-size: 1.1rem;
        line-height: 1.5;
        margin-bottom: 1rem;
    }
    
    .article-meta-info {
        font-size: 0.85rem;
        flex-direction: column;
        align-items: flex-start;
        gap: 0.35rem;
        padding-bottom: 1rem;
    }
    
    .article-meta-info > * {
        margin-right: 0;
    }
    
    .article-meta-info > *::after {
        display: none;
    }

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

    #articleView {
        padding: 4rem 0 1rem 0;
    }
    
    .article-body:empty {
        padding: 0;
        margin: 0;
    }
    
    .liveblog-entries {
        margin-top: 1rem;
        padding-top: 1rem;
    }
    
    .article-full-image {
        max-width: 100%;
        margin-left: 0;
        margin-right: 0;
    }
    
    .article-body img {
        margin-left: 0;
        margin-right: 0;
    }
}

/* Section headers on home page */
.section-header {
    grid-column: 1 / -1;
    margin: 2rem 0 1rem 0;
    padding-bottom: 0.5rem;
    border-bottom: 3px solid var(--primary-color);
    color: var(--primary-color);
    font-size: 1.5rem;
    font-weight: 600;
}

.section-header:first-child {
    margin-top: 1.5rem;
}

/* Liveblog entries */
.liveblog-entries {
    margin-top: 2rem;
    margin-left: auto;
    margin-right: auto;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
    max-width: 800px;
    padding-left: 0.5rem;
    padding-right: 0.5rem;
}

.liveblog-entries h2 {
    color: var(--text-color);
    margin-bottom: 1rem;
    font-size: 1.8rem;
}

.liveblog-entry {
    background: transparent;
    border-top: 1px solid var(--border-color);
    padding: 1.5rem 1rem;
    margin-bottom: 0;
}

.liveblog-entry h3 {
    color: var(--text-color);
    margin-top: 0;
    margin-bottom: 0.5rem;
    font-size: 1.3rem;
}

.liveblog-entry p {
    margin-bottom: 1.2rem;
    line-height: 1.6;
}

.liveblog-entry p:last-child {
    margin-bottom: 0;
}

.liveblog-entry .entry-time {
    color: var(--meta-color);
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.liveblog-entry .entry-content {
    line-height: 1.7;
}

.liveblog-entry .entry-content img {
    max-width: 100%;
    max-height: 500px;
    height: auto;
    display: block;
    margin: 1rem auto;
    border-radius: 4px;
    object-fit: contain;
}

.liveblog-entry .entry-content p:first-child {
    margin-top: 0;
}

.liveblog-entry .entry-content p:last-child {
    margin-bottom: 0;
}

