/* Blog Post Styles */
:root {
    --primary-color: #333;
    --secondary-color: #666;
    --accent-color: #0066cc;
    --tag-background: #e0e0e0;
    /* --card-background: #f5f5f5; */
    --card-background: #ffffff;
    --code-bg: #282c34;
    --code-fg: #abb2bf;
    --toc-background: #f8f8f8;
}

body.dark-mode,
html.dark-mode body {
    --primary-color: #ffffff;
    --secondary-color: #b0b0b0;
    /* --card-background: #2a2a2a; */
    --card-background: #1a1a1a;
    --tag-background: #444;
    --code-bg: #1e1e1e;
    --code-fg: #d4d4d4;
    --toc-background: #222;
}

/* Blog Container */
.blog-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 25px 20px 40px; /* Reduced top padding */
    text-align: center;
}

.blog-container h1 {
    font-size: 2.2rem;
    margin-bottom: 8px;
}

.subtitle {
    color: var(--secondary-color);
    margin-bottom: 25px;
    font-size: 0.95rem;
}

/* Search and Filters */
/* Search and Filters */
.search-filters {
    display: flex;
    justify-content: space-between;
    align-items: stretch; /* Changed from center to stretch */
    margin-bottom: 25px;
    gap: 15px;
}

.search-container {
    flex: 1;
}

#searchInput {
    width: 100%;
    padding: 10px 16px;
    font-size: 1rem;
    border: 1px solid var(--tag-background);
    border-radius: 8px;
    background-color: transparent;
    color: var(--primary-color);
    height: 41px;
    box-sizing: border-box;
    margin: 0; /* Ensure no margin */
}

.filter-container button {
    background-color: white;
    border: 1px solid var(--tag-background);
    color: var(--primary-color);
    padding: 10px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.95rem;
    transition: background-color 0.2s ease;
    white-space: nowrap;
    min-width: 130px;
    height: 41px; /* Ensure consistent height */
    box-sizing: border-box;
}


body.dark-mode .filter-container button,
html.dark-mode .filter-container button {
    background-color: #333;
}

.filter-container button:hover {
    background-color: var(--tag-background);
}

/* Tags */
.tag-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    margin: 0 0 25px 0;
    padding: 15px;
    background-color: var(--card-background);
    border-radius: 8px;
}

.tag {
    background-color: var(--card-background);
    color: var(--primary-color);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
}

.tag:hover, .tag.active {
    background-color: #5daced;
    color: white;
}

/* Blog List */
.blog-list {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.blog-item {
    padding: 20px;
    border-radius: 8px;
    background-color: var(--card-background);
    text-align: left;
    transition: transform 0.2s ease, box-shadow 0.2s ease, background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
    cursor: pointer;
    position: relative;
    border: 1px solid var(--tag-background);
}

.blog-item:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.05);
}

.blog-item h2 {
    font-size: 1.6rem;
    margin-bottom: 8px;
    text-align: left;
}

.blog-item h2 a {
    color: var(--primary-color);
    text-decoration: none;
}

.blog-item .date-line {
    display: flex;
    align-items: center;
    gap: 15px;
    color: var(--secondary-color);
    font-size: 0.85rem;
    margin-bottom: 12px;
    text-align: left;
}

.blog-item .reading-time {
    font-style: italic;
}

.blog-item .summary {
    margin: 12px 0;
    color: var(--primary-color);
    line-height: 1.5;
    font-size: 0.95rem;
}

/* Blog Post */
.blog-post {
    max-width: 800px;
    margin: 0 auto;
    padding: 30px 20px 40px;
    text-align: left;
}

.blog-post h1, 
.blog-post h2, 
.blog-post h3, 
.blog-post h4, 
.blog-post h5, 
.blog-post h6 {
    color: var(--primary-color);
    margin-top: 1.5em;
    margin-bottom: 0.5em;
}

.blog-post h1 { 
    font-size: 2.2em; 
    margin-top: 0.5em;
    margin-bottom: 0.3em;
    text-align: left;
}

.blog-post h2 { font-size: 1.8em; }
.blog-post h3 { font-size: 1.5em; }

.post-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--secondary-color);
    font-size: 0.9rem;
    margin-bottom: 2em;
}

.date-time {
    display: flex;
    gap: 15px;
    align-items: center;
}

.reading-time {
    font-style: italic;
}

.post-author {
    font-weight: 500;
}

.post-content {
    text-align: left;
    line-height: 1.6;
    font-family: -apple-system, "system-ui", "Segoe UI", sans-serif;
    font-size: 16px;
}

.post-content p {
    margin-bottom: 1em;
    margin-top: 0;
}

