/* ======================= Google Fonts ======================= */
@import url('https://fonts.googleapis.com/css2?family=Lato:wght@400;700&family=Montserrat:wght@600&family=Fira+Code&display=swap');

/* ======================= 主题变量定义 ======================= */
.theme-light {
    --theme-bg: #ffffff;
    --theme-fg: #292929;
    --theme-link: #007acc;
    --theme-sidebar-bg: #f9f9f9;
    --theme-border: #e0e0e0;
    --theme-btn-bg: #007acc;
    --theme-btn-fg: #ffffff;
    --theme-btn-hover: #005a99;
    --theme-code-bg: #f0f0f0;
    --theme-blockquote-bg: #f8f9fa;
}

.theme-dark {
    --theme-bg: #1E1E1E;
    --theme-fg: #D4D4D4;
    --theme-link: #4EC9B0;
    --theme-sidebar-bg: #1E1E1E;
    --theme-border: #3C3C3C;
    --theme-btn-bg: #005a99;
    --theme-btn-fg: #ffffff;
    --theme-btn-hover: #0088cc;
    --theme-code-bg: #2D2D2D;
    --theme-blockquote-bg: #2D2D2D;
}

/* ======================= 全局样式 ======================= */
body, .rst-content, .wy-nav-content {
    font-family: 'Lato', Arial, sans-serif !important;
    font-size: 16px;
    line-height: 1.7;
    color: var(--theme-fg);
    background-color: var(--theme-bg);
    overflow-x: hidden;
    transition: background-color 0.3s, color 0.3s;
}

a {
    color: #0071e3; /* 蓝色链接 */
    text-decoration: none;
}
a:hover {
    text-decoration: underline;
}

/* ======================= 标题 ======================= */
.rst-content h1,
.rst-content h2,
.rst-content h3,
.rst-content h4,
.rst-content h5,
.rst-content h6 {
    font-family: 'Montserrat', 'Lato', sans-serif !important;
    font-weight: 600;
    white-space: normal !important;
    word-break: break-word !important;
    overflow-wrap: break-word !important;
    max-width: 100%;
    box-sizing: border-box;
    color: var(--theme-fg);
}

.rst-content h2 {
    color: #0071e3 !important; /* 保留蓝色 H2 */
}

/* ======================= 侧边栏 ======================= */
.wy-nav-side {
    background-color: var(--theme-sidebar-bg);
}

.wy-side-nav-search {
    background-color: var(--theme-sidebar-bg) !important; 
    border-bottom-color: var(--theme-border) !important;
}

.wy-side-nav-search > div.version {
    color: white;
}

.wy-side-nav-search .logo img {
    max-width: 80% !important;   /* 左右留点呼吸感 */
    width: auto !important;
    height: auto !important;
    max-height: 60px !important; /* 限制最高高度，保证不突兀 */
    margin: 10px auto !important;/* 强制居中，并增加上下间距 */
    display: block !important;
    object-fit: contain;
}


.wy-menu a,
.wy-menu a:visited {
    color: var(--theme-fg);
}

.wy-menu a:hover,
.wy-menu-vertical a:hover {
    color: var(--theme-link) !important;
    background-color: rgba(0, 122, 204, 0.1) !important;
}

.wy-menu hr {
    border-top-color: var(--theme-border);
}

/* ======================= 内容区 ======================= */

.wy-nav-content {
    max-width: 1200px; /* 默认宽度 */
  }

/* 让右侧背景跟随主题变化 */
.wy-nav-content-wrap {
    background-color: var(--theme-sidebar-bg) !important;
    transition: background-color 0.3s ease;
}

.wy-nav-content-wrap p,
.wy-nav-content-wrap ul,
.wy-nav-content-wrap ol,
.wy-nav-content-wrap table,
.wy-nav-content-wrap blockquote {
    color: var(--theme-fg);
}

.wy-nav-content-wrap hr {
    border-top-color: var(--theme-border);
}

.wy-nav-content-wrap table {
    border-color: var(--theme-border);
}

.wy-nav-content-wrap table th {
    background-color: var(--theme-sidebar-bg);
    border-color: var(--theme-border);
}

