:root {
    --bg-color: #f4f4f9;
    --text-color: #333;
    --header-bg: #fff;
    --card-bg: #fff;
    --primary-color: #007bff;
    --accent-color: #ff4757;
    --border-color: #ddd;
    --ad-bg: #e0e0e0;
    --nav-text: #555;
    --nav-active: #007bff;
}

body.dark-mode {
    --bg-color: #121212;
    --text-color: #e0e0e0;
    --header-bg: #1e1e1e;
    --card-bg: #1e1e1e;
    --primary-color: #4dabf7;
    --accent-color: #ff6b6b;
    --border-color: #333;
    --ad-bg: #333;
    --nav-text: #ccc;
    --nav-active: #4dabf7;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    touch-action: manipulation;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    transition: background-color 0.3s, color 0.3s;
    overflow-x: hidden;
}

/* Header */
.site-header {
    background-color: var(--header-bg);
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.header-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.logo {
    font-family: 'Merriweather', serif;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-color);
    margin-left: 1.5rem; /* Indent logo and text */
}

.logo a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-img {
    height: 40px;
    width: auto;
    object-fit: contain;
}

.main-nav {
    display: flex;
    padding-left: 1rem;
    padding-right: 1rem;
}

.main-nav ul {
    list-style: none;
    display: flex;
    align-items: center;
}

.main-nav li {
    padding: 0 1rem;
    border-right: 1px solid var(--border-color);
    line-height: 1; /* Helps center the divider vertically relative to text */
}

.main-nav li:last-child {
    border-right: none;
    padding-right: 0;
}

.main-nav li:first-child {
    padding-left: 0;
}

.main-nav a {
    text-decoration: none;
    color: var(--nav-active);
    font-weight: 600;
    font-size: 0.95rem;
    transition: color 0.2s;
}

.main-nav a.active {
    color: var(--nav-text);
    font-weight: 800;
    font-size: 1.25rem;
}

.main-nav a:hover {
    color: var(--nav-text);
}

.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-color);
}

.theme-toggle {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.2rem;
    padding: 0.5rem;
    border-radius: 50%;
    transition: background-color 0.2s;
}

.theme-toggle:hover {
    background-color: var(--ad-bg);
}

/* Layout */
.layout-wrapper {
    display: flex;
    justify-content: center;
    max-width: 100%;
    margin-top: 2rem;
    padding: 0 1rem; /* minimal padding on small screens */
}

.main-content {
    flex: 0 1 800px; /* Grow 0, Shrink 1, Basis 800px */
    margin: 0 1rem;
    max-width: 800px;
    width: 100%;
}

.ad-space {
    flex: 0 0 200px; /* Fixed width for ads */
    display: none; /* Hidden on mobile by default */
}

.ad-placeholder {
    /*background-color: var(--ad-bg);*/
    color: var(--nav-text);
    height: 600px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    border-radius: 8px;
    position: sticky;
    top: 100px;
}

@media (min-width: 1250px) {
    .ad-space {
        display: block;
    }
}

/* Articles */
.article-card {
    background-color: var(--card-bg);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 2rem;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    transition: transform 0.2s;
}

.article-card:hover {
    transform: translateY(-2px);
}

/* feed ad placeholder behaves like article card */
.feed-ad {
    background-color: var(--card-bg);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 2rem;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    transition: transform 0.2s;
    /* height/width same as article; content empty by default */
    min-height: 200px; /* adjust as needed */
}

.feed-ad:hover {
    transform: translateY(-2px);
}

/* hide placeholder when it has no content */
.feed-ad:empty {
    display: none;
    margin: 0;
    padding: 0;
    height: 0;
}

.article-category {
    font-size: 0.75rem;
    text-transform: uppercase;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
    display: inline-block;
    text-decoration: none;
}

a.article-category:hover {
    opacity: 0.7;
}

.article-title {
    font-family: 'Merriweather', serif;
    font-size: 1.5rem;
    margin-bottom: 0.75rem;
    line-height: 1.4;
    color: var(--text-color);
}

.article-excerpt {
    font-size: 1rem;
    line-height: 1.6;
    color: var(--nav-text);
    margin-bottom: 1rem;
}

.read-more {
    text-decoration: none;
    color: var(--primary-color);
    font-weight: 600;
    font-size: 0.9rem;
}

.article-image {
    width: 100%;
    height: 250px;
    object-fit: cover;
    border-radius: 8px;
    margin-bottom: 1rem;
}

