/* ========================================
   CMCS 博客 — 终端 / 技术暗色风格
   基于 GitHub Dark 配色，不重不腻
   ======================================== */

/* === Reset & Theme Variables === */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --bg:        #0d1117;
    --surface:   #161b22;
    --elevated:  #1c2128;
    --border:    #30363d;
    --text:      #c9d1d9;
    --muted:     #8b949e;
    --accent:    #3fb950;
    --accent-dim: rgba(63, 185, 80, 0.12);
    --blue:      #58a6ff;
    --red:       #f85149;
    --orange:    #d2991d;
    --code-bg:   #161b22;

    --font-mono: 'SF Mono', 'Cascadia Code', 'Fira Code', 'Consolas', 'Monaco', monospace;
    --font-sans: system-ui, -apple-system, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
    --font-serif: 'Georgia', 'Noto Serif SC', 'STSong', serif;

    --shadow: 0 0 0 1px rgba(240, 246, 252, 0.04), 0 4px 16px rgba(0,0,0,0.4);
    --radius: 6px;
}

html { scroll-behavior: smooth; }

body {
    font-family: var(--font-sans);
    background: var(--bg);
    color: var(--text);
    line-height: 1.7;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
}

/* 背景微网格 */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    background-image:
        linear-gradient(rgba(255,255,255,0.015) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,0.015) 1px, transparent 1px);
    background-size: 40px 40px;
}

a { color: var(--accent); text-decoration: none; transition: color 0.15s; }
a:hover { color: #5cdb6e; }

/* =========================================
   Header — 终端顶栏
   ========================================= */
.blog-site-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: fixed;
    width: 100%;
    top: 0;
    z-index: 100;
    height: 52px;
    overflow: hidden;
}

/* 底部扫描线 */
.header-scanline {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 1px;
    background: linear-gradient(90deg,
        transparent 0%,
        rgba(63, 185, 80, 0.15) 15%,
        rgba(63, 185, 80, 0.45) 50%,
        rgba(63, 185, 80, 0.15) 85%,
        transparent 100%
    );
    animation: scanline-drift 3s ease-in-out infinite;
}
@keyframes scanline-drift {
    0%, 100% { opacity: 0.35; }
    50% { opacity: 1; }
}

.blog-nav-inner {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 24px;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.blog-site-title {
    font-size: 0.95rem;
    font-weight: 600;
    font-family: var(--font-mono);
    color: var(--text) !important;
    display: flex;
    align-items: center;
    gap: 1px;
}
.blog-site-title .prompt { color: var(--muted); }
.blog-site-title .cursor {
    color: var(--accent);
    animation: blink-cursor 1s step-end infinite;
    font-size: 1rem;
    line-height: 1;
}
.blog-site-title:hover .prompt { color: var(--text); }
@keyframes blink-cursor {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

.blog-site-nav { display: flex; gap: 28px; }
.blog-site-nav a {
    color: var(--muted);
    font-size: 0.8rem;
    font-family: var(--font-mono);
    transition: color 0.15s;
}
.blog-site-nav a:hover { color: var(--accent); }
.blog-site-nav .nav-icon { color: var(--accent); margin-right: 1px; }

/* =========================================
   Footer
   ========================================= */
.blog-site-footer {
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: 28px 0;
    text-align: center;
    color: var(--muted);
    font-size: 0.8rem;
    font-family: var(--font-mono);
}
.blog-site-footer a { color: var(--muted); }
.blog-site-footer a:hover { color: var(--accent); }

/* =========================================
   Layout
   ========================================= */
.blog-wrapper {
    display: flex;
    gap: 48px;
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 24px;
    position: relative;
    z-index: 1;
}
.blog-main { flex: 1; min-width: 0; }
.blog-sidebar { width: 270px; flex-shrink: 0; padding-top: 36px; }

/* =========================================
   文章列表页
   ========================================= */
.blog-list-page { padding-top: 100px; padding-bottom: 80px; }

.blog-list-header {
    margin-bottom: 40px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border);
}
.blog-list-header h1 {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 6px;
    font-family: var(--font-mono);
}
.blog-list-header h1::before { content: '# '; color: var(--accent); }
.blog-list-header p {
    color: var(--muted);
    font-size: 0.9rem;
    font-family: var(--font-mono);
}
.blog-list-header p::before { content: '// '; color: var(--muted); }

/* 文章条目 */
.blog-post-list { display: flex; flex-direction: column; }

.blog-post-item {
    position: relative;
    padding: 24px 20px;
    border: 1px solid transparent;
    border-radius: var(--radius);
    margin-bottom: 4px;
    background: transparent;
    transition: all 0.2s ease;
}
.blog-post-item:hover {
    background: var(--surface);
    border-color: var(--border);
    box-shadow: var(--shadow);
}

.blog-post-item .post-date {
    font-size: 0.75rem;
    color: var(--muted);
    font-family: var(--font-mono);
    margin-bottom: 6px;
}
.blog-post-item .post-date::before { content: '$ date -r '; color: var(--accent); margin-right: 4px; }

.blog-post-item h2 {
    font-size: 1.2rem;
    line-height: 1.4;
    margin-bottom: 6px;
    font-weight: 600;
}
.blog-post-item h2 a { color: var(--text); }
.blog-post-item h2 a:hover { color: var(--accent); }
.blog-post-item h2 a::before { content: '> '; color: var(--accent); font-family: var(--font-mono); }

.blog-post-item .post-excerpt {
    color: var(--muted);
    font-size: 0.9rem;
    line-height: 1.65;
    margin-bottom: 8px;
}

.blog-post-item .post-meta-bottom {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.75rem;
    color: #484f58;
    font-family: var(--font-mono);
}
.blog-post-item .post-meta-bottom .tag {
    display: inline-block;
    padding: 1px 8px;
    background: var(--accent-dim);
    color: var(--accent);
    border-radius: 3px;
    font-size: 0.7rem;
    border: 1px solid rgba(63, 185, 80, 0.2);
}

.blog-post-item .post-cover-thumb {
    float: right;
    width: 120px;
    height: 78px;
    object-fit: cover;
    border-radius: 4px;
    margin-left: 20px;
    margin-bottom: 6px;
    border: 1px solid var(--border);
    filter: brightness(0.85);
    transition: filter 0.2s;
}
.blog-post-item:hover .post-cover-thumb { filter: brightness(1); }

/* 分页 */
.blog-pagination {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin-top: 40px;
}
.blog-pagination .page-btn {
    padding: 7px 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--muted);
    font-size: 0.82rem;
    font-family: var(--font-mono);
    transition: all 0.15s;
}
.blog-pagination .page-btn:hover { border-color: var(--accent); color: var(--accent); }
.blog-pagination .page-btn.active {
    background: var(--accent);
    color: #0d1117;
    border-color: var(--accent);
    font-weight: 600;
}