.wy-nav-content-wrap table td {
    border-color: var(--theme-border);
}

.theme-dark .admonition.note {
    background-color: #2D2D2D;
    border-left-color: #4EC9B0;
    color: #D4D4D4;
}



/* ---------- 暗色模式表格样式 ---------- */
.theme-dark .wy-nav-content-wrap table th {
    background-color: #2A2A2A !important;
  }
  
  .theme-dark .wy-nav-content-wrap table td {
    background-color: #242424 !important;
    border-color: #3C3C3C !important;
  }
  
  .theme-dark .wy-nav-content-wrap table {
    border-color: #3C3C3C !important;
  }
  


/* 代码块 */
.wy-nav-content-wrap .highlight,
.wy-nav-content-wrap .highlight pre,
.wy-nav-content-wrap div.literal-block,
.wy-nav-content-wrap code,
pre, code {
    background-color: var(--theme-code-bg);
    color: var(--theme-fg);
    font-family: 'Fira Code', 'JetBrains Mono', 'Source Code Pro', Consolas, Menlo, Monaco, 'Courier New', monospace !important;
    font-size: 14px;
    padding: 0.2em 0.4em;
    border-radius: 4px;
    line-height: 1.4;
    white-space: pre-wrap;
    word-break: break-word;
    box-shadow: inset 0 0 5px rgba(0,0,0,0.05);
}

/* 引用块 */
.wy-nav-content-wrap blockquote {
    background-color: var(--theme-blockquote-bg);
    border-left-color: var(--theme-link);
}

/* ======================= 按钮 ======================= */
.wy-nav-content-wrap .btn,
.wy-nav-content-wrap .viewcode-link,
.wy-nav-content-wrap .headerlink {
    background-color: var(--theme-btn-bg);
    color: var(--theme-btn-fg);
    border-color: var(--theme-btn-bg);
}

.wy-nav-content-wrap .btn:hover,
.wy-nav-content-wrap .viewcode-link:hover,
.wy-nav-content-wrap .headerlink:hover {
    background-color: var(--theme-btn-hover);
    color: var(--theme-btn-fg);
}

/* ======================= 页面目录 TOC ======================= */
.rst-content .toctree-wrapper,
.rst-content .toctree-wrapper ul,
.rst-content .toctree-wrapper li,
.rst-content .toctree-wrapper a {
    font-family: 'Lato', Arial, sans-serif !important;
    font-size: 16px !important;
    color: var(--theme-fg) !important;
    line-height: 1.5 !important;
    text-decoration: none !important;
}

.rst-content .toctree-wrapper > ul > li > a {
    font-weight: 700 !important;
    font-size: 18px !important;
}

.rst-content .toctree-wrapper a:hover {
    color: #0071e3 !important;
}

.rst-content .toctree-wrapper > p {
    font-family: 'Montserrat', 'Lato', sans-serif !important;
    font-weight: 600 !important;
    font-size: 24px !important;
    color: #0071e3 !important;
    margin-bottom: 0.5em !important;
}

/* 隐藏正文中的 toctree caption */
.rst-content .caption,
.rst-content .caption-text {
    display: none !important;
}

/* ======================= 响应式 ======================= */
@media (max-width: 768px) {
    .wy-nav-content {
        max-width: 100% !important;
        padding: 1em !important;
        box-sizing: border-box;
    }

    .rst-content .toctree-wrapper > p { font-size: 18px !important; }
    .rst-content .toctree-wrapper a { font-size: 14px !important; }

    pre {
        overflow-x: auto;
        white-space: pre !important;
        word-break: normal !important;
    }

    .rst-content p,
    .rst-content li,
    .rst-content td,
    .rst-content a,
    .rst-content h1,
    .rst-content h2,
    .rst-content h3,
    .rst-content h4,
    .rst-content h5,
    .rst-content h6 {
        white-space: normal !important;
        word-break: break-word !important;
        overflow-wrap: break-word !important;
    }

    .rst-content table-wrapper,
    .rst-content .md-table-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .rst-content table {
        width: auto;
        min-width: 600px;
        table-layout: auto;
    }

    .rst-content table td,
    .rst-content table th,
    .rst-content table td p,
    .rst-content table th p {
        white-space: normal !important;
        word-break: normal !important;
        padding: 4px 8px;
        line-height: 1.4;
    }

    body, .rst-content, .wy-nav-content {
        line-height: 1.5;
    }
}

