/* Reset & Base */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; line-height: 1.6; color: #334155; background: #f8f9fa; }
a { color: #2980b9; text-decoration: none; }
a:hover { color: #2471a3; }
img { max-width: 100%; height: auto; }

/* Container */
.container { max-width: 1100px; margin: 0 auto; padding: 0 1rem; }

/* Header */
.site-header { background: #1e3a5f; color: #fff; padding: 1rem 0; position: sticky; top: 0; z-index: 100; }
.header-inner { display: flex; align-items: center; justify-content: space-between; }
.site-logo { font-size: 1.5rem; font-weight: 700; color: #fff; margin: 0; }
.site-logo a { color: inherit; }
.site-logo a:hover { color: #d0dce8; }
.site-nav { display: flex; gap: 1.5rem; }
.site-nav a { color: #b0c4d8; font-weight: 500; }
.site-nav a:hover { color: #fff; }
.nav-toggle { display: none; background: none; border: none; color: #fff; font-size: 1.5rem; cursor: pointer; }

/* Categories bar */
.categories-bar { background: #edf2f7; border-bottom: 1px solid #dee2e6; margin-bottom: 1.5rem; border-radius: 6px; padding: 1rem 0; }
.categories-list { display: flex; gap: 1rem; flex-wrap: wrap; }
.categories-list a { color: #495057; font-size: 0.9rem; padding: 0.25rem 0.75rem; border-radius: 1rem; background: #fff; border: 1px solid #dee2e6; }
.categories-list a:hover, .categories-list a.active { background: #2980b9; color: #fff; border-color: #2980b9; }

/* Main */
.site-main { padding: 2rem 0; min-height: 60vh; }

/* Hero */
.hero { text-align: center; padding: 3rem 0; margin-bottom: 2rem; }
.hero h1 { font-size: 2.5rem; color: #1e3a5f; margin-bottom: 0.5rem; }
.hero p { font-size: 1.1rem; color: #6c757d; }

/* Home intro */
.home-intro { background: #fff; border: 1px solid #dee2e6; border-radius: 8px; padding: 1.5rem 2rem; margin-bottom: 2rem; display: flex; align-items: center; justify-content: space-between; gap: 1.5rem; }
.home-intro p { color: #495057; font-size: 0.95rem; margin: 0; flex: 1; }
.home-intro .btn { white-space: nowrap; flex-shrink: 0; }
@media (max-width: 768px) {
    .home-intro { flex-direction: column; text-align: center; padding: 1.25rem; }
}

/* Home layout */
.home-layout { display: grid; grid-template-columns: 1fr 340px; gap: 2.5rem; align-items: start; }
.home-main { min-width: 0; }
.home-sidebar { position: sticky; top: 5rem; }
.sidebar-posts { list-style: none; }
.sidebar-post { padding: 0.75rem 0; border-bottom: 1px solid #dee2e6; }
.sidebar-post:last-child { border-bottom: none; }
.sidebar-post-link { display: flex; gap: 0.75rem; align-items: center; color: inherit; }
.sidebar-post-link:hover { color: inherit; }
.sidebar-post-thumb { width: 56px; min-width: 56px; height: 56px; border-radius: 4px; object-fit: cover; }
.sidebar-post-thumb-placeholder { object-fit: contain; background: #edf2f7; }
.sidebar-post-title { display: block; font-weight: 600; color: #1e3a5f; font-size: 0.95rem; margin-bottom: 0.2rem; line-height: 1.3; }
.sidebar-post-link:hover .sidebar-post-title { color: #2980b9; }
.sidebar-post-meta { font-size: 0.8rem; color: #6c757d; margin-bottom: 0; }
.sidebar-post-excerpt { font-size: 0.85rem; color: #6c757d; margin: 0; }
.btn-block { display: block; text-align: center; margin-top: 1rem; }

/* Tags cloud */
.tags-cloud { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.tag-link { display: inline-block; padding: 0.35rem 0.75rem; background: #edf2f7; color: #1e3a5f; border-radius: 2rem; font-size: 0.85rem; font-weight: 500; transition: background 0.2s, color 0.2s; }
.tag-link:hover { background: #1e3a5f; color: #fff; text-decoration: none; }

/* Section */
.section { margin-bottom: 3rem; }
.section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; }
.section-header h2 { font-size: 1.5rem; color: #1e3a5f; }

/* Cards */
.cards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 1.5rem; }
.card { background: #fff; border: 1px solid #dee2e6; border-radius: 8px; overflow: hidden; transition: box-shadow 0.2s; }
.card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.08); }
.card-image { width: 100%; height: 200px; object-fit: cover; }
.card-body { padding: 1.25rem; }
.card-title { font-size: 1.1rem; margin-bottom: 0.5rem; }
.card-title a { color: #1e3a5f; }
.card-title a:hover { color: #2980b9; }
.card-meta { display: flex; gap: 1rem; font-size: 0.85rem; color: #6c757d; margin-bottom: 0.75rem; }
.card-excerpt { color: #6c757d; font-size: 0.95rem; }

/* Page header */
.page-header { margin-bottom: 1rem; }
.page-header h1 { font-size: 2rem; color: #1e3a5f; margin-bottom: 0.5rem; }
.sort-options { display: flex; gap: 0.75rem; align-items: center; margin-top: 0.5rem; font-size: 0.9rem; }
.sort-options a { padding: 0.25rem 0.75rem; border-radius: 4px; color: #6c757d; }
.sort-options a.active, .sort-options a:hover { background: #2980b9; color: #fff; }

/* Detail layout (article/post + sidebar) */
.detail-layout { display: grid; grid-template-columns: 1fr 300px; gap: 2.5rem; align-items: start; }
.detail-main { min-width: 0; }
.content-sidebar { position: sticky; top: 5rem; }
.sidebar-section { margin-bottom: 2rem; }
.sidebar-section h4 { font-size: 1.05rem; color: #1e3a5f; margin-bottom: 0.75rem; padding-bottom: 0.5rem; border-bottom: 2px solid #dee2e6; }

/* Article detail */
.article-detail { max-width: none; }
.article-detail-wide { max-width: none; }

/* See also */
.see-also { margin-top: 2.5rem; padding-top: 1.5rem; border-top: 1px solid #dee2e6; }
.see-also h3 { font-size: 1.3rem; color: #1e3a5f; margin-bottom: 1.25rem; }
.see-also-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.25rem; }
.see-also-card { display: block; background: #fff; border: 1px solid #dee2e6; border-radius: 8px; overflow: hidden; color: inherit; transition: box-shadow 0.2s; }
.see-also-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.08); color: inherit; }
.see-also-image { width: 100%; height: 140px; object-fit: cover; display: block; }
.see-also-placeholder { background: #edf2f7; }
.see-also-body { padding: 0.75rem 1rem; }
.see-also-title { font-size: 0.95rem; font-weight: 600; color: #1e3a5f; margin-bottom: 0.3rem; line-height: 1.3; }
.see-also-card:hover .see-also-title { color: #2980b9; }
.see-also-date { font-size: 0.8rem; color: #6c757d; }
.see-also-excerpt { font-size: 0.85rem; color: #6c757d; margin: 0.3rem 0 0; }
.article-header { margin-bottom: 2rem; }
.article-header h1 { font-size: 2rem; color: #1e3a5f; margin-bottom: 0.75rem; }
.article-meta { display: flex; gap: 1.5rem; color: #6c757d; font-size: 0.9rem; margin-bottom: 1rem; flex-wrap: wrap; }
.article-categories, .article-tags { margin-bottom: 0.5rem; font-size: 0.9rem; color: #6c757d; }
.tag { display: inline-block; padding: 0.2rem 0.6rem; background: #edf2f7; border-radius: 4px; font-size: 0.85rem; color: #495057; margin: 0.15rem; }
.tag:hover { background: #2980b9; color: #fff; }
.article-image { margin-bottom: 2rem; border-radius: 8px; overflow: hidden; }
.article-image[data-attribution]::after { content: attr(data-attribution); display: block; text-align: right; font-size: 0.7rem; color: #8b95a5; font-style: italic; margin-top: 0.25rem; }
.article-lead { font-size: 1.1rem; line-height: 1.7; color: #4a5568; font-weight: 700; margin-bottom: 2rem; padding-bottom: 1.5rem; border-bottom: 1px solid #dee2e6; }
.article-content { font-size: 1.05rem; line-height: 1.8; }
.article-content h2 { margin-top: 2rem; margin-bottom: 0.75rem; color: #1e3a5f; }
.article-content h3 { margin-top: 1.5rem; margin-bottom: 0.5rem; color: #1e3a5f; }
.article-content p { margin-bottom: 1rem; }
.article-content ul, .article-content ol { margin-bottom: 1rem; padding-left: 2rem; }
.article-content pre { background: #1e293b; color: #e2e8f0; padding: 1rem; border-radius: 6px; overflow-x: auto; margin-bottom: 1rem; }
.article-content code { background: #edf2f7; padding: 0.15rem 0.4rem; border-radius: 3px; font-size: 0.9em; }
.article-content pre code { background: transparent; padding: 0; }
.article-content blockquote { border-left: 4px solid #2980b9; padding: 1rem 1.5rem; margin: 1.5rem 0; background: #f0f6fb; }
.article-content img { border-radius: 6px; margin: 1rem 0; }

/* Share buttons */
.share-buttons { display: flex; align-items: center; gap: 0.75rem; margin-top: 2rem; padding-top: 1.5rem; border-top: 1px solid #dee2e6; }
.share-label { font-size: 0.9rem; color: #6c757d; font-weight: 500; }
.share-btn { display: inline-block; padding: 0.4rem 1rem; border-radius: 4px; font-size: 0.85rem; font-weight: 500; color: #fff; transition: opacity 0.2s; }
.share-btn:hover { opacity: 0.85; color: #fff; }
.share-btn-fb { background: #1877f2; }
.share-btn-tw { background: #000; }

/* Post navigation (prev/next) */
.post-nav { display: flex; justify-content: space-between; gap: 1rem; margin-top: 2rem; padding-top: 1.5rem; border-top: 1px solid #dee2e6; }
.post-nav-prev, .post-nav-next { flex: 1; min-width: 0; }
.post-nav-next { text-align: right; }
.post-nav a { display: block; padding: 0.75rem 1rem; background: #1e3a5f; border: 1px solid #1e3a5f; border-radius: 6px; color: #fff; transition: background 0.2s; }
.post-nav a:hover { background: #2980b9; border-color: #2980b9; }
.post-nav-label { display: block; font-size: 0.8rem; color: #9db5cc; margin-bottom: 0.25rem; }
.post-nav-title { display: block; font-size: 0.95rem; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Post list (compact) */
.post-list { display: flex; flex-direction: column; gap: 1rem; }
.post-list-item { display: flex; flex-wrap: wrap; background: #fff; border: 1px solid #dee2e6; border-radius: 8px; overflow: hidden; transition: box-shadow 0.2s; }
.post-list-item:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.08); }
.post-list-thumb { width: 180px; min-width: 180px; height: 120px; object-fit: cover; }
.post-list-thumb-placeholder { object-fit: contain; background: #edf2f7; }
.post-list-body { flex: 1; padding: 0.75rem 1.25rem; display: flex; flex-direction: column; justify-content: center; min-width: 0; }
.post-list-footer { display: none; }
.post-list-title { font-size: 1.05rem; margin-bottom: 0.25rem; overflow-wrap: break-word; word-wrap: break-word; }
.post-list-title a { color: #1e3a5f; }
.post-list-title a:hover { color: #2980b9; }
.post-list-meta { display: flex; gap: 1rem; font-size: 0.85rem; color: #6c757d; margin-bottom: 0.35rem; }
.post-list-excerpt { color: #6c757d; font-size: 0.9rem; margin: 0; }
@media (max-width: 768px) {
    .post-list-thumb { width: 100px; min-width: 100px; height: 80px; }
}
@media (max-width: 420px) {
    .post-list-thumb-placeholder { display: none; }
    .post-list-item:has(.post-list-thumb:not(.post-list-thumb-placeholder)) { display: grid; grid-template-columns: 1fr 1fr; }
    .post-list-thumb { width: 100%; min-width: 0; height: 100%; min-height: 80px; }
    .post-list-body { padding: 0.6rem 0.75rem; }
    .post-list-title { font-size: 0.95rem; }
    .post-list-desktop { display: none; }
    .post-list-footer { display: block; grid-column: 1 / -1; padding: 0 0.75rem 0.6rem; }
    .post-list-footer .post-list-meta { margin-bottom: 0.2rem; }
    .post-list-footer .post-list-excerpt { overflow-wrap: break-word; word-wrap: break-word; }
}

/* Pagination */
.pagination-nav { display: flex; justify-content: center; gap: 0.5rem; margin-top: 2rem; padding: 1rem 0; }
.pagination-link { display: inline-block; padding: 0.5rem 1rem; border: 1px solid #dee2e6; border-radius: 4px; color: #495057; }
.pagination-link:hover { background: #edf2f7; }
.pagination-link.active { background: #2980b9; color: #fff; border-color: #2980b9; }

/* Comments */
.comments-section { margin-top: 3rem; padding-top: 2rem; border-top: 1px solid #dee2e6; }
.comments-section h3 { font-size: 1.3rem; margin-bottom: 1.5rem; }
.comments-list { margin-bottom: 2rem; }
.comment { padding: 1rem; border: 1px solid #dee2e6; border-radius: 6px; margin-bottom: 1rem; background: #fff; }
.comment-header { display: flex; justify-content: space-between; margin-bottom: 0.5rem; }
.comment-date { color: #6c757d; font-size: 0.85rem; }
.comment-body { color: #495057; }
.comment-form { max-width: 600px; margin-top: 1rem; }
.form-message { margin-top: 1rem; padding: 0.75rem; border-radius: 4px; }
.form-message.success { background: #dcfce7; color: #166534; }
.form-message.error { background: #fef2f2; color: #991b1b; }

/* Forms */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; margin-bottom: 0.3rem; font-weight: 500; color: #334155; font-size: 0.95rem; }
.form-group input, .form-group textarea, .form-group select {
    width: 100%; padding: 0.6rem 0.75rem; border: 1px solid #ced4da; border-radius: 6px;
    font-size: 1rem; font-family: inherit; background: #fff;
}
.form-group input:focus, .form-group textarea:focus { outline: none; border-color: #2980b9; box-shadow: 0 0 0 3px rgba(41,128,185,0.15); }

/* Buttons */
.btn { display: inline-block; padding: 0.6rem 1.25rem; border-radius: 6px; font-size: 0.95rem; font-weight: 500; cursor: pointer; border: none; text-align: center; }
.btn-primary { background: #2980b9; color: #fff; }
.btn-primary:hover { background: #2471a3; color: #fff; }
.btn-outline { background: transparent; border: 1px solid #2980b9; color: #2980b9; }
.btn-outline:hover { background: #2980b9; color: #fff; }

/* Alerts */
.alert { padding: 0.75rem 1rem; border-radius: 6px; margin-bottom: 1.5rem; }
.alert-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.alert-error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }

/* Narrow content */
.content-narrow { max-width: 600px; }

/* Error page */
.error-page { text-align: center; padding: 4rem 0; }
.error-page h1 { font-size: 5rem; color: #dee2e6; margin-bottom: 0.5rem; }
.error-page h2 { font-size: 1.5rem; color: #334155; margin-bottom: 1rem; }
.error-page p { color: #6c757d; margin-bottom: 2rem; }

/* Text utils */
.text-muted { color: #6c757d; }

/* Footer */
.site-footer { background: #1e3a5f; color: #9db5cc; padding: 3rem 0 1.5rem; margin-top: 3rem; }
.footer-inner { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 2rem; margin-bottom: 2rem; }
.footer-col h4 { color: #fff; margin-bottom: 0.75rem; font-size: 1rem; }
.footer-col p { font-size: 0.9rem; }
.footer-col ul { list-style: none; }
.footer-col ul li { margin-bottom: 0.4rem; }
.footer-col ul a { color: #9db5cc; font-size: 0.9rem; }
.footer-col ul a:hover { color: #fff; }
.footer-bottom { border-top: 1px solid #2c5a8a; padding-top: 1.5rem; text-align: center; font-size: 0.85rem; }

/* Responsive */
@media (max-width: 768px) {
    .site-nav { display: none; flex-direction: column; position: absolute; top: 100%; left: 0; right: 0; background: #1e3a5f; padding: 1rem; gap: 0.5rem; }
    .site-nav.active { display: flex; }
    .nav-toggle { display: block; }
    .home-layout { grid-template-columns: 1fr; }
    .home-sidebar { position: static; }
    .detail-layout { grid-template-columns: 1fr; }
    .content-sidebar { position: static; }
    .see-also-grid { grid-template-columns: 1fr; }
    .cards-grid { grid-template-columns: 1fr; }
    .hero h1 { font-size: 1.8rem; }
    .article-meta { flex-direction: column; gap: 0.25rem; }
    .sort-options { flex-wrap: wrap; }
    .post-nav { flex-direction: column; }
    .post-nav-next { text-align: left; }
}
