/* ================================================================
   post.css — 文章页专用样式
   - 双列布局：主内容 + 右侧 TOC/相关推荐/订阅
   - 浅色主题（与首页统一）
   ================================================================ */

/* ============ 文章页容器 ============ */
.post-wrapper {
    max-width: 1280px;
    margin: 0 auto;
    padding: 1.5rem 1.5rem 2.5rem;
}

/* ============ 面包屑 ============ */
.post-breadcrumb {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.4rem;
    font-size: 0.8125rem;
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}
.post-breadcrumb a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.15s;
}
.post-breadcrumb a:hover { color: var(--accent); }
.post-breadcrumb .separator { color: var(--text-light); }
.post-breadcrumb .current { color: var(--text-primary); font-weight: 500; }

/* ============ 双列布局 ============ */
.post-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    gap: 2rem;
    align-items: start;
}

/* ============ 主内容卡片 ============ */
.post-main {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 2.25rem 2.5rem;
    min-width: 0;
    box-shadow: var(--shadow-sm);
}

/* 文章头部 */
.post-header {
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}
.post-header .pill {
    margin-bottom: 1rem;
}
.post-header h1 {
    font-size: 2rem;
    font-weight: 800;
    line-height: 1.35;
    color: var(--text-primary);
    margin: 0 0 1.25rem;
}
.post-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem 1.25rem;
    font-size: 0.8125rem;
    color: var(--text-secondary);
}
.post-author-avatar,
.post-meta-author,
.post-meta-reading { display: none; }
.post-meta-item {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
}
.post-meta-item svg {
    width: 13px;
    height: 13px;
    color: var(--text-muted);
}
.post-meta-item a {
    color: var(--text-secondary);
    text-decoration: none;
}
.post-meta-item a:hover { color: var(--accent); }
.post-meta-tag svg { color: var(--accent); }
.post-meta-tag a {
    color: var(--accent);
    font-weight: 600;
}
.post-meta-tag a:hover { color: var(--accent-hover); }

/* ============ 右侧栏 ============ */
.post-sidebar {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    position: sticky;
    top: 88px;
    max-height: calc(100vh - 110px);
    overflow-y: auto;
    scrollbar-width: thin;
}
.post-sidebar::-webkit-scrollbar { width: 6px; }
.post-sidebar::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 3px; }

.post-sidebar-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.125rem 1.25rem;
    box-shadow: var(--shadow-sm);
    flex-shrink: 0;

}
.post-sidebar-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 0.875rem;
    padding-bottom: 0.625rem;
    border-bottom: 1px solid var(--border-color);
}

