/* ============================================================
   blog.css — 博客的阅读功能样式
   搜索框、标签筛选、文章目录、阅读进度、代码复制、上下篇。

   ⚠️ 这个文件里**只用站点已有的 CSS 变量**，不写任何硬编码颜色。
   这样深色主题只要覆盖 :root 里的变量，这里会自动跟着变。
   ============================================================ */

/* ---------- 搜索与标签筛选 ---------- */
.blog-toolbar {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    width: 100%;
}

.blog-search {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 44px 0 14px;
    height: 46px;
    background: var(--color-bg-surface);
    border: 1px solid var(--color-border-medium);
    border-radius: 999px;
    box-shadow: var(--shadow-card);
    transition: border-color .22s var(--ease-smooth), box-shadow .22s var(--ease-smooth);
}
.blog-search:focus-within {
    border-color: var(--color-border-accent);
    box-shadow: var(--shadow-card-hover);
}
.blog-search > i {
    flex: none;
    color: var(--color-text-muted);
    font-size: .9rem;
}
.blog-search input {
    flex: 1;
    min-width: 0;
    height: 100%;
    font-size: .92rem;
    color: var(--color-text-primary);
    background: transparent;
    border: 0;
    outline: none;
}
.blog-search input::placeholder { color: var(--color-text-muted); }
.blog-search input::-webkit-search-cancel-button { display: none; }

.blog-search-clear {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    cursor: pointer;
    color: var(--color-text-muted);
    background: transparent;
    border: 0;
    border-radius: 50%;
    transition: background-color .18s var(--ease-smooth), color .18s var(--ease-smooth);
}
.blog-search-clear:hover {
    background: var(--color-bg-hover);
    color: var(--color-text-primary);
}

.blog-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.blog-tag-btn {
    padding: 5px 13px;
    font-size: .78rem;
    letter-spacing: .02em;
    cursor: pointer;
    color: var(--color-text-secondary);
    background: var(--color-bg-surface);
    border: 1px solid var(--color-border-subtle);
    border-radius: 999px;
    transition: background-color .18s var(--ease-smooth),
                color .18s var(--ease-smooth),
                border-color .18s var(--ease-smooth);
}
.blog-tag-btn:hover {
    border-color: var(--color-border-accent);
    color: var(--color-text-primary);
}
.blog-tag-btn[aria-pressed="true"] {
    color: #fff;
    background: var(--accent-grad);
    border-color: transparent;
}

.blog-hint {
    min-height: 1.3em;
    font-size: .82rem;
    color: var(--color-text-muted);
}

/* 搜索命中词高亮 */
.blog-hit {
    padding: 0 2px;
    border-radius: 3px;
    background: var(--accent-grad-soft);
    color: var(--color-text-primary);
    font-weight: 600;
}

/* 空结果 */
.blog-empty {
    padding: var(--space-lg);
    text-align: center;
    font-size: .92rem;
    line-height: 2;
    color: var(--color-text-muted);
    background: var(--color-bg-surface);
    border: 1px dashed var(--color-border-medium);
    border-radius: var(--radius-lg);
}

/* ---------- 阅读进度条 ---------- */
.md-progress {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 60;
    width: 100%;
    height: 3px;
    background: transparent;
    pointer-events: none;
}
.md-progress-bar {
    height: 100%;
    width: 0;
    background: var(--accent-grad);
    border-radius: 0 3px 3px 0;
    transition: width .12s linear;
}

/* ---------- 文章目录 ---------- */
.md-toc {
    padding: var(--space-md);
    background: var(--color-bg-surface);
    border: 1px solid var(--color-border-subtle);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-card);
}
.md-toc > summary {
    cursor: pointer;
    font-size: .88rem;
    font-weight: 600;
    letter-spacing: .04em;
    color: var(--color-text-secondary);
    list-style: none;
}
.md-toc > summary::-webkit-details-marker { display: none; }
.md-toc > summary::before {
    content: '';
    display: inline-block;
    width: 3px;
    height: .95em;
    margin-right: 9px;
    border-radius: 2px;
    background: var(--accent-grad);
    vertical-align: -2px;
}
.md-toc-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-top: var(--space-sm);
    list-style: none;
}
.md-toc-item {
    display: block;
    padding: 5px 10px;
    font-size: .86rem;
    line-height: 1.7;
    color: var(--color-text-secondary);
    text-decoration: none;
    border-left: 2px solid transparent;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    transition: background-color .18s var(--ease-smooth), color .18s var(--ease-smooth);
}
.md-toc-item:hover {
    background: var(--color-bg-hover);
    color: var(--color-text-primary);
}
.md-toc-item.lv3 { padding-left: 24px; font-size: .82rem; }
.md-toc-item.is-active {
    color: var(--accent-color);
    border-left-color: var(--accent-color);
    background: var(--accent-grad-soft);
}

/* ---------- 标题锚点 ---------- */
.md-body h2,
.md-body h3 { scroll-margin-top: 24px; position: relative; }
.md-anchor {
    margin-left: 8px;
    font-size: .7em;
    color: var(--color-text-muted);
    text-decoration: none;
    opacity: 0;
    transition: opacity .18s var(--ease-smooth);
}
.md-body h2:hover .md-anchor,
.md-body h3:hover .md-anchor,
.md-anchor:focus { opacity: 1; }

