/* ============================================================
   暖夜编辑 · Custom Theme
   《2026 实时翻译 AI 工具全攻略：软件和智能硬件》
   ============================================================ */

/* ── Google Fonts: Noto Serif SC 中文衬线 ── */
@import url('https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

/* ── 全局字体变量 ── */
:root {
    --custom-serif: 'Noto Serif SC', 'Source Han Serif SC', 'Songti SC', 'SimSun', Georgia, serif;
    --custom-sans: 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'Noto Sans CJK SC', system-ui, sans-serif;
    --custom-mono: 'JetBrains Mono', 'Source Code Pro', 'Fira Code', Consolas, monospace;
    --content-max-width: 740px;
    --menu-bar-height: 52px;
}

/* ============================================================
   LIGHT MODE · 温润纸面
   ============================================================ */
.light,
html:not(.js) {
    --bg:                    #FAFAF5;
    --fg:                    #1C1A17;
    --sidebar-bg:            #F3F0E8;
    --sidebar-fg:            #3A3830;
    --sidebar-non-existant:  #B0A890;
    --sidebar-active:        #B8761E;
    --sidebar-spacer:        #E5E0D5;
    --sidebar-header-border-color: #D4A853;
    --scrollbar:             #C8C2B0;
    --icons:                 #8A8070;
    --icons-hover:           #B8761E;
    --links:                 #9A6010;
    --inline-code-color:     #A85F1A;
    --quote-bg:              #F7F2E8;
    --quote-border:          #D4A853;
    --table-border-color:    #DDD8CC;
    --table-header-bg:       #EDE8DC;
    --table-alternate-bg:    #F5F2EA;
    --theme-popup-bg:        #F3F0E8;
    --theme-popup-border:    #DDD8CC;
    --theme-hover:           #EDE8DC;
    --searchbar-border-color:#DDD8CC;
    --searchbar-bg:          #FFFFFF;
    --searchbar-fg:          #1C1A17;
    --searchbar-shadow-color:#D4A85340;
    --searchresults-header-fg:#8A8070;
    --searchresults-border-color: #DDD8CC;
    --searchresults-li-bg:   #F7F2E8;
    --search-mark-bg:        #F5D88050;
    --warning-border:        #C8760A;
    --color-scheme:          light;
    --overlay-bg:            rgba(28, 26, 23, 0.5);
}

/* ============================================================
   DARK MODE · 暖夜深色 (navy 主题覆盖)
   ============================================================ */
.navy {
    --bg:                    #1C1A17;
    --fg:                    #E8E4DC;
    --sidebar-bg:            #141210;
    --sidebar-fg:            #C4BEB0;
    --sidebar-non-existant:  #5A5448;
    --sidebar-active:        #E8A23A;
    --sidebar-spacer:        #282420;
    --sidebar-header-border-color: #E8A23A60;
    --scrollbar:             #3A3630;
    --icons:                 #7A7268;
    --icons-hover:           #E8A23A;
    --links:                 #E8A23A;
    --inline-code-color:     #F0B852;
    --quote-bg:              #242018;
    --quote-border:          #E8A23A;
    --table-border-color:    #2E2B24;
    --table-header-bg:       #252218;
    --table-alternate-bg:    #201E1A;
    --theme-popup-bg:        #252218;
    --theme-popup-border:    #3A3630;
    --theme-hover:           #2E2B24;
    --searchbar-border-color:#3A3630;
    --searchbar-bg:          #252218;
    --searchbar-fg:          #E8E4DC;
    --searchbar-shadow-color:#E8A23A30;
    --searchresults-header-fg:#8A8070;
    --searchresults-border-color: #3A3630;
    --searchresults-li-bg:   #252218;
    --search-mark-bg:        #E8A23A30;
    --warning-border:        #E8A23A;
    --color-scheme:          dark;
    --overlay-bg:            rgba(10, 9, 7, 0.7);
}

/* coal 主题也用暖夜色 */
.coal {
    --bg:                    #201E1B;
    --fg:                    #DDD9D0;
    --sidebar-bg:            #171512;
    --sidebar-fg:            #BEB8AA;
    --sidebar-active:        #E8A23A;
    --sidebar-spacer:        #2C2924;
    --sidebar-header-border-color: #E8A23A60;
    --links:                 #E0993A;
    --inline-code-color:     #F0B852;
    --quote-bg:              #28241C;
    --quote-border:          #E8A23A;
    --table-border-color:    #302D26;
    --table-header-bg:       #282420;
    --table-alternate-bg:    #24211C;
    --icons:                 #7A7268;
    --icons-hover:           #E8A23A;
    --color-scheme:          dark;
}

/* ============================================================
   TYPOGRAPHY · 中文排版
   ============================================================ */
html {
    font-family: var(--custom-serif);
}

.content main {
    line-height: 1.88;
    letter-spacing: 0.02em;
    word-spacing: 0.05em;
    font-size: 1.7rem;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--custom-sans);
    letter-spacing: 0.04em;
    font-weight: 600;
    line-height: 1.4;
}

