/* custom.css */

/* 公共样式导入 路径相对于 custom.css 的位置 */
@import url("_tab.css");
@import url("_field_list.css");
@import url("_code_block.css");
@import url("_cpp_ref.css");
@import url("feature_intro.css");

/* 多语言字体配置 */
body:lang(en) p {
    font-family: inherit; /* 继承默认字体 */
}

body:lang(zh-CN) p {
    font-family: "Microsoft YaHei", sans-serif;
}

/* 可选：其他语言扩展 */
body:lang(ja) p {
    font-family: "MS Gothic", sans-serif;
}

/* 支持更多语言扩展 */
body:lang(de) p { font-family: Arial; }
body:lang(ar) p { font-family: Tahoma; }

/* 渐变背景和全局样式 */
:root {
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --secondary-gradient: linear-gradient(to right, #ff758c 0%, #ff7eb3 100%);
    --forum-blue: #4a90e2;
    --forum-orange: #ff7f50;
    --text-dark: #2d3748;
    --text-light: #f7fafc;
    --root-margin-top: 4px;
    --root-margin-bottom: 0px;
}

/* 页面底部 Previous 和 next 按钮 margin-top */
.footer {
    margin-top: 48px;
    text-align: center;
    font-size: 14px;
    color: #6c757d;
}

.footer a {
    color: #6c757d;
    text-decoration: none;
}

.footer a:hover {
    text-decoration: underline;
}

.ic-pram-format *:not(a) {
    color: rgb(4, 0, 255);
    font-weight: bold;
    font-style: italic;
}

.keywordformat {
    color: red;
}

.wy-breadcrumbs {
    display: flex;
    width: 100%;
    align-items: center;
    justify-content: space-between;
    overflow: hidden;
    border-bottom: none !important;
    padding: 15px 0 0 0 !important;
    margin-bottom: 0;
    white-space: nowrap;    /* 确保整个容器内的内容倾向于不换行 */
}

.wy-breadcrumbs > ul {
    display: flex;
    flex-wrap: nowrap;
    white-space: nowrap;
    overflow: hidden;
    margin: 0;
    padding: 0;
    list-style: none;
    min-width: 0;
}

.wy-breadcrumbs > ul > li {
    display: flex;
    align-items: center;
    flex-shrink: 0;  /* 防止项目自身被不期望地压缩 */
}

.wy-breadcrumbs > li > a {
    white-space: nowrap;  /* 强制链接内的文本不换行 */
    overflow: hidden;
    text-overflow: ellipsis;
}

.wy-breadcrumbs a.icon.icon-home {
    margin-right: 5px;
}

.wy-breadcrumbs .language-toggle-container {
    margin-left: auto !important; /* 将此元素推到最右侧 */
    flex-shrink: 0;  /* 确保语言按钮永远不会被压缩 */
    padding-left: 10px;
}

.wy-breadcrumbs li,
.wy-breadcrumbs li a,
.wy-breadcrumbs .language-toggle-container #languageToggle {
    font-family: Lato, proxima-nova, Helvetica Neue, Arial, sans-serif !important;
    font-size: 16px !important;
    font-weight: 400 !important;
    margin-top: 0 !important;
    margin-bottom: 0 !important;
    line-height: 1.5 !important;
}

.wy-breadcrumbs .language-toggle-container #languageToggle {
    color: #404040 !important;
}

.field-list.simple dt {
    margin-top: 0 !important;
    margin-bottom: 0.5em;
    width: 20%;
    font-weight: bold;
    font-style: italic;
    color: brown;
    line-height: 24px !important;  /* Sync with .rst-content dl dd */
}

.rst-content dl.field-list {
    grid-template-columns: max-content auto !important;
}

div.math {
    overflow-x: auto;  /* 當內容寬度超過容器時，顯示水平捲軸 */
    overflow-y: hidden; /* 隱藏不必要的垂直捲軸 */
    padding: 8px;      /* 在公式周圍增加一些內邊距，讓捲軸不至於緊貼公式 */
    background-color: #f9f9f9; /* 淺灰色背景，讓可捲動區域更明顯 */
    border: 1px solid #e0e0e0;  /* 添加一個細邊框 */
    border-radius: 4px; /* 圓角 */
}

mjx-container {
    font-size: 100% !important;   /* 關鍵！強制字體大小與其父元素（<p>）一致，防止被放大 */
    line-height: normal;        /* 重設行高，避免垂直間距問題 */
    text-align: left !important;  /* 確保公式內容靠左對齊 */
}

[id], h1, h2, h3, h4, h5, h6, dt, div[id], span[id], .section[id] {
    scroll-margin-top: var(--top-nav-height) !important; /* 提高优先级 */
}

@media screen and (max-width: 768px) {
    .rst-content {
        max-width: 100%;
        overflow-x: hidden;
    }

    .rst-content figure.align-center {
        overflow-x: auto; /* 當內部圖片寬度超過容器時，顯示水平捲軸 */
        -webkit-overflow-scrolling: touch; /* 在 iOS 上提供更流暢的滾動體驗 */
    }

    /* 1. 確保外部容器可以滾動 */
    .wy-table-responsive {
        width: 100%;
        overflow-x: auto; /* 啟用水平捲動 */
        -webkit-overflow-scrolling: touch; /* 在 iOS 上提供更流暢的滾動體驗 */
    }

    /* 2. 覆寫表格本身的寬度限制，讓它可以自由伸展 */
    .wy-table-responsive table.docutils {
        width: auto !important; /* 關鍵：移除 100% 寬度限制，讓表格根據內容決定自身寬度 */
        table-layout: auto !important; /* 允許瀏覽器根據內容自動調整欄寬 */
    }

    /* 3. 禁止單元格內的文字換行，確保表格列寬由最長內容決定 */
    .wy-table-responsive table.docutils td,
    .wy-table-responsive table.docutils th {
        white-space: nowrap !important; /* 關鍵：防止文字換行 */
    }

    .wy-breadcrumbs li,
    .wy-breadcrumbs li a,
    .wy-breadcrumbs .language-toggle-container #languageToggle {
        font-size: 14px !important;
    }
}
