/* ============================================
   沈超的个人博客 — 现代化主题 v2.0
   ============================================ */

/* === 基础变量 === */
:root {
    --bg: #fafbfc;
    --bg-card: #ffffff;
    --bg-code: #1e1e2e;
    --text: #2c3e50;
    --text-secondary: #7f8c9b;
    --text-muted: #a0aab4;
    --accent: #2563eb;
    --accent-light: #dbeafe;
    --accent-hover: #1d4ed8;
    --green: #059669;
    --green-light: #d1fae5;
    --border: #e5e9ee;
    --border-light: #f0f2f5;
    --shadow-sm: 0 1px 3px rgba(0,0,0,.04);
    --shadow-md: 0 4px 12px rgba(0,0,0,.06);
    --shadow-lg: 0 8px 24px rgba(0,0,0,.08);
    --radius: 10px;
    --radius-sm: 6px;
    --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    --font-serif: Georgia, "Noto Serif SC", "Source Han Serif CN", serif;
    --font-mono: "JetBrains Mono", "Fira Code", "Cascadia Code", Menlo, Monaco, Consolas, monospace;
    --max-w: 960px;
    --header-h: 64px;
}

/* === 全局重置 === */
*, *::before, *::after { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-sans);
    font-size: 15px;
    line-height: 1.7;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* === 链接 === */
a {
    color: var(--accent);
    text-decoration: none;
    transition: color .15s;
}
a:hover { color: var(--accent-hover); }

/* === 排版 === */
h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-sans);
    font-weight: 600;
    line-height: 1.35;
    color: var(--text);
}

/* === 代码 === */
pre, code {
    font-family: var(--font-mono);
    font-size: 13px;
}
code {
    padding: 2px 7px;
    background: #f1f5f9;
    color: #e11d48;
    border-radius: 4px;
    font-size: .88em;
}
pre {
    margin: 1.4em 0;
    padding: 0;
    background: var(--bg-code);
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid #2d2d3f;
}
pre code {
    display: block;
    padding: 18px 22px;
    color: #e2e8f0;
    background: transparent;
    overflow-x: auto;
    line-height: 1.65;
}

/* === 引用 === */
blockquote {
    margin: 1.4em 0;
    padding: 16px 22px;
    border-left: 4px solid var(--accent);
    background: var(--accent-light);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    color: #475569;
    font-size: .95em;
}
blockquote p:last-child { margin-bottom: 0; }

/* === 表格 === */
table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.4em 0;
    font-size: .92em;
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--border);
}
th, td {
    padding: 10px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border-light);
}
th {
    background: #f8fafc;
    font-weight: 600;
    color: var(--text);
    font-size: .88em;
    text-transform: uppercase;
    letter-spacing: .03em;
}
tr:hover td { background: #f8fafc; }

/* === 表单 === */
input[type="text"], input[type="email"], input[type="url"],
input[type="password"], textarea {
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: var(--font-sans);
    transition: border-color .15s, box-shadow .15s;
    width: 100%;
    box-sizing: border-box;
}
input:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
}
textarea { resize: vertical; }

/* ============================================
   头部导航
   ============================================ */
#header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(255,255,255,.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    padding: 0;
    height: var(--header-h);
}

#header .container {
    max-width: var(--max-w);
    margin: 0 auto;
    padding: 0 24px;
}

#header .row {
    display: flex;
    align-items: center;
    height: var(--header-h);
    flex-wrap: nowrap;
}

.site-name {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

#logo {
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -.02em;
    white-space: nowrap;
}
#logo:hover { color: var(--accent); }
#logo img { max-height: 36px; }

.description {
    margin: 0;
    padding-left: 16px;
    border-left: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 13px;
    white-space: nowrap;
}

/* 导航菜单 */
#nav-menu {
    margin: 0;
    padding: 0;
    display: flex;
    align-items: center;
    gap: 2px;
    margin-left: auto;
}
#nav-menu a {
    display: inline-block;
    padding: 6px 16px;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    border-radius: var(--radius-sm);
    border: none;
    height: auto;
    line-height: 1.5;
    float: none;
    transition: color .15s, background .15s;
}
#nav-menu a:hover,
#nav-menu .current {
    color: var(--accent);
    background: var(--accent-light);
}

/* 搜索 */
.site-search { display: none; }

/* ============================================
   主内容区
   ============================================ */
#body {
    max-width: var(--max-w);
    margin: 0 auto;
    padding: 32px 24px 0;
}

#body .container {
    max-width: none;
    padding: 0;
}

#main {
    width: 100%;
    max-width: none;
    padding: 0;
}

/* ============================================
   文章卡片（列表页）
   ============================================ */
