/* =========================================================
   my-theme 样式表（纯 CSS，无需编译）
   文件名 style.css，通过 layout.ejs 里的 <%- css('/css/style.css') %> 引入
   ========================================================= */

/* ---------- 深浅色主题变量 ---------- */
:root {
    --text-primary: #333;                       /* 主文字色 */
    --text-secondary: #666;                     /* 次要文字 */
    --text-muted: #999;                         /* 弱化文字（元信息） */
    --text-nav: #555;                           /* 导航文字 */
    --link: #3c79b6;                            /* 链接色 */
    --link-hover: #2a5f91;                      /* 链接悬停色 */
    --card-bg: rgba(255, 255, 255, 0.72);       /* 卡片/栏半透明背景 */
    --border: #e8e8e8;                          /* 边框 */
    --border-light: #eee;                       /* 更浅的边框 */
    --code-bg: #f6f8fa;                         /* 代码背景 */
    --tag-bg: #f0f2f5;                          /* 标签背景 */
    --tag-hover: #e2e6ea;                       /* 标签悬停 */
    --shadow: rgba(0, 0, 0, 0.05);              /* 卡片阴影 */
    --body-bg: #f5f6f8;                         /* 页面底色 */
}

/* 暗色主题：当 <html> 上有 data-theme="dark" 时启用 */
[data-theme="dark"] {
    --text-primary: #eee;
    --text-secondary: #ccc;
    --text-muted: #999;
    --text-nav: #bbb;
    --link: #6ba3e0;
    --link-hover: #8bb8ef;
    --card-bg: rgba(28, 30, 34, 0.75);
    --border: #333;
    --border-light: #2c2c2c;
    --code-bg: #2c2c2c;
    --tag-bg: #2c2c2c;
    --tag-hover: #3a3a3a;
    --shadow: rgba(0, 0, 0, 0.3);
    --body-bg: #111;
}

/* ---------- 基础重置 ---------- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Microsoft YaHei", sans-serif;
    line-height: 1.7;
    color: var(--text-primary);
    background-color: var(--body-bg);
    background-position: center center;
    background-attachment: fixed;
    background-size: cover;
    transition: background-color 0.3s, color 0.3s;
    position: relative;
    min-height: 100vh;
}

/* 让页面内容有统一宽度并居中 */
.container {
    max-width: 90vw;
    margin: 0 auto;
    padding: 0 20px;
}

.home-layout {
    display: flex;
    margin: 0 5vw;
    gap: 2vw;
    align-items: flex-start;
}

.sidebar {
    background-color: var(--card-bg);
    padding-top: 30px;
    padding-right: 20px;
    padding-left: 20px;
    padding-bottom: 60px;
    border-radius: 10px;
    box-shadow: 0 2px 8px var(--shadow);
}

.sidebar-avatar {
    margin: 0 auto;
    border-radius: 100px;
    transition: box-shadow 0.3s;
}

.sidebar-name {
    margin-top: 10px;
    color: var(--text-primary);
}

.sidebar-signature {
    margin-top: 10px;
    font-size: 15px;
    color: var(--text-secondary);
}

/* .home-content {
    margin-left: auto;
} */

/* ---------- 全屏背景层 ---------- */
.bg-layer {
    position: fixed;       /* 固定铺满整个视口 */
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;           /* 垫到最底层，内容显示在上面 */
    background-size: cover;
    background-position: center;
    /* filter: blur(1px);     微模糊 
    transform: scale(1.1); 放大一点，避免模糊后边缘露白 */
}

a {
    color: var(--link);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* ---------- 顶部导航栏 ---------- */
.site-header {
    background-color: var(--card-bg);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 10;
    transition: background-color 0.3s, border-color 0.3s;
}

.site-header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 70px;
}

.logo img {
    width: 70px;
}

.logo:hover {
    text-decoration: none;
}

.nav a {
    margin-left: 20px;
    color: var(--text-nav);
}

.nav a:hover {
    color: var(--link);
}

/* ---------- 首页 Hero 区 ---------- */
.hero {
    text-align: center;
    margin: 50px auto 30px ;
    border-radius: 10px;
}

.hero h1 {
    font-size: 32px;
    font-weight: 800;
    color: rgba(255, 255, 255, 0.8);
    text-shadow: 1px 1px 3px rgba(0,0,0,0.7);
    /* mix-blend-mode: exclusion; */
}

.hero-sub {
    margin-top: 10px;
    font-size: 18px;
    color: #fff;
    text-shadow: 0 1px 3px rgba(0,0,0,0.4);
}

/* ---------- 文章列表卡片 ---------- */
.post-list {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    padding-bottom: 40px;
}

