/* ============================================================
 * 知识详情页专属样式
 * 从 knowledge_detail.html 内联 <style> 中抽离，优化 SEO 代码文本比
 * =========================================================== */

/* 作者徽章 */
.knowledge-author-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 8px 0 14px 0;
    padding: 6px 12px;
    background: rgba(229, 193, 88, 0.08);
    border: 1px solid rgba(229, 193, 88, 0.22);
    border-radius: 8px;
}
.author-icon {
    font-size: 1rem;
}
.author-info {
    display: flex;
    flex-direction: column;
}
.author-name {
    font-size: 0.84rem;
    font-weight: 700;
    color: #E5C158;
}
.author-verify-tag {
    font-size: 0.74rem;
    color: #00D77A;
}

/* 核心要点卡片 */
.knowledge-takeaways-card {
    background: linear-gradient(145deg, rgba(20, 35, 55, 0.45) 0%, rgba(10, 18, 30, 0.65) 100%);
    border: 1px solid rgba(0, 215, 122, 0.3);
    border-left: 4px solid #00D77A;
    border-radius: 12px;
    padding: 16px;
    margin: 18px 0 24px 0;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}
.takeaways-header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.92rem;
    color: #00FF88;
    font-weight: 700;
    margin-bottom: 8px;
}
.takeaways-icon {
    font-size: 1rem;
}
.takeaways-summary {
    font-size: 0.88rem;
    color: #F1F5F9;
    line-height: 1.6;
    margin: 0 0 10px 0;
}
.takeaways-bullets {
    display: flex;
    flex-direction: column;
    gap: 6px;
    border-top: 1px dashed rgba(255, 255, 255, 0.08);
    padding-top: 8px;
}
.takeaway-bullet {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-size: 0.82rem;
    color: #CBD5E1;
    line-height: 1.5;
}
.bullet-dot {
    color: #E5C158;
    font-size: 0.75rem;
    line-height: 1.5;
}

/* 商业推广卡片 */
.knowledge-commercial-card {
    background: linear-gradient(135deg, rgba(229, 193, 88, 0.08) 0%, rgba(0, 215, 122, 0.06) 100%);
    border: 1px solid rgba(229, 193, 88, 0.3);
    border-radius: 12px;
    padding: 16px 20px;
    margin: 28px 0 16px 0;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}