@media (max-width: 480px) {
    body, .rst-content, .wy-nav-content {
        font-size: 15px;
    }
}

/* ======================= 页脚社交图标 ======================= */
.forlinx-footer-social a {
    text-decoration: none !important;
}

/* ======================= 下拉主题菜单 ======================= */

/* ======================= 浮动主题切换按钮 ======================= */
#theme-switcher {
    position: fixed;
    z-index: 9999;
    top: 10px;
    right: 10px;
    display: block;
    pointer-events: auto; /* 确保可点击 */
}

/* 按钮样式 */
#theme-switcher-btn {
    padding: 8px 12px;
    background: rgba(0, 122, 204, 0.85); /* 半透明蓝色 */
    color: #fff;
    border: none;
    border-radius: 50px; /* 圆形/胶囊形 */
    cursor: pointer;
    font-size: 14px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.25);
    transition: all 0.3s ease;
    backdrop-filter: blur(6px); /* 背景轻微模糊 */
}

/* 悬浮效果 */
#theme-switcher-btn:hover {
    background: rgba(0, 122, 204, 1);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0,0,0,0.3);
}

/* ======================= 移动端右下角 ======================= */
@media (max-width: 768px) {
    #theme-switcher {
        top: 42px !important;
        right: 16px !important;
        bottom: auto !important; 
        z-index: 10005 !important;
    }
    #theme-switcher-btn {
        padding: 10px 14px;
        font-size: 15px;
    }
}

/* ======================= 移动端修复：汉堡菜单吸顶与展开修正 ======================= */
@media screen and (max-width: 768px) {
    
    /* 1. 顶部横条：确保始终吸顶且在最上层 */
    .wy-nav-top {
        position: -webkit-sticky !important; /* 👈 核心修复：专门拯救 iOS WebKit 内核 */
        position: sticky !important;
        top: 0 !important;
        z-index: 10001 !important;
        
        /* 👈 核心优化：开启 iOS 硬件加速，防止滚动时导航栏闪烁或撕裂 */
        -webkit-transform: translateZ(0); 
        transform: translateZ(0);

        box-shadow: 0 2px 4px rgba(0,0,0,0.1);
        width: 100% !important;
        display: block !important;
    }

    /* 2. 覆盖默认 shift 类：防止正文跳动和右移 */
    .wy-nav-content-wrap.shift {
        position: relative !important;
        height: auto !important;
        overflow: visible !important;
        top: auto !important;
        left: 0 !important;
        transform: none !important;
    }

    /* 3. 侧边栏：避开顶部导航栏，防止遮挡汉堡菜单 */
    .wy-nav-side.shift {
        position: fixed !important;
        top: 45px !important;  /* 👈 核心改动：向下挪动 45px，让出汉堡菜单的位置 */
        left: 0 !important;
        width: 85% !important;
        max-width: 320px !important;
        height: calc(100vh - 45px) !important; /* 👈 核心改动：高度相应扣除顶部 */
        z-index: 9999 !important;
        overflow-y: auto !important;
        box-shadow: 5px 0 15px rgba(0,0,0,0.3) !important;
    }
}

/* ======================= 一键置顶按钮样式 ======================= */
#back-to-top {
    display: none; /* 默认隐藏，由 JS 控制显示 */
    position: fixed;
    bottom: 40px;
    right: 40px;
    z-index: 999;
    border: none;
    outline: none;
    background-color: var(--theme-btn-bg); /* 使用你的主题变量 */
    color: var(--theme-btn-fg);
    cursor: pointer;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    font-size: 20px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
    transition: background-color 0.3s, transform 0.3s;
    justify-content: center;
    align-items: center;
}

#back-to-top:hover {
    background-color: var(--theme-btn-hover); /* 使用你的主题变量 */
    transform: translateY(-3px);
}

@media (max-width: 768px) {
    #back-to-top {
        bottom: 20px;
        right: 20px;
        width: 38px;
        height: 38px;
        font-size: 16px;
    }
}  


