/* ==========================================================================
   Kaxiluo's Blog — 自定义样式（简洁现代）
   设计要点：冷调纸白底 / 靛蓝点缀 / 终端式深色代码卡片 / CJK 排版调校
   ========================================================================== */

/* ---------- 基础变量与字体 ---------- */

:root {
    --content-max-width: 44em;
    --mono-font: "Cascadia Code", "JetBrains Mono", "SF Mono", Menlo, Consolas,
        "Source Code Pro", "PingFang SC", "Microsoft YaHei", monospace;
}

html {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI",
        "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei",
        "Noto Sans CJK SC", "Source Han Sans SC", sans-serif;
}

/* ---------- 主题调色板 ---------- */

/* 亮色（默认） */
.light {
    --bg: #fafaf8;
    --fg: #24292f;
    --sidebar-bg: #f4f4f1;
    --sidebar-fg: #4d5768;
    --sidebar-non-existant: #b0b6c0;
    --sidebar-active: #3e63dd;
    --sidebar-spacer: #e7e7e3;
    --scrollbar: #c4c8ce;
    --icons: #6a737d;
    --icons-hover: #24292f;
    --links: #3e63dd;
    --inline-code-color: #33439e;
    --theme-popup-bg: #ffffff;
    --theme-popup-border: #e3e4e8;
    --theme-hover: #f0f2f8;
    --quote-bg: #f3f5fa;
    --quote-border: #d9e0f4;
    --table-border-color: #e6e7ea;
    --table-header-bg: transparent;
    --table-alternate-bg: #f5f6f4;
    --searchbar-border-color: #d8dade;
    --searchbar-bg: #ffffff;
    --searchbar-shadow-color: #b9c6ee;
    --color-scheme: light;

    --accent: #3e63dd;
    --accent-soft: #eef1fc;
    --accent-border: #c6d2f5;
    --heading-anchor: #b3bac4;
    --card-border: #e5e6e9;
    --inline-code-bg: #eef0f5;
    --code-card-bg: #0d1117;
    --code-card-border: #2a3646;
    --code-card-fg: #c9d1d9;
}

/* 暗色：navy 是 prefers-color-scheme: dark 的回退主题，
   其余暗色主题统一映射到同一套调色板，保证观感一致 */
.dark,
.navy,
.coal,
.ayu,
.rust {
    --bg: #0d1117;
    --fg: #c9d1d9;
    --sidebar-bg: #10151c;
    --sidebar-fg: #97a1ae;
    --sidebar-non-existant: #454e5a;
    --sidebar-active: #8b9eff;
    --sidebar-spacer: #1e242d;
    --scrollbar: #3a4250;
    --icons: #768390;
    --icons-hover: #c9d1d9;
    --links: #8b9eff;
    --inline-code-color: #a8b6ff;
    --theme-popup-bg: #161b22;
    --theme-popup-border: #2c3440;
    --theme-hover: #1c232d;
    --quote-bg: #151b24;
    --quote-border: #232c3a;
    --table-border-color: #232a35;
    --table-header-bg: transparent;
    --table-alternate-bg: #12171f;
    --searchbar-border-color: #2c3440;
    --searchbar-bg: #0f151d;
    --searchbar-fg: #c9d1d9;
    --searchbar-shadow-color: #3d5aee;
    --color-scheme: dark;

    --accent: #8b9eff;
    --accent-soft: #1a2338;
    --accent-border: #31406b;
    --heading-anchor: #4a5460;
    --card-border: #232a35;
    --inline-code-bg: #1b2230;
    --code-card-bg: #161b22;
    --code-card-border: #30363d;
    --code-card-fg: #c9d1d9;
}

/* ---------- 顶栏 ---------- */

#menu-bar,
#mdbook-menu-bar {
    background-color: var(--bg);
    border-block-end: 1px solid var(--table-border-color);
    transition: background-color 0.2s ease;
}

