/* ==========================================================================
   CSS Variables & Base Styles
   ========================================================================== */

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

html {
  scroll-padding-top: 100px; /* Adjust based on your header height */
}

:root {
    --primary-color: #2563eb;
    --secondary-color: #64748b;
    --accent-color: #f59e0b;
    --text-dark: #1f2937;
    --text-light: #6b7280;
    --bg-light: #f8fafc;
    --white: #ffffff;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --reading-width: 65ch;
}

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

/* ==========================================================================
   Header & Navigation
   ========================================================================== */

header {
    background: var(--white);
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 1000;
}

nav {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}


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

.logo a {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: inherit;
    text-decoration: none;
}

.logo img {
    width: 30px;
    height: 30px;
}

.nav-menu {
    display: flex;
    list-style: none;
    gap: 2rem;
}

.nav-menu a {
    text-decoration: none;
    color: var(--text-dark);
    font-weight: 500;
    transition: color 0.3s ease;
}

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

.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-dark);
}

.mobile-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--white);
    box-shadow: var(--shadow);
    padding: 1rem 2rem;
}

.mobile-menu.show {
    display: block;
}

.mobile-menu ul {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.mobile-menu a {
    text-decoration: none;
    color: var(--text-dark);
    font-weight: 500;
    padding: 0.5rem 0;
    border-bottom: 1px solid #e5e7eb;
}

/* ==========================================================================
   Hero Section (Home Page)
   ========================================================================== */

.hero {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: var(--white);
    padding: 4rem 2rem;
    text-align: center;
}

.hero-content {
    max-width: 800px;
    margin: 0 auto;
}

.hero h1 {
    font-size: 3rem;
    margin-bottom: 1rem;
    font-weight: 700;
}

.hero p {
    font-size: 1.25rem;
    margin-bottom: 2rem;
    opacity: 0.9;
}

.cta-button {
    display: inline-block;
    background: var(--accent-color);
    color: var(--white);
    padding: 1rem 2rem;
    text-decoration: none;
    border-radius: 8px;
    font-weight: 600;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.cta-button:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

/* ==========================================================================
   Main Content (Home Page)
   ========================================================================== */

main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 4rem 2rem;
}

.section {
    margin-bottom: 4rem;
}

.section h2 {
    font-size: 2.5rem;
    margin-bottom: 2rem;
    text-align: center;
    color: var(--primary-color);
}

/* Recent Updates (Home Page) */
.updates-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
    margin-top: 2rem;
}

.update-card {
    background: var(--white);
    border-radius: 12px;
    padding: 2rem;
    box-shadow: var(--shadow);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.update-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
}

.update-date {
    color: var(--text-light);
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.update-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text-dark);
}

.update-excerpt {
    color: var(--text-light);
    line-height: 1.6;
}

/* Features Grid (Home Page) */
.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2rem;
    margin-top: 2rem;
}

.feature-card {
    text-align: center;
    padding: 2rem;
    background: var(--bg-light);
    border-radius: 12px;
    transition: transform 0.3s ease;
}

.feature-card:hover {
    transform: translateY(-5px);
}

.feature-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.feature-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--primary-color);
}

.feature-description {
    color: var(--text-light);
}

/* ==========================================================================
   Article Layout (Article Pages)
   ========================================================================== */

.article-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
    display: grid;
    grid-template-columns: 250px 1fr;
    gap: 3rem;
    align-items: start;
}

/* Table of Contents Sidebar */
.toc-sidebar {
    position: sticky;
    top: 120px;
    background: var(--bg-light);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

.toc-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--primary-color);
}

.toc-list {
    list-style: none;
}

.toc-list li {
    margin-bottom: 0.5rem;
}

.toc-list a {
    text-decoration: none;
    color: var(--text-light);
    font-size: 0.9rem;
    transition: color 0.3s ease;
    display: block;
    padding: 0.25rem 0;
}

.toc-list a:hover,
.toc-list a.active {
    color: var(--primary-color);
    font-weight: 500;
}

.toc-list .toc-level-2 {
    padding-left: 1rem;
}

.toc-list .toc-level-3 {
    padding-left: 2rem;
}

/* Article Content */
.article-content {
    max-width: var(--reading-width);
}

/* Article Header */
.article-header {
    margin-bottom: 3rem;
    padding-bottom: 2rem;
    border-bottom: 2px solid #e5e7eb;
}

.article-meta {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
    font-size: 0.9rem;
    color: var(--text-light);
}

.article-category {
    background: var(--primary-color);
    color: var(--white);
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
}

.article-title {
    font-size: 2.5rem;
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: 1rem;
    color: var(--text-dark);
}

.article-subtitle {
    font-size: 1.25rem;
    color: var(--text-light);
    font-weight: 400;
    line-height: 1.4;
}

/* Article Typography */
.article-body {
    line-height: 1.7;
}

.article-body h2 {
    font-size: 1.75rem;
    font-weight: 600;
    margin: 2.5rem 0 1rem 0;
    color: var(--primary-color);
    line-height: 1.3;
}

.article-body h3 {
    font-size: 1.4rem;
    font-weight: 600;
    margin: 2rem 0 1rem 0;
    color: var(--text-dark);
    line-height: 1.3;
}