.commercial-card-inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}
.commercial-text {
    flex: 1;
    min-width: 240px;
}
.commercial-text strong {
    color: #E5C158;
    font-size: 0.95rem;
    font-weight: 700;
    display: block;
    margin-bottom: 4px;
}
.commercial-text p {
    color: #CBD5E1;
    font-size: 0.84rem;
    margin: 0;
    line-height: 1.5;
}
.commercial-action {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}
.commercial-btn {
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 0.84rem;
    font-weight: 700;
    text-decoration: none;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.commercial-btn.primary {
    background: linear-gradient(135deg, #E5C158 0%, #D4A838 100%);
    color: #0F172A !important;
    box-shadow: 0 2px 8px rgba(229, 193, 88, 0.25);
}
.commercial-btn.primary:hover {
    transform: translateY(-1px);
    filter: brightness(1.05);
}
.commercial-btn.secondary {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #F8FAFC !important;
}
.commercial-btn.secondary:hover {
    background: rgba(255, 255, 255, 0.12);
    transform: translateY(-1px);
}

/* 合规免责声明 */
.knowledge-compliance-disclaimer {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin: 20px 0 10px 0;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
}
.compliance-icon {
    font-size: 1rem;
    flex-shrink: 0;
    margin-top: 1px;
}
.compliance-text {
    font-size: 0.78rem;
    color: #94A3B8;
    line-height: 1.5;
    margin: 0;
}

/* 视频播放器样式 */
.knowledge-video-card {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
}
.knowledge-video-container {
    position: relative;
    width: 100%;
    max-width: 440px;
    margin: 0 auto;
    background: #000;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
    aspect-ratio: 9 / 16;
    max-height: 75vh;
    display: flex;
    align-items: center;
    justify-content: center;
}
.knowledge-video-player {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #000;
}

/* 移动端适配 */
@media (max-width: 719px) {
    .knowledge-commercial-card {
        padding: 14px 16px;
        margin: 22px 0 14px;
    }
    .commercial-action {
        width: 100%;
        display: flex;
        gap: 8px;
    }
    .commercial-btn {
        flex: 1;
        min-width: 0;
        padding: 8px 10px;
        font-size: 0.82rem;
        text-align: center;
        white-space: nowrap;
    }
}

/* 屏幕阅读器仅用链接（知识图集） */
.knowledge-gallery-direct-links.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* 视频子图集 */
.knowledge-video-sub-gallery {
    margin-top: 8px;
}
.sub-gallery-title {
    font-size: 0.8rem;
    color: #94A3B8;
    margin-bottom: 6px;
    display: block;
}
.sub-gallery-items {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 4px;
}
.sub-gallery-thumb img {
    width: 56px;
    height: 56px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.15);
}

/* 社交矩阵徽标 */
.knowledge-social-sources {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin: 4px 0 12px 0;
    font-size: 0.8rem;
}
.social-source-label {
    color: #94A3B8;
    font-size: 0.78rem;
}
.social-source-badges {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}
.social-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 0.76rem;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.2s ease;
}
.social-badge-ig {
    background: linear-gradient(45deg, #f09433 0%, #e6683c 25%, #dc2743 50%, #cc2366 75%, #bc1888 100%);
    color: #fff !important;
}
.social-badge-tk {
    background: #000;
    color: #fff !important;
    border: 1px solid rgba(255, 255, 255, 0.2);
}
.social-badge-fb {
    background: #1877F2;
    color: #fff !important;
}
.social-badge-yt {
    background: #FF0000;
    color: #fff !important;
}
.social-badge:hover {
    transform: translateY(-1px);
    filter: brightness(1.1);
}

/* 标签样式 */
.knowledge-tags-section {
    margin: 16px 0 20px 0;
}
.knowledge-tags-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.knowledge-tag-badge {
    display: inline-block;
    padding: 3px 10px;
    background: rgba(229, 193, 88, 0.08);
    border: 1px solid rgba(229, 193, 88, 0.2);
    border-radius: 14px;
    font-size: 0.76rem;
    color: #E5C158;
}

/* ============================================================
 * 富文本文章排版（多格式内容重构新增）
 * =========================================================== */

.knowledge-article-body {
    font-size: 16px;
    line-height: 1.8;
    color: #e2e8f0;
    word-break: break-word;
}

/* 标题层级 */
.knowledge-article-body h1,
.knowledge-article-body h2,
.knowledge-article-body h3,
.knowledge-article-body h4,
.knowledge-article-body h5,
.knowledge-article-body h6 {
    color: #f1f5f9;
    font-weight: 700;
    line-height: 1.4;
    margin-top: 1.8em;
    margin-bottom: 0.8em;
    scroll-margin-top: 80px;
}
.knowledge-article-body h1 { font-size: 1.75rem; }
.knowledge-article-body h2 {
    font-size: 1.45rem;
    padding-bottom: 0.4em;
    border-bottom: 1px solid rgba(229, 193, 88, 0.2);
}
.knowledge-article-body h3 { font-size: 1.2rem; }
.knowledge-article-body h4 { font-size: 1.05rem; }

/* 段落与文本 */
.knowledge-article-body p {
    margin: 1em 0;
}
.knowledge-article-body strong,
.knowledge-article-body b {
    color: #f1f5f9;
    font-weight: 700;
}
.knowledge-article-body em,
.knowledge-article-body i {
    font-style: italic;
}
.knowledge-article-body del {
    text-decoration: line-through;
    opacity: 0.6;
}
.knowledge-article-body mark {
    background: rgba(229, 193, 88, 0.25);
    color: #E5C158;
    padding: 0 4px;
    border-radius: 3px;
}

/* 引用块 */
.knowledge-article-body blockquote {
    margin: 1.5em 0;
    padding: 12px 20px;
    background: rgba(229, 193, 88, 0.06);
    border-left: 4px solid #E5C158;
    border-radius: 0 8px 8px 0;
    color: #cbd5e1;
    font-style: italic;
}
.knowledge-article-body blockquote p {
    margin: 0.5em 0;
}

/* 列表 */
.knowledge-article-body ul,
.knowledge-article-body ol {
    margin: 1em 0;
    padding-left: 1.8em;
}
.knowledge-article-body li {
    margin: 0.4em 0;
    line-height: 1.7;
}
.knowledge-article-body ul li::marker {
    color: #E5C158;
}
.knowledge-article-body ol li::marker {
    color: #E5C158;
    font-weight: 600;
}

/* 图片与媒体 */
.knowledge-article-body img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 1em auto;
    display: block;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}
