/*!
 * Markdown 内容增强样式（前台文章页 + 后台预览 iframe 共用）
 * 依赖：static/css/style.css（主题排版）、highlight 主题
 */

/* ---------- Mermaid ---------- */
.article-entry .mermaid-diagram {
    position: relative;
    margin: 1.4em 0;
    padding: 16px 12px;
    background: #fff;
    border: 1px solid #eef0f0;
    border-radius: 8px;
    overflow-x: auto;
    text-align: center;
}

.article-entry .mermaid-diagram svg {
    max-width: 100%;
    height: auto;
}

.article-entry .mermaid-diagram[data-mermaid-source]::after {
    content: 'Mermaid';
    position: absolute;
    top: 6px;
    right: 8px;
    font-size: 10px;
    letter-spacing: .08em;
    color: #b9c2c0;
    text-transform: uppercase;
    pointer-events: none;
}

.article-entry .mermaid-error {
    margin: 1.4em 0;
    padding: 12px 14px;
    background: #fff6f5;
    border: 1px solid #f3c9c4;
    border-radius: 8px;
    color: #8a2a20;
    font-size: 13px;
}

.article-entry .mermaid-error-title {
    font-weight: 600;
    margin-bottom: 6px;
}

.article-entry .mermaid-error-message {
    margin: 0 0 8px;
    padding: 8px 10px;
    background: rgba(0, 0, 0, .04);
    border-radius: 4px;
    color: #8a2a20;
    font-size: 12px;
    white-space: pre-wrap;
    word-break: break-word;
}

.article-entry .mermaid-error details {
    color: #666;
}

.article-entry .mermaid-error summary {
    cursor: pointer;
    font-size: 12px;
}

.article-entry .mermaid-error pre {
    margin: 8px 0 0;
}

/* ---------- 代码块 ---------- */
.article-entry .code-block {
    position: relative;
    margin: 1.3em 0;
}

.article-entry .code-block pre {
    margin: 0;
}

.article-entry .code-block pre code,
.article-entry .code-block pre code.hljs {
    display: block;
    padding: 16px 16px 14px;
    border-radius: 8px;
    font-size: 13px;
    line-height: 1.65;
    overflow-x: auto;
}

.article-entry .code-lang {
    position: absolute;
    top: 8px;
    right: 64px;
    padding: 1px 7px;
    border-radius: 4px;
    background: rgba(255, 255, 255, .14);
    color: #c9d2cf;
    font-size: 11px;
    letter-spacing: .04em;
    line-height: 18px;
    pointer-events: none;
}

.article-entry .code-copy {
    position: absolute;
    top: 8px;
    right: 8px;
    padding: 1px 8px;
    border: 1px solid rgba(255, 255, 255, .18);
    border-radius: 4px;
    background: rgba(255, 255, 255, .1);
    color: #d6dddb;
    font-size: 11px;
    line-height: 18px;
    cursor: pointer;
    transition: background .2s ease, color .2s ease;
}

.article-entry .code-copy:hover,
.article-entry .code-copy:focus {
    background: rgba(255, 255, 255, .22);
    color: #fff;
    outline: none;
}

.article-entry .code-copy.is-copied {
    color: #9be3c8;
    border-color: rgba(155, 227, 200, .5);
}

/* 没有启用高亮时（例如脚本未加载）保证代码块仍然可读 */
.article-entry .code-block pre {
    background: #f8f8f8;
    border-radius: 8px;
}

.article-entry .code-block pre code.hljs {
    background: #171c19;
}

