/* 文章头部数据增强 */
.post-header {
    background: var(--card-bg);
    position: sticky;
    margin-bottom: 2rem;
    z-index: 5000;
    /* 调低至 5000，确保低于全局 Header 的 11000 */
    top: 80px;
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 15px var(--shadow-color);
    transition: all 0.3s ease;
}

.post-meta-extra {
    display: flex;
    gap: 15px;
    font-size: 0.9em;
    color: var(--main-text);
    opacity: 0.7;
    /* 替代原本固定的 #967272，使其在深色模式下也清晰 */
    margin-top: 10px;
}

/* --- 文章标题点击回顶样式 --- */
.post-title-top {
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-block;
    position: relative;
    color: var(--title-color);
}

.post-title-top:hover {
    color: var(--accent-color);
    transform: translateY(-2px);
}

.post-title-top:active {
    transform: translateY(1px);
}

/* 封面大图 */
.post-cover {
    width: 100%;
    aspect-ratio: 21 / 9;
    min-height: 200px;
    max-height: 450px;
    background-color: var(--sub-bg);
    object-fit: cover;
    border-radius: 20px;
    margin-bottom: 2rem;
    display: block;
    opacity: 1;
    transition: transform 0.5s ease, box-shadow 0.5s ease;
    cursor: zoom-in;
}

.post-cover:hover {
    transform: scale(1.02);
    box-shadow: 0 15px 40px var(--shadow-color);
}

/* 文章详情页整体布局 */
.post-detail-wrapper {
    display: flex;
    gap: 40px;
    margin-top: 2rem;
    align-items: flex-start;
    position: relative;
    overflow: visible;
}

.post-main-content {
    flex: 1;
    min-width: 0 !important;
    /* 核心：解除宽度锁定 */
    max-width: 100%;
    /* 限制最大宽度 */
    width: 0;
    /* 技巧：强制让 flex 重新计算宽度 */
    flex-grow: 1;
    /* 占据剩余空间 */
    position: relative;
    z-index: 1;
}

/* 2. 核心：侧边栏目录样式修正 */
.post-sidebar {
    width: 220px;
    position: sticky;
    top: 230px;
    /* 适配双层吸顶高度 */
    height: fit-content;
    z-index: 4000;
    transition: top 0.3s ease;
}



.toc-container {
    border-left: 2px solid var(--border-color);
    padding-left: 15px;
    position: relative;
}

/* 目录中的进度条小球 */
.toc-progress-dot {
    position: absolute;
    left: -5px;
    top: 0;
    width: 8px;
    height: 8px;
    background: var(--accent-color);
    border-radius: 50%;
    transition: top 0.2s ease;
    z-index: 2;
}

.toc-list {
    font-family: var(--font-display);
    list-style: none;
    padding: 0;
    margin: 0;
}

.toc-item {
    margin-bottom: 12px;
    font-size: 0.9em;
    line-height: 1.4;
}

.toc-link {
    font-size: 0.95rem;
    color: var(--sidebar-text);
    letter-spacing: 0.02em;
    transition: all 0.2s;
}

.toc-link.active {
    font-weight: 600;
    color: var(--accent-color);
    text-shadow: 0 0 1px var(--mark-bg);
}

.toc-item.h3 {
    padding-left: 15px;
    font-size: 0.85em;
    opacity: 0.8;
}

/* --- 1. 正文字体与排版 --- */
.post-body-text {
    font-family: var(--font-post);
    font-size: 1.15rem;
    font-weight: 400;
    line-height: 1.9;
    letter-spacing: 0.03em;
    color: var(--main-text);
    min-width: 0;
    width: 100%;
    max-width: 100%;
    overflow-wrap: break-word;
}

/* 正文中的标题 */
.post-body-text h2,
.post-body-text h3 {
    font-family: var(--font-post);
    font-weight: 600;
    color: var(--title-color);
    margin-top: 2.8rem;
}

.post-body-text p {
    margin-bottom: 1.5rem;
}

/* --- 1.5 正文链接样式 --- */
.post-body-text a {
    color: #1a73e8; /* 冷色调：谷歌蓝 */
    text-decoration: none;
    border-bottom: 1px dashed #1a73e8;
    transition: all 0.2s ease;
    font-weight: 500;
    padding-bottom: 1px;
}

/* 深色模式适配 */
@media (prefers-color-scheme: dark) {
    .post-body-text a {
        color: #64b5f6; /* 浅蓝，适合深色背景 */
        border-bottom-color: #64b5f6;
    }
}
html.dark-mode .post-body-text a {
    color: #64b5f6;
    border-bottom-color: #64b5f6;
}

.post-body-text a:hover {
    color: var(--title-color);
    border-bottom-style: solid;
    background-color: rgba(26, 115, 232, 0.1);
    border-radius: 4px;
    padding: 2px 4px;
    margin: 0 -4px;
    text-decoration: none;
}

/* 深色模式 Hover 适配 */
@media (prefers-color-scheme: dark) {
    .post-body-text a:hover {
        background-color: rgba(100, 181, 246, 0.2);
    }
}
html.dark-mode .post-body-text a:hover {
    background-color: rgba(100, 181, 246, 0.2);
}

