@import url('https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;700&display=swap');
@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;700&display=swap');

/* View Transitions API */
@view-transition {
    navigation: auto;
}

html {
    scroll-behavior: auto; /* 禁用全局平滑滚动，防止 SPA 跳转时出现奇怪的滚动动画 */
}

:root {
    /* 暖色调主题 (Warm Theme) - 修复版 */
    --bg-color: #f7f5eb; /* 更加明显的米黄色/羊皮纸色，拒绝惨白 */
    --text-color: #433e3e; /* 深褐灰色，柔和清晰 */
    --heading-color: #2c2525; /* 深咖啡色标题 */
    --accent-color: #c05b4d; /* 砖红色强调 */
    --link-color: #8c5b5b; /* 藕荷色/深红棕色链接 */
    --meta-color: #8c8888;
    --border-color: #e3e0d0;
    --code-bg: #282c34;
    
    /* 字体切换为思源宋体 */
    --font-primary: "Noto Serif SC", "Source Han Serif SC", "Songti SC", serif;
    --font-mono: "JetBrains Mono", "Fira Code", "Menlo", monospace;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: var(--font-primary);
    line-height: 1.8;
    font-size: 17px;
    margin: 0;
    padding: 20px;
    -webkit-font-smoothing: antialiased;
}

.container {
    max-width: 720px;
    margin: 60px auto;
    padding: 0 20px;
}

/* 顶部导航容器 */
header {
    display: flex;
    justify-content: space-between;
    align-items: center; /* 垂直居中对齐 */
    margin-bottom: 60px;
    padding-top: 20px;
}

.site-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--heading-color);
    text-decoration: none;
    font-family: var(--font-primary);
    border-bottom: none !important; /* 确保没有下划线 */
}

/* 导航链接容器 */
nav {
    display: flex;
    align-items: center; /* 垂直居中对齐 */
}

/* 顶部导航链接容器 */
header nav a {
    margin-left: 20px;
    text-decoration: none;
    color: var(--meta-color);
    font-size: 1rem;
    position: relative;
    font-weight: 400;
}

header nav a:hover {
    color: var(--heading-color);
}

/* 移除顶部导航链接下方的点点 */
header nav a::after {
    content: none !important;
    display: none !important;
}

/* 列表页布局 */
.post-list {
    list-style: none !important; /* 强制去除列表样式 */
    padding: 0 !important;
    margin: 0 !important;
}

.post-item {
    background: transparent;
    padding: 0;
    margin-bottom: 40px;
    border-radius: 0;
    border: none;
    border-bottom: 1px dashed rgba(0,0,0,0.1);
    padding-bottom: 40px;
    transition: transform 0.2s ease;
    list-style: none !important; /* 再次强制去除列表样式 */
}

/* 确保没有伪元素生成点点 */
.post-item::before,
.post-item::after,
.post-list::before,
.post-list::after {
    content: none !important;
    display: none !important;
}

.post-item:last-child {
    border-bottom: none;
}

.post-item:hover {
    transform: none; /* 移除位移 */
    box-shadow: none; /* 移除阴影 */
    border-color: rgba(0,0,0,0.1);
}

.post-item-content {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 30px; /* 增加图文间距 */
}

.post-text {
    flex: 1;
    min-width: 0;
}

.post-title {
    font-size: 1.4rem; /* 稍微加大标题 */
    font-weight: 700;
    color: var(--heading-color);
    text-decoration: none;
    display: block;
    margin-bottom: 12px;
    line-height: 1.3;
    border-bottom: none !important;
}

.post-title:hover {
    color: var(--accent-color);
}

.post-desc {
    font-size: 0.95rem;
    color: #666;
    margin: 0 0 15px 0;
    line-height: 1.6;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-align: justify; /* 两端对齐更整齐 */
}

.post-cover-wrapper {
    width: 220px; /* 稍微加大图片宽度 */
    flex-shrink: 0;
}

.post-cover {
    display: block;
    width: 100%;
    aspect-ratio: 16 / 9;
    border-radius: 8px;
    overflow: hidden;
    margin: 0;
    background-color: rgba(0,0,0,0.03);
}

