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

/* Ensure anchor tags don't create line breaks */
a {
    display: inline;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f8f9fa;
}

/* Header Styles */
.blog-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 1rem 0;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    border-radius: 0 0 20px 20px;
    margin-bottom: 1rem;
}

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

.nav-link {
    color: white;
    text-decoration: none;
    font-weight: 500;
    transition: opacity 0.3s ease;
}

.nav-link:hover {
    opacity: 0.8;
}

.blog-title {
    font-size: 2.8rem;
    font-weight: 600;
}

/* Main Content */
.blog-main {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

.blog-intro {
    text-align: center;
    margin-bottom: 3rem;
    padding: 2rem;
    background: white;
    border-radius: 20px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
    position: relative;
    overflow: hidden;
}

.blog-intro::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.blog-intro h2 {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    color: #2c3e50;
    font-weight: 700;
}

.blog-intro p {
    font-size: 1.2rem;
    color: #64748b;
    max-width: 600px;
    margin: 0 auto;
    line-height: 1.6;
}

.blog-stats {
    display: flex;
    justify-content: center;
    gap: 2rem;
    flex-wrap: wrap;
    margin-top: 1.5rem;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1rem 1.5rem;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border-radius: 12px;
    border: 1px solid rgba(0,0,0,0.05);
    min-width: 120px;
}

.stat-number {
    font-size: 2rem;
    font-weight: 700;
    color: #667eea;
    margin-bottom: 0.25rem;
}

.stat-label {
    font-size: 0.9rem;
    color: #64748b;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Posts Grid - Optimized for better space usage */
.posts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-bottom: 3rem;
}

@media (min-width: 768px) {
    .posts-grid {
        grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
        gap: 1.8rem;
    }
}

@media (min-width: 1024px) {
    .posts-grid {
        grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
        gap: 2rem;
    }
}

@media (min-width: 1200px) {
    .posts-grid {
        grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
        gap: 2rem;
    }
    
    .blog-main {
        padding: 2rem;
    }
}

@media (min-width: 1400px) {
    .posts-grid {
        grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
        gap: 2.5rem;
    }
}

.post-card {
    background: white;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
    overflow: hidden;
    transition: all 0.3s ease;
    cursor: pointer;
    border: 1px solid rgba(0,0,0,0.05);
    position: relative;
    display: flex;
    flex-direction: column;
    min-height: 400px; /* Set a minimum height */
}

.post-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 12px 40px rgba(0,0,0,0.15);
    border-color: rgba(102, 126, 234, 0.2);
}

.post-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 10; /* Ensure it appears above the image */
}

.post-card:hover::before {
    opacity: 1;
}

.post-image {
    width: 100%;
    height: 120px; /* Reduced from 180px to make symbol space smaller */
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem; /* Reduced from 3.5rem */
    color: #667eea;
    position: relative;
    overflow: hidden;
    background-size: contain; /* Changed from 'cover' to 'contain' */
    background-position: center;
    background-repeat: no-repeat;
    z-index: 1; /* Lower z-index than the hover effect */
}

.post-image img {
    width: 100%;
    height: 100%;
    object-fit: contain; /* Changed from 'cover' to 'contain' */
    object-position: center;
}

.post-image::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(0,0,0,0.1), transparent);
}

.post-content {
    padding: 1.5rem 2rem 1.5rem 2rem; /* Added bottom padding for spacing */
    display: flex;
    flex-direction: column;
    gap: 0.75rem; /* Reduced gap between elements */
    flex-grow: 1; /* Allow content to grow and fill available space */
}

.post-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem; /* Reduced margin */
    color: #2c3e50;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2; /* Standard property for compatibility */
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.post-excerpt {
    color: #64748b;
    margin-bottom: 1rem; /* Reduced margin */
    line-height: 1.6;
    display: -webkit-box;
    -webkit-line-clamp: 3; /* Reduced from 4 to 3 lines for better spacing */
    line-clamp: 3; /* Standard property for compatibility */
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-size: 0.95rem;
}

.post-meta {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    font-size: 0.9rem;
    margin-top: auto; /* Push meta section to bottom */
    padding-top: 1rem;
    padding-bottom: 0.5rem; /* Add bottom padding for spacing from card border */
    border-top: 1px solid #f1f5f9;
}

