/* ==========================================================================
   CSS Variables & Theming
   ========================================================================== */
   :root {
    /* Light Theme (Default) */
    --bg-color: #f4f7f6;
    --text-color: #333333;
    --card-bg: #ffffff;
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --secondary-text: #6b7280;
    --border-color: #e5e7eb;
    --header-bg: #ffffff;
    --footer-bg: #1f2937;
    --footer-text: #f3f4f6;
    
    /* Layout */
    --max-width: 1200px;
    --spacing: 1.5rem;
    --border-radius: 8px;
    --box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --transition: all 0.3s ease;
}

[data-theme="dark"] {
    --bg-color: #111827;
    --text-color: #f9fafb;
    --card-bg: #1f2937;
    --primary-color: #3b82f6;
    --primary-hover: #60a5fa;
    --secondary-text: #9ca3af;
    --border-color: #374151;
    --header-bg: #1f2937;
    --footer-bg: #111827;
    --box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.5);
}

/* ==========================================================================
   Reset & Base Styles
   ========================================================================== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    transition: background-color var(--transition), color var(--transition);
}

a {
    color: var(--primary-color);
    text-decoration: none;
    transition: color 0.2s;
}

a:hover {
    color: var(--primary-hover);
}

ul {
    list-style: none;
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

.container {
    width: 100%;
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 1rem;
}

.card {
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    transition: background-color var(--transition), border-color var(--transition);
}

.btn {
    display: inline-block;
    background-color: var(--primary-color);
    color: #fff;
    padding: 0.5rem 1.5rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
    text-align: center;
    transition: background-color 0.2s;
}
.btn:hover {
    background-color: var(--primary-hover);
    color: #fff;
}

/* ==========================================================================
   Header & Navigation
   ========================================================================== */
.site-header {
    background-color: var(--header-bg);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 1000;
    transition: background-color var(--transition);
}

.header-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 70px;
}

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
}

.main-nav {
    display: flex;
    align-items: center;
    gap: 2rem;
}

.main-nav ul {
    display: flex;
    gap: 1.5rem;
}

.main-nav a {
    color: var(--text-color);
    font-weight: 500;
}

.main-nav a:hover, .main-nav a.active {
    color: var(--primary-color);
}

.nav-actions {
    display: flex;
    gap: 0.5rem;
}

.icon-btn {
    background: none;
    border: none;
    color: var(--text-color);
    cursor: pointer;
    padding: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s;
}
.icon-btn:hover {
    background-color: var(--border-color);
}

/* Mobile Menu Toggle */
.mobile-menu-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
}

.hamburger {
    display: block;
    width: 24px;
    height: 2px;
    background-color: var(--text-color);
    position: relative;
    transition: background-color 0.2s;
}
.hamburger::before, .hamburger::after {
    content: '';
    position: absolute;
    width: 24px;
    height: 2px;
    background-color: var(--text-color);
    left: 0;
    transition: transform 0.2s;
}
.hamburger::before { top: -6px; }
.hamburger::after { top: 6px; }

/* Search Overlay */
.search-overlay {
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    background-color: var(--header-bg);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 0;
    z-index: 999;
}
.search-overlay.hidden {
    display: none;
}
.search-form {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}
.search-form input {
    flex: 1;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background-color: var(--bg-color);
    color: var(--text-color);
}
.btn-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-color);
}

/* ==========================================================================
   Layout (Main + Sidebar)
   ========================================================================== */
.layout-wrapper {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 2rem;
    padding-top: 2rem;
    padding-bottom: 2rem;
}

/* Hero Section */
.hero-section {
    text-align: center;
    padding: 3rem 1rem;
    background-color: var(--card-bg);
    border-radius: var(--border-radius);
    margin-bottom: 2rem;
    border: 1px solid var(--border-color);
}
.hero-section h1 {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    color: var(--primary-color);
}

/* Article List */
.article-list h2 {
    margin-bottom: 1.5rem;
    border-bottom: 2px solid var(--primary-color);
    display: inline-block;
    padding-bottom: 0.5rem;
}

.article-card {
    display: flex;
    flex-direction: column;
}
.entry-title {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
}
.entry-meta {
    font-size: 0.875rem;
    color: var(--secondary-text);
    margin-bottom: 1rem;
}
.entry-summary {
    margin-bottom: 1rem;
}
.read-more {
    font-weight: 600;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 2rem;
    align-items: center;
}
.btn-page {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background-color: var(--card-bg);
    color: var(--text-color);
}
.btn-page:hover:not(.disabled) {
    background-color: var(--primary-color);
    color: #fff;
    border-color: var(--primary-color);
}
.btn-page.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
.current-page {
    padding: 0.5rem 1rem;
    background-color: var(--primary-color);
    color: #fff;
    border-radius: 4px;
}