.post-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
    border-radius: 8px;
}

.post-item:hover .post-cover img {
    transform: scale(1.02);
}

/* 移动端适配 */
@media (max-width: 600px) {
    .container {
        margin: 30px auto; /* 减小顶部边距 */
        padding: 0 15px; /* 稍微减小内边距 */
    }

    header {
        margin-bottom: 40px; /* 减小头部下方间距 */
    }

    .site-title {
        font-size: 1.3rem; /* 稍微减小标题字号 */
    }

    header nav a {
        margin-left: 15px; /* 减小导航间距 */
        font-size: 0.95rem;
    }

    .post-item-content {
        flex-direction: column-reverse;
        gap: 15px; /* 减小间距 */
    }
    
    .post-cover-wrapper {
        width: 100%;
        margin-bottom: 10px;
    }

    .post-title {
        font-size: 1.25rem;
    }

    .post-desc {
        -webkit-line-clamp: 2; /* 移动端只显示2行简介 */
    }

    /* 优化代码块在移动端的显示 */
    pre {
        margin: 1.5em -15px; /* 让代码块在移动端贴边，增加可视区域 */
        border-radius: 0;
        padding: 15px;
        padding-top: 45px;
    }
    
    pre::before {
        left: 15px; /* 调整圆点位置 */
    }

    /* 优化大图显示 */
    .post-cover-large {
        margin: -20px -15px 20px -15px;
        width: calc(100% + 30px);
        border-radius: 0;
    }
}

/* 夜间模式适配 - 仅在使用 dark-mode 类时生效 */
body.dark-mode {
    --bg-color: #1a1b1e;
    --text-color: #c1c2c5;
    --heading-color: #e4e5e7;
    --accent-color: #ff8787;
    --link-color: #a5d8ff;
    --meta-color: #909296;
    --border-color: #2c2e33;
    --code-bg: #25262b;
}

body.dark-mode .post-item {
    background: transparent;
    border-bottom-color: rgba(255,255,255,0.1);
}

body.dark-mode .tag-small, 
body.dark-mode .tag {
    background-color: transparent;
}

body.dark-mode img {
    opacity: 0.9;
}
    color: var(--accent-color);
    font-weight: 600;
    text-decoration: none;
    border-bottom: none !important;
}

.category-link-small {
    color: var(--meta-color);
    font-size: 0.85rem;
    text-decoration: none;
    border-bottom: 1px dotted var(--meta-color);
}

.category-link:hover, .category-link-small:hover {
    color: var(--accent-color);
    border-bottom-color: var(--accent-color);
    background: none;
}

/* 分类列表页样式 */
.category-list {
    list-style: none;
    padding: 0;
}

.category-list li {
    margin-bottom: 10px;
    font-size: 1.1rem;
}

.category-list a {
    text-decoration: none;
    color: var(--heading-color);
    border-bottom: none !important;
}

.category-list a:hover {
    color: var(--accent-color);
}

.tag-small {
    background-color: transparent;
    padding: 0;
    border-radius: 0;
    font-size: 12px !important; /* 强制设为 12px，极小 */
    color: var(--accent-color);
    font-weight: 400;
    border: none !important;
    opacity: 0.8;
}

.tag {
    background-color: transparent;
    padding: 0;
    border-radius: 0;
    font-size: 12px !important; /* 强制设为 12px */
    color: var(--accent-color);
    font-weight: 400;
    border: none !important;
    text-decoration: none;
}

.tag::before {
    content: ""; /* 移除 CSS 里的 # */
    margin-right: 0;
}

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

/* 面包屑导航样式 */
.breadcrumb {
    font-size: 14px;
    color: var(--meta-color);
    margin-bottom: 20px;
    font-family: var(--font-primary);
    opacity: 0.8;
    padding-left: 0 !important;
    margin-left: 0 !important;
    display: flex;
    align-items: center;
}