/* 空状态 */
.blog-empty {
    text-align: center;
    padding: 80px 20px;
    color: var(--muted);
    font-family: var(--font-mono);
}
.blog-empty i { display: block; font-size: 2.5rem; margin-bottom: 16px; color: #30363d; }

/* =========================================
   侧边栏
   ========================================= */
.sidebar-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 16px;
    margin-bottom: 16px;
}
.sidebar-card h4 {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--muted);
    margin-bottom: 12px;
    font-weight: 700;
    font-family: var(--font-mono);
}
.sidebar-card h4::before { content: '# '; color: var(--accent); }

.sidebar-about .sidebar-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #0d1117;
    font-size: 1.2rem;
    font-weight: 700;
    font-family: var(--font-mono);
    margin-bottom: 10px;
}
.sidebar-about p {
    font-size: 0.82rem;
    color: var(--muted);
    line-height: 1.6;
}

.sidebar-links a {
    display: block;
    padding: 5px 0;
    color: var(--muted);
    font-size: 0.82rem;
    font-family: var(--font-mono);
    transition: color 0.15s;
}
.sidebar-links a:hover { color: var(--accent); }
.sidebar-links a i { margin-right: 6px; width: 14px; text-align: center; font-size: 0.75rem; }
.sidebar-links a::before { content: '> '; color: var(--accent); font-size: 0.7rem; }

.sidebar-tags .tag-cloud { display: flex; flex-wrap: wrap; gap: 6px; }
.sidebar-tags .tag-item {
    padding: 2px 8px;
    background: var(--accent-dim);
    border: 1px solid rgba(63, 185, 80, 0.2);
    color: var(--accent);
    border-radius: 3px;
    font-size: 0.72rem;
    font-family: var(--font-mono);
    transition: all 0.15s;
}
.sidebar-tags .tag-item:hover {
    background: var(--accent);
    color: #0d1117;
}

/* =========================================
   文章详情页
   ========================================= */
.blog-post-detail { padding-top: 100px; padding-bottom: 80px; }
.blog-article { max-width: 740px; margin: 0 auto; }

/* 文章头部 */
.blog-article .article-header {
    margin-bottom: 40px;
    text-align: left;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border);
}
.blog-article .article-header h1 {
    font-size: 2rem;
    line-height: 1.35;
    color: var(--text);
    font-weight: 700;
    margin-bottom: 12px;
    font-family: var(--font-sans);
}
.blog-article .article-meta {
    display: flex;
    align-items: center;
    gap: 16px;
    color: var(--muted);
    font-size: 0.8rem;
    font-family: var(--font-mono);
    flex-wrap: wrap;
}
.blog-article .article-meta i { margin-right: 2px; }
.blog-article .article-meta .tag {
    display: inline-block;
    padding: 1px 8px;
    background: var(--accent-dim);
    color: var(--accent);
    border-radius: 3px;
    font-size: 0.72rem;
    margin: 0 2px;
    border: 1px solid rgba(63, 185, 80, 0.2);
}