/* ============ TOC 目录 ============ */
.toc-list {
    list-style: none;
    padding: 0;
    margin: 0;
    counter-reset: toc-h2 toc-sub;
    max-height: 360px;
    overflow-y: auto;
}
.toc-list li {
    margin-bottom: 0.25rem;
    line-height: 1.45;
    padding-left: 0.625rem;
    border-left: 3px solid var(--border-light);
    transition: border-color 0.2s, background 0.2s;
    display: flex;
    align-items: baseline;
    gap: 0.25rem;
}
.toc-list li a {
    flex: 1;
    min-width: 0;
    color: var(--text-primary);
    text-decoration: none;
    font-size: 0.8125rem;
    font-weight: 500;
    padding: 0.25rem 0.125rem;
    border-bottom: none;
    transition: color 0.15s;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.toc-list li a:hover { color: var(--accent); }
.toc-list li.toc-sub {
    counter-increment: toc-sub;
    padding-left: 1.5rem;
}
.toc-list li:not(.toc-sub) {
    counter-increment: toc-h2;
    counter-reset: toc-sub;
}
.toc-list li:not(.toc-sub)::before {
    content: counter(toc-h2) ".";
    color: var(--text-muted);
    font-weight: 700;
    font-size: 0.8125rem;
    flex-shrink: 0;
}
.toc-list li.toc-sub::before {
    content: counter(toc-h2, decimal) "." counter(toc-sub, lower-alpha);
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.8125rem;
    flex-shrink: 0;
}
/* TOC active state — vertical accent line + blue bold text */
.toc-list li.toc-active {
    border-left-color: var(--accent);
    background: var(--accent-light);
    border-radius: 0 4px 4px 0;
}
.toc-list li.toc-active::before { color: var(--accent); }
.toc-list li.toc-active a { color: var(--accent); font-weight: 700; }

/* ============ 相关推荐 ============ */
.related-item {
    display: flex;
    gap: 0.75rem;
    padding: 0.5rem;
    border-radius: 8px;
    margin-bottom: 0.5rem;
    text-decoration: none;
    color: inherit;
    transition: background 0.15s;
}
.related-item:hover {
    background: var(--accent-light);
    text-decoration: none;
    color: inherit;
}
.related-item:last-child { margin-bottom: 0; }
.related-thumb {
    width: 56px;
    height: 56px;
    border-radius: 6px;
    background: linear-gradient(135deg, var(--accent), var(--accent-hover));
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1.125rem;
    font-weight: 700;
}
.related-content {
    flex: 1;
    min-width: 0;
}
.related-title {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 0.25rem;
    transition: color 0.15s;
}
.related-item:hover .related-title { color: var(--accent); }
.related-date {
    font-size: 0.7rem;
    color: var(--text-muted);
}

/* ============ 订阅周刊卡片 ============ */
.subscribe-card {
    background: #0F172A;
    border: none;
    color: #fff;
    padding: 1.5rem 1.5rem 1.5rem;
    border-radius: 12px;
    box-shadow: var(--shadow-md);
    position: relative;
    overflow: hidden;
}
.subscribe-card::before {
    content: "";
    position: absolute;
    top: 0; right: 0;
    width: 96px; height: 96px;
    background: linear-gradient(135deg, rgba(59,130,246,0.18), transparent 60%);
    pointer-events: none;
}

/* ============ 文章图片 + 图注 ============ */
article section figure {
    margin: 1.75rem 0;
    text-align: center;
}
article section figure img {
    display: block;
    margin: 0 auto;
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
}
article section figcaption {
    margin-top: 0.625rem;
    color: var(--text-muted);
    font-size: 0.8125rem;
    font-style: italic;
}
/* 与 figure 等价的纯 img + 段落模式（caption 段以「图」/「Figure」开头） */
article section img + p.caption,
article section img + p:where(:first-child) {
    /* 由 JS 给「图 X: ...」段落追加 .caption 类，这里仅作 fallback */
}
article section p.caption {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.8125rem;
    font-style: italic;
    margin: -0.5rem 0 1.5rem;
}
article section p.lead {
    font-style: italic;
    color: var(--text-secondary);
    margin-top: 0.5rem;
    margin-bottom: 1.5rem;
    font-size: 1rem;
}
.subscribe-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: #fff;
    margin: 0 0 0.4rem;
}
.subscribe-desc {
    color: rgba(255, 255, 255, 0.78);
    font-size: 0.8rem;
    line-height: 1.55;
    margin: 0 0 0.95rem;
}
.subscribe-form {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    position: relative;
    z-index: 1;
}
.subscribe-input {
    width: 100%;
    height: 38px;
    padding: 0 0.875rem;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 8px;
    color: #fff;
    font-size: 0.8125rem;
    transition: border-color 0.15s, background 0.15s;
}
.subscribe-input::placeholder { color: rgba(255, 255, 255, 0.5); }
.subscribe-input:focus {
    outline: none;
    border-color: var(--accent);
    background: rgba(255, 255, 255, 0.14);
}
.subscribe-btn {
    width: 100%;
    height: 38px;
    background: var(--accent);
    border: 1px solid var(--accent);
    color: #fff;
    border-radius: 8px;
    font-size: 0.8125rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}
.subscribe-btn:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
}

/* ============ 文章内容样式 ============ */
article {
    max-width: none;
    counter-reset: post-h2-counter;
}
article section {
    line-height: 1.85;
    color: var(--text-primary);
    font-size: 1rem;
}
article section p { margin: 1rem 0; }
article section a {
    color: var(--accent);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: border-color 0.15s;
}
article section img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 1.5rem auto;
    display: block;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
}
article section h2 {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 2.25rem 0 1rem;
    padding: 0.25rem 0 0.25rem 0.875rem;
    border-left: 4px solid var(--accent);
    line-height: 1.5;
    scroll-margin-top: 80px;
}
article section h2::before {
    counter-increment: post-h2-counter;
    content: counter(post-h2-counter) ". ";
    color: var(--text-primary);
    font-weight: 700;
    margin-right: 0.25rem;
}
article section h3 {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 1.5rem 0 0.75rem;
    padding: 0.125rem 0 0.125rem 0.75rem;
    border-left: 3px solid var(--accent);
    line-height: 1.5;
    scroll-margin-top: 80px;
}
article section h4 {
    font-size: 1.0625rem;
    margin: 1.5rem 0 0.75rem;
    font-weight: 700;
    color: var(--text-primary);
    scroll-margin-top: 80px;
}