/* SVG 元素：公众号排版工具常用 SVG 做装饰（背景图、动效载体）
   外层独立 SVG（含 viewBox + background-image）需确保高度随宽度等比缩放；
   嵌套 SVG 保持其内部定位与宽高；foreignObject 内部元素撑满容器 */
.knowledge-article-body svg:not(svg svg) {
    max-width: 100%;
    height: auto;
    display: block;
}
.knowledge-article-body foreignObject {
    overflow: visible;
}
.knowledge-article-body foreignObject > * {
    width: 100%;
    height: 100%;
}
.knowledge-article-body foreignObject svg {
    width: 100%;
    height: 100%;
    display: block;
}
/* 公众号画中画/视差滚动及富文本局部滚动容器在移动端的触控支持 */
.knowledge-article-body section[style*="overflow-y: auto"],
.knowledge-article-body section[style*="overflow-y: scroll"],
.knowledge-article-body [style*="overflow-y:auto"],
.knowledge-article-body [style*="overflow-y:scroll"] {
    -webkit-overflow-scrolling: touch !important;
    touch-action: pan-y !important;
    overscroll-behavior-y: contain !important;
}
.knowledge-article-body section[style*="overflow-y: auto"] img,
.knowledge-article-body [style*="overflow-y:auto"] img {
    touch-action: pan-y !important;
    -webkit-user-drag: none !important;
    user-select: none !important;
}
/* 前景固定遮罩/绝对布局层手势穿透，确保触控直达底层滚动容器 */
.knowledge-article-body [style*="pointer-events: none"],
.knowledge-article-body [style*="pointer-events:none"],
.knowledge-article-body [data-role="absolute-layout"],
.knowledge-article-body [data-mode="svg"] {
    pointer-events: none !important;
}
.knowledge-article-body [style*="pointer-events: none"] *,
.knowledge-article-body [style*="pointer-events:none"] *,
.knowledge-article-body [data-role="absolute-layout"] *,
.knowledge-article-body [data-mode="svg"] * {
    pointer-events: none !important;
}
/* 微信画中画多图层视窗：内嵌滚动容器通常为首个图层，后续的 height:0 图层均为前景遮罩 */
.knowledge-article-body section[style*="overflow: hidden"] > section:not(:first-child),
.knowledge-article-body section[style*="overflow:hidden"] > section:not(:first-child) {
    pointer-events: none !important;
}
.knowledge-article-body section[style*="overflow: hidden"] > section:not(:first-child) *,
.knowledge-article-body section[style*="overflow:hidden"] > section:not(:first-child) * {
    pointer-events: none !important;
}
/* Markdown 渲染的图片会被 <p> 包裹，含图片的段落适当减小外边距 */
.knowledge-article-body p:has(img) {
    margin: 0.5em 0;
}
/* 纯图片段落（内容全是图片）：消除图片间空白文本节点的行高，图片间距为0 */
.knowledge-article-body p.img-only-paragraph {
    line-height: 0;
    margin: 0;
}
.knowledge-article-body p.img-only-paragraph img {
    margin: 0 auto;
    border-radius: 0;
}
/* 同一段落内多张图片时，后续图片上边距减小（组图/纯图卡片场景） */
.knowledge-article-body p img ~ img {
    margin-top: 0.5em;
}
.knowledge-article-body figure {
    margin: 1.5em 0;
    text-align: center;
}
.knowledge-article-body figure img {
    margin: 0 auto;
}
.knowledge-article-body figcaption {
    font-size: 0.85rem;
    color: #94a3b8;
    margin-top: 0.6em;
    text-align: center;
}

/* 视频与嵌入 */
.knowledge-article-body .video-embed-container,
.knowledge-article-body .video-container {
    position: relative;
    padding-bottom: 56.25%;
    height: 0;
    overflow: hidden;
    border-radius: 8px;
    margin: 1.5em 0;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}
.knowledge-article-body .video-embed-container iframe,
.knowledge-article-body .video-embed-container video,
.knowledge-article-body .video-container iframe,
.knowledge-article-body .video-container video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 0;
}
.knowledge-article-body video {
    max-width: 100%;
    border-radius: 8px;
    display: block;
    margin: 1.5em auto;
}