h1 { font-size: 2.2em; margin-block-start: 0.6em; }
h2 { font-size: 1.65em; }
h3 { font-size: 1.3em; }

code, pre, .hljs {
    font-family: var(--custom-mono) !important;
}

/* ============================================================
   LAYOUT · 页面结构优化
   ============================================================ */

/* 内容区最大宽度 */
.content {
    padding: 0 20px;
}

/* 章节标题下加分隔线 */
.content main h1:first-child {
    margin-top: 0.5em;
    padding-bottom: 0.4em;
    border-bottom: 1px solid var(--table-border-color);
}

/* ============================================================
   MENU BAR · 顶部导航栏
   ============================================================ */
.menu-bar {
    border-bottom: 1px solid var(--table-border-color);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.navy .menu-bar,
.coal .menu-bar {
    background-color: #1C1A17ee;
}

.light .menu-bar {
    background-color: #FAFAF5ee;
}

/* ============================================================
   SIDEBAR · 侧边栏
   ============================================================ */
#mdbook-sidebar {
    border-right: 1px solid var(--table-border-color);
}

/* 激活项：左侧琥珀色指示条 */
.sidebar-scrollbox a.active {
    border-left: 3px solid var(--sidebar-active);
    padding-left: 12px;
    margin-left: -3px;
    font-weight: 500;
}

.sidebar-scrollbox a {
    transition: color 0.15s ease, border-color 0.15s ease;
    border-radius: 4px;
}

/* ============================================================
   BLOCKQUOTE · 引用块
   ============================================================ */
blockquote {
    border-left: 3px solid var(--quote-border);
    border-radius: 0 6px 6px 0;
    background-color: var(--quote-bg);
    padding: 0.8em 1.2em;
    margin: 1.5em 0;
    font-style: italic;
}

blockquote p:last-child {
    margin-bottom: 0;
}

/* ============================================================
   TABLE · 表格
   ============================================================ */
table {
    border-collapse: collapse;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

table th {
    font-family: var(--custom-sans);
    font-weight: 600;
    letter-spacing: 0.03em;
    font-size: 0.9em;
}

/* ============================================================
   CODE BLOCKS · 代码块
   ============================================================ */
pre {
    border-radius: 8px;
    padding: 1.2em 1.4em;
}

.navy pre,
.coal pre {
    background-color: #201E1A !important;
    border: 1px solid #2E2B24;
}

.light pre {
    background-color: #F0EDE5 !important;
    border: 1px solid #DDD8CC;
}

code:not(pre code) {
    padding: 0.15em 0.4em;
    border-radius: 4px;
    font-size: 0.88em;
}

.light code:not(pre code) {
    background-color: #EDE8DC;
}

.navy code:not(pre code),
.coal code:not(pre code) {
    background-color: #2A2720;
}

/* ============================================================
   LINKS · 链接
   ============================================================ */
a {
    text-decoration: underline;
    text-decoration-color: transparent;
    text-underline-offset: 3px;
    transition: color 0.15s ease, text-decoration-color 0.15s ease;
}

a:hover {
    text-decoration-color: var(--links);
}

/* ============================================================
   CHAPTER NAV BUTTONS · 翻页按钮
   ============================================================ */
.nav-chapters {
    font-family: var(--custom-sans);
    font-size: 1.4rem;
    color: var(--sidebar-fg);
    transition: color 0.15s ease;
}

.nav-chapters:hover {
    color: var(--sidebar-active);
    text-decoration: none;
}

/* ============================================================
   SEARCH · 搜索
   ============================================================ */
#searchbar {
    border-radius: 8px;
    border: 1px solid var(--searchbar-border-color);
    font-family: var(--custom-sans);
    padding: 6px 12px;
    transition: box-shadow 0.2s ease;
}