.article-source {
    font-size: 0.85rem;
    color: var(--nav-text);
    margin-top: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.article-source a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
}

.article-date {
    font-size: 0.85rem;
    color: var(--nav-text);
    white-space: nowrap;
}

.article-share {
    cursor: pointer;
    color: var(--primary-color);
    font-size: 0.85rem;
    user-select: none;
    transition: opacity 0.2s;
}

.article-share:hover {
    opacity: 0.7;
}

.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 240px;
    color: var(--nav-text);
    gap: 1rem;
}

.spinner {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary-color);
    animation: spin 0.9s linear infinite;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

/* Mobile Responsiveness */
@media (max-width: 1000px) {
    .header-container {
        padding: 0.75rem 1rem;
        justify-content: flex-start; /* Align items to start, we push logo left */
    }

    .logo {
        margin-right: auto; /* Pushes other items (toggle, menu) to the right */
        font-size: 1.1rem;
    }

    .theme-toggle {
        margin-right: 0.5rem; /* Space between toggle and burger */
    }

    .mobile-menu-btn {
        display: block;
    }


    .main-nav {
        display: block;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background-color: var(--header-bg);
        border-top: 1px solid var(--border-color);
        box-shadow: 0 4px 6px rgba(0,0,0,0.1);

        /* Animation State: Closed */
        opacity: 0;
        visibility: hidden;
        transform: translateY(-10px);
        pointer-events: none;

        /* Hardware Accelerated Transitions */
        transition: opacity 0.3s cubic-bezier(0.4, 0.0, 0.2, 1), 
                    transform 0.3s cubic-bezier(0.4, 0.0, 0.2, 1),
                    visibility 0.3s;
        will-change: opacity, transform;
    }

    .main-nav.open {
        /* Animation State: Open */
        opacity: 1;
        visibility: visible;
        transform: translateY(0);
        pointer-events: auto;
    }

    .main-nav ul {
        flex-direction: column;
        padding: 1rem;
        gap: 2rem;
    }

    .main-nav li {
        padding: 0;
        border-right: none;
    }

    .layout-wrapper {
        margin-top: 1rem;
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }

    .main-content {
        margin: 0;
    }
    
    .article-title {
        font-size: 1.25rem;
    }
}

/* Footer */
.site-footer {
    background-color: var(--header-bg);
    border-top: 1px solid var(--border-color);
    margin-top: 3rem;
    padding: 2rem 1rem;
    width: 100%;
}

.footer-container {
    max-width: 1200px;
    margin: 0 auto;
    text-align: center;
}

.footer-links {
    display: flex;
    justify-content: center;
    gap: 2rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.footer-links a {
    color: var(--nav-text);
    text-decoration: none;
    font-size: 0.95rem;
    transition: color 0.2s;
}

.footer-links a:hover {
    color: var(--nav-active);
}

.footer-copyright {
    color: var(--nav-text);
    font-size: 0.85rem;
    opacity: 0.8;
}

/* Text Page Formatting (Privacy, Imprint, Terms) */
.text-page {
    line-height: 1.6;
}

.text-page h1 {
    font-size: 2.2rem;
    margin-bottom: 2rem;
    color: var(--text-color);
}

.text-page h2 {
    font-size: 1.75rem;
    margin-top: 2.5rem;
    margin-bottom: 1.25rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--border-color);
    color: var(--text-color);
}

.text-page h3 {
    font-size: 1.4rem;
    margin-top: 2rem;
    margin-bottom: 1rem;
    color: var(--text-color);
}

.text-page h4 {
    font-size: 1.1rem;
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
    font-weight: 700;
    color: var(--text-color);
}

.text-page p {
    margin-bottom: 1rem;
    color: var(--text-color);
}

.text-page ul {
    margin-bottom: 1.5rem;
    padding-left: 2rem;
}

.text-page li {
    margin-bottom: 0.5rem;
    color: var(--text-color);
}

.text-page a {
    color: var(--primary-color);
    text-decoration: underline;
}

.text-page a:hover {
    text-decoration: none;
}

/* Cookie Banner */
#cookie-banner {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 600px;
    background-color: var(--card-bg);
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.2);
    z-index: 2000;
    display: none; /* Hidden by default */
    border: 1px solid var(--border-color);
    flex-direction: column;
    gap: 1rem;
}

#cookie-banner.show {
    display: flex;
}

