/* ===== 五环魔法师 自定义样式 ===== */

/* --- 文章页元信息条（日期 + 标签） --- */
.post-meta {
    flex-basis: 100%; /* 在 flex 头部里独占一行，位于标题下方 */
    color: #57606a;
    font-size: 14px;
    margin: 2px 0 6px;
}
.post-meta .post-label {
    display: inline-block;
    background: #ddf4ff;
    color: #0969da;
    border-radius: 10px;
    padding: 1px 10px;
    margin-left: 6px;
    font-size: 12px;
    line-height: 18px;
    text-decoration: none;
}
.post-meta .post-label:hover { background: #b6e3ff; }
[data-color-mode="dark"] .post-meta { color: #8b949e; }
[data-color-mode="dark"] .post-meta .post-label { background: #1f3a52; color: #58a6ff; }

/* --- 文章页 上一篇 / 下一篇 导航 --- */
.prev-next {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    border-top: 1px solid #d0d7de;
    margin-top: 28px;
    padding-top: 14px;
    font-size: 14px;
}
.prev-next a { text-decoration: none; }
.prev-next .pn-cell { max-width: 48%; min-width: 0; }
.prev-next .pn-next { margin-left: auto; text-align: right; }
.prev-next .pn-hint {
    display: block;
    color: #57606a;
    font-size: 12px;
    margin-bottom: 2px;
}
.prev-next .pn-title {
    display: block;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}
[data-color-mode="dark"] .prev-next { border-top-color: #30363d; }
[data-color-mode="dark"] .prev-next .pn-hint { color: #8b949e; }

/* --- 生词表格优化：横向滚动 + 斑马纹 --- */
.markdown-body table {
    display: block;
    max-width: 100%;
    overflow-x: auto;
}
.markdown-body table table { display: table; } /* 防御嵌套 */
.markdown-body tbody tr:nth-child(2n) { background: rgba(175, 184, 193, 0.15); }
.markdown-body th { white-space: nowrap; }

/* --- 头部允许换行：标题（头像+博客名）不许被压缩，空间不够时导航整体换到下一行 --- */
#header { flex-wrap: wrap; }
#header h1:has(.avatar) { flex-shrink: 0; white-space: nowrap; }

/* --- 导航图标补文字标签（宽屏显示，窄屏保持纯图标） --- */
@media (min-width: 761px) {
    .title-right { flex-wrap: wrap; justify-content: flex-end; row-gap: 4px; }
    .title-right > a.circle { padding: 8px 10px; } /* 带文字后收紧按钮 */
    .title-right > a::after {
        content: attr(title);
        font-size: 12px;
        margin-left: 4px;
        color: #57606a;
        white-space: nowrap;
    }
    [data-color-mode="dark"] .title-right > a::after { color: #8b949e; }
}

/* --- 中文正文排版：字体栈 + 行距（原模板只用 sans-serif / line-height 1.25，中文偏挤） --- */
html body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", "Source Han Sans SC", "WenQuanYi Micro Hei", sans-serif;
    line-height: 1.7;
    -webkit-font-smoothing: antialiased;
}
.markdown-body {
    font-size: 16.5px;
    line-height: 1.85;
    overflow-wrap: break-word;
    word-break: break-word;
}
.markdown-body p { margin-bottom: 1.15em; }
.markdown-body li { line-height: 1.85; }
.markdown-body h2, .markdown-body h3, .markdown-body h4 { line-height: 1.4; }
.markdown-body blockquote { line-height: 1.75; }
.markdown-body code, .markdown-body pre, .markdown-body tt {
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

/* --- 图片与图注：图片居中圆角、图注居中弱化（原图注是普通引用块，视觉上和正文混在一起） --- */
.markdown-body img {
    display: block;
    max-width: 100%;
    height: auto;
    margin: 0 auto;
    border-radius: 8px;
    cursor: zoom-in;
}
.markdown-body p:has(img) { margin-bottom: 4px; }
.markdown-body p:has(img) + blockquote {
    margin: 0 0 20px;
    padding: 0;
    border: 0;
    background: none;
    color: #57606a;
    font-size: 14px;
    line-height: 1.6;
    text-align: center;
}
[data-color-mode="dark"] .markdown-body p:has(img) + blockquote { color: #8b949e; }

/* --- 回到顶部按钮 --- */
#toTop {
    position: fixed;
    right: 20px;
    bottom: 24px;
    width: 42px;
    height: 42px;
    padding: 0;
    border: 1px solid var(--color-border-default, #d0d7de);
    border-radius: 50%;
    background: var(--color-canvas-default, #fff);
    color: var(--color-fg-muted, #57606a);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    z-index: 60;
    opacity: 0;
    visibility: hidden;
    transform: translateY(6px);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    transition: opacity 0.2s, transform 0.2s, visibility 0.2s, color 0.2s;
}
#toTop.show { opacity: 1; visibility: visible; transform: none; }
#toTop:hover { color: var(--color-accent-fg, #0969da); }

/* --- 图片灯箱（点击正文图片放大查看） --- */
.img-lightbox {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(0, 0, 0, 0.88);
    z-index: 100;
    cursor: zoom-out;
}
.img-lightbox.show { display: flex; }
.img-lightbox img {
    max-width: 100%;
    max-height: calc(100vh - 96px);
    border-radius: 6px;
    cursor: default;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
}
.img-lightbox-caption {
    position: fixed;
    left: 16px;
    right: 16px;
    bottom: 16px;
    color: #d0d7de;
    font-size: 14px;
    text-align: center;
}
.img-lightbox-close {
    position: fixed;
    top: 12px;
    right: 16px;
    width: 40px;
    height: 40px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
}
.img-lightbox-close:hover { background: rgba(255, 255, 255, 0.24); }
body.lightbox-open { overflow: hidden; }

@media (max-width: 600px) {
    #toTop { right: 12px; bottom: 16px; width: 38px; height: 38px; }
    .markdown-body { font-size: 16px; }
}

/* ===== 文章收藏（Curated Articles） ===== */
.curated-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}
.curated-toolbar .form-control { flex: 1 1 240px; max-width: 420px; }
.curated-count { color: #57606a; font-size: 13px; white-space: nowrap; }
.curated-list {
    list-style: none;
    margin: 0;
    padding: 0;
    border: 1px solid var(--color-border-default, #d0d7de);
    border-radius: 6px;
    overflow: hidden;
}
.curated-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--color-border-muted, #d8dee4);
}
.curated-item:last-child { border-bottom: 0; }
.curated-item:hover { background: rgba(175, 184, 193, 0.12); }
.curated-link { flex: 1 1 auto; min-width: 0; text-decoration: none; }
.curated-link:hover { text-decoration: underline; }
.curated-tag {
    flex: 0 0 auto;
    font-size: 12px;
    color: #57606a;
    border: 1px solid var(--color-border-muted, #d8dee4);
    border-radius: 10px;
    padding: 0 8px;
    line-height: 18px;
    white-space: nowrap;
}
.curated-source {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin: 12px 0 4px;
    padding: 10px 12px;
    border: 1px solid var(--color-border-muted, #d8dee4);
    border-radius: 6px;
    background: rgba(175, 184, 193, 0.1);
    font-size: 14px;
}
.curated-note { flex-basis: 100%; color: #57606a; font-size: 12px; }
.curated-footer {
    margin: 24px 0 0;
    padding-top: 12px;
    border-top: 1px solid var(--color-border-default, #d0d7de);
    font-size: 14px;
}
[data-color-mode="dark"] .curated-count,
[data-color-mode="dark"] .curated-tag,
[data-color-mode="dark"] .curated-note { color: #8b949e; }
[data-color-mode="dark"] .curated-list,
[data-color-mode="dark"] .curated-item,
[data-color-mode="dark"] .curated-source { border-color: #30363d; }
[data-color-mode="dark"] .curated-source { background: rgba(110, 118, 129, 0.15); }
[data-color-mode="dark"] .curated-footer { border-top-color: #30363d; }

@media (max-width: 600px) {
    .curated-item { flex-wrap: wrap; gap: 4px; }
    .curated-tag { font-size: 11px; }
}

/* --- 收藏文章里的留言卡片 --- */
.curated-article-meta { margin: 10px 0 0; color: #57606a; font-size: 13px; }
.curated-comments { margin-top: 28px; }
.curated-comments-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 18px;
    margin: 0 0 12px;
    padding-top: 16px;
    border-top: 1px solid var(--color-border-default, #d0d7de);
}
.curated-comments-count {
    font-size: 12px;
    font-weight: normal;
    color: #57606a;
    border: 1px solid var(--color-border-muted, #d8dee4);
    border-radius: 10px;
    padding: 0 8px;
    line-height: 18px;
}
.curated-comment {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px;
    margin-bottom: 10px;
    border: 1px solid var(--color-border-muted, #d8dee4);
    border-radius: 8px;
    background: var(--color-canvas-subtle, #f6f8fa);
}
.curated-avatar {
    flex: 0 0 auto;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    background: #d0d7de;
}
.curated-avatar-empty { display: inline-block; }
.curated-comment-main { flex: 1 1 auto; min-width: 0; }
.curated-comment-head {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    font-size: 13px;
    color: #57606a;
}
.curated-nick { font-weight: 600; color: var(--color-fg-default, #1f2328); }
.curated-badge {
    font-size: 11px;
    color: #0969da;
    background: #ddf4ff;
    border-radius: 8px;
    padding: 0 6px;
    line-height: 16px;
}
.curated-likes { margin-left: auto; white-space: nowrap; }
.curated-comment-text {
    margin-top: 4px;
    font-size: 15px;
    line-height: 1.72;
    overflow-wrap: break-word;
    word-break: break-word;
}
.curated-comment-text p { margin: 0 0 6px; }
.curated-comment-text p:last-child { margin-bottom: 0; }
.curated-comment-reply {
    margin: 10px 0 0;
    background: rgba(175, 184, 193, 0.16);
    border-left: 3px solid var(--color-border-default, #d0d7de);
}
.curated-comment-reply .curated-avatar { width: 24px; height: 24px; }
[data-color-mode="dark"] .curated-article-meta,
[data-color-mode="dark"] .curated-comment-head,
[data-color-mode="dark"] .curated-comments-count { color: #8b949e; }
[data-color-mode="dark"] .curated-comment {
    background: #161b22;
    border-color: #30363d;
}
[data-color-mode="dark"] .curated-comment-reply { background: #1c2128; border-left-color: #30363d; }
[data-color-mode="dark"] .curated-nick { color: #e6edf3; }
[data-color-mode="dark"] .curated-badge { background: #1f3a52; color: #58a6ff; }
[data-color-mode="dark"] .curated-comments-title { border-top-color: #30363d; }