.post-card {
    background-color: var(--card-bg);
    border-radius: 10px;
    padding: 25px;
    margin-bottom: 10px;
    box-shadow: 0 2px 8px var(--shadow);
    transition: transform 0.2s, box-shadow 0.2s, background-color 0.3s;
    width: 31vw;
}

.post-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.1);
}

.post-title {
    font-size: 20px;
    margin-bottom: 8px;
}

.post-title a {
    color: var(--text-primary);
}

.post-title a:hover {
    color: var(--link);
    text-decoration: none;
}

.post-meta {
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 10px;
}

.post-category {
    color: var(--link);
}

.post-excerpt {
    color: var(--text-secondary);
    font-size: 15px;
    margin-bottom: 10px;
}

.post-tags {
    margin-top: 10px;
}

.tag {
    display: inline-block;
    background-color: var(--tag-bg);
    color: var(--text-nav);
    font-size: 13px;
    padding: 2px 10px;
    border-radius: 20px;
    margin-right: 8px;
    transition: background-color 0.3s;
}

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

/* ---------- 文章详情页 ---------- */
.post-page {
    display: flex;
    gap: 2vw;
    /* margin-right: 10px; */
    align-items: flex-start;
    margin-left: -55px;
}

.post-toc {
    margin-top: 30px;
    background-color: var(--card-bg);
    width: 200px;
    padding-left: 30px;
    padding-right: 10px;
    padding-top: 40px;
    color: var(--text-primary);
    border-radius: 10px;
    padding-bottom: 40px;
}

.post-toc h4 {
    font-size: 20px;
    margin-bottom: 10px;
}

.toc {
    list-style-type: none !important;
}

.toc li {
    list-style: none !important;
}

.toc ol {
    padding-left: 1.5em;
}

.toc a {
    color: var(--text-primary);
    text-decoration: none;
}

.toc a:hover {
    color: #3c79b6;
}

.post {
    background-color: var(--card-bg);
    border-radius: 10px;
    padding: 40px 40px;
    margin-top: 30px;
    box-shadow: 0 2px 8px var(--shadow);
    transition: background-color 0.3s;
    max-width: 70vw;
    margin-right: 20px;
    /* 关键修复：.post 是 .post-page（flex 容器）的子项，
       默认 min-width: auto 会被代码块里的超长行（white-space: pre 不换行）
       撑破 max-width: 70vw，导致整个文章元素横向溢出。
       设为 0 后，宽度由 max-width 约束，超长代码改为在 pre 内部横向滚动。 */
    min-width: 0;
}

/* 关于等独立页面的卡片：顶部与侧边栏对齐，去掉 margin-top */
.page-post {
    margin-top: 0;
}

/* 关于等独立页面：整体下移留出顶部空间，侧边栏与内容一起下移保持对齐 */
.page-layout {
    padding-top: 45px;
}

.post-header {
    border-bottom: 1px solid var(--border-light);
    padding-bottom: 20px;
    margin-bottom: 24px;
}

.post-header .post-title {
    font-size: 28px;
}

.post-content {
    font-size: 16px;
    color: var(--text-primary);
}

.post-content h2 {
    font-size: 22px;
    margin: 28px 0 12px;
    padding-bottom: 6px;
    border-bottom: 2px solid var(--border-light);
}

.post-content h3 {
    font-size: 19px;
    margin: 20px 0 10px;
}

.post-content p {
    margin-bottom: 16px;
}

/* 列表：恢复被全局重置清掉的缩进与间距 */
.post-content ol,
.post-content ul {
    margin: 0 0 16px;      /* 列表整体底部留白，避免与后文紧贴丢换行 */
    padding-left: 2em;     /* 给序号/圆点留出缩进，避免"突出"段落一格 */
}

.post-content li {
    margin-bottom: 8px;    /* 各列表项之间留出间隔 */
}

.post-content img {
    max-width: 100%;
    border-radius: 6px;
}

.post-content pre,
.post-content code {
    background-color: var(--code-bg);
    border-radius: 4px;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
    /* color: var(--text-primary); */
}

.post-content code {
    padding: 2px 6px;
    font-size: 14px;
}

.post-content pre {
    padding: 16px;
    overflow-x: auto;        /* 代码过长时横向滚动，不撑破文章 */
    margin-bottom: 16px;
}

.post-content pre code {
    padding: 0;
    /* background: none; */
}

/* ---------- 带行号的代码块（Hexo 高亮生成 figure.highlight 结构） ----------
   结构：<figure class="highlight"><table>
             <td class="gutter">行号</td> <td class="code"><pre><code>
   关键：figure 本身要能横向滚动，否则超长行会把文章元素撑破 */