/* 避免图片链接出现下划线 */
.post-body-text a:has(img) {
    border-bottom: none;
    background: none !important;
    padding: 0;
    margin: 0;
}

/* --- 2. 引用样式 (Blockquote) --- */
.post-body-text blockquote {
    margin: 2rem 0;
    padding: 1rem 1.5rem;
    background: var(--sub-bg);
    border-left: 5px solid var(--accent-color);
    border-radius: 4px;
    color: var(--main-text);
    opacity: 0.8;
    font-style: italic;
}

/* --- 3. 代码块基础样式 (配合 Prism) --- */
.post-body-text pre {
    border-radius: 12px;
    margin: 1.5rem 0;
    box-shadow: 0 5px 15px var(--shadow-color);
}

/* --- 3.5 表格样式 (Markdown Table) --- */
.post-body-text table {
    width: 100%;
    max-width: 100%;
    margin: 2rem 0;
    border-collapse: collapse;
    border-radius: 8px;
    overflow: hidden; /* 圆角 */
    font-size: 0.95em;
    background-color: var(--card-bg); /* 表格底色 */
    box-shadow: 0 0 0 1px var(--border-color); /* 边框替代方案 */
}

.post-body-text thead {
    background-color: var(--sub-bg);
    border-bottom: 2px solid var(--border-color);
}

/* 深色模式下增强边框 */
@media (prefers-color-scheme: dark) {
    .post-body-text th,
    .post-body-text td {
        border-color: rgba(255, 255, 255, 0.2);
    }
}
html.dark-mode .post-body-text th,
html.dark-mode .post-body-text td {
    border-color: rgba(255, 255, 255, 0.2);
}

.post-body-text th,
.post-body-text td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    line-height: 1.6;
}

.post-body-text th {
    font-weight: 600;
    color: var(--title-color);
}

/* 斑马纹 */
.post-body-text tr:nth-child(even) {
    background-color: rgba(127, 127, 127, 0.03); /* 微弱的深色透明度，适配深浅模式 */
}

.post-body-text tr:hover {
    background-color: rgba(255, 149, 0, 0.05); /* Hover 时的淡橙色 */
}

/* 消除最后一个边框 */
.post-body-text tbody tr:last-child td {
    border-bottom: none;
}

/* --- 4. 图片灯箱样式 --- */
.post-body-text img {
    max-width: 100%;
    height: auto;
    border-radius: 12px;
    background-color: var(--sub-bg);
    margin: 1.5rem auto;
    display: block;
    transition: transform 0.5s cubic-bezier(0.165, 0.84, 0.44, 1), box-shadow 0.5s ease;
    cursor: zoom-in;
}

.post-body-text img:hover {
    transform: scale(1.03);
    box-shadow: 0 10px 30px var(--shadow-color);
}

/* 灯箱黑罩子 */
#lightbox-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    /* 灯箱罩子在两种模式下均应保持深色 */
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 20000;
    cursor: zoom-out;
    opacity: 0;
    transition: opacity 0.3s ease;
}

#lightbox-overlay.active {
    display: flex;
    opacity: 1;
}

#lightbox-img {
    max-width: 90%;
    max-height: 90%;
    border-radius: 8px;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

#lightbox-overlay.active #lightbox-img {
    transform: scale(1);
}

/* --- 文章结尾标签栏 --- */
.post-tags-detail {
    margin-top: 4rem;
    padding-top: 1.5rem;
    border-top: 1px dashed var(--border-color);
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

/* 复用并微调 .tag 样式 */
.post-tags-detail .tag {
    font-size: 0.9rem;
    padding: 6px 15px;
    background: var(--sub-bg);
    border: 1px solid var(--border-color);
    color: var(--sidebar-text);
    border-radius: 20px;
    /* 更圆润的胶囊型 */
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: var(--font-display);
}

.post-tags-detail .tag:hover {
    background: var(--accent-color);
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px var(--shadow-color);
    border-color: var(--accent-color);
}

/* --- 5. 图文混排辅助类 --- */
/* 左浮动 + 文字环绕 */
.post-body-text .img-left {
    float: left;
    margin: 0.5rem 1.5rem 1rem 0 !important; /* Override default auto margin */
    max-width: 45%; /* 防止图片过大 */
    display: inline-block; /* 允许 float */
}

/* 右浮动 + 文字环绕 */
.post-body-text .img-right {
    float: right;
    margin: 0.5rem 0 1rem 1.5rem !important;
    max-width: 45%;
    display: inline-block;
}

/* 清除浮动，防止布局塌陷 */
.clearfix::after {
    content: "";
    display: table;
    clear: both;
}

/* 确保移动端不浮动 */
@media (max-width: 768px) {
    .post-body-text .img-left,
    .post-body-text .img-right {
        float: none;
        display: block;
        margin: 1.5rem auto !important;
        max-width: 100%;
    }
}

.no-scroll {
    overflow: hidden;
    padding-right: var(--scrollbar-width, 0px);
}
