/* 博文详情页专用样式 */

.lazy-image {
    opacity: 0;
    transition: opacity 0.3s ease-in;
}

.lazy-image.loaded {
    opacity: 1;
}

/* 博文头部区域样式 */
.post-header {
    border-radius: var(--border-radius-md);
    padding: var(--spacing-lg);
    border: 2px solid transparent;
    box-shadow: var(--shadow-heavy);
    margin-top: 1.5rem;
    transition: var(--transition-default);
}

/* 博文正文容器样式 */
.post-content-container {
    border-radius: var(--border-radius-md);
    padding: var(--spacing-lg);
    border: 2px solid transparent;
    box-shadow: var(--shadow-heavy);
    margin-top: 1.5rem;
    transition: var(--transition-default);
}

/* 博文标题样式 */
.post-title {
    font-size: 2.2rem;
    font-weight: bold;
    color: var(--primary-text);
    line-height: 1.3;
}

/* 博文元信息样式 */
.post-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1.5rem;
    margin-top: 1rem;
    color: var(--secondary-text);
    font-size: 0.9rem;
}

/* 分类和标签样式 */
.post-meta .post-categories,
.post-meta .post-tags {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* 日期样式 */
.post-date {
    white-space: nowrap;
}

.post-update-date {
    white-space: nowrap;
}

/* 博文详情页日期容器 */
#post-date {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: flex-start;
}

.post-date-item,
.post-update-date-item,
.reading-time-item {
    white-space: nowrap;
} 

.post-reading-time {
    white-space: nowrap;
}

.reading-time-item {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
} 

/* 分类和标签的badge样式 */
.post-meta .category-badge,
.post-meta .tag-badge {
    display: inline-block;
    padding: 4px 10px;
    background-color: var(--light-accent);
    color: var(--secondary-color);
    border-radius: var(--border-radius-md);
    text-decoration: none;
    font-size: 0.8rem;
    transition: var(--transition-default);
    border: 2px solid transparent;
}

.post-meta .category-badge:hover,
.post-meta .tag-badge:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-medium);
    border-color: var(--secondary-color);
    background-color: var(--secondary-color);
    color: white;
}

/* 博文摘要样式 */
.post-excerpt {
    font-size: 1.1rem;
    color: var(--secondary-text);
    font-style: italic;
    margin-bottom: 2rem;
    padding: 1rem;
    background-color: var(--secondary-bg);
    border-left: 4px solid var(--accent-color);
    border-radius: var(--border-radius-md);
}

/* 博文正文样式 */
.post-content {
    font-size: 1rem;
    line-height: 1.8;
    color: var(--primary-text);
}

/* 正文段落样式 */
.post-content p {
    margin-bottom: 1.5rem;
    text-align: justify;
}

/* 正文标题样式 */
.post-content h1,
.post-content h2,
.post-content h3,
.post-content h4,
.post-content h5,
.post-content h6 {
    margin: 2rem 0 1rem;
    color: var(--primary-text);
    font-weight: bold;
}

.post-content h1 { font-size: 1.8rem; }
.post-content h2 { 
    font-size: 1.6rem;
    border-bottom: none;
    padding-bottom: 0;
}
.post-content h3 { font-size: 1.4rem; }
.post-content h4 { font-size: 1.2rem; }
.post-content h5, .post-content h6 { font-size: 1.1rem; }

/* 列表样式 */
.post-content ul,
.post-content ol {
    margin: 1rem 0 1.5rem 2rem;
}

.post-content li {
    margin-bottom: 0.5rem;
}

/* 引用样式 */
.post-content blockquote {
    margin: 1.5rem 0;
    padding: 1rem 1.5rem;
    border-left: 4px solid var(--accent-color);
    border-top: 1px solid var(--accent-color);
    border-right: 1px solid var(--accent-color);
    border-bottom: 1px solid var(--accent-color);
    background-color: var(--secondary-bg);
    color: var(--secondary-text);
    font-style: italic;
    border-radius: var(--border-radius-md);
}

/* 代码块样式 */
.post-content pre {
    margin: 1.5rem 0;
    padding: 1rem;
    background-color: var(--code-bg);
    border-radius: var(--border-radius-md);
    overflow-x: auto;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
}

.post-content pre.code-with-line-numbers {
    padding: 1rem 0;
}

.post-content pre.code-with-line-numbers .code-line {
    display: block;
    padding: 0 1rem;
}

