@import url('https://fonts.googleapis.com/css2?family=Lora:ital,wght@0,400;0,700;1,400&display=swap');

/* /blog/css/blog.css */

/* ==========================================================================
   Blog General & Shared Styles
   ========================================================================== */

body {
    font-family: 'Inter', sans-serif;
    font-size: 18px; /* Increased base font size */
    line-height: 1.7; /* Increased line height */
}

:root {
    --blog-accent-color: #007bff;
    --blog-text-color: var(--text-primary);
    --blog-meta-color: var(--text-secondary);
    --blog-card-bg: var(--background-secondary);
    --blog-card-shadow: 0 4px 8px rgba(0, 0, 0, 0.05);
    --blog-card-hover-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
    --blog-code-bg: #f4f4f8;
    --blog-code-text: #333;
    --blog-border-color: var(--border-color);
}

[data-theme="dark"] {
    --blog-accent-color: #4dabf7;
    --blog-code-bg: #2e2e3e;
    --blog-code-text: #e0e0e0;
}

.blog-section {
    padding: 4rem 0;
    max-width: 1200px;
    margin: 0 auto;
}

.blog-container {
    padding: 0 2rem;
    background-color: var(--background-primary);
    border-radius: 12px;
    padding-top: 2rem;
    padding-bottom: 2rem;
}


/* Blog Home Page: Post Grid */

.blog-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 2rem;
    margin-top: 2rem;
}

.post-card {
    background-color: var(--blog-card-bg);
    border-radius: 12px;
    overflow: hidden;
    text-decoration: none;
    color: var(--blog-text-color);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    border: 1px solid var(--blog-border-color);
    display: flex;
    flex-direction: column;
}

.post-card:hover {
    transform: translateY(-5px) scale(1.02);
    box-shadow: var(--blog-card-hover-shadow);
}

.post-card-thumbnail {
    width: 100%;
    height: 200px; /* Fixed height for regular post thumbnails */
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-color: var(--border-color); /* Placeholder color */
}

.post-card-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    border-radius: inherit;
}

.post-card-content {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.post-card-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0 0 0.75rem 0;
    color: var(--text-primary);
}

.post-card-excerpt {
    font-size: 1rem;
    line-height: 1.6;
    margin-bottom: 1rem;
    flex-grow: 1;
}

.post-card-meta {
    display: flex;
    justify-content: space-between;
    font-size: 0.875rem;
    color: var(--blog-meta-color);
    margin-top: auto;
}

.post-card-tags,
.blog-post-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 1rem;
}

.tag-badge {
    background-color: var(--background-tertiary);
    color: var(--text-secondary);
    padding: 0.4em 0.8em;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 500;
    text-transform: capitalize;
}


/* ==========================================================================
   Blog Post Page: Article Styles
   ========================================================================== */

.scroll-progress-bar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background-color: var(--blog-accent-color);
    transform-origin: left;
    transform: scaleX(0);
    transition: transform 0.1s linear;
    z-index: 1000;
}

.blog-post-container {
    display: flex;
    justify-content: center;
    gap: 2rem;
    padding: 2rem;
}

.blog-post-article {
    max-width: 960px; /* Increased from 840px for wider reading area */
    width: 100%;
}

.blog-post-header {
    margin-bottom: 2.5rem;
    border-bottom: 1px solid var(--blog-border-color);
    padding-bottom: 1.5rem;
}

.blog-post-title {
    font-size: 2.8rem;
    font-weight: 800;
    line-height: 1.2;
    margin-bottom: 1rem;
}

.blog-post-meta {
    color: var(--blog-meta-color);
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    font-size: 0.9rem;
}

.blog-post-content {
    font-family: 'Lora', serif;
    font-size: 1.15rem;
    line-height: 1.8;
}

.blog-post-content h2 {
    font-family: 'Inter', sans-serif; /* Keep headings in Inter */
    font-size: 2rem;
    font-weight: 700;
    margin-top: 3rem;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--blog-border-color);
}