/* 表格 */
.knowledge-article-body table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5em 0;
    font-size: 0.92rem;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}
.knowledge-article-body thead {
    background: rgba(229, 193, 88, 0.15);
}
.knowledge-article-body th,
.knowledge-article-body td {
    padding: 10px 14px;
    text-align: left;
    border-bottom: 1px solid rgba(148, 163, 184, 0.15);
}
.knowledge-article-body th {
    font-weight: 700;
    color: #E5C158;
}
.knowledge-article-body tbody tr:hover {
    background: rgba(229, 193, 88, 0.04);
}

/* 知识卡片文章内图片网格表格样式
   —— 仅对包含图片的表格应用网格样式（用于图片网格功能）
   普通文字表格保持默认样式（有边框、有表头）
   使用 :has() 选择器区分（Chrome 105+/Safari 15.4+ 支持） */
.knowledge-article-body table:has(img) {
    border: none;
    border-collapse: separate;
    border-spacing: 8px;
    margin: 1.5em 0;
    width: 100%;
    box-shadow: none;
    border-radius: 0;
    overflow: visible;
}

.knowledge-article-body table:has(img) thead {
    display: none; /* 图片网格表格隐藏空表头 */
}

.knowledge-article-body table:has(img) th,
.knowledge-article-body table:has(img) td {
    border: none;
    padding: 0;
    background: transparent;
    vertical-align: top;
}

.knowledge-article-body table:has(img) td img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 8px;
    margin: 0;
    display: block;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.knowledge-article-body table:has(img) tbody tr:hover {
    background: transparent;
}

