/* Crafting Interpreters inspired design */

/* Layout inspired by CI book */
.page-wrapper {
    display: flex;
    min-height: 100vh;
    max-width: 1400px;
    margin: 0 auto;
}

/* Sidebar Navigation */
.sidebar {
    width: 250px;
    background: #fafafa;
    border-right: 1px solid #e1e5e9;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    top: 0;
    left: 0;
    z-index: 100;
}

.sidebar-content {
    padding: 2rem 1.5rem;
}

.blog-title {
    margin: 0 0 2rem 0;
    font-size: 1.4rem;
    font-weight: 600;
    color: #2c3e50;
}

.blog-title a {
    text-decoration: none;
    color: inherit;
}

.blog-title a:hover {
    color: #3498db;
}

.blog-nav {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.blog-nav a {
    text-decoration: none;
    color: #555;
    padding: 0.5rem 0;
    font-size: 0.95rem;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.blog-nav a:hover {
    color: #3498db;
    background: rgba(52, 152, 219, 0.05);
    padding-left: 0.5rem;
}

.nav-divider {
    height: 1px;
    background: #e1e5e9;
    margin: 1rem 0;
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: 250px;
    min-height: 100vh;
    background: white;
}

/* Override Tufte body styles for new layout */
body {
    width: 100%;
    margin: 0;
    padding: 0;
    background: #fafafa;
}

article {
    padding: 3rem 4rem 3rem 3rem;
    max-width: none;
}

/* Page Header */
.page-header {
    margin-bottom: 3rem;
    border-bottom: 1px solid #e1e5e9;
    padding-bottom: 2rem;
}

.page-header h1 {
    margin: 0 0 1rem 0;
    color: #2c3e50;
    font-size: 2.5rem;
}

.page-header .subtitle {
    margin: 0;
    color: #7f8c8d;
    font-size: 1.2rem;
}

/* Navigation active state */
.blog-nav a.active {
    color: #3498db;
    background: rgba(52, 152, 219, 0.1);
    padding-left: 0.5rem;
    font-weight: 500;
}

/* Home page styles */
.hero-section {
    margin-bottom: 4rem;
    text-align: left;
    border-bottom: 1px solid #e1e5e9;
    padding-bottom: 3rem;
}

.hero-section h1 {
    font-size: 3rem;
    margin-bottom: 1rem;
    color: #2c3e50;
}

.hero-subtitle {
    font-size: 1.4rem;
    color: #7f8c8d;
    margin-bottom: 1.5rem;
    font-style: italic;
}

.hero-description {
    font-size: 1.2rem;
    color: #555;
    line-height: 1.6;
    max-width: 600px;
}

/* About section */
.about-section {
    margin-bottom: 4rem;
    padding-bottom: 3rem;
    border-bottom: 1px solid #e1e5e9;
}

.about-content {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 3rem;
    margin-top: 2rem;
}

.about-text p {
    margin-bottom: 1.5rem;
    font-size: 1.1rem;
    line-height: 1.7;
}

.about-stats {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.stat-item {
    text-align: center;
    padding: 1.5rem;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e9ecef;
}

.stat-number {
    display: block;
    font-size: 2.5rem;
    font-weight: 700;
    color: #3498db;
    margin-bottom: 0.5rem;
}

.stat-label {
    color: #6c757d;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Recent posts section */
.recent-posts-section {
    margin-bottom: 4rem;
    padding-bottom: 3rem;
    border-bottom: 1px solid #e1e5e9;
}

.recent-post-item {
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid #f1f3f4;
}

.recent-post-item:last-child {
    border-bottom: none;
}

.recent-post-item h3 {
    margin: 0 0 0.5rem 0;
    font-size: 1.4rem;
}

.recent-post-item h3 a {
    color: #2c3e50;
    text-decoration: none;
    transition: color 0.2s ease;
}

.recent-post-item h3 a:hover {
    color: #3498db;
}

.post-meta {
    color: #7f8c8d;
    font-size: 0.9rem;
    margin: 0 0 1rem 0;
    font-style: italic;
}

.section-footer {
    text-align: center;
    margin-top: 2rem;
}

.view-all-link {
    color: #3498db;
    text-decoration: none;
    font-weight: 500;
    padding: 0.5rem 1rem;
    border: 1px solid #3498db;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.view-all-link:hover {
    background: #3498db;
    color: white;
}

/* Projects section */
.projects-section {
    margin-bottom: 4rem;
    padding-bottom: 3rem;
    border-bottom: 1px solid #e1e5e9;
}

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

.project-card {
    background: white;
    border: 1px solid #e1e5e9;
    border-radius: 8px;
    padding: 1.5rem;
    transition: box-shadow 0.2s ease;
}

.project-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.project-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
}

.project-header h3 {
    margin: 0;
    font-size: 1.3rem;
    color: #2c3e50;
}

.project-status {
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.status-active { background: #d4edda; color: #155724; }
.status-completed { background: #d1ecf1; color: #0c5460; }
.status-in-progress { background: #fff3cd; color: #856404; }
.status-planning { background: #f8d7da; color: #721c24; }

.project-description {
    color: #555;
    line-height: 1.6;
    margin-bottom: 1rem;
}

.project-tech {
    margin-bottom: 1rem;
}

.tech-tag {
    display: inline-block;
    background: #f1f3f4;
    color: #555;
    padding: 0.25rem 0.5rem;
    border-radius: 12px;
    font-size: 0.8rem;
    margin: 0.25rem 0.25rem 0.25rem 0;
}

.project-links a {
    color: #3498db;
    text-decoration: none;
    margin-right: 1rem;
    font-size: 0.9rem;
    font-weight: 500;
}

.project-links a:hover {
    text-decoration: underline;
}

/* Books section */
.books-section {
    margin-bottom: 4rem;
}

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

.book-card {
    background: white;
    border: 1px solid #e1e5e9;
    border-radius: 8px;
    padding: 1.5rem;
    transition: box-shadow 0.2s ease;
}

.book-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.book-header h3 {
    margin: 0 0 0.5rem 0;
    color: #2c3e50;
    font-size: 1.3rem;
}

.book-author {
    color: #7f8c8d;
    margin: 0 0 1rem 0;
    font-style: italic;
}

.book-rating {
    color: #f39c12;
    font-size: 1.1rem;
    margin-bottom: 1rem;
}

.book-review {
    color: #555;
    line-height: 1.6;
    margin-bottom: 1rem;
}

.book-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.read-date {
    color: #7f8c8d;
    font-size: 0.9rem;
}

.book-tags {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.tag {
    background: #e9f4fd;
    color: #2980b9;
    padding: 0.25rem 0.5rem;
    border-radius: 12px;
    font-size: 0.8rem;
}

.book-link {
    color: #3498db;
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9rem;
}

.book-link:hover {
    text-decoration: underline;
}

/* Error message */
.error-message {
    color: #721c24;
    background: #f8d7da;
    padding: 1rem;
    border-radius: 4px;
    border: 1px solid #f5c6cb;
}

.post-preview {
    margin-bottom: 3rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid #eee;
}

.post-preview:last-child {
    border-bottom: none;
}

.post-title {
    font-size: 1.8rem;
    margin-bottom: 0.8rem;
    line-height: 1.3;
    font-weight: 600;
}

.post-title a {
    color: #2c3e50;
    text-decoration: none;
    transition: color 0.2s ease;
}

.post-title a:hover {
    color: #3498db;
}

.post-date {
    font-style: italic;
    color: #666;
    font-size: 1.1rem;
    margin-bottom: 1rem;
}

.post-excerpt {
    font-size: 1.3rem;
    line-height: 1.8;
    margin-bottom: 1rem;
}

.read-more {
    font-size: 1.1rem;
    color: #0066cc;
}

/* Enhanced code styling inspired by CI */
pre {
    background: #f7f9fc;
    border: 1px solid #e1e5e9;
    border-left: 4px solid #3498db;
    border-radius: 4px;
    padding: 1.2rem;
    margin: 2rem 0;
    overflow-x: auto;
    font-size: 0.9rem;
    line-height: 1.5;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

code {
    background: #f1f3f4;
    color: #c7254e;
    padding: 0.2rem 0.4rem;
    border-radius: 3px;
    font-size: 0.85em;
    border: 1px solid #e8ecef;
}

pre code {
    background: transparent;
    color: #2c3e50;
    padding: 0;
    border: none;
    font-size: inherit;
}

/* Tables */
table {
    border-collapse: collapse;
    margin: 1.5rem 0;
    width: 100%;
}

table th,
table td {
    border: 1px solid #ddd;
    padding: 0.5rem 1rem;
    text-align: left;
}

table th {
    background-color: #f8f8f8;
    font-weight: bold;
}

/* Responsive Images */
img {
    max-width: 100%;
    height: auto;
    margin: 1rem 0;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Figure with caption */
figure {
    margin: 2rem 0;
    text-align: center;
}

figure img {
    margin-bottom: 0.5rem;
}

figcaption {
    font-style: italic;
    color: #666;
    font-size: 0.9rem;
    margin-top: 0.5rem;
}

/* Blockquotes */
blockquote {
    border-left: 4px solid #ddd;
    padding-left: 1rem;
    margin: 1.5rem 0;
    font-style: italic;
    color: #666;
}

/* Loading state */
.loading {
    text-align: center;
    color: #666;
    font-style: italic;
    padding: 2rem;
}

/* Error state */
.error {
    background-color: #f8d7da;
    color: #721c24;
    padding: 1rem;
    border: 1px solid #f5c6cb;
    border-radius: 4px;
    margin: 1rem 0;
}

/* LaTeX Math Styling */
.katex-display {
    margin: 1.5rem 0;
    text-align: center;
}

.katex {
    font-size: 1.1em;
}

/* Table of Contents */
#toc {
    margin-top: 1rem;
}

#toc h3 {
    font-size: 0.9rem;
    margin: 0 0 0.5rem 0;
    color: #7f8c8d;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

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

#toc li {
    margin: 0.3rem 0;
}

#toc a {
    text-decoration: none;
    color: #555;
    font-size: 0.85rem;
    padding: 0.2rem 0;
    display: block;
    transition: color 0.2s ease;
}

#toc a:hover {
    color: #3498db;
}

/* Mobile menu toggle - hidden on desktop */
.mobile-menu-toggle {
    display: none;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        box-shadow: 2px 0 10px rgba(0,0,0,0.1);
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
    }
    
    article {
        padding: 2rem 1.5rem;
    }
    
    .page-header h1,
    .hero-section h1 {
        font-size: 2rem;
    }
    
    .post-title {
        font-size: 1.4rem;
    }
    
    .post-excerpt {
        font-size: 1.1rem;
    }
    
    /* Mobile home page adjustments */
    .about-content {
        grid-template-columns: 1fr;
        gap: 2rem;
    }
    
    .about-stats {
        flex-direction: row;
        justify-content: space-around;
    }
    
    .stat-item {
        padding: 1rem;
        flex: 1;
        margin: 0 0.5rem;
    }
    
    .stat-number {
        font-size: 2rem;
    }
    
    .projects-grid,
    .books-grid {
        grid-template-columns: 1fr;
    }
    
    .project-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    .book-meta {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    
    /* Mobile menu toggle */
    .mobile-menu-toggle {
        display: block;
        position: fixed;
        top: 1rem;
        left: 1rem;
        z-index: 200;
        background: #3498db;
        color: white;
        border: none;
        padding: 0.75rem;
        border-radius: 6px;
        cursor: pointer;
        font-size: 1.1rem;
        box-shadow: 0 2px 8px rgba(0,0,0,0.15);
        transition: background 0.2s ease;
    }
    
    .mobile-menu-toggle:hover {
        background: #2980b9;
    }
    
    /* Better code block handling on mobile */
    pre {
        margin: 1.5rem -1.5rem;
        border-radius: 0;
        border-left: none;
        border-right: none;
    }
}

@media (max-width: 480px) {
    .post-title {
        font-size: 1.4rem;
    }
    
    .post-excerpt {
        font-size: 1.1rem;
    }
    
    /* Even smaller screens */
    pre {
        font-size: 0.8rem;
        margin: 1rem -1rem;
        border-radius: 0;
    }
}