@supports (backdrop-filter: blur(8px)) {
    #menu-bar,
    #mdbook-menu-bar {
        background-color: color-mix(in srgb, var(--bg) 86%, transparent);
        backdrop-filter: blur(8px);
        -webkit-backdrop-filter: blur(8px);
    }
}

.menu-title {
    font-weight: 600;
    font-size: 2rem;
    letter-spacing: 0.02em;
    color: var(--fg);
}

/* ---------- 正文排版 ---------- */

.content main {
    padding-block: 1.2em 4em;
}

.content p,
.content ol,
.content ul {
    line-height: 1.85;
}

.content p {
    margin-block: 0.95em;
}

.content li {
    margin-block: 0.3em;
}

.content h1 {
    font-size: 3rem;
    font-weight: 700;
    line-height: 1.35;
    margin-block: 0.4em 0.9em;
    letter-spacing: 0.01em;
}

.content h2 {
    font-size: 2.4rem;
    font-weight: 600;
    line-height: 1.4;
    margin-block: 2.4em 0.9em;
    padding-inline-start: 14px;
    border-inline-start: 4px solid var(--accent);
}

.content h3 {
    font-size: 2rem;
    font-weight: 600;
    margin-block: 2.1em 0.8em;
}

.content h4 {
    font-size: 1.7rem;
    font-weight: 600;
    margin-block: 1.8em 0.7em;
}

/* 标题锚点：标题文字始终可见；hover 标题时尾部浮现 # 提示 */
.content .header:link,
.content .header:visited {
    color: inherit;
    border-bottom: none;
}

.content .header:hover {
    border-bottom: none;
}

.content .header::after {
    content: "#";
    margin-inline-start: 0.3em;
    color: var(--heading-anchor);
    opacity: 0;
    transition: opacity 0.15s ease;
}

.content h1:hover .header::after,
.content h2:hover .header::after,
.content h3:hover .header::after,
.content h4:hover .header::after,
.content .header:focus-visible::after {
    opacity: 1;
}

/* ---------- 链接 ---------- */

.content a {
    color: var(--links);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: border-color 0.15s ease, color 0.15s ease;
}

.content a:hover {
    text-decoration: none;
    border-bottom-color: currentColor;
}

a:focus-visible,
button:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: 3px;
}

/* ---------- 行内代码 ---------- */

.content :not(pre) > code {
    background-color: var(--inline-code-bg);
    color: var(--inline-code-color);
    padding: 0.15em 0.4em;
    border-radius: 5px;
    font-size: 0.86em;
}

/* ---------- 代码卡片（两种页面主题下均为深色终端卡片） ---------- */

pre {
    margin-block: 1.6em;
    padding: 0;
    border-radius: 10px;
    border: 1px solid var(--code-card-border);
    background-color: var(--code-card-bg);
    color: var(--code-card-fg);
    overflow-x: auto;
}

pre > code.hljs {
    display: block;
    padding: 14px 18px;
    background: transparent;
    color: var(--code-card-fg);
    line-height: 1.7;
}

pre > .result {
    margin: 0;
    border-block-start: 1px solid var(--code-card-border);
}

/* 复制按钮在深色卡片上的配色 */
pre > .buttons button {
    border-color: var(--code-card-border);
    background-color: #1c232d;
    color: #8b949e;
}

pre > .buttons button:hover {
    color: #e6edf3;
    border-color: #3d4653;
    background-color: #262d38;
}

/* ---------- 语法高亮：GitHub Dark 风格（卡片恒为深色） ---------- */

pre .hljs-comment,
pre .hljs-quote {
    color: #7c8797;
    font-style: italic;
}

pre .hljs-keyword,
pre .hljs-selector-tag,
pre .hljs-deletion,
pre .hljs-doctag,
pre .hljs-regexp {
    color: #ff7b72;
}

pre .hljs-string,
pre .hljs-meta .hljs-string,
pre .hljs-addition,
pre .hljs-template-tag {
    color: #a5d6ff;
}