article section blockquote {
    border-left: 3px solid var(--accent);
    background: #F8FAFC;
    padding: 1rem 1.25rem;
    margin: 1.5rem 0;
    border-radius: 0 8px 8px 0;
    color: var(--text-secondary);
    font-style: italic;
}
article section blockquote p { margin: 0; }

article section ul,
article section ol {
    padding-left: 1.5rem;
    margin: 1rem 0;
}
article section li {
    margin-bottom: 0.4rem;
    line-height: 1.75;
}

article section hr {
    border: 0;
    border-top: 1px solid var(--border-color);
    margin: 2rem 0;
}

article section table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5rem 0;
    font-size: 0.9rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
}
article section th,
article section td {
    padding: 0.625rem 0.875rem;
    border: 1px solid var(--border-color);
    text-align: left;
}
article section th {
    background: var(--bg-page);
    font-weight: 600;
    color: var(--text-primary);
}

article section :not(pre) > code {
    background: #F1F5F9;
    color: #2563EB;
    padding: 0.125rem 0.375rem;
    border-radius: 4px;
    font-size: 0.9em;
    border: 1px solid #E2E8F0;
    font-family: "SFMono-Regular", Consolas, monospace;
}

/* ============ 代码块头部（语言标签，匹配 UI 设计） ============ */
article section pre[data-lang] {
    position: relative;
    background: #1E1F1C;
    border-radius: 8px;
    padding-top: 2.25rem;
    margin: 1.5rem 0;
    box-shadow: var(--shadow-md);
    overflow: hidden;
}
article section pre[data-lang]::before {
    content: attr(data-lang);
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1.85rem;
    padding: 0 1rem;
    display: flex;
    align-items: center;
    background: #272822;
    color: #A1A1AA;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    font-family: "SFMono-Regular", Consolas, monospace;
    border-top-left-radius: 8px;
    border-top-right-radius: 8px;
    border-bottom: 1px solid #3E3D32;
}
article section pre[data-lang] > code {
    display: block;
    background: #272822;
    color: #F8F8F2;
    padding: 1rem 1.25rem;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    font-size: 0.85rem;
    line-height: 1.6;
    overflow-x: auto;
}
article section pre[data-lang] > code .highlight,
article section pre[data-lang] > code div.highlight {
    background: transparent;
    padding: 0;
    margin: 0;
    box-shadow: none;
    border-radius: 0;
}
article section pre[data-lang] > code .highlight > pre,
article section pre[data-lang] > code div.highlight > pre {
    background: transparent;
    padding: 0;
    margin: 0;
    font-size: inherit;
}
/* hide style.css decorative ::after dots to match design */
article section pre[data-lang] > code .highlight::after { display: none; }
article section pre[data-lang] > code .highlight::before { display: none; }
/* ============ 系列文章框 ============ */
.series-box {
    border: 1px solid var(--border-color);
    border-radius: 12px;
    margin-bottom: 2rem;
    overflow: hidden;
    background: var(--bg-surface);
    box-shadow: var(--shadow-sm);
}
.series-box .card-header {
    background: var(--accent-light);
    border-bottom: 1px solid var(--border-color);
    color: var(--accent);
    font-weight: 700;
    padding: 0.875rem 1.25rem;
}
.series-box .list-group-item {
    border-color: var(--border-light);
    padding: 0.75rem 1.25rem;
}
.series-box .list-group-item.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
    border-left: 3px solid var(--accent-hover);
}
.series-box a.list-group-item-action:hover {
    background: var(--accent-light);
    color: var(--accent);
}

/* ============ 上下篇导航 ============ */
.post-navigation {
    border-top: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
    padding: 1.5rem 0;
    margin: 2rem 0;
}
.post-nav-link {
    display: flex;
    padding: 0.875rem 1.125rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-surface);
    color: var(--text-primary);
    transition: all 0.15s;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
}
.post-nav-link:hover {
    background: var(--accent-light);
    border-color: var(--accent);
    color: var(--accent);
    text-decoration: none;
}
.post-nav-link small {
    color: var(--text-muted);
    font-size: 0.8rem;
    flex-shrink: 0;
}
.post-nav-link .post-nav-title {
    color: var(--text-primary);
    font-weight: 500;
    font-size: 0.9rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    min-width: 0;
}
.post-nav-link:hover .post-nav-title { color: var(--accent); }
.next-post .post-nav-link { flex-direction: row-reverse; text-align: right; }