/* 修复面包屑链接的左边距问题 */
.breadcrumb a {
    margin-left: 0 !important; /* 强制去除继承的左边距 */
    color: var(--meta-color);
    text-decoration: none;
    border-bottom: none;
}

.breadcrumb .sep {
    margin: 0 8px; /* 分隔符左右留空 */
    font-size: 0.8em;
    opacity: 0.6;
}

.breadcrumb .current {
    opacity: 0.6;
}

/* 头部导航按钮 */
.nav-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 5px;
    margin-left: 15px;
    color: var(--meta-color);
    font-size: 1.2rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
    vertical-align: middle;
}

.nav-btn:hover {
    color: var(--accent-color);
}

/* 强制夜间模式 (通过 JS 触发) */
/* 这里的代码已经在上面合并了，移除重复部分 */

/* 列表页图片 */
.post-cover {
    margin-bottom: 20px;
    border-radius: 8px;
    overflow: hidden;
    width: 100%;
    /* 移除固定高度限制，让图片自适应，或者使用更智能的比例 */
    aspect-ratio: 16 / 9; /* 强制宽屏比例，保证整齐 */
    background-color: rgba(0,0,0,0.03); /* 图片加载前的占位色 */
}

.post-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover; /* 关键：裁切图片以填满容器，不拉伸 */
    display: block;
    border-radius: 8px;
    margin: 0;
    box-shadow: none;
    transition: transform 0.3s ease;
}

.post-item:hover .post-cover img {
    transform: scale(1.02); /* 悬停微放大效果 */
}

/* 详情页头图 */
.post-cover-large {
    margin: -30px -20px 30px -20px; /* 负边距，让图片在移动端撑满屏幕 */
    width: calc(100% + 40px);
    overflow: hidden;
    /* 移除圆角，或者只在桌面端显示圆角 */
    aspect-ratio: 21 / 9; /* 更宽的电影感比例 */
}

@media (min-width: 768px) {
    .post-cover-large {
        margin: 0 0 40px 0;
        width: 100%;
        border-radius: 12px;
    }
}

.post-cover-large img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    margin: 0;
}

/* 正文图片优化 */
article img {
    max-width: 100%;
    height: auto; /* 保持原始比例，绝不拉伸 */
    border-radius: 8px;
    box-shadow: 0 8px 25px rgba(0,0,0,0.08);
    margin: 30px auto; /* 居中显示 */
    display: block;
}

/* 正文内容 */
.post-content {
    font-size: 0.95rem; /* 稍微调小字号，原来可能是继承的 1rem */
    line-height: 1.8;
    color: var(--text-color);
}

.post-content p {
    margin-bottom: 1.5em;
    text-align: justify; /* 两端对齐 */
}

/* 详情页元数据 - 去除框框，回归极简 */
.post-meta {
    background: transparent;
    padding: 0;
    border-radius: 0;
    margin-bottom: 30px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    font-size: 0.9rem;
    color: var(--meta-color);
    border-left: none;
    border-bottom: 1px solid rgba(0,0,0,0.05);
    padding-bottom: 15px;
    /* 关键：重置内边距和外边距，确保左对齐 */
    padding-left: 0 !important;
    margin-left: 0 !important;
}

/* 列表页元数据 */
.post-item-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    font-size: 0.9rem;
    color: var(--meta-color);
    margin-bottom: 12px;
    /* 关键：重置内边距和外边距，确保左对齐 */
    padding-left: 0 !important;
    margin-left: 0 !important;
}

.meta-primary {
    display: flex;
    align-items: center;
    gap: 8px;
    /* 确保内部元素没有左侧间距 */
    padding-left: 0 !important;
    margin-left: 0 !important;
}

.meta-sep {
    margin: 0 2px;
    opacity: 0.5;
}

.meta-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 2px;
}

/* 文章详情页标题样式 */
article h1 {
    list-style: none; /* 移除列表样式 */
    display: block; /* 确保是块级元素 */
}

/* 确保没有伪元素生成点点 */
article h1::before {
    content: none !important;
    display: none !important;
}

/* 通用标题样式 */
h1, h2, h3 {
    color: var(--heading-color);
    font-weight: 700;
    margin-top: 2em;
    margin-bottom: 0.8em;
    line-height: 1.3;
}

