/* ==========================================================
   upx8wiki · post
   文章页 / 独立页面：两栏（正文 + 目录）
   只引用 base 的变量，不新增颜色字面量
   ========================================================== */

/* 注意：只能写上下内边距。写成 padding: 24px 0 会把 .wrap 的左右 24px 覆盖成 0，
   1200px 以下视口内容直接贴边 */
.pg {
    padding-top: 24px;
    padding-bottom: 64px;
}

/* ---------- 面包屑 ---------- */

.crumb {
    display: flex;
    align-items: center;
    gap: 2px;
    font-size: 12.5px;
    color: var(--tx-3);
    margin-bottom: 14px;
    white-space: nowrap;
    overflow: hidden;
}

.crumb a {
    color: var(--tx-3);
    transition: color .15s ease;
}

.crumb a:hover {
    color: var(--accent);
}

.crumb-c {
    color: var(--tx-4);
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ---------- 两栏骨架 ---------- */

.pg-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 268px;
    gap: 26px;
    align-items: start;
}

.pg-grid--full {
    grid-template-columns: minmax(0, 1fr);
}

/* ---------- 正文卡片 ---------- */

.art {
    min-width: 0;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r);
    box-shadow: var(--shadow);
    padding: 32px 38px 36px;
}

.art-hd {
    padding-bottom: 20px;
    margin-bottom: 26px;
    border-bottom: 1px solid var(--line-2);
}

.art-cat {
    display: inline-block;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .04em;
    line-height: 18px;
    padding: 0 8px;
    border-radius: 3px;
    color: var(--c, var(--tx-3));
    background: var(--cbg, var(--line-2));
}

.art-t {
    font-size: 27px;
    line-height: 1.36;
    font-weight: 750;
    letter-spacing: -.012em;
    color: var(--tx);
    margin: 12px 0 14px;
    overflow-wrap: break-word;
}

.art-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 2px;
    font-size: 12.5px;
    color: var(--tx-3);
}

.art-meta a {
    color: var(--tx-3);
}

.art-meta a:hover {
    color: var(--accent);
}

/* ---------- 正文排版 ---------- */

.prose {
    font-size: 15px;
    line-height: 1.82;
    color: var(--tx);
    overflow-wrap: break-word;
    word-break: break-word;
}

.prose > *:first-child {
    margin-top: 0;
}

.prose > *:last-child {
    margin-bottom: 0;
}

.prose p {
    margin: 15px 0;
}

.prose h2 {
    position: relative;
    font-size: 20px;
    line-height: 1.45;
    font-weight: 700;
    letter-spacing: -.01em;
    margin: 38px 0 14px;
    padding-left: 12px;
    scroll-margin-top: 76px;
}

.prose h2::before {
    content: "";
    position: absolute;
    left: 0;
    top: .22em;
    bottom: .22em;
    width: 3px;
    border-radius: 2px;
    background: var(--accent);
}

.prose h3 {
    font-size: 16.5px;
    line-height: 1.5;
    font-weight: 700;
    margin: 28px 0 10px;
    scroll-margin-top: 76px;
}

.prose h4 {
    font-size: 15px;
    font-weight: 700;
    margin: 22px 0 8px;
}

/* base.css 已清掉列表样式，正文里恢复 */
.prose ul,
.prose ol {
    margin: 15px 0;
    padding-left: 1.5em;
}

.prose ul {
    list-style: disc;
}

.prose ol {
    list-style: decimal;
}

.prose li {
    margin: 6px 0;
}

.prose li::marker {
    color: var(--tx-3);
}

.prose li > ul,
.prose li > ol {
    margin: 6px 0;
}

.prose a {
    color: var(--accent);
    border-bottom: 1px solid transparent;
    transition: border-color .15s ease;
}

.prose a:hover {
    border-bottom-color: var(--accent);
}

.prose strong {
    font-weight: 700;
    color: var(--tx);
}

.prose blockquote {
    margin: 20px 0;
    padding: 12px 18px;
    background: var(--line-2);
    border-left: 3px solid var(--tx-4);
    border-radius: 0 6px 6px 0;
    color: var(--tx-2);
}

.prose blockquote p {
    margin: 6px 0;
}

.prose hr {
    height: 0;
    border: 0;
    border-top: 1px solid var(--line);
    margin: 32px 0;
}

/* 行内代码 */
.prose code {
    font-size: .9em;
    padding: 2px 5px;
    border-radius: 4px;
    background: var(--line-2);
    color: var(--tx);
    border: 1px solid var(--line);
    white-space: break-spaces;
}

/* 代码块 */
.prose pre {
    margin: 20px 0;
    padding: 14px 16px;
    background: var(--code-bg);
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    overflow-x: auto;
    font-size: 13px;
    line-height: 1.72;
    -webkit-overflow-scrolling: touch;
}

.prose pre code {
    display: block;
    padding: 0;
    border: 0;
    background: none;
    font-size: inherit;
    color: var(--tx-2);
    white-space: pre;
}

/* 表格 */
.prose table {
    width: 100%;
    margin: 20px 0;
    border-collapse: collapse;
    font-size: 13.5px;
    line-height: 1.65;
}

.prose th,
.prose td {
    padding: 8px 12px;
    border: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
}

.prose th {
    background: var(--line-2);
    font-weight: 700;
    color: var(--tx-2);
    white-space: nowrap;
}