/* Sidebar Widgets */
.widget h3 {
    margin-bottom: 1rem;
    font-size: 1.1rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.5rem;
}
.widget-popular ul li {
    margin-bottom: 0.5rem;
    border-bottom: 1px dashed var(--border-color);
    padding-bottom: 0.5rem;
}
.widget-popular ul li:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

/* ==========================================================================
   Static Pages (About, Contact, Privacy, etc.)
   ========================================================================== */
.page-layout {
    grid-template-columns: 1fr; /* Single column for static pages by default */
    max-width: 800px;
}
.page-content h1 {
    margin-bottom: 1.5rem;
    color: var(--primary-color);
}
.page-content h2 {
    margin: 1.5rem 0 1rem;
}
.page-content p {
    margin-bottom: 1rem;
}
.page-content ul {
    list-style: disc;
    margin-left: 1.5rem;
    margin-bottom: 1rem;
}
.breadcrumb {
    margin-bottom: 1rem;
    font-size: 0.875rem;
    color: var(--secondary-text);
}
.breadcrumb ol {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.breadcrumb li:not(:last-child)::after {
    content: "/";
    margin-left: 0.5rem;
}

/* Form Styles */
.form-group {
    margin-bottom: 1rem;
}
.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
}
.form-group input, .form-group textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: inherit;
}
.form-group input:focus, .form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
}

/* ==========================================================================
   AdSense Placeholders
   ========================================================================== */
.ad-placeholder {
    background-color: #e5e7eb;
    border: 1px dashed #9ca3af;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: #6b7280;
    font-size: 0.875rem;
    margin-bottom: 1.5rem;
    padding: 1rem;
}
[data-theme="dark"] .ad-placeholder {
    background-color: #374151;
    border-color: #4b5563;
    color: #9ca3af;
}

.ad-top { min-height: 90px; }
.ad-infeed { min-height: 250px; }
.ad-sidebar { min-height: 250px; margin-bottom: 1.5rem; }
.ad-footer { min-height: 90px; margin-bottom: 0; border: none; border-top: 1px dashed var(--border-color); background: transparent; }

/* ==========================================================================
   Footer
   ========================================================================== */
.site-footer {
    background-color: var(--footer-bg);
    color: var(--footer-text);
    padding: 2rem 0;
    margin-top: 2rem;
}
.footer-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}
.footer-links {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1rem;
}
.footer-links a {
    color: var(--footer-text);
    opacity: 0.8;
}
.footer-links a:hover {
    opacity: 1;
    color: #fff;
}
.copyright {
    font-size: 0.875rem;
    opacity: 0.7;
}

/* ==========================================================================
   Utilities
   ========================================================================== */
.back-to-top {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background-color: var(--primary-color);
    color: #fff;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s, background-color 0.2s;
    z-index: 99;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}
.back-to-top.visible {
    opacity: 1;
    visibility: visible;
}
.back-to-top:hover {
    background-color: var(--primary-hover);
}

#reading-progress {
    position: fixed;
    top: 70px; /* Below header */
    left: 0;
    width: 0%;
    height: 3px;
    background-color: var(--primary-color);
    z-index: 999;
    transition: width 0.1s;
}

/* ==========================================================================
   Responsive Design (Mobile First Approach Additions)
   ========================================================================== */

/* Tablet & Smaller (Max 1024px) */
@media (max-width: 1024px) {
    .layout-wrapper {
        grid-template-columns: 1fr 250px;
    }
}

/* Mobile (Max 768px) */
@media (max-width: 768px) {
    .layout-wrapper {
        grid-template-columns: 1fr;
    }
    
    .mobile-menu-toggle {
        display: block;
    }

    .main-nav {
        position: absolute;
        top: 70px;
        left: 0;
        width: 100%;
        background-color: var(--header-bg);
        flex-direction: column;
        align-items: flex-start;
        padding: 1rem;
        border-bottom: 1px solid var(--border-color);
        box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1);
        display: none;
    }
    
    .main-nav.active {
        display: flex;
    }

    .main-nav ul {
        flex-direction: column;
        width: 100%;
        gap: 0;
    }

    .main-nav ul li {
        width: 100%;
        border-bottom: 1px solid var(--border-color);
    }
    
    .main-nav ul li a {
        display: block;
        padding: 1rem 0;
    }

    .nav-actions {
        width: 100%;
        padding-top: 1rem;
        justify-content: flex-start;
    }
    
    .hero-section h1 {
        font-size: 1.75rem;
    }
}

/* Small Mobile (Max 412px) */
@media (max-width: 412px) {
    .hero-section h1 {
        font-size: 1.5rem;
    }
    .footer-links {
        flex-direction: column;
        align-items: center;
        gap: 0.5rem;
    }
}