.blog-article .article-cover {
    width: 100%;
    border-radius: var(--radius);
    margin-bottom: 40px;
    max-height: 380px;
    object-fit: cover;
    border: 1px solid var(--border);
}

/* ===== 文章正文 ===== */
.blog-article .article-body {
    font-family: var(--font-serif);
    font-size: 1.08rem;
    line-height: 1.9;
    color: #c9d1d9;
}

/* 标题 */
.blog-article .article-body h2 {
    font-family: var(--font-sans);
    font-size: 1.4rem;
    font-weight: 600;
    color: #f0f6fc;
    margin: 44px 0 14px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}
.blog-article .article-body h2:first-child { margin-top: 0; }
.blog-article .article-body h3 {
    font-family: var(--font-sans);
    font-size: 1.15rem;
    font-weight: 600;
    color: #f0f6fc;
    margin: 32px 0 10px;
}
.blog-article .article-body h4 {
    font-family: var(--font-sans);
    font-size: 1.02rem;
    font-weight: 600;
    color: var(--text);
    margin: 24px 0 8px;
}

/* 段落与文字 */
.blog-article .article-body p { margin: 16px 0; }
.blog-article .article-body strong { color: #f0f6fc; }
.blog-article .article-body em { color: var(--muted); }

/* 链接 */
.blog-article .article-body a {
    color: var(--accent);
    text-decoration: underline;
    text-underline-offset: 3px;
    text-decoration-color: rgba(63, 185, 80, 0.3);
}
.blog-article .article-body a:hover { color: #5cdb6e; text-decoration-color: var(--accent); }

/* 行内代码 */
.blog-article .article-body code {
    font-family: var(--font-mono);
    background: var(--code-bg);
    padding: 2px 7px;
    border-radius: 4px;
    font-size: 0.88em;
    color: var(--orange);
    border: 1px solid var(--border);
}

/* 代码块 */
.blog-article .article-body pre {
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 20px 22px;
    border-radius: var(--radius);
    overflow-x: auto;
    margin: 22px 0;
    line-height: 1.6;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: #c9d1d9;
}
.blog-article .article-body pre code {
    background: none;
    padding: 0;
    color: inherit;
    font-size: inherit;
    border: none;
    border-radius: 0;
}

/* 列表 */
.blog-article .article-body ul,
.blog-article .article-body ol { padding-left: 24px; margin: 14px 0; }
.blog-article .article-body li { margin: 6px 0; }
.blog-article .article-body li::marker { color: var(--accent); }

/* 引用 */
.blog-article .article-body blockquote {
    border-left: 3px solid var(--accent);
    padding: 12px 18px;
    margin: 24px 0;
    background: var(--accent-dim);
    border-radius: 0 var(--radius) var(--radius) 0;
    font-style: italic;
    color: var(--muted);
}
.blog-article .article-body blockquote p { margin: 4px 0; }
.blog-article .article-body blockquote p:first-child { margin-top: 0; }
.blog-article .article-body blockquote p:last-child { margin-bottom: 0; }

/* 图片 */
.blog-article .article-body img {
    max-width: 100%;
    border-radius: var(--radius);
    margin: 24px auto;
    display: block;
    border: 1px solid var(--border);
}

/* 表格 */
.blog-article .article-body table {
    width: 100%;
    border-collapse: collapse;
    margin: 22px 0;
    font-size: 0.9rem;
    font-family: var(--font-sans);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}
.blog-article .article-body th {
    background: var(--surface);
    color: #f0f6fc;
    padding: 10px 14px;
    text-align: left;
    font-weight: 600;
    border-bottom: 1px solid var(--border);
}
.blog-article .article-body td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
}
.blog-article .article-body tr:last-child td { border-bottom: none; }

/* 分割线 */
.blog-article .article-body hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 36px 0;
}

/* ===== 文章底部导航 ===== */
.article-nav {
    display: flex;
    justify-content: space-between;
    margin-top: 48px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
    font-family: var(--font-mono);
}
.article-nav a {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--muted);
    font-size: 0.82rem;
    max-width: 46%;
    transition: color 0.15s;
}
.article-nav a:hover { color: var(--accent); }
.article-nav a span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.article-back {
    text-align: center;
    margin-top: 24px;
    font-family: var(--font-mono);
}
.article-back a {
    color: var(--muted);
    font-size: 0.8rem;
    transition: color 0.15s;
}
.article-back a:hover { color: var(--accent); }

/* =========================================
   响应式
   ========================================= */
@media (max-width: 860px) {
    .blog-wrapper { flex-direction: column; gap: 28px; }
    .blog-sidebar { width: 100%; padding-top: 0; }
    .blog-article .article-header h1 { font-size: 1.4rem; }
    .blog-article .article-body { font-size: 1rem; }
    .blog-post-item .post-cover-thumb {
        float: none; width: 100%; height: auto;
        max-height: 180px; margin: 0 0 14px 0;
    }
    .blog-list-header h1 { font-size: 1.5rem; }
}