.blog-post-content h3 {
    font-family: 'Inter', sans-serif; /* Keep headings in Inter */
    font-size: 1.5rem;
    font-weight: 600;
    margin-top: 2.5rem;
    margin-bottom: 1rem;
}

.blog-post-content p {
    margin-bottom: 1.25rem;
}

.blog-post-content a {
    color: var(--blog-accent-color);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: border-bottom 0.2s ease;
}

.blog-post-content a:hover {
    border-bottom-color: var(--blog-accent-color);
}

.blog-post-content blockquote {
    margin: 2rem 0;
    padding: 1rem 1.5rem;
    border-left: 4px solid var(--blog-accent-color);
    background-color: var(--blog-card-bg);
    font-style: italic;
}

.blog-post-content pre {
    background-color: var(--blog-code-bg);
    color: var(--blog-code-text);
    padding: 1.5rem;
    border-radius: 8px;
    overflow-x: auto;
    font-family: 'Fira Code', 'Courier New', monospace;
    font-size: 0.95rem;
    line-height: 1.6;
}

.blog-post-content code {
    font-family: 'Fira Code', 'Courier New', monospace;
    background-color: var(--blog-code-bg);
    padding: 0.2em 0.4em;
    border-radius: 4px;
    font-size: 0.9em;
}

.blog-post-content pre code {
    padding: 0;
    background: none;
    font-size: inherit;
}

/* Table of Contents (TOC) */
.toc-container {
    position: sticky;
    top: 100px;
    width: 280px;
    height: calc(100vh - 120px);
    overflow-y: auto;
    padding-left: 1.5rem;
    border-left: 1px solid var(--blog-border-color);
}

.toc-container h3 {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

.toc-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.toc-list li a {
    display: block;
    padding: 0.5rem 0;
    color: var(--blog-meta-color);
    text-decoration: none;
    font-size: 0.9rem;
    border-left: 2px solid transparent;
    padding-left: 1rem;
    transition: all 0.2s ease;
}

.toc-list li a:hover {
    color: var(--text-primary);
    background-color: var(--blog-card-bg);
}

.toc-list li a.active {
    color: var(--blog-accent-color);
    font-weight: 600;
    border-left-color: var(--blog-accent-color);
}


main {
    flex-grow: 1;
}

/* ==========================================================================
   Tag Filter Section
   ========================================================================== */
.tag-filter-section {
    margin-bottom: 3rem;
    padding: 0 2rem;
}

.tag-filter-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.tag-filter-header h3 {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.tag-cloud {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.tag-button {
    background-color: var(--background-tertiary);
    color: var(--text-secondary);
    padding: 0.6em 1.2em;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid var(--blog-border-color);
    transition: all 0.2s ease;
}

.tag-button:hover {
    background-color: var(--blog-accent-color);
    color: white;
    border-color: var(--blog-accent-color);
}

.tag-button.active {
    background-color: var(--blog-accent-color);
    color: white;
    border-color: var(--blog-accent-color);
    font-weight: 600;
}

.clear-filter-btn {
    background: none;
    border: none;
    color: var(--blog-accent-color);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: color 0.2s ease;
}

.clear-filter-btn:hover {
    text-decoration: underline;
}

/* ==========================================================================
   Featured Post Section
   ========================================================================== */
.featured-post-section {
    margin-bottom: 3rem;
    grid-column: 1 / -1; /* Make section span full grid width */
}

.featured-post-card {
    display: grid; /* Use Grid for more complex layout */
    grid-template-columns: 40% 1fr; /* 40% for image, rest for content */
    grid-template-rows: auto 1fr; /* Auto for title, rest for content */
    background-color: var(--background-card);
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--blog-border-color);
    box-shadow: var(--blog-card-shadow);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    align-items: center; /* Vertically align content */
    text-decoration: none; /* Ensure the card itself acts as a clean link */
    color: inherit; /* Inherit text color */
}

.featured-post-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--blog-card-hover-shadow);
}