/* ============ 文章底部：标签 + 操作 ============ */
.post-footer-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
    padding: 1.5rem 0;
    margin: 2rem 0 1rem;
    border-top: 1px solid var(--border-color);
}
.post-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.post-tag {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    background: #F1F5F9;
    color: var(--text-secondary);
    border: none;
    border-radius: 6px;
    font-size: 0.8125rem;
    font-weight: 500;
    transition: color 0.15s, background 0.15s;
}
.post-tag:hover {
    color: var(--accent);
    background: var(--accent-light);
}
.post-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.post-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.35rem 0.5rem;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: var(--text-secondary);
    font-size: 0.8125rem;
    cursor: pointer;
    transition: color 0.15s, background 0.15s;
}
.post-action-btn:hover {
    color: var(--accent);
    background: var(--accent-light);
}
.post-action-btn svg {
    width: 16px;
    height: 16px;
}

/* ============ 响应式 ============ */
@media (max-width: 991.98px) {
    .post-grid {
        grid-template-columns: 1fr;
    }
    .post-sidebar {
        position: static;
        max-height: none;
        overflow-y: visible;
    }
}
@media (max-width: 767.98px) {
    .post-wrapper { padding: 1rem; }
    .post-main { padding: 1.5rem 1.25rem; }
    .post-header h1 { font-size: 1.5rem; }
}
@media (max-width: 767.98px) {
    .post-wrapper { padding: 0 16px 2rem; }
    .post-breadcrumb { margin: 12px 0 14px; font-size: .66rem; white-space: nowrap; overflow: hidden; flex-wrap: nowrap; }
    .post-breadcrumb .current { overflow: hidden; text-overflow: ellipsis; }
    .post-grid { display: block; }
    .post-main { padding: 0; border: 0; border-radius: 0; box-shadow: none; background: transparent; }
    .post-header { margin-bottom: 18px; padding-bottom: 16px; }
    .post-header .pill { display: none; }
    .post-header h1 { margin-bottom: 14px; font-size: 1.38rem; line-height: 1.35; }
    .post-meta { gap: 4px 10px; font-size: .68rem; }
    .post-author-avatar { width: 25px; height: 25px; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; background: #0F172A; color: #fff; font: 700 .65rem var(--font-headline); }
    .post-meta-author { display: inline-flex; font-weight: 700; color: var(--text-primary); }
    .post-meta-reading { display: inline-flex; }
    .post-meta-date { order: 3; }
    .post-meta-reading { order: 4; }
    .post-meta-author-legacy, .post-meta-tag, .post-meta-item:last-child { display: none; }
    article section { font-size: .92rem; line-height: 1.8; }
    article section h2 { margin-top: 1.8rem; font-size: 1.2rem; }
    article section h3 { font-size: 1.02rem; }
    article section img { margin: 1.1rem auto; border-radius: 6px; }
    .post-sidebar {
        position: fixed;
        z-index: 1050;
        inset: 0 0 0 auto;
        width: min(82vw, 320px);
        max-height: none;
        overflow-y: auto;
        padding: 0 10px 20px;
        background: #F8FAFC;
        box-shadow: -12px 0 30px rgba(15,23,42,.14);
        transform: translateX(102%);
        transition: transform 220ms ease;
    }
    .post-sidebar.is-open { transform: translateX(0); }
    .post-sidebar .post-sidebar-card { border: 0; border-radius: 0; box-shadow: none; background: transparent; padding: 14px 6px; }
    .post-sidebar .post-sidebar-card:not(:first-of-type) { display: none; }
    .toc-list { max-height: none; }
    .post-grid .mobile-drawer-backdrop { display: none; }
    .post-navigation { padding: 1.1rem 0; margin: 1.5rem 0; border: 0; flex-direction: column; gap: 0.6rem; }
    .post-navigation .prev-post,
    .post-navigation .next-post { flex-basis: auto; margin: 0; }
    .post-nav-link { padding: 0.6rem 0.8rem; gap: 0.4rem; border-radius: 6px; max-width: 100%; }
    .post-nav-link small { font-size: 0.7rem; }
    .post-nav-link .post-nav-title { font-size: 0.78rem; }
}