/* ---------- 表格 ---------- */
.article-entry .table-wrap {
    margin: 1.2em 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.article-entry .table-wrap table {
    margin: 0;
    min-width: 100%;
}

/* ---------- 任务列表 ---------- */
.article-entry .task-list-item {
    list-style: none;
    margin-left: -1.25em;
}

.article-entry .task-list-item input.task-list-item-checkbox {
    margin-right: .45em;
    vertical-align: middle;
}

/* ---------- 脚注 ---------- */
.article-entry .footnotes {
    margin-top: 2.4em;
    padding-top: 1em;
    border-top: 1px dashed #e6e6e6;
    font-size: .86em;
    color: #6b6b6b;
}

.article-entry .footnotes ol {
    padding-left: 1.2em;
}

.article-entry .footnote-ref a {
    text-decoration: none;
}

/* ---------- 图片 ---------- */
.article-entry img {
    max-width: 100%;
    height: auto;
}

/* ---------- 标题锚点偏移（目录跳转时不被固定头部遮挡） ---------- */
.article-entry h1,
.article-entry h2,
.article-entry h3,
.article-entry h4,
.article-entry h5,
.article-entry h6 {
    scroll-margin-top: 84px;
}

/* ============================================================
 * 以下为"接近飞书文档"的阅读体验增强（v3）
 * ============================================================ */

/* ---------- 正文排版 ---------- */
html {
    scroll-behavior: smooth;
}

.article-entry {
    font-size: 16px;
    line-height: 1.9;
}

.article-entry p {
    margin: 0 0 1.05em;
}

.article-entry h2 {
    margin-top: 1.9em;
}

.article-entry h3 {
    margin-top: 1.5em;
}

/* ---------- 标题锚点 ---------- */
.article-entry .heading-anchor {
    margin-left: 8px;
    opacity: 0;
    color: #c3c9c7;
    font-weight: 400;
    text-decoration: none;
    transition: opacity .15s ease, color .15s ease;
}

.article-entry h1:hover .heading-anchor,
.article-entry h2:hover .heading-anchor,
.article-entry h3:hover .heading-anchor,
.article-entry h4:hover .heading-anchor,
.article-entry h5:hover .heading-anchor {
    opacity: 1;
}

.article-entry .heading-anchor:hover {
    color: #1abc9c;
}

/* ---------- 提示块（[!NOTE] / [!TIP] / ...） ---------- */
.article-entry .callout {
    margin: 1.3em 0;
    padding: 12px 16px;
    border-left: 3px solid #1abc9c;
    border-radius: 6px;
    background: #f3faf8;
    color: #2f3a36;
}

.article-entry .callout-title {
    margin-bottom: 6px;
    font-weight: 600;
    font-size: 14px;
}

.article-entry .callout-note {
    border-left-color: #2f7ed8;
    background: #f2f7fd;
}

.article-entry .callout-tip {
    border-left-color: #1abc9c;
    background: #f3faf8;
}

.article-entry .callout-important {
    border-left-color: #7b5cd6;
    background: #f6f3fd;
}

.article-entry .callout-warning {
    border-left-color: #d9822b;
    background: #fff8ec;
}

.article-entry .callout-caution {
    border-left-color: #d64545;
    background: #fdf3f3;
}

/* ---------- 图片放大 ---------- */
.article-entry img.rh-zoomable {
    cursor: zoom-in;
    transition: transform .18s ease;
}

.article-entry img.rh-zoomable:hover {
    transform: translateY(-1px);
}

.rh-lightbox {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(15, 20, 18, .86);
}

.rh-lightbox[hidden] {
    display: none;
}

.rh-lightbox img {
    max-width: min(92vw, 1400px);
    max-height: 86vh;
    border-radius: 8px;
    box-shadow: 0 24px 64px rgba(0, 0, 0, .45);
    cursor: zoom-out;
}

.rh-lightbox-caption {
    margin-top: 12px;
    color: #dfe6e3;
    font-size: 13px;
    text-align: center;
}

.rh-lightbox-close {
    position: absolute;
    top: 14px;
    right: 18px;
    width: 34px;
    height: 34px;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, .25);
    border-radius: 50%;
    background: rgba(255, 255, 255, .08);
    color: #fff;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
}

.rh-lightbox-close:hover {
    background: rgba(255, 255, 255, .2);
}

body.rh-lightbox-open {
    overflow: hidden;
}

/* ---------- 目录高亮 ---------- */
.l_side .toc-wrapper .content a.active {
    color: #1abc9c;
    font-weight: 600;
}