.post-date {
    font-weight: 600;
    color: #667eea;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.post-date::before {
    content: '📅';
    font-size: 0.9rem;
}

.post-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: flex-start;
}

.post-tag {
    background: #e9ecef;
    color: #495057;
    padding: 0.3rem 0.8rem;
    border-radius: 15px;
    font-size: 0.75rem;
    font-weight: 500;
    white-space: nowrap;
    transition: all 0.2s ease;
}

.post-tag:hover {
    background: #667eea;
    color: white;
    cursor: pointer;
    transform: translateY(-1px);
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
}

.pagination button {
    padding: 0.75rem 1rem;
    border: 1px solid #dee2e6;
    background: white;
    color: #495057;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
}

.pagination button:hover {
    background: #e9ecef;
    border-color: #adb5bd;
}

.pagination button.active {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

.pagination button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Footer */
.blog-footer {
    background: #2c3e50;
    color: white;
    text-align: center;
    padding: 2rem;
    margin-top: 4rem;
}

/* Loading State Enhancement */
.loading {
    text-align: center;
    padding: 4rem 2rem;
    font-size: 1.2rem;
    color: #6c757d;
    background: white;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
    margin: 2rem 0;
}

.loading::before {
    content: '⏳';
    font-size: 3rem;
    display: block;
    margin-bottom: 1rem;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 0.7; }
    50% { opacity: 1; }
}

/* Empty State Enhancement */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: #6c757d;
    background: white;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
    margin: 2rem 0;
}

.empty-state h3 {
    font-size: 1.8rem;
    margin-bottom: 1rem;
    color: #2c3e50;
}

.empty-state p {
    font-size: 1.1rem;
    line-height: 1.6;
}

.empty-state::before {
    content: '📝';
    font-size: 4rem;
    display: block;
    margin-bottom: 1.5rem;
    opacity: 0.7;
}

/* Tag Filter Styles */
.tag-filter-section {
    margin-bottom: 3rem;
    text-align: center;
}

.tag-filter-section h3 {
    font-size: 1.1rem;
    color: #2c3e50;
    margin-bottom: 1.5rem;
    font-weight: 600;
}

.tag-filter {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.tag-filter-btn {
    padding: 0.7rem 1.5rem;
    border: 2px solid #e2e8f0;
    background: white;
    color: #64748b;
    border-radius: 30px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 600;
    font-size: 0.9rem;
    position: relative;
    overflow: hidden;
}

.tag-filter-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    z-index: -1;
}

.tag-filter-btn:hover::before,
.tag-filter-btn.active::before {
    left: 0;
}

.tag-filter-btn:hover,
.tag-filter-btn.active {
    color: white;
    border-color: #667eea;
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.3);
}

/* Code Block Styles */
.code-block {
    position: relative;
    margin: 1.5rem 0;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.code-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #1e293b;
    color: #e2e8f0;
    padding: 0.75rem 1rem;
    font-size: 0.9rem;
}

.code-language {
    font-weight: 500;
}

.copy-btn {
    background: transparent;
    border: 1px solid #475569;
    color: #e2e8f0;
    padding: 0.25rem 0.75rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.2s ease;
}

.copy-btn:hover {
    background: #334155;
    border-color: #64748b;
}

.copy-btn.copied {
    background: #22c55e;
    border-color: #22c55e;
    color: white;
}

.code-content {
    background: #2d3748 !important;
    margin: 0;
}

.code-content pre {
    background: #2d3748 !important;
    color: #e2e8f0 !important;
    padding: 1.5rem !important;
    margin: 0 !important;
    border-radius: 0 !important;
    overflow-x: auto;
    font-family: 'Fira Code', 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', monospace !important;
    line-height: 1.5;
    font-size: 0.9rem;
}

.code-content pre code {
    background: transparent !important;
    color: inherit !important;
    padding: 0 !important;
    border-radius: 0 !important;
    font-size: inherit !important;
}

/* Override Prism.js theme to match our design */
.code-content pre[class*="language-"] {
    background: #2d3748 !important;
    color: #e2e8f0 !important;
}

