/* ========================================
   编程文章详情页样式 - 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: 1.5rem 0 0.5rem;
}

/* 查看原文是「离开本站」的次要操作：用浅底 + 品牌蓝字，避免 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;
}

/* 引用块内最后一段的底部外边距归零：
   .post-body p 给所有段落加了 margin-bottom，引用块内的段落也会吃到，
   块底就多出一整段空白，看起来像漏了一行 */
.post-body blockquote > :last-child {
    margin-bottom: 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;
}

/* Wagtail 表格块：后台「右键 → 对齐」会把 htLeft/htCenter/htRight/htJustify
   输出到 td/th 上，必须在这里写规则才能生效；Markdown 表格的对齐
   由 markdown-body.css + 表格自身 style 处理，与本组规则无关。 */
.post-body .htLeft    { text-align: left; }
.post-body .htCenter  { text-align: center; }
.post-body .htRight   { text-align: right; }
.post-body .htJustify { text-align: justify; }

/* 垂直对齐同理：Bulma 的 td 默认 vertical-align: top，合并单元格会贴顶 */
.post-body .htTop    { vertical-align: top; }
.post-body .htMiddle { vertical-align: middle; }
.post-body .htBottom { vertical-align: bottom; }

/* 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);
}

/* 分类胶囊 + 权限角标并排容器：卡片是纵向 flex，
   容器自身靠左，避免拉伸成整行 */
.post-related-tags {
    align-self: flex-start;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.35rem;
}

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

/* 相关文章里角标紧跟在胶囊右侧，间距由容器 gap 控制，去掉左外边距 */
.post-related-tags .post-badge {
    margin-left: 0;
}

.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;
    }
}

/* ---------------- 长文阅读辅助：底部快捷操作条 + 回到顶部 ----------------
   与教案页（.tp-action-bar / .tp-back-to-top）、课堂笔记页同一套交互：
   滚过正文后操作条推上来，接近页面底部时淡出（让位给文末的上/下篇卡片），
   回到顶部按钮常驻在操作条上方。参数保持一致，跨页滚动体验统一。 */
.post-action-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 900;
    background: rgba(255, 255, 255, 0.97);
    border-top: 1px solid #e2e8f0;
    box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.08);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    opacity: 0;
    visibility: hidden;
    transform: translateY(100%);
    transition: opacity 0.25s ease, transform 0.25s ease, visibility 0.25s;
}

.post-action-bar.is-visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.post-action-bar-inner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    height: 56px;
    padding: 0.5rem 1.25rem;
}

/* 两侧按钮弹性等分剩余空间（标题长了就省略，悬停 title 看全文），
   中间「返回编程分享」固定宽度，不会被两个长标题挤扁 */
.post-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    flex: 1 1 0;
    min-width: 0;
    max-width: 360px;
    padding: 0.45rem 0.9rem;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 0.5rem;
    color: #4a5568;
    font-size: 0.85rem;
    font-weight: 500;
    text-decoration: none;
    white-space: nowrap;
    transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.post-action-btn.is-home {
    flex: 0 0 auto;
    max-width: none;
}

.post-action-btn:hover,
.post-action-btn:focus {
    color: #3273dc;
    border-color: #bcd7f8;
    background: #f8fbff;
}

.post-action-btn i {
    flex-shrink: 0;
}

.post-action-label {
    flex-shrink: 0;
    color: #94a3b8;
    font-size: 0.78rem;
}

/* 文章标题可能很长：单行省略，按剩余空间收缩 */
.post-action-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #3d5a73;
    font-size: 0.82rem;
    transition: color 0.2s ease;
}

.post-action-btn:hover .post-action-name {
    color: #3273dc;
}

/* ---------------- 回到顶部 ---------------- */
.post-back-to-top {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.35);
    transition: all 0.3s;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    z-index: 999;
}

.post-back-to-top.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.post-back-to-top:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.5);
}

/* 操作条出现时把按钮抬到它上方，否则会被压在条下面 */
.post-back-to-top.lifted {
    bottom: calc(56px + 1rem);
}

@media (max-width: 768px) {
    .post-action-bar-inner {
        gap: 0.6rem;
        height: 52px;
        padding: 0.45rem 0.75rem;
        justify-content: space-between;
    }

    /* 窄屏优先保证「上一篇 / 下一篇」的方位感，标题让位 */
    .post-action-btn {
        max-width: none;
        flex: 1 1 0;
        justify-content: center;
        padding: 0.45rem 0.6rem;
        font-size: 0.8rem;
    }

    .post-action-btn.is-home {
        flex: 0 0 auto;
    }

    .post-action-name {
        display: none;
    }

    .post-back-to-top {
        bottom: 1.25rem;
        right: 1.25rem;
        width: 40px;
        height: 40px;
        font-size: 1rem;
    }

    .post-back-to-top.lifted {
        bottom: calc(52px + 1rem);
    }
}

/* 打印时不出现悬浮控件 */
@media print {
    .post-action-bar,
    .post-back-to-top {
        display: none !important;
    }
}