.cookie-content h3 {
    margin-bottom: 0.5rem;
    color: var(--text-color);
}

.cookie-content p {
    font-size: 0.9rem;
    color: var(--nav-text);
    line-height: 1.5;
}

.cookie-actions {
    display: flex;
    gap: 1rem;
    align-items: center;
    justify-content: flex-end;
}

.cookie-btn {
    padding: 0.5rem 1rem;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-weight: 600;
    transition: opacity 0.2s;
}

.cookie-btn.accept {
    background-color: var(--primary-color);
    color: #fff;
}

.cookie-btn.reject {
    background-color: transparent;
    border: 1px solid var(--border-color);
    color: var(--nav-text);
}

.cookie-btn:hover {
    opacity: 0.9;
}

#cookie-settings-link {
    cursor: pointer;
}

/* Lightbox */
.lightbox {
    display: none;
    position: fixed;
    z-index: 3000;
    padding-top: 50px;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.9);
}

.lightbox-content {
    margin: auto;
    display: block;
    width: 80%;
    max-width: 1000px;
    max-height: 90vh;
    object-fit: contain;
}

/* Social Media Icons */
.social-c-icons {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 24px;
    padding: 30px 0;
    width: 100%;
    margin-top: 20px;
}

.social-c-icons a {
    display: block;
    transition: transform 0.2s ease;
}

.social-c-icons a:hover {
    transform: translateY(-3px);
}

.social-icon {
    width: 32px;
    height: 32px;
    display: block;
}

/* Dark mode adjustments */
body.dark-mode .social-icon {
    filter: invert(1);
}

.lightbox-close {
    position: absolute;
    top: 15px;
    right: 35px;
    color: #f1f1f1;
    font-size: 40px;
    font-weight: bold;
    transition: 0.3s;
    cursor: pointer;
}

.lightbox-close:hover,
.lightbox-close:focus {
    color: #bbb;
    text-decoration: none;
    cursor: pointer;
}

.article-image {
    cursor: pointer;
}

/* Pull to Refresh */
.pull-to-refresh {
    position: fixed;
    top: 80px; /* Below header */
    left: 0;
    width: 100%;
    height: 50px;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 900;
    pointer-events: none;
    transform: translateY(-150%);
    transition: transform 0.2s cubic-bezier(0,0,0.2,1);
}

.ptr-content {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--card-bg); /* Use card-bg to match theme */
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    color: var(--text-color);
}

.ptr-arrow {
    font-size: 20px;
    color: var(--primary-color);
    transition: transform 0.3s;
}

.pull-to-refresh.pulling .ptr-arrow {
    transform: rotate(180deg);
}

.ptr-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: ptr-spin 0.8s linear infinite;
    display: none;
}

.pull-to-refresh.refreshing .ptr-spinner {
    display: block;
}

.pull-to-refresh.refreshing .ptr-arrow {
    display: none;
}

@keyframes ptr-spin {
    to { transform: rotate(360deg); }
}

/* Prevent native pull-to-refresh on supported browsers */
body {
    overscroll-behavior-y: contain;
}

/* Mobile Lightbox Adjustments */
@media (max-width: 1000px) {
    .lightbox {
        padding-top: 80px;
    }

    .lightbox-content {
        width: 100%;
    }

    .lightbox-close {
        top: 20px;
        right: 20px;
    }
}

/* Article Detail View */
.article-back-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35em;
    margin-bottom: 1rem;
    margin-left: 0.5rem;
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.95rem;
    line-height: 1.4;
    transition: opacity 0.2s;
}

.article-back-btn::before {
    content: '';
    display: inline-block;
    width: 0.45em;
    height: 0.45em;
    border-left: 0.13em solid currentColor;
    border-bottom: 0.13em solid currentColor;
    transform: rotate(45deg);
    flex-shrink: 0;
}

.article-back-btn:hover {
    opacity: 0.7;
}

.article-detail .article-title {
    font-size: 1.5rem;
    margin-bottom: 1rem;
}

.article-detail .article-excerpt {
    font-size: 1rem;
    line-height: 1.7;
}

/* Clickable article titles in feed */
.article-detail-link {
    color: inherit;
    text-decoration: none;
    transition: color 0.2s;
}

.article-detail-link:hover {
    color: var(--primary-color);
}

/* Fade-in for article content */
.content-fade-in {
    animation: fadeInContent 0.35s ease-out both;
}

@keyframes fadeInContent {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}