/* 代码块 */
.knowledge-article-body pre {
    background: #0f172a;
    border: 1px solid rgba(148, 163, 184, 0.15);
    border-radius: 8px;
    padding: 16px;
    margin: 1.5em 0;
    overflow-x: auto;
    font-size: 0.88rem;
    line-height: 1.6;
}
.knowledge-article-body code {
    font-family: 'SF Mono', 'Menlo', 'Monaco', 'Consolas', monospace;
    font-size: 0.88em;
    background: rgba(148, 163, 184, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
    color: #38bdf8;
}
.knowledge-article-body pre code {
    background: none;
    padding: 0;
    color: #e2e8f0;
}

/* 分割线 */
.knowledge-article-body hr {
    border: none;
    border-top: 1px solid rgba(148, 163, 184, 0.2);
    margin: 2em 0;
}

/* 链接 */
.knowledge-article-body a {
    color: #38bdf8;
    text-decoration: none;
    border-bottom: 1px solid rgba(56, 189, 248, 0.3);
    transition: all 0.2s ease;
}
.knowledge-article-body a:hover {
    color: #7dd3fc;
    border-bottom-color: #7dd3fc;
}

/* 提示/警告卡片（admonition） */
.knowledge-article-body .admonition {
    margin: 1.5em 0;
    padding: 14px 18px;
    border-radius: 8px;
    border-left: 4px solid;
}
.knowledge-article-body .admonition.note,
.knowledge-article-body .admonition.info {
    background: rgba(56, 189, 248, 0.08);
    border-color: #38bdf8;
}
.knowledge-article-body .admonition.warning,
.knowledge-article-body .admonition.caution {
    background: rgba(251, 191, 36, 0.08);
    border-color: #fbbf24;
}
.knowledge-article-body .admonition.danger,
.knowledge-article-body .admonition.error {
    background: rgba(248, 113, 113, 0.08);
    border-color: #f87171;
}
.knowledge-article-body .admonition.success,
.knowledge-article-body .admonition.tip {
    background: rgba(0, 215, 122, 0.08);
    border-color: #00D77A;
}
.knowledge-article-body .admonition-title {
    font-weight: 700;
    margin-bottom: 0.5em;
}

/* 移动端适配 */
@media (max-width: 768px) {
    .knowledge-article-body {
        font-size: 15px;
        line-height: 1.75;
    }
    .knowledge-article-body h1 { font-size: 1.5rem; }
    .knowledge-article-body h2 { font-size: 1.25rem; }
    .knowledge-article-body h3 { font-size: 1.1rem; }
    .knowledge-article-body table {
        font-size: 0.85rem;
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
}

/* ============================================================
 * 文章内嵌目录树卡片（TOC）
 * =========================================================== */

.knowledge-article-toc {
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(229, 193, 88, 0.25);
    border-radius: 10px;
    padding: 16px 20px;
    margin: 1.5rem 0 2rem;
    backdrop-filter: blur(8px);
}
.toc-header {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #E5C158;
    font-size: 0.95rem;
    padding-bottom: 8px;
    border-bottom: 1px dashed rgba(229, 193, 88, 0.2);
    margin-bottom: 10px;
}
.toc-icon {
    font-size: 1.1rem;
}
.toc-list {
    list-style: none;
    padding: 0;
    margin: 0;
}
.toc-item {
    margin: 6px 0;
}
.toc-level-2 {
    padding-left: 0;
    font-weight: 600;
}
.toc-level-3 {
    padding-left: 18px;
    font-size: 0.9rem;
}
.toc-level-4 {
    padding-left: 36px;
    font-size: 0.85rem;
}
.toc-link {
    color: #cbd5e1;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: color 0.2s;
}
.toc-link:hover {
    color: #E5C158;
}
.toc-bullet {
    color: #E5C158;
    opacity: 0.6;
    font-weight: 700;
}

/* 移动端 TOC 适配 */
@media (max-width: 768px) {
    .knowledge-article-toc {
        padding: 12px 14px;
        margin: 1rem 0 1.5rem;
    }
    .toc-header {
        font-size: 0.85rem;
    }
    .toc-level-3 {
        padding-left: 14px;
    }
    .toc-level-4 {
        padding-left: 28px;
    }
}

/* ============================================================
 * 自适应排版布局（Media Mode 驱动）
 * =========================================================== */

/* 视觉聚焦模式（画廊/视频统一聚焦 · 左视右文，向下兼容 gallery_focus 与 video_focus） */
.media-focus-aside,
.media-mode-video_focus .video-focus-aside,
.media-mode-gallery_focus .gallery-focus-aside {
    width: 100%;
    margin-bottom: 24px;
}
.media-focus-aside .knowledge-video-card,
.media-mode-video_focus .video-focus-aside .knowledge-video-card {
    max-width: 100%;
}
.media-focus-aside .knowledge-video-container,
.media-mode-video_focus .video-focus-aside .knowledge-video-container {
    width: 100%;
    max-width: 440px;
    margin: 0 auto;
    border-radius: 14px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    background: #000;
}
.media-focus-aside .knowledge-video-player,
.media-mode-video_focus .video-focus-aside .knowledge-video-player {
    width: 100%;
    height: auto;
    max-height: 80vh;
    object-fit: contain;
    border-radius: 14px;
    display: block;
}

/* 模式 2：图文混排 —— 顶图流式 */
.knowledge-mixed-hero-cover {
    width: 100%;
    margin-bottom: 24px;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.3);
}
.knowledge-mixed-hero-cover img {
    width: 100%;
    height: auto;
    display: block;
    object-fit: cover;
}

/* 混排模式下，隐藏左侧 aside（因为视觉内容已内嵌正文流） */
.media-mode-mixed .knowledge-detail-visual {
    display: none;
}
.media-mode-mixed .knowledge-detail-primary-workspace {
    display: flex;
    flex-direction: column;
}
.media-mode-mixed .knowledge-detail-reading {
    max-width: 100%;
}

/* 响应式：移动端下统一为单列流式布局，视频呈现完整尺寸与自然比例 */
@media (max-width: 768px) {
    .media-focus-aside,
    .media-mode-gallery_focus .gallery-focus-aside,
    .media-mode-video_focus .video-focus-aside {
        width: 100%;
        margin-bottom: 16px;
    }
    .knowledge-video-container,
    .media-focus-aside .knowledge-video-container,
    .media-mode-video_focus .video-focus-aside .knowledge-video-container {
        max-width: 100% !important;
        aspect-ratio: auto !important;
        max-height: none !important;
        height: auto !important;
    }
    .knowledge-video-player,
    .media-focus-aside .knowledge-video-player,
    .media-mode-video_focus .video-focus-aside .knowledge-video-player {
        width: 100% !important;
        height: auto !important;
        max-height: 75vh !important;
        object-fit: contain !important;
        border-radius: 12px !important;
    }
    .knowledge-mixed-hero-cover {
        margin-bottom: 16px;
        border-radius: 8px;
    }
}