.post-content figure.highlight {
    position: relative;
    max-width: 100%;
    overflow-x: auto;
    margin-bottom: 16px;
    border-radius: 4px;
    background-color: var(--code-bg);
    -webkit-overflow-scrolling: touch;
}

/* 行号列与代码列：去掉默认表格间隙，让代码块紧凑 */
.post-content figure.highlight table {
    border-collapse: collapse;
}

.post-content figure.highlight .gutter {
    border-right: 1px solid var(--border);
    user-select: none;       /* 行号不可选中，复制时自然不带行号 */
}

.post-content figure.highlight .code pre {
    margin-bottom: 0;
    overflow: visible;       /* 由外层 figure 统一滚动，避免双层滚动条 */
    background: none;
}

/* ---------- 代码块复制按钮 ---------- */
/* JS 给每个代码块（figure.highlight 或裸 pre）包一层 .code-block，
   并把复制按钮放在 wrapper 右上角——按钮在滚动容器外，不随代码滚动 */
.code-block {
    position: relative;
    margin-bottom: 16px;
}

.code-block pre,
.code-block figure.highlight {
    margin-bottom: 0;        /* 外边距交给 wrapper 统一控制 */
}

.code-block .copy-code-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 2;
    padding: 3px 10px;
    font-size: 12px;
    line-height: 1.6;
    color: var(--text-secondary);
    background-color: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 5px;
    cursor: pointer;
    opacity: 1;              /* 始终可见，方便移动端触摸使用 */
    transition: color 0.2s, background-color 0.2s, border-color 0.2s;
}

.code-block .copy-code-btn:hover {
    color: var(--link);
    border-color: var(--link);
}

.code-block .copy-code-btn.copied {
    color: #fff;
    background-color: #2ea44f;
    border-color: #2ea44f;
}

.code-block .copy-code-btn.copy-failed {
    color: #fff;
    background-color: #d9534f;
    border-color: #d9534f;
}

/* ---------- 代码块复制按钮 ---------- */
/* JS 会给每个 .post-content pre 包一层 .code-block，并把复制按钮放进来，
   按钮绝对定位在 wrapper 上，不会随代码内容一起横向滚动 */
.code-block {
    position: relative;
    margin-bottom: 16px;
}

.code-block pre {
    margin-bottom: 0;
}

.code-block .copy-code-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 2;
    padding: 3px 10px;
    font-size: 12px;
    line-height: 1.6;
    color: var(--text-secondary);
    background-color: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 5px;
    cursor: pointer;
    opacity: 1;              /* 始终可见，方便移动端触摸使用 */
    transition: color 0.2s, background-color 0.2s, border-color 0.2s;
}

.code-block .copy-code-btn:hover {
    color: var(--link);
    border-color: var(--link);
}

.code-block .copy-code-btn.copied {
    color: #fff;
    background-color: #2ea44f;
    border-color: #2ea44f;
}

.code-block .copy-code-btn.copy-failed {
    color: #fff;
    background-color: #d9534f;
    border-color: #d9534f;
}

/* ---------- 页脚 ---------- */
.site-footer {
    position: absolute;
    bottom: -60px;
    width: 100%;
    /* margin-top: 40px; */
    padding: 10px 0;
    text-align: center;
    color: var(--text-muted);
    font-size: 14px;
    border-top: 1px solid var(--border);
    background-color: var(--card-bg);
    transition: background-color 0.3s;
}

/* ---------- 右下角深浅色切换按钮 ---------- */
.theme-toggle {
    position: fixed;
    right: 24px;
    bottom: 24px;
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 50%;
    background-color: var(--card-bg);
    color: var(--text-primary);
    font-size: 20px;
    cursor: pointer;
    box-shadow: 0 2px 10px var(--shadow);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.3s, transform 0.2s;
    backdrop-filter: blur(4px);
}

.theme-toggle:hover {
    transform: scale(1.1);
}

/* 切换按钮图标 */
.theme-toggle-icon {
    width: 22px;
    height: 22px;
    pointer-events: none;
    transition: filter 0.3s;
}

/* 浅色：图标保持原色 */
.theme-toggle-icon {
    filter: none;
}

/* 深色：图标反色，让中性图标在深色背景下更清晰 */
[data-theme="dark"] .theme-toggle-icon {
    filter: invert(1);
}

/* ---------- 归档 / 标签 / 分类 页面 ---------- */
.page-hero {
    text-align: center;
    margin: 40px auto 30px;
}