pre .hljs-number,
pre .hljs-literal,
pre .hljs-variable,
pre .hljs-template-variable,
pre .hljs-type,
pre .hljs-attr,
pre .hljs-selector-attr,
pre .hljs-selector-pseudo,
pre .hljs-meta {
    color: #79c0ff;
}

pre .hljs-title,
pre .hljs-title.class_,
pre .hljs-title.function_,
pre .hljs-built_in {
    color: #d2a8ff;
}

pre .hljs-title.class_ {
    color: #ffa657;
}

pre .hljs-name,
pre .hljs-tag,
pre .hljs-selector-id,
pre .hljs-selector-class {
    color: #7ee787;
}

pre .hljs-section,
pre .hljs-emphasis {
    font-style: italic;
}

pre .hljs-strong {
    font-weight: 600;
}

/* ---------- 表格 ---------- */

.content table {
    margin-block: 1.6em;
    border-collapse: collapse;
    font-size: 0.95em;
    line-height: 1.7;
}

.content td,
.content th {
    padding: 8px 14px;
    border: none;
    border-block-start: 1px solid var(--table-border-color);
    text-align: start;
}

.content thead td,
.content thead th {
    font-weight: 600;
    border: none;
    border-block-end: 2px solid var(--accent-border);
    background: transparent;
}

.content thead {
    background: transparent;
}

.content tbody tr:last-child td,
.content tbody tr:last-child th {
    border-block-end: 1px solid var(--table-border-color);
}

/* ---------- 引用块 ---------- */

.content blockquote {
    margin-block: 1.6em;
    padding: 10px 20px;
    border: none;
    border-inline-start: 3px solid var(--accent-border);
    border-radius: 0 8px 8px 0;
    background-color: var(--quote-bg);
}

/* ---------- 分隔线 ---------- */

.content hr {
    border: none;
    border-block-start: 1px solid var(--table-border-color);
    margin-block: 2.4em;
}

/* ---------- 侧边栏 ---------- */

.sidebar {
    border-inline-end: 1px solid var(--sidebar-spacer);
}

.sidebar .sidebar-scrollbox {
    padding: 18px 12px;
}

.chapter li.chapter-item {
    margin-block-start: 2px;
}

.chapter li a {
    display: block;
    padding: 3px 10px;
    border-radius: 6px;
    line-height: 1.7;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.chapter li a:hover {
    color: var(--sidebar-active);
    background-color: var(--theme-hover);
}

.chapter li a.active {
    color: var(--sidebar-active);
    font-weight: 600;
    background-color: var(--accent-soft);
}

.chapter li a strong[aria-hidden] {
    color: var(--sidebar-non-existant);
    font-weight: 500;
    margin-inline-end: 4px;
}

.chapter li a.active strong[aria-hidden] {
    color: var(--sidebar-active);
}

/* ---------- 搜索与主题弹窗 ---------- */

#searchbar,
#mdbook-searchbar {
    border-radius: 8px;
    padding: 9px 16px;
}

#searchbar:focus,
#mdbook-searchbar:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.theme-popup {
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.14);
}

.theme-popup .theme {
    padding-block: 5px;
}

/* ---------- mdbook-admonish 提示框微调 ---------- */

.admonition {
    border-radius: 8px;
    border-inline-start-width: 3px;
    box-shadow: 0 1px 6px rgba(0, 0, 0, 0.04);
}

.admonition-title {
    font-weight: 600;
}

/* ---------- 图片 ---------- */

.content img {
    border-radius: 8px;
    border: 1px solid var(--card-border);
}

/* ---------- 打印：代码卡片转浅色，避免大面积深色墨块 ---------- */

@media print {
    pre {
        background: #f6f8fa;
        border-color: #d0d7de;
        color: #24292f;
    }

    #menu-bar,
    #mdbook-menu-bar,
    .sidebar,
    .nav-chapters {
        display: none;
    }
}

/* ---------- 动效尊重 ---------- */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
    }
}