#searchbar:focus {
    outline: none;
    box-shadow: 0 0 0 2px var(--sidebar-active)50;
}

/* ============================================================
   SCROLLBAR · 滚动条细化
   ============================================================ */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background-color: var(--scrollbar);
    border-radius: 3px;
}

/* ============================================================
   WATERMARK · 全页水印
   ============================================================ */
body::after {
    content: "【微信: 15600871059】";
    position: fixed;
    bottom: 14px;
    right: 20px;
    font-family: var(--custom-sans);
    font-size: 11px;
    letter-spacing: 0.04em;
    color: var(--sidebar-active);
    opacity: 0.55;
    pointer-events: none;
    z-index: 9999;
    user-select: none;
    -webkit-user-select: none;
}

@media print {
    body::after {
        position: fixed;
        bottom: 10px;
        right: 15px;
        font-size: 9px;
        opacity: 0.6;
        color: #888;
    }
}

/* ============================================================
   PRINT · 打印 / PDF 优化
   ============================================================ */
@media print {
    /* 强制亮色模式 — 深色背景不适合纸张和 PDF */
    :root,
    .navy, .coal, .ayu, .rust,
    html.navy, html.coal, html.ayu {
        --bg:                 #FFFFFF !important;
        --fg:                 #1A1816 !important;
        --sidebar-bg:         #F5F2EC !important;
        --sidebar-fg:         #3A3830 !important;
        --sidebar-active:     #8B5A10 !important;
        --links:              #7A4A08 !important;
        --inline-code-color:  #8B5A10 !important;
        --quote-bg:           #F9F5ED !important;
        --quote-border:       #C4913A !important;
        --table-border-color: #DEDACC !important;
        --table-header-bg:    #EDE8DC !important;
        --table-alternate-bg: #F7F4EE !important;
        color-scheme:         light !important;
    }

    /* 隐藏所有导航 UI */
    .menu-bar,
    #mdbook-sidebar,
    .nav-chapters,
    #mdbook-sidebar-resize-handle,
    #mdbook-menu-bar-hover-placeholder,
    .mobile-nav-chapters { display: none !important; }

    /* 正文排版 */
    html {
        font-family: var(--custom-serif) !important;
        font-size: 62.5%;
    }

    .content main {
        font-size: 1.45rem !important;
        line-height: 1.78 !important;
        max-width: 100% !important;
        padding: 0 !important;
        margin: 0 !important;
    }

    /* 代码块 */
    pre {
        background-color: #F0EDE5 !important;
        border: 1px solid #DEDACC !important;
        border-radius: 4px !important;
        font-size: 0.82em !important;
        page-break-inside: avoid;
    }

    code:not(pre code) {
        background-color: #EDE8DC !important;
        color: #8B5A10 !important;
    }

    /* 标题分页控制 */
    h1, h2 { page-break-before: auto; page-break-after: avoid; }
    h3, h4, h5 { page-break-after: avoid; }

    /* 表格 */
    table { page-break-inside: avoid; box-shadow: none !important; }

    /* 引用块 */
    blockquote {
        background-color: #F9F5ED !important;
        border-left-color: #C4913A !important;
    }

    /* 水印 — 打印时保留，颜色改为深棕 */
    body::after {
        position: fixed !important;
        bottom: 8mm !important;
        right: 10mm !important;
        font-size: 8.5px !important;
        color: #9A7040 !important;
        opacity: 0.7 !important;
    }

    /* 页边距由 Chrome --print-to-pdf 控制，这里重置 body margin */
    body { margin: 0 !important; background: white !important; }
    .page-wrapper { margin: 0 !important; }
    .content { padding: 0 !important; }
}

/* ============================================================
   RESPONSIVE · 移动端
   ============================================================ */
@media (max-width: 768px) {
    .content main {
        font-size: 1.6rem;
        line-height: 1.8;
    }
}
