/* Variables */
:root {
    --color-bg: #ffffff;
    --color-text: #1a1a1a;
    --color-text-light: #666666;
    --color-primary: #2563eb;
    --color-primary-dark: #1d4ed8;
    --color-border: #e5e7eb;
    --color-code-bg: #f6f8fa;
    --color-code-border: #d1d5db;
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'Fira Code', 'Consolas', 'Monaco', monospace;
    --max-width: 1200px;
    --content-width: 720px;
}

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

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-sans);
    color: var(--color-text);
    background: var(--color-bg);
    line-height: 1.6;
}

.container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 1.5rem;
}

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

h1 { font-size: 2.5rem; }
h2 { font-size: 2rem; }
h3 { font-size: 1.5rem; }
h4 { font-size: 1.25rem; }

p {
    margin-bottom: 1rem;
}

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

a:hover {
    color: var(--color-primary-dark);
    text-decoration: underline;
}

/* Header permalinks */
.headerlink {
    color: #999999;
    opacity: 0.6;
    margin-left: 0.5rem;
    text-decoration: none;
    transition: opacity 0.2s;
}

.headerlink:hover {
    color: #999999;
    opacity: 1;
    text-decoration: none;
}

/* Header */
.site-header {
    padding: 2rem 0;
    border-bottom: 1px solid var(--color-border);
    margin-bottom: 3rem;
}

.nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-logo {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-text);
    text-decoration: none;
}

.nav-logo:hover {
    color: var(--color-primary);
    text-decoration: none;
}

.nav-links {
    display: flex;
    gap: 2rem;
}

.nav-links a {
    color: var(--color-text);
    font-weight: 500;
}

/* Main Content */
.main {
    min-height: calc(100vh - 200px);
    margin-bottom: 4rem;
}

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

.hero h1 {
    margin-top: 0;
    margin-bottom: 1rem;
}

.hero-subtitle {
    font-size: 1.25rem;
    color: var(--color-text-light);
}

/* Posts Grid */
.posts-grid {
    display: grid;
    gap: 2rem;
    margin-bottom: 4rem;
}

.post-card {
    padding: 2rem;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    transition: transform 0.2s, box-shadow 0.2s;
}

.post-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.post-card-content {
    display: flex;
    gap: 1.5rem;
    align-items: flex-start;
}

.post-thumbnail {
    flex-shrink: 0;
    width: 150px;
    height: 150px;
    overflow: hidden;
    border-radius: 8px;
}

.post-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s;
}

.post-thumbnail:hover img {
    transform: scale(1.05);
}

.post-info {
    flex: 1;
    min-width: 0;
}

.post-header h2 {
    margin-top: 0;
    margin-bottom: 0.5rem;
}

.post-meta {
    display: flex;
    gap: 1rem;
    color: var(--color-text-light);
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

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

.post-tags {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.tag {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    background: var(--color-code-bg);
    border-radius: 20px;
    font-size: 0.875rem;
    color: var(--color-text);
}

.tag:hover {
    background: var(--color-primary);
    color: white;
    text-decoration: none;
}

.read-more {
    font-weight: 500;
}

/* Single Post */
.post-single {
    max-width: var(--content-width);
    margin: 0 auto;
}

.post-single .post-header {
    text-align: center;
    margin-bottom: 3rem;
}

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

.post-single .post-meta {
    justify-content: center;
}

.separator {
    color: var(--color-text-light);
}

.post-content {
    font-size: 1.125rem;
    line-height: 1.75;
}

.post-content img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 2rem 0;
}

/* Code Blocks */
.post-content pre {
    margin: 1.5rem 0;
    border-radius: 8px;
    overflow-x: auto;
}

.post-content code {
    font-family: var(--font-mono);
    font-size: 0.875em;
    background: var(--color-code-bg);
    padding: 0.2em 0.4em;
    border-radius: 3px;
}

.post-content pre code {
    background: none;
    padding: 0;
    font-size: 0.875rem;
}

.highlight {
    position: relative;
    margin: 1.5rem 0;
}

.highlight pre {
    padding: 1.5rem;
    margin: 0;
    overflow-x: auto;
    border: 1px solid var(--color-code-border);
}

/* Tables */
.post-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 2rem 0;
    font-size: 0.95rem;
}

.post-content table th,
.post-content table td {
    padding: 0.75rem;
    text-align: left;
    border: 1px solid var(--color-border);
}

.post-content table th {
    background: var(--color-code-bg);
    font-weight: 600;
}

.post-content table tr:nth-child(even) {
    background: rgba(0, 0, 0, 0.02);
}

/* Blockquotes */
.post-content blockquote {
    border-left: 4px solid var(--color-primary);
    padding-left: 1.5rem;
    margin: 1.5rem 0;
    font-style: italic;
    color: var(--color-text-light);
}

/* Lists */
.post-content ul,
.post-content ol {
    margin: 1rem 0 1rem 2rem;
}

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

/* Task Lists */
.post-content .task-list-item {
    list-style: none;
    margin-left: -1.5rem;
}

.post-content .task-list-item input[type="checkbox"] {
    margin-right: 0.5rem;
}

/* Footer */
.site-footer {
    padding: 2rem 0;
    border-top: 1px solid var(--color-border);
    text-align: center;
    color: var(--color-text-light);
}

.footer-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.social-links {
    display: flex;
    gap: 1.5rem;
}

/* Search Modal */
.search-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
}

.search-modal.active {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 10vh;
}

.search-content {
    background: white;
    padding: 2rem;
    border-radius: 8px;
    width: 90%;
    max-width: 600px;
    position: relative;
}

#search-input {
    width: 100%;
    padding: 0.75rem;
    font-size: 1.125rem;
    border: 2px solid var(--color-border);
    border-radius: 4px;
    margin-bottom: 1rem;
}

#search-results {
    max-height: 400px;
    overflow-y: auto;
}

.search-result {
    padding: 1rem;
    border-bottom: 1px solid var(--color-border);
}

.search-result:last-child {
    border-bottom: none;
}

.search-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: none;
    border: none;
    font-size: 2rem;
    cursor: pointer;
    color: var(--color-text-light);
}

/* Responsive */
@media (max-width: 768px) {
    html {
        font-size: 15px;
    }
    
    .nav-links {
        gap: 1rem;
    }
    
    .hero {
        padding: 2rem 0;
    }
    
    .post-card {
        padding: 1.5rem;
    }
    
    .footer-content {
        flex-direction: column;
        gap: 1rem;
    }
}