/* Blog Page Specific Styles */

.blog-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 120px 0 60px;
    text-align: center;
}

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

.blog-header p {
    font-size: 1.2rem;
    opacity: 0.9;
    max-width: 600px;
    margin: 0 auto;
}

.blog-posts {
    padding: 60px 0;
    background: #f8fafc;
}

/* Blog Post Layout with Sidebar TOC */
.blog-post-layout {
    display: flex;
    gap: 3rem;
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
    align-items: flex-start;
}

.table-of-contents {
    flex: 0 0 280px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 1.5rem;
    height: fit-content;
    position: sticky;
    top: 120px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    align-self: flex-start;
    z-index: 10;
}

.table-of-contents h4 {
    font-size: 1.1rem;
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid #e2e8f0;
}

.table-of-contents ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.table-of-contents li {
    margin-bottom: 0.5rem;
}

.table-of-contents li.h3 {
    margin-left: 1rem;
    font-size: 0.9rem;
}

.table-of-contents a {
    color: #4b5563;
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 500;
    transition: color 0.2s ease;
    display: block;
    padding: 0.25rem 0;
}

.table-of-contents a:hover,
.table-of-contents a.active {
    color: #2563eb;
}

.blog-post-main {
    flex: 1;
    min-width: 0; /* Prevents flex item from overflowing */
    margin-left: 0; /* Ensure no negative margin */
    overflow-wrap: break-word;
    width: calc(100% - 280px - 3rem); /* Explicit width calculation */
    max-width: 100%;
}

/* Post Content Container */
.post-content {
    padding-top: 2rem !important;
    padding-bottom: 2rem !important;
    background: white;
    min-height: 100vh;
}

/* Ensure main content area has proper spacing */
.blog-post-main .post-article {
    padding: 0;
    margin: 0;
}

.blog-post-main .post-article > * {
    margin-left: 0;
    margin-right: 0;
}

/* Featured Post */
.featured-post {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 3rem;
    background: white;
    border-radius: 15px;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    margin-bottom: 4rem;
}

.featured-post .post-image {
    position: relative;
    height: 350px;
}

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

