/* ============================================================================
   Pongsak Blog — Minimal Clean Stylesheet
   ============================================================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    line-height: 1.7;
    color: #1a1a1a;
    background: #fafafa;
    -webkit-font-smoothing: antialiased;
}

.container {
    max-width: 720px;
    margin: 0 auto;
    padding: 40px 20px;
}
/* Expand container when homepage has TOC sidebar */
.container:has(.home-layout) {
    max-width: 1100px;
}

a { color: #2563eb; text-decoration: none; }
a:hover { text-decoration: underline; }

/* Blog Header */
.blog-header {
    margin-bottom: 48px;
    padding-bottom: 24px;
    border-bottom: 1px solid #e5e5e5;
}
.blog-header h1 {
    font-size: 32px;
    font-weight: 800;
    letter-spacing: -0.5px;
    margin-bottom: 4px;
}
.blog-subtitle {
    color: #666;
    font-size: 17px;
}

/* Post List */
.post-list { display: flex; flex-direction: column; gap: 32px; }

.post-card {
    padding-bottom: 32px;
    border-bottom: 1px solid #eee;
}
.post-card:last-child { border-bottom: none; }

.post-card h2 {
    font-size: 22px;
    font-weight: 700;
    line-height: 1.3;
    margin-bottom: 6px;
}
.post-card a { color: #1a1a1a; }
.post-card a:hover { color: #2563eb; text-decoration: none; }

.post-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    color: #888;
    margin-bottom: 8px;
}
.post-meta time { font-variant-numeric: tabular-nums; }

.post-excerpt {
    color: #555;
    font-size: 16px;
    line-height: 1.6;
}

/* Tags */
.post-tags { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.tag {
    background: #f0f0f0;
    color: #555;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

/* Single Post */
.post-top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}
.back-link {
    display: inline-block;
    color: #888;
    font-size: 14px;
}
.back-link:hover { color: #2563eb; }

.post-actions { display: flex; gap: 8px; align-items: center; }
.btn-sm {
    padding: 5px 14px;
    border: none;
    border-radius: 5px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    font-family: inherit;
}
.btn-edit { background: #e5e7eb; color: #374151; }
.btn-edit:hover { background: #d1d5db; text-decoration: none; }
.btn-delete { background: #fee2e2; color: #dc2626; }
.btn-delete:hover { background: #fecaca; }

.post-full .post-title {
    font-size: 34px;
    font-weight: 800;
    line-height: 1.2;
    letter-spacing: -0.5px;
    margin-bottom: 12px;
}
.post-full .post-meta { margin-bottom: 32px; }

/* Homepage two-column layout: TOC left + posts right */
.home-layout {
    display: flex;
    gap: 40px;
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 20px;
}
.home-layout .home-main {
    flex: 1;
    min-width: 0;
    max-width: 720px;
}

/* Table of Contents — sticky left sidebar */
.toc {
    width: 220px;
    flex-shrink: 0;
    position: sticky;
    top: 24px;
    align-self: flex-start;
    max-height: calc(100vh - 48px);
    overflow-y: auto;
    padding: 16px 0;
}
.toc-title {
    font-weight: 700;
    font-size: 13px;
    color: #999;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
}
.toc ul {
    list-style: none;
    margin: 0;
    padding: 0;
    border-left: 2px solid #e5e5e5;
    padding-left: 14px;
}
.toc li { margin: 8px 0; }
.toc li a {
    color: #555;
    font-size: 13px;
    text-decoration: none;
    line-height: 1.4;
    display: block;
    transition: color 0.15s;
}
.toc li a:hover { color: #2563eb; }

/* On mobile/tablet: TOC hidden (post list IS the content) */
@media (max-width: 900px) {
    .home-layout {
        flex-direction: column;
        gap: 0;
        max-width: 720px;
    }
    .toc { display: none; }
}

/* Post Content Typography */
.post-content {
    font-size: 17px;
    line-height: 1.8;
}
.post-content h2 {
    font-size: 24px;
    font-weight: 700;
    margin: 40px 0 16px;
}
.post-content h3 {
    font-size: 20px;
    font-weight: 700;
    margin: 32px 0 12px;
}
.post-content p { margin-bottom: 20px; }
.post-content img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 24px 0;
}
.post-content ul, .post-content ol {
    margin: 0 0 20px 24px;
}
.post-content li { margin-bottom: 6px; }
.post-content blockquote {
    border-left: 3px solid #ddd;
    padding: 8px 20px;
    margin: 20px 0;
    color: #555;
    font-style: italic;
    background: #f9f9f9;
    border-radius: 0 6px 6px 0;
}
.post-content code {
    background: #f3f4f6;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.9em;
    font-family: "SF Mono", "Fira Code", "Fira Mono", Menlo, monospace;
}
.post-content pre {
    background: #1e293b;
    color: #e2e8f0;
    padding: 20px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 20px 0;
}
.post-content pre code {
    background: none;
    padding: 0;
    color: inherit;
}
.post-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 20px 0;
}
.post-content th, .post-content td {
    border: 1px solid #e5e5e5;
    padding: 10px 14px;
    text-align: left;
}
.post-content th { background: #f5f5f5; font-weight: 600; }
.post-content hr {
    border: none;
    border-top: 1px solid #e5e5e5;
    margin: 32px 0;
}
.post-content a { text-decoration: underline; }

/* Empty State */
.empty-state { color: #888; font-size: 18px; text-align: center; padding: 60px 0; }

/* Footer */
.site-footer {
    text-align: center;
    padding: 32px 20px;
    color: #aaa;
    font-size: 14px;
    border-top: 1px solid #eee;
    max-width: 720px;
    margin: 40px auto 0;
}

/* Responsive */
@media (max-width: 600px) {
    .container { padding: 24px 16px; }
    .blog-header h1 { font-size: 26px; }
    .post-full .post-title { font-size: 26px; }
    .post-card h2 { font-size: 19px; }
    .post-content { font-size: 16px; }
}
