/* Reset and Base Styles */
*, *::before, *::after {
    box-sizing: border-box;
}

/* CSS Variables for Theming */
:root {
    --bg-color: #FDF6E3;
    --text-color: #2b2b2b;
    --text-secondary: #586e75;
    --link-color: #D44638;
    --link-hover: #B83628;
    --border-color: #eee8d5;
    --code-bg: #f7f0dd;
    --nav-bg: rgba(253, 246, 227, 0.95);
    --max-width: 984px;
    --font-body: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --font-mono: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
}

[data-theme="dark"] {
    --bg-color: #002b36;
    --text-color: #93a1a1;
    --text-secondary: #657b83;
    --link-color: #E57373;
    --link-hover: #EF5350;
    --border-color: #073642;
    --code-bg: #073642;
    --nav-bg: rgba(0, 43, 54, 0.95);
}

/* Base Typography */
html {
    font-family: var(--font-body);
    font-size: 18px;
    line-height: 1.6;
    color: var(--text-color);
    background-color: var(--bg-color);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    margin: 0;
    padding: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Navigation */
.nav-header {
    position: sticky;
    top: 0;
    background: var(--nav-bg);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-color);
    z-index: 100;
}

.nav-container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-home {
    font-weight: 600;
    text-decoration: none;
    color: var(--text-color);
    font-size: 1.1rem;
}

.nav-links {
    display: flex;
    gap: 1.5rem;
    align-items: center;
}

.nav-links a {
    color: var(--text-color);
    text-decoration: none;
    transition: color 0.2s;
}

.nav-links a:hover {
    color: var(--link-color);
}

/* Theme Toggle Button */
.theme-toggle {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.2rem;
    padding: 0.25rem;
    transition: transform 0.2s;
}

.theme-toggle:hover {
    transform: scale(1.1);
}

/* Main Content */
.main-content {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 2rem 1.5rem;
    flex: 1;
    width: 100%;
}

/* Hero Section */
.hero {
    margin-bottom: 4rem;
    text-align: center;
}

.hero h1 {
    font-size: 2rem;
    margin: 0 0 1rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.subtitle {
    font-size: 1.25rem;
    color: var(--text-secondary);
    margin: 0;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    margin: 2rem 0 1rem;
    font-weight: 600;
    line-height: 1.3;
}

h1 { font-size: 1.8rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.2rem; }

p {
    margin: 0 0 1.5rem;
}

a {
    color: var(--link-color);
    transition: color 0.2s;
}

a:hover {
    color: var(--link-hover);
}

/* Posts */
.recent-posts h2 {
    margin-bottom: 2rem;
}

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

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

.post-preview time {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.post-preview h3 {
    margin: 0.5rem 0 1rem;
    font-size: 1.5rem;
}

.post-preview h3 a {
    text-decoration: none;
    color: var(--text-color);
}

.post-preview h3 a:hover {
    color: var(--link-color);
}

.post-preview p {
    color: var(--text-secondary);
    margin: 0;
}

.view-all {
    display: inline-block;
    margin-top: 1rem;
    text-decoration: none;
    font-weight: 500;
}

/* Code Blocks */
pre, code {
    font-family: var(--font-mono);
    font-size: 0.9rem;
}

code {
    background: var(--code-bg);
    padding: 0.1em 0.3em;
    border-radius: 3px;
}

pre {
    background: var(--code-bg);
    padding: 1rem;
    border-radius: 6px;
    overflow-x: auto;
    line-height: 1.4;
}

pre code {
    background: none;
    padding: 0;
}

/* Footer */
.site-footer {
    text-align: center;
    padding: 2rem 1.5rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
    border-top: 1px solid var(--border-color);
}

/* Blog Post Styles */
.post-header {
    margin-bottom: 3rem;
}

.post-title {
    margin-bottom: 1rem;
}

.post-meta {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.post-content {
    margin-bottom: 4rem;
}

.post-content img {
    max-width: 100%;
    height: auto;
    border-radius: 6px;
}

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

/* Projects Section */
.projects-list {
    margin: 2rem 0;
}

.project-item {
    margin-bottom: 2rem;
}

.project-item h3 {
    margin-bottom: 0.5rem;
}

.project-item p {
    color: var(--text-secondary);
    margin: 0;
}

/* Featured Posts */
.featured-posts {
    margin: 2rem 0;
}

.featured-posts ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.featured-posts li {
    margin-bottom: 0.8rem;
}

.featured-posts a {
    font-weight: 500;
}

/* Personal Section */
.personal-section {
    margin-top: 3rem;
}

/* Links Page */
.links-section {
    margin-bottom: 3rem;
}

.links-section h2 {
    margin-bottom: 1rem;
}

.links-section ul {
    list-style: none;
    padding: 0;
}

.links-section li {
    margin-bottom: 0.8rem;
}

.links-section a {
    font-weight: 500;
}

/* Posts by Topic */
.posts-by-topic {
    margin-bottom: 3rem;
}

.posts-by-topic h2 {
    font-size: 1.3rem;
    margin-bottom: 1.2rem;
    color: var(--text-secondary);
}

/* Responsive Design */
@media (max-width: 600px) {
    html {
        font-size: 16px;
    }
    
    .hero h1 {
        font-size: 2rem;
    }
    
    .subtitle {
        font-size: 1.1rem;
    }
    
    .nav-container {
        padding: 0.75rem 1rem;
    }
    
    .nav-home {
        font-size: 1rem;
    }
    
    .nav-links {
        gap: 0.75rem;
        font-size: 0.9rem;
    }
    
    .nav-links a {
        white-space: nowrap;
    }
    
    .theme-toggle {
        font-size: 1rem;
        padding: 0.1rem;
    }
}

/* Extra small devices */
@media (max-width: 400px) {
    .nav-links {
        gap: 0.5rem;
        font-size: 0.85rem;
    }
    
    /* Hide RSS link on very small screens */
    .nav-links a[href="/rss.xml"] {
        display: none;
    }
}