.post-content ul, 
.post-content ol {
    margin-left: 1.5em;
    margin-bottom: 1em;
}

.post-content li {
    margin-bottom: 0.5em;
}

.post-content a {
    color: var(--accent-color);
    text-decoration: none;
}

.post-content a:hover {
    text-decoration: underline;
}

/* Code blocks */
.post-content pre {
    background-color: var(--code-bg);
    padding: 1.5em;
    border-radius: 8px;
    overflow-x: auto;
    margin: 1.5em 0;
    text-align: left;
}

.post-content code {
    font-family: 'Fira Code', monospace;
    font-size: 0.9em;
}

/* Image Styles */
.post-content img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 1.5em auto;
    border-radius: 4px;
}

.post-content img.rounded {
    border-radius: 12px;
}

.post-content img.shadow {
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.post-content .image-caption {
    text-align: center;
    color: var(--secondary-color);
    font-size: 0.9rem;
    margin-top: -1em;
    margin-bottom: 1.5em;
}

/* Image alignment classes */
.post-content .image-left {
    float: left;
    margin-right: 1.5em;
    margin-bottom: 1em;
    max-width: 50%;
}

.post-content .image-right {
    float: right;
    margin-left: 1.5em;
    margin-bottom: 1em;
    max-width: 50%;
}

/* Clear floats */
.post-content .clearfix::after {
    content: "";
    clear: both;
    display: table;
}

/* Figure and figcaption for image captions */
.post-content figure {
    margin: 2em 0;
}

.post-content figcaption {
    text-align: center;
    color: var(--secondary-color);
    font-size: 0.9rem;
    margin-top: 0.5em;
}

/* Image gallery */
.image-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1rem;
    margin: 2em 0;
}

.image-gallery img {
    width: 100%;
    height: 200px;
    object-fit: cover;
    margin: 0;
}

/* LaTeX Equation Styling */
.post-content .MathJax {
    display: block;
    overflow-x: auto;
    overflow-y: hidden;
    margin: 1.5em 0;
    padding: 0.5em 0;
}

/* Centered equations (display mode) */
.post-content .MathJax_Display {
    margin: 1.5em 0;
}

/* Ensure equations don't overflow on mobile */
@media screen and (max-width: 600px) {
    .post-content .MathJax_Display {
        overflow-x: auto;
        overflow-y: hidden;
    }
}

/* Optional: add a subtle background to block equations */
.post-content .MathJax_Display {
    background-color: rgba(0, 0, 0, 0.02);
    padding: 1em;
    border-radius: 4px;
}

body.dark-mode .post-content .MathJax_Display,
html.dark-mode .post-content .MathJax_Display {
    background-color: rgba(255, 255, 255, 0.05);
}

/* Table of Contents */
.toc-toggle {
    margin: 1.5em 0;
}

#toggleToc {
    background-color: var(--card-background);
    border: none;
    border-radius: 8px;
    padding: 8px 12px;
    width: 100%;
    text-align: left;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    color: var(--primary-color);
    transition: background-color 0.2s ease;
}

#toggleToc:hover {
    background-color: var(--tag-background);
}

.toggle-icon {
    display: inline-block;
    margin-right: 5px;
    font-size: 0.8rem;
}

.toc-container {
    margin-top: 10px;
    padding: 10px 15px;
    background-color: var(--toc-background);
    border-radius: 8px;
}

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

.toc-container li {
    margin-bottom: 3px;
    padding-left: 20px;
}

.toc-container a {
    color: var(--primary-color);
    text-decoration: none;
    transition: color 0.2s ease;
    font-size: 0.9rem;
    display: block;
    padding: 2px 0;
    line-height: 1.3;
}

.toc-container a:hover {
    color: var(--accent-color);
}

.toc-level-0 { margin-left: 0; }
.toc-level-1 { margin-left: 12px; }
.toc-level-2 { margin-left: 24px; }
.toc-level-3 { margin-left: 36px; }
.toc-level-4 { margin-left: 48px; }

/* Tags at end of post */
.post-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 40px 0 20px 0;
    justify-content: flex-start;
}

.back-to-blog {
    margin-top: 30px;
}

.back-to-blog a {
    color: var(--accent-color);
    text-decoration: none;
}

.back-to-blog a:hover {
    text-decoration: underline;
}

@media screen and (max-width: 600px) {
    .blog-post {
        padding: 20px;
    }
    .blog-post h1 { font-size: 1.8rem; }
    .blog-post h2 { font-size: 1.5rem; }
    .blog-item h2 { font-size: 1.3rem; }
    
    .search-filters {
        flex-direction: column;
    }
    
    .post-meta {
        flex-direction: column;
        gap: 10px;
        align-items: flex-start;
    }
}