.page-hero h1 {
    font-size: 30px;
    font-weight: 700;
    color: var(--text-primary);
    text-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.page-sub {
    margin-top: 8px;
    color: var(--text-muted);
    font-size: 15px;
}

/* 归档列表 */
.archive-list {
    padding-bottom: 40px;
}

.archive-item {
    display: flex;
    align-items: baseline;
    background-color: var(--card-bg);
    border-radius: 10px;
    padding: 18px 24px;
    margin-bottom: 12px;
    box-shadow: 0 2px 8px var(--shadow);
    transition: transform 0.2s, background-color 0.3s;
}

.archive-item:hover {
    transform: translateY(-2px);
}

.archive-date {
    flex-shrink: 0;
    width: 110px;
    color: var(--text-muted);
    font-size: 14px;
    font-family: "SFMono-Regular", Consolas, monospace;
}

.archive-main {
    flex: 1;
    min-width: 0;
}

/* 标签云 */
.tag-cloud {
    padding: 10px 0 40px;
    text-align: center;
}

.tag-large {
    font-size: 16px;
    padding: 6px 16px;
    margin: 6px 6px;
}

.tag-count {
    opacity: 0.6;
    font-size: 13px;
    margin-left: 4px;
}

/* 分类列表 */
.category-list {
    padding-bottom: 40px;
}

.category-item {
    background-color: var(--card-bg);
    border-radius: 10px;
    padding: 16px 24px;
    margin-bottom: 10px;
    box-shadow: 0 2px 8px var(--shadow);
    transition: transform 0.2s, background-color 0.3s;
}

.category-item:hover {
    transform: translateY(-2px);
}

.category-item a {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--text-primary);
}

.category-name {
    font-size: 17px;
    font-weight: 600;
}

.category-count {
    color: var(--text-muted);
    font-size: 14px;
}

/* 分页 */
.pagination {
    text-align: center;
    padding: 20px 0 40px;
}

.pagination .page-number,
.pagination .extend,
.pagination .space {
    display: inline-block;
    padding: 6px 14px;
    margin: 0 4px;
    border-radius: 6px;
    background-color: var(--card-bg);
    color: var(--text-primary);
    box-shadow: 0 2px 6px var(--shadow);
    transition: background-color 0.2s;
}

.pagination .current {
    background-color: var(--link);
    color: #fff;
}

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

/* ---------- 404 页面 ---------- */
.error-404 {
    text-align: center;
    padding: 80px 20px;
}

.error-404 h1 {
    font-size: 72px;
    font-weight: 700;
    color: var(--text-primary);
}

.error-404 p {
    margin: 16px 0 24px;
    color: var(--text-secondary);
}

.error-404 a {
    display: inline-block;
    padding: 10px 24px;
    border-radius: 6px;
    background-color: var(--link);
    color: #fff;
    transition: opacity 0.2s;
}

.error-404 a:hover {
    opacity: 0.85;
    text-decoration: none;
}

/* ---------- 响应式 ---------- */
@media (max-width: 1260px) {
    .post-list {
        display: block;
    }
    .post-card {
        width: 60vw;
    }
    .post-page {
        margin-left: 0;
    }
}
@media (max-width: 800px) {
    .hero h1 {
        font-size: 26px;
    }
    .post {
        padding: 24px 20px;
    }
    .nav a {
        margin-left: 12px;
    }
    .site-header .container {
        font-size: 15px;
    }
    .site-header {
        height: 70px;
    }
    .home-layout {
        display: block;
    }
    .post-list {
        display: block;
    }
    .post-card {
        width: 100%;
    }
    .sidebar {
        display: flex;
        gap: 10px;
        padding-top: 10px;
        padding-left: 0;
        padding-bottom: 10px;
        padding-right: 25px;
        margin-bottom: 20px;
    }
    .sidebar-text {
        display: block;
    }
    .sidebar-avatar {
        margin-left: 25px;
    }
    .container {
        max-width: 200vw;
    }
    .post {
        zoom: 0.85;
    }
    body {
        background-color: 0;
    }
    .home-layout {
        margin-left: 2vw;
        margin-right: 2vw;
    }
    .post-page {
        display: block;
        align-items: center;
        width: 90vw;
    }
    .post-toc {
        width: 90vw;
        display: flex;
        justify-content: space-between;
        margin-top: 20px;
        padding-top: 10px;
        padding-bottom: 10px;
    }
    .post-toc h4 {
        flex: 1;
        margin: auto 0;
        text-align: center;
        margin-right: 15px;
    }
    .toc-div {
        flex: 2;
        display: flex;
        justify-content: center;
    }
    .post {
        margin-right: 0;
        min-width: 100%;
    }
}