.post-content pre.code-with-line-numbers .line-number {
    display: inline-block;
    width: 2.5rem;
    text-align: right;
    margin-right: 1rem;
    color: var(--light-text);
    user-select: none;
    border-right: 1px solid var(--border-color);
    padding-right: 0.5rem;
}

.post-content code {
    background-color: var(--code-bg);
    padding: 0.2rem 0.4rem;
    border-radius: var(--border-radius-md);
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
}

/* 表格样式 */
.post-content table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin: 1.5rem 0;
    border: 1px solid var(--table-border-color);
    border-radius: var(--border-radius-md);
}

.post-content th,
.post-content td {
    padding: 0.75rem;
    text-align: left;
    border-right: 1px solid var(--table-border-color);
}

.post-content td {
    border-bottom: 1px solid var(--table-border-color);
}

.post-content th {
    border-bottom: 1px solid var(--table-border-color);
    background-color: var(--light-accent);
    font-weight: bold;
}

.post-content th:last-child,
.post-content td:last-child {
    border-right: none;
}

.post-content tr:last-child td {
    border-bottom: none;
}

.post-content th:first-child {
    border-top-left-radius: var(--border-radius-md);
}

.post-content th:last-child {
    border-top-right-radius: var(--border-radius-md);
}

.post-content tr:last-child td:first-child {
    border-bottom-left-radius: var(--border-radius-md);
}

.post-content tr:last-child td:last-child {
    border-bottom-right-radius: var(--border-radius-md);
}

/* 图片样式 */
.post-content img {
    max-width: 80%;
    max-height: 70vh;
    height: auto;
    display: block;
    margin: 1.5rem auto;
    border-radius: var(--border-radius-md);
}

/* 上标样式 */
.sub {
    vertical-align: sub;
    font-size: 0.75em;
    line-height: 0;
    position: relative;
    bottom: -0.25em;
}

/* 下标样式 */
.sup {
    vertical-align: super;
    font-size: 0.75em;
    line-height: 0;
    position: relative;
    top: -0.25em;
}

/* 上标HTML元素样式 */
sub {
    vertical-align: sub;
    font-size: 0.75em;
    line-height: 0;
    position: relative;
    bottom: -0.25em;
}

/* 上标HTML元素样式 */
sup {
    vertical-align: super;
    font-size: 0.75em;
    line-height: 0;
    position: relative;
    top: -0.25em;
}

/* 脚注样式 */
.footnote-ref {
    display: inline-block;
    vertical-align: super;
    font-size: 0.75em;
    margin: 0 0.1em;
    color: var(--accent-color);
}

.footnote-backref {
    text-decoration: none;
    color: var(--accent-color);
    font-size: 0.75em;
}

.footnote-backref:hover {
    color: var(--accent-hover);
}

.footnote-definition {
    margin: 0.5rem 0;
    border-left: 2px solid var(--border-color);
    font-size: 0.9em;
}

.footnote-definition p {
    margin: 0.25rem 0;
}

/* markdown-it-footnote 插件生成的样式 */
.footnotes {
    margin: 2rem 0 0 0;
    padding: 1rem;
    border-top: 1px solid var(--border-color);
    background-color: transparent !important;
    box-shadow: none !important;
    transform: none !important;
    transition: none !important;
}

.footnotes:hover {
    transform: none !important;
    box-shadow: none !important;
    background-color: transparent !important;
}

.footnotes-list {
    margin: 0;
    padding: 0;
    list-style-position: inside;
}

.footnote-item {
    margin: 0 0 1.5rem 0;
    padding: 0;
    font-size: 0.9em;
}

.footnote-item:last-child {
    margin-bottom: 0;
}

.footnote-item p {
    margin: 0;
    padding: 0;
    display: inline;
}

/* 定义列表样式 */
.post-content dl {
    margin: 1em 0;
}

.post-content dt {
    font-weight: bold;
    margin-top: 1em;
    margin-bottom: 0.5em;
    font-style: italic;
}

.post-content dd {
    margin-left: 2em;
    margin-bottom: 0.5em;
    padding-left: 0.5em;
    color: var(--text-color);
}

/* 导航链接样式 */
.nav-links {
    display: flex;
    justify-content: space-between;
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}