.prose img {
    max-width: 100%;
    height: auto;
    margin: 20px auto;
    border-radius: var(--r-sm);
    border: 1px solid var(--line-2);
}

.prose figcaption {
    font-size: 12px;
    color: var(--tx-4);
    text-align: center;
    margin-top: -10px;
    margin-bottom: 20px;
}

/* ---------- 标签 ---------- */

.art-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    margin-top: 30px;
    padding-top: 22px;
    border-top: 1px solid var(--line-2);
}

.tag {
    font-size: 12px;
    line-height: 20px;
    padding: 1px 10px;
    border-radius: 20px;
    color: var(--tx-3);
    background: var(--line-2);
    transition: color .15s ease, background .15s ease;
}

.tag:hover {
    color: var(--accent);
    background: var(--accent-soft);
}

/* ---------- 上下篇 ---------- */

.pager {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-top: 26px;
    padding-top: 22px;
    border-top: 1px solid var(--line-2);
}

.pager-i {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
    padding: 11px 14px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: var(--surface-2);
    transition: border-color .15s ease, background .15s ease;
}

a.pager-i:hover {
    border-color: var(--accent);
    background: var(--accent-soft);
}

.pager-next {
    text-align: right;
}

.pager-lb {
    font-size: 11px;
    letter-spacing: .06em;
    color: var(--tx-4);
}

.pager-t {
    font-size: 13px;
    font-weight: 600;
    color: var(--tx-2);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pager-empty {
    opacity: .45;
}

/* ---------- 相关文档 ---------- */

.sec-t {
    font-size: 14px;
    font-weight: 700;
    color: var(--tx-2);
    letter-spacing: .02em;
    margin: 34px 0 6px;
}

.rel-list li a {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 14px;
    padding: 9px 0;
    border-bottom: 1px dashed var(--line-2);
}

.rel-list li:last-child a {
    border-bottom: 0;
}

.rel-t {
    font-size: 13.5px;
    color: var(--tx-2);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    transition: color .15s ease;
}

.rel-list li a:hover .rel-t {
    color: var(--accent);
}

.rel-d {
    flex: 0 0 auto;
    font-size: 11.5px;
    color: var(--tx-4);
    font-variant-numeric: tabular-nums;
}

/* ---------- 目录侧栏 ---------- */

.pg-side {
    position: sticky;
    top: 76px;
    min-width: 0;
}

.toc {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r);
    box-shadow: var(--shadow);
    padding: 13px 14px 10px;
    max-height: calc(100vh - 104px);
    overflow-y: auto;
}

.toc-h {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .06em;
    color: var(--tx-3);
    padding-bottom: 9px;
    margin-bottom: 6px;
    border-bottom: 1px solid var(--line-2);
    cursor: default;
}

.toc-h svg {
    display: none;
    width: 14px;
    height: 14px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    transition: transform .2s ease;
}

.toc-l a {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-size: 12.8px;
    line-height: 1.45;
    color: var(--tx-3);
    padding: 5px 8px;
    border-radius: 5px;
    border-left: 2px solid transparent;
    transition: color .15s ease, background .15s ease, border-color .15s ease;
}

.toc-l a:hover {
    color: var(--tx);
    background: var(--line-2);
}

.toc-l a.on {
    color: var(--accent);
    background: var(--accent-soft);
    border-left-color: var(--accent);
}

.toc-l ul {
    padding-left: 8px;
}

.toc-l ul a {
    font-size: 12px;
    line-height: 1.4;
    color: var(--tx-3);
}

/* ---------- 响应式 ---------- */

@media (max-width: 1024px) {
    .pg-grid {
        grid-template-columns: minmax(0, 1fr);
        gap: 16px;
    }

    /* 单栏时目录移到正文上方，折叠态 */
    .pg-side {
        position: static;
        order: -1;
    }

    .toc {
        max-height: none;
        padding: 12px 14px;
    }

    .toc-h {
        cursor: pointer;
        padding-bottom: 0;
        margin-bottom: 0;
        border-bottom: 0;
    }

    .toc-h svg {
        display: block;
    }

    .toc.open .toc-h {
        padding-bottom: 9px;
        margin-bottom: 6px;
        border-bottom: 1px solid var(--line-2);
    }

    .toc.open .toc-h svg {
        transform: rotate(180deg);
    }

    .toc-body {
        display: none;
    }

    .toc.open .toc-body {
        display: block;
    }

    /* 折叠后目录行高更紧凑 */
    .toc.open .toc-l a {
        padding: 6px 8px;
    }
}

@media (max-width: 760px) {
    .pg {
        padding-top: 16px;
        padding-bottom: 44px;
    }

    .art {
        padding: 22px 18px 26px;
        border-radius: var(--r);
    }

    .art-t {
        font-size: 21px;
        line-height: 1.4;
    }

    .prose {
        font-size: 14.5px;
        line-height: 1.8;
    }

    .prose h2 {
        font-size: 18px;
        margin-top: 30px;
    }

    .prose h3 {
        font-size: 15.5px;
    }

    .prose pre {
        font-size: 12.5px;
        padding: 12px 13px;
        border-radius: 6px;
    }

    /* 窄屏表格允许横向滚动，不挤压列宽 */
    .prose table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
    }

    .pager {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .pager-next {
        text-align: left;
    }

    .art-meta {
        font-size: 12px;
    }
}