.article-body h4 {
    font-size: 1.2rem;
    font-weight: 600;
    margin: 1.5rem 0 0.75rem 0;
    color: var(--text-dark);
}

.article-body p {
    margin-bottom: 1.5rem;
    line-height: 1.8;
    font-size: 1.1rem;
}

.article-body ul,
.article-body ol {
    margin-bottom: 1.5rem;
    padding-left: 2rem;
}

.article-body li {
    margin-bottom: 0.5rem;
    line-height: 1.7;
}

.article-body blockquote {
    margin: 2rem 0;
    padding: 1.5rem;
    background: var(--bg-light);
    border-left: 4px solid var(--primary-color);
    border-radius: 0 8px 8px 0;
    font-style: italic;
    color: var(--text-light);
}

.article-body code {
    background: #f1f5f9;
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    color: var(--primary-color);
}

.article-body pre {
    background: #1e293b;
    color: #e2e8f0;
    padding: 1.5rem;
    border-radius: 8px;
    overflow-x: auto;
    margin: 1.5rem 0;
}

.article-body pre code {
    background: none;
    padding: 0;
    color: inherit;
}

/* Article Images */
.article-image {
    margin: 2rem 0;
    text-align: center;
}

.article-image img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.article-image figcaption {
    margin-top: 0.75rem;
    font-size: 0.9rem;
    color: var(--text-light);
    font-style: italic;
}

/* Reading Progress Bar */
.progress-bar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: rgba(37, 99, 235, 0.1);
    z-index: 1001;
}

.progress-fill {
    height: 100%;
    background: var(--primary-color);
    transition: width 0.1s ease;
}

/* Pagination */
.article-pagination {
    margin-top: 4rem;
    padding-top: 2rem;
    border-top: 2px solid #e5e7eb;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.pagination-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem 1.5rem;
    background: var(--primary-color);
    color: var(--white);
    text-decoration: none;
    border-radius: 8px;
    font-weight: 500;
    transition: all 0.3s ease;
}

.pagination-btn:hover {
    background: #1d4ed8;
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.pagination-btn.disabled {
    background: #e5e7eb;
    color: var(--text-light);
    cursor: not-allowed;
    transform: none;
}

.pagination-info {
    color: var(--text-light);
    font-size: 0.9rem;
    text-align: center;
    flex-basis: 100%;
}

/* Author Bio */
.author-bio {
    margin-top: 3rem;
    padding: 2rem;
    background: var(--bg-light);
    border-radius: 12px;
    display: flex;
    gap: 1.5rem;
    align-items: center;
}

.author-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--white);
    font-size: 2rem;
    font-weight: bold;
    flex-shrink: 0;
}

.author-info h4 {
    margin-bottom: 0.5rem;
    color: var(--text-dark);
}

.author-info p {
    color: var(--text-light);
    margin: 0;
    line-height: 1.6;
}

/* Related Articles */
.related-articles {
    margin-top: 4rem;
    padding-top: 2rem;
    border-top: 2px solid #e5e7eb;
}

.related-title {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    color: var(--primary-color);
}

.related-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
}

.related-card {
    background: var(--white);
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: var(--shadow);
    transition: transform 0.3s ease;
}

.related-card:hover {
    transform: translateY(-3px);
}

.related-card h5 {
    margin-bottom: 0.5rem;
    font-size: 1.1rem;
}

.related-card a {
    text-decoration: none;
    color: var(--text-dark);
}

.related-card p {
    color: var(--text-light);
    font-size: 0.9rem;
    margin: 0;
}

/* ==========================================================================
   Footer
   ========================================================================== */

footer {
    background: var(--text-dark);
    color: var(--white);
    padding: 3rem 2rem 1rem;
    margin-top: 4rem;
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2rem;
}

.footer-section h3 {
    margin-bottom: 1rem;
    color: var(--accent-color);
}

.footer-section a {
    color: #d1d5db;
    text-decoration: none;
    display: block;
    margin-bottom: 0.5rem;
    transition: color 0.3s ease;
}

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

.footer-bottom {
    text-align: center;
    padding-top: 2rem;
    margin-top: 2rem;
    border-top: 1px solid #374151;
    color: #9ca3af;
}

/* ==========================================================================
   Animation Classes
   ========================================================================== */

.fade-in {
    animation: fadeIn 0.6s ease-in-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.loading {
    opacity: 0.5;
    pointer-events: none;
}

/* ==========================================================================
   Responsive Design
   ========================================================================== */

@media (max-width: 1024px) {
    .article-container {
        grid-template-columns: 1fr;
        gap: 2rem;
    }

    .toc-sidebar {
        position: static;
        order: -1;
    }
}

@media (max-width: 768px) {
    .nav-menu {
        display: none;
    }

    .mobile-menu-btn {
        display: block;
    }

    .hero h1 {
        font-size: 2rem;
    }

    .hero p {
        font-size: 1rem;
    }

    nav {
        padding: 1rem;
    }

    main {
        padding: 2rem 1rem;
    }

    .article-container {
        padding: 2rem;
        margin-top: 1rem;
    }

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

    .article-body h2 {
        font-size: 1.5rem;
    }

    .article-body h3 {
        font-size: 1.3rem;
    }

    .author-bio {
        flex-direction: column;
        text-align: center;
    }

    .pagination-btn {
        flex: 1;
        justify-content: center;
    }
}