article.post {
    margin-bottom: 24px;
    padding: 28px 32px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: transform .2s, box-shadow .2s, border-color .2s;
}
article.post:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
    border-color: transparent;
}

.post-title {
    margin: 0 0 12px;
    font-size: 22px;
    font-weight: 700;
    line-height: 1.4;
    letter-spacing: -.01em;
}
.post-title a {
    color: var(--text);
    border: none;
}
.post-title a:hover { color: var(--accent); }

/* 文章元信息 */
.post-meta {
    margin: 0 0 16px;
    font-size: 13px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}
.post-meta li {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 0;
    margin: 0;
    border: none;
}
.post-meta a {
    color: var(--text-secondary);
    border: none;
}
.post-meta a:hover { color: var(--accent); }

/* 分类标签 */
.post-categories {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}
.post-categories .category-tag {
    display: inline-block;
    padding: 3px 12px;
    border-radius: 20px;
    background: var(--green-light);
    color: var(--green);
    font-size: 12px;
    font-weight: 600;
    border: none;
    transition: background .15s;
}
.post-categories .category-tag:hover {
    background: #a7f3d0;
    color: #047857;
}

/* 文章摘要 */
.post-content {
    font-size: 15px;
    line-height: 1.8;
    color: #4b5563;
}

/* 阅读量 */
.views-counter {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    font-size: 12px;
    color: var(--text-muted);
    background: #f1f5f9;
    border-radius: 20px;
}
.views-counter::before { content: "👁"; font-size: 11px; }

/* ============================================
   文章详情页
   ============================================ */
.post-content h2 {
    margin: 2.2em 0 .8em;
    padding-bottom: .5em;
    border-bottom: 2px solid var(--border-light);
    font-size: 20px;
    font-weight: 700;
}
.post-content h3 {
    margin: 1.8em 0 .6em;
    font-size: 17px;
    font-weight: 600;
}
.post-content p { margin: 0 0 1.2em; }

.post-content img {
    max-width: 100%;
    border-radius: var(--radius);
    margin: 1.2em 0;
    box-shadow: var(--shadow-sm);
}

.post-content hr {
    margin: 2.5em auto;
    width: 80px;
    height: 2px;
    border: none;
    background: var(--border);
}

/* 标签 */
.tags {
    margin: 24px 0;
    font-size: 13px;
    color: var(--text-muted);
}
.tags a {
    display: inline-block;
    padding: 4px 14px;
    margin: 3px 4px;
    border-radius: 20px;
    background: #f1f5f9;
    color: var(--text-secondary);
    font-size: 13px;
    border: none;
    transition: background .15s, color .15s;
}
.tags a:hover {
    background: var(--accent-light);
    color: var(--accent);
}

/* 上下篇 */
.post-near {
    list-style: none;
    margin: 32px 0;
    padding: 0;
    display: flex;
    justify-content: space-between;
    gap: 16px;
}
.post-near li {
    flex: 1;
    padding: 16px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    color: var(--text-secondary);
    transition: border-color .15s;
}
.post-near li:hover { border-color: var(--accent); }
.post-near a {
    font-weight: 600;
    color: var(--text);
}

/* ============================================
   侧边栏
   ============================================ */
#secondary {
    padding-top: 0;
}
.widget {
    margin-bottom: 28px;
    padding: 20px 24px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.widget-title {
    margin: 0 0 14px;
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
    text-transform: uppercase;
    letter-spacing: .05em;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--accent);
}
.widget-list {
    list-style: none;
    margin: 0;
    padding: 0;
}
.widget-list li {
    margin: 0;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-light);
    font-size: 14px;
    line-height: 1.5;
}
.widget-list li:last-child { border-bottom: none; }
.widget-list a {
    color: var(--text-secondary);
    border: none;
}
.widget-list a:hover { color: var(--accent); }

/* ============================================
   评论区
   ============================================ */
#comments {
    margin-top: 40px;
    padding-top: 24px;
    border-top: 2px solid var(--border-light);
}
.comment-list, .comment-list ol {
    list-style: none;
    margin: 0;
    padding: 0;
}
.comment-list li {
    padding: 18px 22px;
    margin-top: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
}
.comment-list li.comment-by-author {
    border-color: var(--accent);
    background: var(--accent-light);
}
.comment-author {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text);
}
.comment-author .avatar {
    border-radius: 50%;
}
.comment-meta a {
    color: var(--text-muted);
    font-size: 13px;
}
.comment-content {
    font-size: 14px;
    line-height: 1.7;
    color: #4b5563;
}

/* 评论表单 */
#comment-form label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    font-size: 14px;
}
#comment-form .required:after {
    content: " *";
    color: #ef4444;
}
.respond input[type="submit"],
button[type="submit"] {
    display: inline-block;
    padding: 10px 28px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s;
}
.respond input[type="submit"]:hover { background: var(--accent-hover); }