.code-content code[class*="language-"] {
    background: #2d3748 !important;
    color: #e2e8f0 !important;
}

/* Syntax Highlighting */
.token.comment { color: #64748b; }
.token.keyword { color: #e879f9; }
.token.string { color: #10b981; }
.token.number { color: #f59e0b; }
.token.function { color: #06b6d4; }
.token.operator { color: #e2e8f0; }
.token.punctuation { color: #94a3b8; }
.token.property { color: #8b5cf6; }
.token.tag { color: #ef4444; }
.token.attr-name { color: #06b6d4; }
.token.attr-value { color: #10b981; }

/* Table of Contents Styles */
.table-of-contents {
    position: fixed;
    top: 20%;
    right: 2rem;
    width: 280px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    border: 1px solid #e9ecef;
    z-index: 1000;
    max-height: 60vh;
    overflow-y: auto;
}

.toc-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    border-bottom: 1px solid #e9ecef;
    background: #f8f9fa;
    border-radius: 12px 12px 0 0;
}

.toc-header h3 {
    margin: 0;
    font-size: 1rem;
    color: #2c3e50;
    font-weight: 600;
}

.toc-toggle {
    background: none;
    border: none;
    font-size: 1.2rem;
    color: #6c757d;
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 4px;
    transition: background-color 0.2s ease;
}

.toc-toggle:hover {
    background: #e9ecef;
}

.toc-nav {
    padding: 0.5rem 0;
}

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

.toc-item {
    margin: 0;
}

.toc-link {
    display: block;
    padding: 0.5rem 1rem;
    color: #495057;
    text-decoration: none;
    font-size: 0.9rem;
    line-height: 1.4;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
}

.toc-link:hover {
    background: #f8f9fa;
    color: #667eea;
    border-left-color: #667eea;
}

.toc-link.active {
    background: #e7f3ff;
    color: #667eea;
    border-left-color: #667eea;
    font-weight: 500;
}

/* Different indentation levels for headings */
.toc-h1 .toc-link {
    padding-left: 1rem;
    font-weight: 600;
}

.toc-h2 .toc-link {
    padding-left: 1.5rem;
    font-size: 0.85rem;
}

.toc-h3 .toc-link {
    padding-left: 2rem;
    font-size: 0.8rem;
}

.toc-h4 .toc-link {
    padding-left: 2.5rem;
    font-size: 0.75rem;
}

.toc-h5 .toc-link {
    padding-left: 3rem;
    font-size: 0.75rem;
}

.toc-h6 .toc-link {
    padding-left: 3.5rem;
    font-size: 0.75rem;
}

/* Responsive TOC */
@media (max-width: 1200px) {
    .table-of-contents {
        position: relative;
        top: auto;
        right: auto;
        width: 100%;
        margin: 2rem 0;
        max-height: none;
    }
}

@media (max-width: 768px) {
    .table-of-contents {
        margin: 1rem 0;
        border-radius: 8px;
    }
    
    .toc-header {
        padding: 0.75rem;
        border-radius: 8px 8px 0 0;
    }
    
    .toc-link {
        font-size: 0.85rem;
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    .nav {
        padding: 0 1rem;
        flex-direction: column;
        gap: 1rem;
    }
    
    .blog-title {
        font-size: 1.5rem;
    }
    
    .blog-main {
        padding: 1rem;
    }
    
    .blog-intro h2 {
        font-size: 2rem;
    }
    
    .posts-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    
    .pagination {
        flex-wrap: wrap;
    }
}

@media (max-width: 480px) {
    .post-content {
        padding: 1rem;
    }
    
    .post-title {
        font-size: 1.2rem;
    }
    
    .blog-intro p {
        font-size: 1rem;
    }
}

/* Individual Blog Post Styles */
.post-content {
    max-width: 1000px;
    /* margin: 2rem auto; */
    padding: 0 2rem;
    line-height: 1.8;
}

/* Ensure TOC doesn't overlap with wider content */
@media (min-width: 1201px) {
    .post-content {
        /* margin-left: auto; */
        padding-right: 2rem;
        padding-left: 3rem; /* Extra left padding to extend content area */
    }
}