h1 { 
    font-size: 2.2rem; 
    margin-top: 0; /* 详情页标题顶部不需要太大间距，因为上面有 meta */
    margin-bottom: 30px;
    text-align: left;
}

h2 { font-size: 1.6rem; border-bottom: 1px dashed var(--border-color); padding-bottom: 10px; }

p {
    margin-bottom: 1.6em;
    text-align: justify;
}

a {
    color: var(--link-color);
    text-decoration: none;
    border-bottom: 1px dashed var(--link-color); /* 虚线下划线，更有质感 */
    transition: all 0.2s ease;
    padding-bottom: 2px;
}

/* 特别针对标题和导航，去除下划线 */
.site-title, nav a, .post-item a {
    border-bottom: none !important;
    padding-bottom: 0;
}

a:hover {
    color: var(--accent-color);
    border-bottom-style: solid;
    background-color: rgba(192, 91, 77, 0.05);
}

/* 导航和标题悬停时不显示背景色和下划线 */
.site-title:hover, nav a:hover, .post-item a:hover {
    background-color: transparent;
    border-bottom: none !important;
}

/* 恢复代码块 macOS 风格 */
pre {
    background-color: #282c34;
    padding: 20px;
    padding-top: 50px; /* 增加顶部空间 */
    border-radius: 12px;
    overflow-x: auto;
    margin: 2em 0;
    position: relative;
    box-shadow: 0 15px 35px rgba(0,0,0,0.2); /* 更强的阴影 */
}

pre::before {
    content: "";
    display: block;
    position: absolute;
    top: 18px;
    left: 18px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background-color: #ff5f56;
    box-shadow: 
        20px 0 0 #ffbd2e,
        40px 0 0 #27c93f;
}

code {
    font-family: var(--font-mono);
    background-color: rgba(0,0,0,0.06);
    padding: 3px 6px;
    border-radius: 4px;
    font-size: 0.9em;
    color: #c7254e; /* 行内代码用醒目的红色 */
}

pre code {
    background-color: transparent;
    padding: 0;
    font-family: var(--font-mono);
    font-size: 15px; /* 代码字体稍微大一点 */
    color: #abb2bf;
}

/* 移除旧的 img 样式，避免冲突 */
/* img {
    border-radius: 8px;
    box-shadow: 0 8px 25px rgba(0,0,0,0.1);
} */

/* 目录样式 */
.toc-container {
    position: fixed;
    right: 30px;
    top: 100px;
    z-index: 1000;
}

.toc-toggle {
    background: transparent;
    border: none;
    padding: 8px;
    cursor: pointer;
    font-family: var(--font-primary);
    color: var(--meta-color);
    font-size: 0.95rem;
    transition: color 0.2s;
    /* 去除阴影 */
    box-shadow: none;
}

.toc-toggle:hover {
    color: var(--accent-color);
    background: rgba(0,0,0,0.03); /* 极淡的背景 */
    border-radius: 4px;
}

.toc-content {
    display: none;
    position: absolute;
    right: 0;
    top: 40px;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 15px;
    width: 250px;
    max-height: 70vh;
    overflow-y: auto;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

.toc-content.show {
    display: block;
}

.toc-content ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.toc-content li {
    margin-bottom: 8px;
    line-height: 1.4;
}

.toc-content a {
    color: var(--text-color);
    text-decoration: none;
    font-size: 0.9rem;
    border-bottom: none !important;
}

.toc-content a:hover {
    color: var(--accent-color);
}

.toc-level-3 { margin-left: 15px; font-size: 0.85rem; }
.toc-level-4 { margin-left: 30px; font-size: 0.85rem; }

/* 移动端隐藏目录 */
@media (max-width: 1000px) {
    .toc-container {
        display: none;
    }
}

footer {
    margin-top: 100px;
    padding-top: 40px;
    border-top: 1px dashed var(--border-color);
    text-align: center;
    color: var(--meta-color);
    font-size: 0.9rem;
}