.featured-post-title {
    grid-column: 1 / -1; /* Make title span both columns */
    padding: 1.5rem 2rem 1rem;
    font-size: 2.2rem;
    font-weight: 800;
    line-height: 1.2;
    color: var(--text-primary);
    margin-bottom: 1.25rem;
}

.featured-post-thumbnail {
    grid-row: 2; /* Place thumbnail in the second row */
    grid-column: 1;
    aspect-ratio: 1200 / 630;
    background-color: var(--border-color);
    background-size: cover;
    background-position: center;
    border-radius: 12px 0 0 12px; /* Rounded corner bottom-left */
}

.featured-post-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.featured-post-content {
    grid-row: 2; /* Place content in the second row */
    grid-column: 2;
    padding: 1.5rem 2rem 2rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between; /* Distribute content vertically */
}

.featured-badge {
    display: inline-block;
    align-self: flex-start;
    background-color: var(--blog-accent-color);
    color: white;
    padding: 0.4em 0.8em;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

.featured-post-excerpt {
    font-size: 1.1rem;
    line-height: 1.6;
    color: var(--blog-meta-color);
    margin-bottom: 2rem;
}

.featured-post-meta {
    display: flex;
    gap: 1rem;
    font-size: 0.9rem;
    color: var(--blog-meta-color);
}

.featured-post-button {
    margin-top: 2rem;
    align-self: flex-start;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background-color: var(--blog-accent-color);
    color: white;
    padding: 0.8rem 1.5rem;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    font-size: 1rem;
    transition: background-color 0.2s ease, transform 0.2s ease;
}

.featured-post-button:hover {
    background-color: var(--primary-dark);
    transform: translateY(-2px);
}

/* ==========================================================================
   Search Bar Styles
   ========================================================================== */
.search-container {
    max-width: 600px;
    margin: 0 auto 3rem auto;
    position: relative;
}

.search-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.search-input {
    width: 100%;
    padding: 0.8rem 1rem 0.8rem 3rem;
    border: 1px solid var(--blog-border-color);
    border-radius: 8px;
    background-color: var(--background-card);
    color: var(--text-primary);
    font-size: 1rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.search-input:focus {
    border-color: var(--blog-accent-color);
    box-shadow: 0 0 0 3px rgba(var(--blog-accent-color-rgb), 0.2);
    outline: none;
}

.search-icon {
    position: absolute;
    left: 1rem;
    color: var(--blog-meta-color);
    font-size: 1rem;
}

.search-clear {
    position: absolute;
    right: 0.8rem;
    background: none;
    border: none;
    color: var(--blog-meta-color);
    font-size: 1.1rem;
    cursor: pointer;
    padding: 0.2rem;
    border-radius: 50%;
    transition: color 0.2s ease, background-color 0.2s ease;
}

.search-clear:hover {
    color: var(--text-primary);
    background-color: var(--background-tertiary);
}

.search-clear:focus {
    outline: 2px solid var(--blog-accent-color);
    outline-offset: 2px;
}

/* ==========================================================================
   Responsiveness
   ========================================================================== */

@media (max-width: 1024px) {
    .toc-container {
        display: none; /* Hide TOC on smaller screens */
    }

    .blog-post-container {
        padding: 1rem; /* Adjust padding for smaller screens */
    }
}

@media (max-width: 900px) {
    .featured-post-card {
        display: flex; /* Revert to flex for simpler stacking */
        flex-direction: column;
    }

    .featured-post-title {
        padding: 1.5rem 1.5rem 0;
        font-size: 1.8rem;
    }

    .featured-post-thumbnail {
        width: 100%;
        border-radius: 0; /* Remove corner radius for stacked view */
    }

    .featured-post-content {
        width: 100%;
        padding: 1rem 1.5rem 1.5rem;
    }
}

@media (max-width: 768px) {
    .blog-container {
        padding: 0 1rem; /* Consistent padding for mobile */
    }

    .blog-post-container {
        padding: 1rem;
    }

    .blog-post-title {
        font-size: 2.2rem;
    }

    .featured-post-section {
        padding: 0; /* Remove horizontal padding on mobile */
    }

    .tag-filter-section {
        padding: 0; /* Remove horizontal padding on mobile */
    }
    
    .blog-post-navigation {
        flex-direction: column;
        gap: 1rem;
    }

    .nav-link-post {
        width: 100%;
        flex-direction: column; /* Stack icon and title */
        text-align: center; /* Center content */
        padding: 0.8rem 1rem; /* Adjust padding */
    }

    .nav-link-post .nav-post-title {
        white-space: normal; /* Allow text wrapping */
        font-size: 0.9rem; /* Slightly reduced font size */
        margin-top: 0.5rem; /* Add space between icon and title */
    }

    .blog-section {
        padding: 2rem 0; /* Adjust section padding for mobile */
    }

    .related-posts-grid {
        padding: 0;
    }
}

/* Specific styles for TOC h2 and h3 links */
.toc-list li a.h2 {
    font-weight: 600;
    color: var(--text-primary);
}

.toc-list li a.h3 {
    padding-left: 2rem;
    font-size: 0.85rem;
}

.toc-list li a.h3.active {
    border-left-color: var(--blog-accent-color);
}

/* Blog Post Navigation */
.blog-post-navigation {
    display: flex;
    justify-content: space-between;
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 1px solid var(--blog-border-color);
}

.nav-link-post {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    border: 1px solid var(--blog-border-color);
    border-radius: 8px;
    text-decoration: none;
    color: var(--text-primary);
    transition: all 0.2s ease;
    font-size: 1.2rem;
    flex: 1;
    color: var(--blog-accent-color);
    max-width: 48%; /* Adjust as needed */
}

.nav-link-post.hidden {
    display: none;
}

.nav-link-post:hover {
    background-color: var(--blog-card-bg);
    transform: translateY(-2px);
    box-shadow: var(--blog-card-shadow);
}

.nav-link-post .nav-post-title {
    font-weight: 600;
    font-size: 1rem;
    display: block;
    margin-top: 0.25rem;
}

.nav-link-post.prev-post {
    order: -1;
}

.nav-link-post.prev-post i {
    margin-top: 0.25rem;
}

.nav-link-post.next-post {
    background-color: var(--background-secondary); /* Added background */
    text-align: right;
    border-radius: 12px; /* Added border-radius */
    justify-content: flex-end;
}

.section-title {
    margin-bottom: 2rem;
    text-align: center;
}

/* Related Posts Section */
.related-posts-section {
    margin-top: 4rem;
    padding: 2rem 0; /* Adjusted padding */
    border-top: 1px solid var(--blog-border-color);
    background-color: var(--background-secondary); /* Added background */
    border-radius: 12px; /* Added border-radius */
    padding: 0 2rem; /* Added padding to align with blog-container */
}

.related-posts-section .section-title {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 2rem;
    box-shadow: var(--blog-card-shadow); /* Added box-shadow */
    text-align: center;
}

.related-posts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); /* Slightly smaller cards */
    gap: 1.5rem;
}

.related-posts-grid .post-card {
    /* Inherits most styles from .post-card, can override if needed */
    border-radius: 12px; /* Added border-radius */
    box-shadow: var(--blog-card-shadow); /* Added box-shadow */
    height: auto; /* Ensure cards adjust to content */
}

.related-posts-grid .post-card-thumbnail {
    height: 160px; /* Smaller thumbnails */
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

.related-posts-grid .post-card-title {
    padding: 0 2rem; /* Added padding to align with blog-container */
    font-size: 1.25rem;
}

.related-posts-grid .post-card-excerpt {
    font-size: 0.9rem;
}