/* ---------- 代码块复制 ---------- */
.md-pre { position: relative; }
.md-copy {
    position: absolute;
    top: 8px;
    right: 8px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    font-size: .74rem;
    cursor: pointer;
    color: #cbd5e1;
    background: rgba(255, 255, 255, .10);
    border: 1px solid rgba(255, 255, 255, .18);
    border-radius: 999px;
    opacity: 0;
    transition: opacity .18s var(--ease-smooth), background-color .18s var(--ease-smooth);
}
.md-pre:hover .md-copy,
.md-copy:focus { opacity: 1; }
.md-copy:hover { background: rgba(255, 255, 255, .20); }
.md-copy[disabled] { cursor: default; }

/* 代码块在窄屏上给复制按钮留出余地 */
@media (max-width: 720px) {
    .md-copy { opacity: 1; }
}

/* ---------- 上一篇 / 下一篇 ---------- */
.md-nav {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: var(--space-sm);
    width: 100%;
}
.md-nav-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: var(--space-md);
    text-decoration: none;
    color: inherit;
    background: var(--color-bg-surface);
    border: 1px solid var(--color-border-subtle);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-card);
    transition: transform .22s var(--ease-smooth),
                border-color .22s var(--ease-smooth),
                box-shadow .22s var(--ease-smooth);
}
.md-nav-item:hover {
    transform: translateY(-2px);
    border-color: var(--color-border-accent);
    box-shadow: var(--shadow-card-hover);
}
.md-nav-item.is-next { text-align: right; }
.md-nav-label {
    font-size: .74rem;
    letter-spacing: .12em;
    color: var(--color-text-muted);
}
.md-nav-title {
    font-family: var(--font-serif);
    font-size: .96rem;
    line-height: 1.7;
    color: var(--color-text-primary);
}
.md-nav-item.is-empty { visibility: hidden; }

/* ---------- 窄屏 ---------- */
@media (max-width: 720px) {
    .blog-search { height: 42px; }
    .md-toc { padding: var(--space-sm) var(--space-md); }
    .md-nav { grid-template-columns: 1fr; }
    .md-nav-item.is-next { text-align: left; }
}

@media (prefers-reduced-motion: reduce) {
    .md-progress-bar,
    .blog-search,
    .blog-tag-btn,
    .md-toc-item,
    .md-copy,
    .md-anchor,
    .md-nav-item,
    .md-nav-item:hover { transition: none; transform: none; }
}

/* ============================================================
   首页「最近更新」
   只使用站点已有的 CSS 变量，深色主题会自动生效
   ============================================================ */
.recent-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: var(--space-md);
    width: 100%;
}
.recent-col {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    padding: var(--space-md);
    background: var(--color-bg-surface);
    border: 1px solid var(--color-border-subtle);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-card);
}
.recent-heading {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: .88rem;
    font-weight: 600;
    letter-spacing: .06em;
    color: var(--color-text-secondary);
}
.recent-heading i { color: var(--accent-color); }
.recent-list { display: flex; flex-direction: column; gap: 2px; list-style: none; margin: 0; }
.recent-item {
    display: flex; flex-direction: column; gap: 2px;
    padding: 8px 10px; text-decoration: none; color: inherit;
    border-radius: var(--radius-sm);
    transition: background-color .18s var(--ease-smooth);
}
.recent-item:hover { background: var(--color-bg-hover); }
.recent-date { font-family: var(--font-mono); font-size: .72rem; letter-spacing: .06em; color: var(--color-text-muted); }
.recent-title { font-size: .92rem; line-height: 1.7; color: var(--color-text-primary); }
.recent-item:hover .recent-title { color: var(--accent-color); }
.recent-more { display: inline-flex; align-items: center; gap: 6px; margin-top: 4px; font-size: .8rem; text-decoration: none; color: var(--accent-color); }
.recent-more i { transition: transform .22s var(--ease-smooth); }
.recent-more:hover i { transform: translateX(4px); }

@media (max-width: 560px) { .recent-grid { grid-template-columns: 1fr; } }
@media (prefers-reduced-motion: reduce) {
    .recent-item, .recent-more i, .recent-more:hover i { transition: none; transform: none; }
}

/* ============================================================
   相关文章（SPA 文章底部）
   ============================================================ */
.md-related {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    width: 100%;
    padding-top: var(--space-md);
    border-top: 1px solid var(--color-border-subtle);
}
.md-related-heading {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: .88rem;
    font-weight: 600;
    letter-spacing: .06em;
    color: var(--color-text-secondary);
}
.md-related-heading i { color: var(--accent-color); }
.md-related-list { display: flex; flex-direction: column; gap: 2px; list-style: none; margin: 0; }
.md-related-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 8px 10px;
    text-decoration: none;
    color: inherit;
    border-radius: var(--radius-sm);
    transition: background-color .18s var(--ease-smooth);
}
.md-related-item:hover { background: var(--color-bg-hover); }
.md-related-date { font-family: var(--font-mono); font-size: .72rem; letter-spacing: .06em; color: var(--color-text-muted); }
.md-related-title { font-size: .92rem; line-height: 1.7; color: var(--color-text-primary); }
.md-related-item:hover .md-related-title { color: var(--accent-color); }