/* ========================================
   编程文章详情页样式 - programming_post
   单列阅读布局：Hero + 正文卡片 + 上/下一篇 + 相关文章
   ======================================== */

body {
    background-color: #f5f6fa;
}

/* ---------------- Hero ---------------- */
.post-hero {
    background: linear-gradient(135deg, #36d1dc 0%, #5b86e5 100%);
    color: #fff;
    padding: 2.5rem 1.25rem 3.5rem;
}

.post-hero-inner {
    max-width: 860px;
    margin: 0 auto;
}

.post-hero-cat {
    padding: 0.25rem 0.9rem;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.22);
    color: #fff;
    backdrop-filter: blur(4px);
}

.post-hero-title {
    font-size: 2.1rem;
    font-weight: 700;
    line-height: 1.35;
    color: #fff;
    margin-bottom: 1rem;
}

.post-hero-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1.25rem;
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.92);
}

.post-hero-meta span {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

/* ---------------- 主体 ---------------- */
.post-main {
    margin-top: -2rem;
    padding: 0 1.25rem 3.5rem;
}

.post-container {
    max-width: 860px;
    margin: 0 auto;
}

/* ---------------- 正文卡片 ---------------- */
.post-content-card {
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 6px 24px rgba(31, 45, 61, 0.08);
    padding: 2.25rem 2.5rem;
}

/* 卡片右上角操作区（查看原文）：与正文标题同屏，读完正文不必再往下找 */
.post-card-actions {
    display: flex;
    justify-content: flex-end;
    margin: -0.4rem 0 1rem;
}

/* 查看原文是「离开本站」的次要操作：用浅底 + 品牌蓝字，避免 Bulma 默认的高饱和
   电光蓝（hsl(233,100%,63%)）喧宾夺主，把注意力留给正文与下方的彩色下载按钮；
   hover 时反色成实心，指向性更强 */
.post-card-actions .button {
    font-weight: 600;
    color: #4f6ef7;
    background: #eef1ff;
    border: 1px solid #d9e1ff;
}

.post-card-actions .button:hover {
    color: #fff;
    background: #4f6ef7;
    border-color: #4f6ef7;
}

.post-body {
    font-size: 1.05rem;
    line-height: 1.9;
    color: #374151;
    word-break: break-word;
}

.post-body h2 {
    font-size: 1.5rem;
    margin: 2rem 0 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #eef1f5;
}

.post-body h3 {
    font-size: 1.28rem;
    margin: 1.6rem 0 0.8rem;
}

.post-body p {
    margin-bottom: 1rem;
}

.post-body img {
    max-width: 100%;
    height: auto;
    border-radius: 10px;
}

.post-body a {
    color: #3273dc;
}

.post-body blockquote {
    border-left: 4px solid #d1d9e6;
    background: #fafbfc;
    color: #6b7280;
    padding: 0.4rem 1rem;
    margin: 1.25rem 0;
    border-radius: 0 8px 8px 0;
}

/* 富文本里的普通 pre：排除 wagtailcodeblock 的行号代码块（pre.line-numbers），
   避免灰底样式盖掉 Prism 主题 */
.post-body pre:not(.line-numbers) {
    background: #f6f8fa;
    padding: 15px;
    border-radius: 8px;
    overflow-x: auto;
}

/* 富文本里的行内 code：排除语法高亮的 code（class 含 language-） */
.post-body code:not([class*="language-"]) {
    background: #f1f3f6;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.9rem;
}

/* Markdown 正文样式来自共享文件 markdown-body.css（base_math.html 已加载） */

.post-empty {
    color: #9ca3af;
    text-align: center;
    padding: 2rem 0;
}

/* 正文末尾标签 */
.post-tags {
    margin-top: 2rem;
    padding-top: 1.25rem;
    border-top: 1px solid #eef1f5;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

.post-tags .post-tags-label {
    color: #9ca3af;
    font-size: 0.85rem;
    margin-right: 0.25rem;
}

.post-tags .tag {
    background: #eef1ff;
    color: #4f6ef7;
    font-weight: 500;
}

/* ---------------- 下载资源列表 ----------------
   整体一个卡片，内部每行一份资源：类型图标（颜色随类型）+ 名称/说明 + 类型标签 + 下载，
   行与行之间细分割线、hover 整行高亮，比多张卡片并排更清爽，也更好区分。
   --res-color 由模板按资源类型注入 */
.post-resources {
    margin-top: 2rem;
    padding-top: 1.25rem;
    border-top: 1px solid #eef1f5;
}

.post-resources-head {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.85rem;
}

.post-resources-title {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.05rem;
    font-weight: 700;
    color: #1f2d3d;
}

.post-resources-title i {
    color: #5b86e5;
}

.post-resources-count {
    margin-left: auto;
    font-size: 0.75rem;
    font-weight: 600;
    color: #7b8794;
    background: #f2f4f8;
    padding: 0.15rem 0.6rem;
    border-radius: 999px;
}

.post-resource-list {
    background: #fff;
    border: 1px solid #e8ecf2;
    border-radius: 14px;
    box-shadow: 0 2px 12px rgba(31, 45, 61, 0.05);
    overflow: hidden;
}

.post-resource {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    padding: 0.9rem 1.15rem;
    color: inherit;
    transition: background-color 0.18s ease;
}

.post-resource + .post-resource {
    border-top: 1px solid #f2f4f8;
}

.post-resource:hover {
    background: #f8faff;
}

.post-resource-icon {
    flex-shrink: 0;
    width: 2.5rem;
    height: 2.5rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 11px;
    font-size: 1.1rem;
    color: var(--res-color, #64748b);
    background: var(--res-tint, #eef1f5);
}

.post-resource-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.post-resource-name {
    font-size: 0.98rem;
    font-weight: 600;
    color: #1f2d3d;
    line-height: 1.45;
    word-break: break-word;
}

.post-resource-note {
    font-size: 0.78rem;
    color: #9ca3af;
    line-height: 1.5;
    word-break: break-word;
}

.post-resource-kind {
    flex-shrink: 0;
    font-size: 0.7rem;
    font-weight: 600;
    line-height: 1.4;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    color: var(--res-color, #64748b);
    background: var(--res-tint, #eef1f5);
    white-space: nowrap;
}

/* 下载次数：类型标签与下载按钮之间的次要信息，弱化配色不抢主体 */
.post-resource-count {
    flex-shrink: 0;
    margin-left: auto;
    font-size: 0.72rem;
    color: #9aa4b2;
    white-space: nowrap;
}

.post-resource-action {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.78rem;
    font-weight: 600;
    line-height: 1;
    padding: 0.45rem 0.85rem;
    border: 1px solid var(--res-color, #5b86e5);
    border-radius: 999px;
    color: var(--res-color, #5b86e5);
    white-space: nowrap;
    transition: all 0.18s ease;
}

.post-resource:hover .post-resource-action {
    background: var(--res-color, #5b86e5);
    color: #fff;
}

/* ---------------- 上一篇 / 下一篇 ---------------- */
.post-nav {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-top: 1.75rem;
}

.post-nav-card {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    background: #fff;
    border: 1px solid #e8ecf2;
    border-radius: 12px;
    padding: 1rem 1.25rem;
    height: 100%;
    color: inherit;
    transition: all 0.2s ease;
}

.post-nav-card:hover {
    border-color: #5b86e5;
    box-shadow: 0 6px 18px rgba(91, 134, 229, 0.15);
    transform: translateY(-2px);
}

.post-nav-card.is-disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.post-nav-card.is-right {
    text-align: right;
    align-items: flex-end;
}

.post-nav-label {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.78rem;
    font-weight: 600;
    color: #5b86e5;
}

.post-nav-title {
    font-size: 0.98rem;
    font-weight: 600;
    color: #1f2d3d;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* 标题行：标题自适应可压缩，角标固定宽度不被压扁 */
.post-nav-line {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    min-width: 0;
    max-width: 100%;
}

.post-nav-line .post-nav-title {
    min-width: 0;
}

.post-nav-line .post-badge {
    flex-shrink: 0;
    margin-left: 0;
}

/* ---------------- 相关文章 ---------------- */
.post-related {
    margin-top: 2.5rem;
}

.post-related-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.25rem;
    font-weight: 700;
    color: #1f2d3d;
    margin-bottom: 1.25rem;
}

.post-related-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 1rem;
}

.post-related-card {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    background: #fff;
    border: 1px solid #e8ecf2;
    border-radius: 12px;
    padding: 1.1rem 1.25rem;
    color: inherit;
    transition: all 0.2s ease;
}

.post-related-card:hover {
    border-color: #5b86e5;
    box-shadow: 0 6px 18px rgba(91, 134, 229, 0.15);
    transform: translateY(-3px);
}

.post-related-cat {
    align-self: flex-start;
    font-size: 0.72rem;
    font-weight: 600;
    color: #4f6ef7;
    background: #eef1ff;
    padding: 0.15rem 0.6rem;
    border-radius: 999px;
}

.post-related-name {
    font-size: 1rem;
    font-weight: 600;
    color: #1f2d3d;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 3em;
}

.post-related-date {
    font-size: 0.8rem;
    color: #9ca3af;
}

/* ---------------- 查看权限角标（上下篇 / 相关文章）：
    与列表页同款：直角、无边框、纯色块 ---------------- */
.post-badge {
    display: inline-block;
    margin-left: 0.4rem;
    padding: 0.12rem 0.45rem;
    border-radius: 0;
    font-size: 0.68rem;
    font-weight: 500;
    line-height: 1.4;
    vertical-align: middle;
    white-space: nowrap;
}

.post-badge-locked {
    background: #fff3e0;
    color: #ef6c00;
}

.post-badge-open {
    background: #f1f3f6;
    color: #6b7280;
}

/* ---------------- 评论（紧凑布局） ---------------- */
.post-comments {
    margin-top: 1.5rem;
    padding: 1.1rem 1.25rem;
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, .04);
}
.post-comments-title {
    font-size: 1.05rem;
    font-weight: 600;
    margin-bottom: .85rem;
    display: flex;
    align-items: center;
    gap: .5rem;
}
.post-comments-count {
    color: #8e9aaf;
    font-size: .9rem;
    font-weight: 400;
}
.post-comment-form textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #e5e9f2;
    border-radius: 8px;
    resize: vertical;
    font: inherit;
    font-size: .92rem;
    min-height: 64px;
    color: #1f2d3d;
    box-sizing: border-box;
}
.post-comment-form-foot {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: .5rem;
    gap: 1rem;
}
.post-comment-form-foot .button {
    padding: 6px 18px;
    font-size: .88rem;
}
.post-comment-tip {
    color: #8e9aaf;
    font-size: .8rem;
}
.post-comment-login-tip {
    padding: 10px;
    background: #f5f6fa;
    border-radius: 8px;
    text-align: center;
    color: #8e9aaf;
    font-size: .88rem;
}
.post-comment-login-tip a { color: #5b86e5; }

.post-comment-list,
.post-comment-children {
    list-style: none;
    padding: 0;
    margin: .75rem 0 0;
}
.post-comment-children {
    margin-top: .4rem;
    padding-left: .85rem;
    border-left: 2px solid #f0f2f5;
}
.post-comment {
    display: flex;
    gap: 10px;
    padding: .6rem 0;
}
.post-comment + .post-comment {
    border-top: 1px solid #f0f2f5;
}
.post-comment-avatar {
    flex: 0 0 32px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #5b86e5;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    font-weight: 600;
    font-size: .85rem;
    margin-top: 2px;
}
.post-comment-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.post-comment-body {
    flex: 1;
    min-width: 0;
}
.post-comment-head {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: baseline;
    margin-bottom: 2px;
}
.post-comment-name { font-weight: 600; color: #1f2d3d; font-size: .92rem; }
.post-comment-time { color: #8e9aaf; font-size: .75rem; }
.post-comment-tag {
    font-size: .68rem;
    padding: 1px 7px;
    border-radius: 999px;
    line-height: 1.4;
}
.tag-pending {
    background: #fff5e0;
    color: #b45309;
}
.tag-rejected {
    background: #fdecec;
    color: #b91c1c;
}
.post-comment-content {
    color: #2a3a4e;
    font-size: .92rem;
    line-height: 1.55;
    margin: 0 0 .2rem;
    word-break: break-word;
}
.post-comment-content.is-deleted-text,
.post-comment-content.is-rejected-text,
.post-comment.is-deleted .post-comment-content {
    color: #b0b8c5;
    font-style: italic;
}
.post-comment-actions {
    display: flex;
    gap: 12px;
    align-items: center;
    font-size: .78rem;
}
.post-comment-reply {
    color: #5b86e5;
    cursor: pointer;
    text-decoration: none;
}
.post-comment-delete-form { display: inline; }
.post-comment-delete-form button {
    background: none;
    border: none;
    color: #ef6c00;
    cursor: pointer;
    padding: 0;
    font: inherit;
}
.post-comment-empty {
    text-align: center;
    padding: 1.25rem 0;
    color: #8e9aaf;
    font-size: .9rem;
}

/* ---------------- 响应式 ---------------- */
@media (max-width: 768px) {
    .post-hero {
        padding: 2rem 1rem 3rem;
    }

    .post-hero-title {
        font-size: 1.5rem;
    }

    .post-content-card {
        padding: 1.5rem 1.25rem;
    }

    .post-nav {
        grid-template-columns: 1fr;
    }

    /* 窄屏资源行：类型标签让位给名称（图标颜色仍可区分类型），行内留白收紧 */
    .post-resource {
        padding: 0.75rem 0.85rem;
        gap: 0.6rem;
    }

    .post-resource-kind {
        display: none;
    }

    .post-resource-icon {
        width: 2rem;
        height: 2rem;
        font-size: 0.9rem;
    }

    .post-nav-card.is-right {
        text-align: left;
        align-items: flex-start;
    }
}