.nav-links a {
    color: var(--accent-color);
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: var(--border-radius-md);
    transition: var(--transition-default);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.nav-links a:hover {
    background-color: var(--secondary-bg);
    color: var(--accent-hover);
}

/* 返回列表按钮样式 */
.post-nav {
    margin-top: 0;
    /* 不设置 margin-top，让按钮直接与 .mainbox 的 padding 对齐
       目的是让 .post-nav 与 .post-header、.post-content-container 之间的间距一致
       都是通过 .post-header 和 .post-content-container 的 margin-top: 1.5rem 来控制间距 */
}

.back-to-list {
    display: inline-block;
    color: var(--accent-color);
    text-decoration: none;
    padding: 0.75rem 1.5rem;
    border-radius: var(--border-radius-md);
    border: 2px solid var(--accent-color);
    transition: var(--transition-default);
    font-weight: bold;
}

.back-to-list:hover {
    background-color: var(--accent-color);
    color: white;
    text-decoration: none;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .post-header,
    .post-content-container {
        padding: 1.5rem;
    }
    
    .post-title {
        font-size: 1.8rem;
    }
    
    .post-meta {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }
    
    .post-meta .post-categories,
    .post-meta .post-tags {
        width: 100%;
        flex-wrap: wrap;
    }
    
    .post-date,
    .post-update-date {
        white-space: normal;
    }
    
    .nav-links {
        flex-direction: column;
        gap: 1rem;
    }
    
    .nav-links a {
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .post-header,
    .post-content-container {
        padding: 1rem;
    }
    
    .post-title {
        font-size: 1.6rem;
    }
    
    .post-content h1 { font-size: 1.5rem; }
    .post-content h2 { font-size: 1.4rem; }
    .post-content h3 { font-size: 1.3rem; }
}

/* 夜间模式主题切换支持 */
body.dark-theme .post-header,
body.dark-theme .post-content-container {
    background-color: var(--bg-color);
    box-shadow: var(--box-shadow);
}

body.dark-theme .post-title,
body.dark-theme .post-content h1,
body.dark-theme .post-content h2,
body.dark-theme .post-content h3,
body.dark-theme .post-content h4,
body.dark-theme .post-content h5,
body.dark-theme .post-content h6 {
    color: var(--primary-text);
}

body.dark-theme .post-meta,
body.dark-theme .post-excerpt,
body.dark-theme .post-content blockquote {
    color: var(--secondary-text);
}

body.dark-theme .post-content {
    color: var(--primary-text);
}

body.dark-theme .post-meta .category-badge,
body.dark-theme .post-meta .tag-badge {
    background-color: var(--light-accent);
    color: var(--secondary-color);
}

body.dark-theme .post-meta .category-badge:hover,
body.dark-theme .post-meta .tag-badge:hover {
    background-color: var(--secondary-color);
    color: white;
    border-color: var(--secondary-color);
}

body.dark-theme .post-content pre,
body.dark-theme .post-content code {
    background-color: var(--code-bg);
    color: var(--primary-text);
}

body.dark-theme .post-content table th {
    background-color: var(--light-accent);
}

body.dark-theme .nav-links a {
    color: var(--accent-color);
}

body.dark-theme .nav-links a:hover {
    background-color: var(--dark-primary-hover-color);
    color: var(--accent-hover);
}

body.dark-theme .back-to-list a {
    background-color: var(--accent-color);
}

body.dark-theme .back-to-list a:hover {
    background-color: var(--dark-primary-hover-color);
}

/* 错误页面样式 */
.post-content .error {
    text-align: center;
    padding: 3rem 2rem;
    margin: 2rem 0;
    background-color: var(--secondary-bg);
    border-radius: var(--border-radius-md);
    border: 2px solid var(--border-color);
}

.post-content .error-type {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--accent-color);
    margin-bottom: 1rem;
}

.post-content .error-message {
    font-size: 1.1rem;
    color: var(--primary-text);
    margin-bottom: 0.5rem;
}

.post-content .error-detail {
    font-size: 0.9rem;
    color: var(--secondary-text);
    margin-bottom: 1.5rem;
    padding: 0.75rem;
    background-color: var(--bg-color);
    border-radius: var(--border-radius-sm);
    font-family: monospace;
}

.post-content .error .back-to-list {
    margin-top: 1rem;
}

body.dark-theme .post-content .error {
    background-color: var(--bg-color);
    border-color: var(--border-color);
}

body.dark-theme .post-content .error-detail {
    background-color: var(--secondary-bg);
}