.featured-post .post-content {
    padding: 3rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.featured-post h2 {
    font-size: 2rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    color: #1f2937;
    line-height: 1.3;
}

.featured-post h2 a {
    color: inherit;
    text-decoration: none;
    transition: color 0.3s ease;
}

.featured-post h2 a:hover {
    color: #2563eb;
}

.featured-post p {
    font-size: 1.1rem;
    color: #6b7280;
    line-height: 1.6;
    margin-bottom: 2rem;
}

/* Post Categories */
.post-category {
    position: absolute;
    top: 1rem;
    left: 1rem;
    background: #2563eb;
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.post-category.featured {
    background: #f59e0b;
}

/* Blog Grid */
.blog-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 2rem;
    margin-bottom: 4rem;
}

.blog-card {
    background: white;
    border-radius: 15px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.blog-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
}

.blog-image {
    position: relative;
    height: 200px;
    overflow: hidden;
}

.blog-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.blog-card:hover .blog-image img {
    transform: scale(1.05);
}

.blog-content {
    padding: 2rem;
}

.blog-card .blog-content p {
    color: #334155;
    line-height: 1.6;
    margin-bottom: 1.5rem;
    font-size: 1rem;
    font-weight: 400;
}

.blog-card .blog-date, .blog-card .read-time {
    color: #334155;
    font-weight: 600;
    font-size: 0.98rem;
    letter-spacing: 0.01em;
    text-shadow: none;
}

.featured-post .post-meta .post-date, .featured-post .post-meta .read-time {
    color: #334155;
    font-weight: 600;
    font-size: 1rem;
    letter-spacing: 0.01em;
    text-shadow: none;
}

.blog-meta, .post-meta {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
    font-size: 0.95rem;
    color: #fff;
    text-shadow: 0 1px 4px rgba(0,0,0,0.18);
    font-weight: 500;
}

.blog-meta i, .post-meta i {
    color: #ffd700;
    margin-right: 0.3em;
    font-size: 1em;
    vertical-align: middle;
}

.blog-date, .post-date {
    font-weight: 600;
    color: #fff;
    letter-spacing: 0.02em;
    text-shadow: 0 1px 4px rgba(0,0,0,0.18);
}

.read-time {
    color: #ffd700;
    font-weight: 600;
    text-shadow: 0 1px 4px rgba(0,0,0,0.18);
}

.blog-content h3 {
    font-size: 1.3rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: #fff;
    line-height: 1.4;
}

.blog-content h3 a {
    color: inherit;
    text-decoration: none;
    transition: color 0.3s ease;
}

.blog-content h3 a:hover {
    color: #2563eb;
}

.blog-content p {
    color: #e0e7ff;
    line-height: 1.6;
    margin-bottom: 1.5rem;
}

.read-more {
    color: #2563eb;
    text-decoration: none;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    transition: color 0.3s ease;
}

.read-more:hover {
    color: #1d4ed8;
}

.read-more i {
    font-size: 0.8rem;
    transition: transform 0.3s ease;
}

.read-more:hover i {
    transform: translateX(3px);
}

/* Newsletter Section */
.newsletter-section {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 15px;
    padding: 3rem;
    text-align: center;
    color: white;
}

.newsletter-content h3 {
    font-size: 2rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

.newsletter-content p {
    font-size: 1.1rem;
    opacity: 0.9;
    margin-bottom: 2rem;
}

.newsletter-form {
    display: flex;
    gap: 1rem;
    max-width: 400px;
    margin: 0 auto;
}

.newsletter-form input {
    flex: 1;
    padding: 1rem;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    background: rgba(255, 255, 255, 0.95);
}

.newsletter-form button {
    padding: 1rem 2rem;
    background: #fbbf24;
    color: #1f2937;
    border: none;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.newsletter-form button:hover {
    background: #f59e0b;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .blog-post-layout {
        flex-direction: column;
        gap: 2rem;
        padding: 1rem;
    }
    
    .table-of-contents {
        position: static;
        flex: none;
        width: 100%;
        max-width: 100%;
        margin-bottom: 2rem;
        order: -1; /* Show TOC first on mobile */
    }
    
    .blog-post-main {
        margin-left: 0;
        width: 100%;
        max-width: 100%;
    }
    
    .post-article {
        width: 100%;
        max-width: 100%;
        padding: 0;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 0 15px;
    }
    
    .blog-header h1 {
        font-size: 2.5rem;
    }
    
    .featured-post {
        grid-template-columns: 1fr;
        gap: 0;
    }
    
    .featured-post .post-content {
        padding: 2rem;
    }
    
    .featured-post h2 {
        font-size: 1.5rem;
    }
    
    .blog-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    
    .blog-card {
        margin: 0;
        width: 100%;
    }
    
    .newsletter-form {
        flex-direction: column;
    }
    
    .newsletter-form input,
    .newsletter-form button {
        width: 100%;
    }
    
    .blog-post-layout {
        padding: 0 15px;
        margin: 0;
    }
    
    .post-content {
        padding: 20px 0;
    }
    
    .post-article {
        width: 100%;
        margin: 0;
        padding: 0;
    }
    
    .post-article section {
        margin-bottom: 2rem;
    }
    
    .post-article h2 {
        font-size: 1.8rem;
        margin-bottom: 1rem;
    }
    
    .post-article h3 {
        font-size: 1.4rem;
        margin-bottom: 0.8rem;
    }
    
    .post-article p {
        margin-bottom: 1rem;
        line-height: 1.6;
    }
    
    .resources-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .key-insights ul,
    .result-box ul,
    .visualization-section ul {
        padding-left: 1.5rem;
    }
    
    pre {
        overflow-x: auto;
        font-size: 0.85rem;
    }
    
    .info-box,
    .result-box,
    .key-insights,
    .visualization-section {
        margin: 1.5rem 0;
        padding: 1.5rem;
    }
}

@media (max-width: 480px) {
    .blog-header {
        padding: 100px 0 40px;
    }
    
    .blog-header h1 {
        font-size: 2rem;
    }
    
    .blog-posts {
        padding: 40px 0;
    }
    
    .blog-content {
        padding: 1.5rem;
    }
    
    .newsletter-section {
        padding: 2rem;
    }
    
    .container {
        padding: 0 10px;
    }
    
    .post-article {
        padding: 0 10px;
    }
    
    .post-meta {
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    
    .post-title {
        font-size: 1.8rem;
        line-height: 1.3;
    }
    
    .post-subtitle {
        font-size: 1rem;
    }
    
    .author-info {
        flex-direction: column;
        text-align: center;
        gap: 1rem;
    }
    
    .author-avatar {
        margin: 0 auto;
    }
    
    .read-more {
        font-size: 1.05rem;
        font-weight: 600;
        padding: 0.8rem 0.5rem;
        min-width: 120px;
        margin: 0.5rem auto;
        letter-spacing: 0.01em;
    }
    .newsletter-form button {
        font-size: 1.1rem;
        font-weight: 600;
        padding: 0.9rem 0.5rem;
        min-width: 140px;
        margin: 0.5rem auto;
        box-shadow: 0 2px 8px rgba(99,102,241,0.12);
        letter-spacing: 0.01em;
    }
}

.blog-card h3 a {
    color: #1e293b;
    text-decoration: none;
    font-weight: 700;
    transition: color 0.3s ease;
}

.blog-card h3 a:hover {
    color: #2563eb;
}