/* ==========================================================================
   Labplus 知识库聚合站点 - 站点级自定义样式
   适配 sphinx_rtd_theme：门户首页卡片、三大板块、中文排版小优化
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. 全局字体与中文排版
   -------------------------------------------------------------------------- */
/* 全局字体：修复中文 Windows 下"不平滑"。
   sphinx_rtd_theme 直接在 body / 标题 / 代码等元素上声明了纯拉丁字体
   （Lato、Roboto Slab、SFMono…），不含任何中文字形；中文只能回退到浏览器
   默认字体——中文 Windows 常回退宋体（SimSun），小字号发虚、边缘锯齿。
   仅写在 html 上无效：主题对 body 的声明比"从 html 继承"更具体。
   custom.css 在 theme.css 之后加载，故这里以与主题"同等特异性"的选择器
   逐一覆盖 body / 标题 / 代码 / 表单：保留原拉丁字体，再补入各平台优质
   中文字体，确保中日韩字符走：
     · 中文 Windows → Microsoft YaHei（微软雅黑，ClearType 平滑）
     · 中文 macOS   → PingFang SC（苹方）/ Hiragino Sans GB
     · Linux / 兜底 → Source Han Sans SC / Noto Sans CJK SC / WenQuanYi Micro Hei
   三套字体栈集中为 CSS 变量，正文 / 标题 / 等宽分别复用。 */
:root {
    /* 正文与 UI：沿用主题 Lato 拉丁栈 + 中文字体 */
    --labplus-font-sans: Lato, "proxima-nova", "Helvetica Neue", Arial,
        "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "微软雅黑",
        "Source Han Sans SC", "Noto Sans CJK SC", "WenQuanYi Micro Hei",
        sans-serif;
    /* 标题：沿用主题 Roboto Slab 拉丁栈 + 中文无衬线（衬线宋体小字号易发虚） */
    --labplus-font-heading: "Roboto Slab", "ff-tisa-web-pro", Georgia, Arial,
        "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "微软雅黑",
        "Source Han Sans SC", "Noto Sans CJK SC", sans-serif;
    /* 等宽 / 代码：沿用主题 SFMono 拉丁栈 + 中文兜底（代码内中文注释平滑） */
    --labplus-font-mono: "SFMono-Regular", Menlo, Monaco, Consolas,
        "Liberation Mono", "Courier New", Courier,
        "PingFang SC", "Microsoft YaHei", "微软雅黑", monospace;
}

/* 正文：导航、段落、列表等所有继承文本均取自 body */
html, body {
    font-family: var(--labplus-font-sans);
}

/* 标题与章节图注（覆盖主题 Roboto Slab 纯拉丁栈） */
.rst-content .toctree-wrapper > p.caption,
h1, h2, h3, h4, h5, h6, legend {
    font-family: var(--labplus-font-heading);
}

/* 侧栏标题 */
.rst-content .sidebar .sidebar-title {
    font-family: var(--labplus-font-heading);
}

/* 代码与等宽文本：行内 code/tt、代码块 pre、行号栏等 */
.rst-content code, .rst-content tt, .rst-content kbd, .rst-content samp,
.rst-content pre, .rst-content pre.literal-block,
.rst-content .linenodiv pre, .rst-content div[class^="highlight"] pre,
code, kbd, pre, samp, tt {
    font-family: var(--labplus-font-mono);
}

/* 按钮 / 表单 / 版本切换等 UI 元素（覆盖主题 Lato 栈，含中文的按钮亦平滑） */
.btn, .rst-versions,
.wy-side-nav-search input[type="text"],
input[type="button"], input[type="submit"], input[type="reset"],
textarea, select {
    font-family: var(--labplus-font-sans);
}

/* 长中文与长 URL 在表格内自动换行，避免表格撑破内容区 */
.rst-content table.docutils td,
.rst-content table.docutils th {
    word-break: break-word;
    overflow-wrap: anywhere;
}

/* 正文段落与列表的中文行距稍放宽，阅读更舒适 */
.rst-content p,
.rst-content li,
.rst-content dd {
    line-height: 1.75;
}

/* --------------------------------------------------------------------------
   2. 门户首页 - 产品线入口卡片
   使用方式：index.rst 中以 .. raw:: html 插入 .portal-cards 结构
   -------------------------------------------------------------------------- */
.portal-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
    gap: 16px;
    margin: 24px 0 8px 0;
}

.portal-card {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 18px 18px 16px 18px;
    border: 1px solid #d8dde2;
    border-radius: 8px;
    background: #fff;
    color: #40474f;
    text-decoration: none;
    overflow: hidden;
    transition: transform 0.15s ease, box-shadow 0.15s ease,
        border-color 0.15s ease;
}

.portal-card::before {
    /* 顶部品牌色条 */
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--card-accent, #0e7c86);
}

.portal-card:hover,
.portal-card:focus-visible {
    transform: translateY(-3px);
    border-color: var(--card-accent, #0e7c86);
    box-shadow: 0 6px 16px rgba(30, 41, 51, 0.12);
    text-decoration: none;
}

/* 卡片内容 */
.portal-card-chip {
    align-self: flex-start;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.04em;
    color: #fff;
    background: var(--card-accent, #0e7c86);
    border-radius: 999px;
    padding: 2px 10px;
}

.portal-card-title {
    font-size: 18px;
    font-weight: 700;
    color: #1c2b33;
    line-height: 1.35;
}

.portal-card-desc {
    font-size: 14px;
    color: #55606a;
    line-height: 1.6;
    flex-grow: 1;
}

.portal-card-keywords {
    font-size: 13px;
    color: #75828c;
    line-height: 1.7;
    border-top: 1px dashed #d8dde2;
    padding-top: 8px;
    margin-top: 4px;
}

.portal-card-keywords::before {
    content: "关键词";
    font-weight: 600;
    color: #9aa4ac;
    margin-right: 8px;
    font-size: 12px;
}

/* 各产品线品牌色变量（卡片上以内联 style 提供 --card-accent） */

/* --------------------------------------------------------------------------
   3. 门户首页 - 三大板块说明
   -------------------------------------------------------------------------- */
.portal-sections {
    margin: 8px 0;
}

.portal-sections .portal-section {
    display: flex;
    gap: 14px;
    padding: 14px 16px;
    margin-bottom: 12px;
    border: 1px solid #e2e6ea;
    border-left: 4px solid #0e7c86;
    border-radius: 6px;
    background: #fafbfc;
}

.portal-sections .portal-section-icon {
    flex: 0 0 auto;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: #0e7c86;
    color: #fff;
    font-size: 14px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

.portal-sections .portal-section-body h4 {
    margin: 0 0 4px 0;
    font-size: 16px;
    font-weight: 700;
    color: #1c2b33;
}

.portal-sections .portal-section-body p {
    margin: 0;
    font-size: 14px;
    color: #55606a;
    line-height: 1.7;
}

/* --------------------------------------------------------------------------
   4. 选型页 - 指向详细资料的链接列（可选微调）
   -------------------------------------------------------------------------- */
.rst-content table.docutils td a.reference.internal {
    white-space: nowrap;
}