@media screen and (max-width: 768px) {

    /* ===== 1. 彻底清除白边 ===== */
    html {
        margin: 0 !important;
        padding: 0 !important;
        max-width: 100vw;
        overflow-x: hidden;
    }

    body {
        margin: 0 !important;
        padding: 0 !important;
        width: 100% !important;
    }

    body.wy-body-for-nav,
    div.wy-grid-for-nav {
        min-width: 0 !important;
        width: 100% !important;
        padding: 0 !important;
        margin: 0 !important;
    }

    .wy-grid-for-nav {
        margin-top: 0 !important;
        padding-top: 0 !important;
    }

    /* ===== 2. 顶部导航栏：fixed 固定 ===== */
    .wy-nav-top {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        z-index: 10001 !important;
        -webkit-transform: translateZ(0);
        transform: translateZ(0);
        box-shadow: 0 2px 4px rgba(0,0,0,0.1);
        display: flex !important;
        align-items: center !important;
        padding: 0 !important;
        margin: 0 !important;
    }

    .wy-nav-top i {
        flex-shrink: 0;
        width: 44px;
        text-align: center;
    }

    .wy-nav-top a {
        flex: 1 !important;
        text-align: center !important;
        padding-right: 44px;
    }

    /* ===== 3. 给 body 留出导航栏高度，防止内容被遮住 ===== */
    body.wy-body-for-nav {
        padding-top: 45px !important;
    }

    body, .rst-content, .wy-nav-content {
        overflow-x: visible !important;
    }
}


/* ==========================================================================
   🌟 新增：右侧智能浮动目录 (TOC) 宽屏布局样式
   ========================================================================== */
   @media (min-width: 1200px) {
    /* 为右侧固定目录腾出 360px 空间，保持正文排版不被挤压 */
    .wy-nav-content-wrap {
        padding-right: 360px !important;
    }
    
    /* 右侧悬浮目录主容器 */
    #right-side-toc {
        position: fixed;
        top: 80px;
        right: 80px;
        width: 260px;
        max-height: calc(100vh - 200px);
        overflow-y: auto;
        padding: 10px 0 10px 15px;
        border-left: 1px solid var(--theme-border);
        font-size: 13px;
        z-index: 998; /* 确保层级低于置顶按钮和主题按钮 */
    }
    
    /* 目录小标题 */
    #right-side-toc-title {
        font-family: 'Montserrat', sans-serif;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.5px;
        margin-bottom: 12px;
        color: var(--theme-link);
    }
    
    #right-side-toc ul {
        list-style: none !important;
        padding-left: 0 !important;
        margin-left: 0 !important;
    }
    
    #right-side-toc li {
        margin-bottom: 8px;
        line-height: 1.4;
    }
    
    /* H3 三级标题向内缩进，体现层级结构 */
    #right-side-toc li.toc-h3 {
        padding-left: 12px;
    }

    #right-side-toc li.toc-h4 {
        padding-left: 24px;
        font-size: 12.5px; 
    }
    
    #right-side-toc a {
        color: var(--theme-fg);
        opacity: 0.65;
        transition: all 0.2s ease;
        display: block;
        word-break: break-all;
    }
    
    #right-side-toc a:hover {
        opacity: 1;
        color: #0071e3 !important;
        text-decoration: none;
    }

    /* 🌟 核心高亮：当滑动到正文对应标题时，由 JS 自动激活的样式 */
    #right-side-toc li.active a {
        color: #0071e3 !important; /* 浅色模式激活时变成飞凌/苹果蓝 */
        opacity: 1 !important;
        font-weight: 700;
        border-left: 2px solid #0071e3;
        padding-left: 8px;
        margin-left: -16px;
    }
    
    /* 暗色模式下激活的高亮色彩自动微调 */
    .theme-dark #right-side-toc li.active a {
        color: var(--theme-link) !important;
        border-left-color: var(--theme-link);
    }
}

/* 窄屏、平板或移动端下，右侧目录自动隐形，确保主体阅读宽度 */
@media (max-width: 1199px) {
    #right-side-toc {
        display: none !important;
    }
}