/* ============================================
   页脚
   ============================================ */
#footer {
    max-width: var(--max-w);
    margin: 48px auto 0;
    padding: 32px 24px;
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
    border-top: 1px solid var(--border);
}
#footer a {
    color: var(--text-secondary);
    border: none;
}
#footer a:hover { color: var(--accent); }

/* ============================================
   分页
   ============================================ */
.page-navigator {
    list-style: none;
    margin: 32px 0;
    padding: 0;
    text-align: center;
    display: flex;
    justify-content: center;
    gap: 6px;
}
.page-navigator li { display: inline-block; }
.page-navigator a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 14px;
    transition: all .15s;
}
.page-navigator a:hover {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}
.page-navigator .current a {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

/* ============================================
   归档标题
   ============================================ */
.archive-title {
    margin: 0 0 24px;
    padding: 0;
    color: var(--text-secondary);
    font-size: 16px;
    font-weight: 600;
}

/* ============================================
   更多/受保护
   ============================================ */
.more {
    text-align: center;
    margin: 16px 0;
}
.more a {
    display: inline-block;
    padding: 8px 24px;
    background: var(--accent);
    color: #fff;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    border: none;
    transition: background .15s;
}
.more a:hover { background: var(--accent-hover); }

.protected .text {
    width: 50%;
    max-width: 300px;
}

/* ============================================
   响应式
   ============================================ */
@media (max-width: 768px) {
    :root { --header-h: 56px; }
    
    #header .row { flex-wrap: wrap; }
    
    .site-name {
        width: 100%;
        justify-content: space-between;
    }
    
    .description { display: none; }
    
    #nav-menu {
        width: 100%;
        overflow-x: auto;
        padding: 4px 0 8px;
        gap: 0;
    }
    #nav-menu a {
        padding: 6px 12px;
        font-size: 13px;
        white-space: nowrap;
    }
    
    #body { padding: 20px 16px 0; }
    
    article.post {
        padding: 20px;
        margin-bottom: 16px;
    }
    .post-title { font-size: 18px; }
    
    .post-near { flex-direction: column; }
    
    .post-categories { gap: 4px; }
}

/* ============================================
   Prism.js 覆盖
   ============================================ */
pre[class*="language-"] {
    border-radius: var(--radius);
    margin: 1.4em 0;
    border: 1px solid #2d2d3f;
}
code[class*="language-"] {
    font-family: var(--font-mono);
}
:not(pre) > code {
    padding: 2px 7px;
    background: #f1f5f9;
    color: #e11d48;
    border-radius: 4px;
    font-size: .88em;
}

/* ============================================
   工具类
   ============================================ */
.hidden { display: none !important; visibility: hidden; }
.sr-only {
    border: 0; height: 1px; margin: -1px;
    overflow: hidden; padding: 0;
    position: absolute; width: 1px;
}
.sr-only.focusable:active, .sr-only.focusable:focus {
    clip: auto; height: auto; margin: 0;
    overflow: visible; position: static; width: auto;
}
.invisible { visibility: hidden; }

/* 平滑滚动 */
html { scroll-behavior: smooth; }

/* 选中文本高亮 */
::selection {
    background: var(--accent-light);
    color: var(--accent);
}

/* 打印样式 */
@media print {
    #header, #footer, #secondary, .post-near, #comments, #back-to-top, #reading-progress { display: none; }
    article.post { border: none; box-shadow: none; padding: 0; }
    body { background: #fff; font-size: 12pt; }
    .post-content a::after { content: " (" attr(href) ")"; font-size: .8em; color: #666; }
}

/* 加载动画 */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}
article.post { animation: fadeIn .4s ease; }
article.post:nth-child(2) { animation-delay: .05s; }
article.post:nth-child(3) { animation-delay: .1s; }
article.post:nth-child(4) { animation-delay: .15s; }
article.post:nth-child(5) { animation-delay: .2s; }

/* 链接下划线动画 */
.post-content a {
    border-bottom: 1px solid var(--accent-light);
    transition: border-color .15s;
}
.post-content a:hover {
    border-bottom-color: var(--accent);
}

/* 图片悬停放大 */
.post-content img {
    transition: transform .2s;
    cursor: zoom-in;
}
.post-content img:hover {
    transform: scale(1.02);
}

/* 代码块复制按钮样式 */
.code-block-wrap {
    position: relative;
}

/* 阅读时间 */
.reading-time {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    font-size: 12px;
    color: var(--text-muted);
    background: #f1f5f9;
    border-radius: 20px;
}
.reading-time::before {
    content: "⏱";
    font-size: 11px;
}
