/* ===== 本地字体定义 (Google Fonts 本地化) ===== */

/* Noto Serif SC - Light (300) */
@font-face {
    font-family: "Noto Serif SC";
    src: url("/assets/fonts/google-fonts/NotoSerifSC-300.woff2") format("woff2");
    font-weight: 300;
    font-style: normal;
    font-display: swap;
}

/* Noto Serif SC - Regular (400) */
@font-face {
    font-family: "Noto Serif SC";
    src: url("/assets/fonts/google-fonts/NotoSerifSC-400.woff2") format("woff2");
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

/* Noto Serif SC - Bold (700) */
@font-face {
    font-family: "Noto Serif SC";
    src: url("/assets/fonts/google-fonts/NotoSerifSC-700.woff2") format("woff2");
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

/* Ma Shan Zheng - Regular (400) - 艺术手写体 */
@font-face {
    font-family: "Ma Shan Zheng";
    src: url("/assets/fonts/google-fonts/MaShanZheng-400.woff2") format("woff2");
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

/* Inter - Light (300) */
@font-face {
    font-family: "Inter";
    src: url("/assets/fonts/google-fonts/Inter-300.woff2") format("woff2");
    font-weight: 300;
    font-style: normal;
    font-display: swap;
}

/* Inter - Regular (400) */
@font-face {
    font-family: "Inter";
    src: url("/assets/fonts/google-fonts/Inter-400.woff2") format("woff2");
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

/* Inter - Semibold (600) */
@font-face {
    font-family: "Inter";
    src: url("/assets/fonts/google-fonts/Inter-600.woff2") format("woff2");
    font-weight: 600;
    font-style: normal;
    font-display: swap;
}

/* ===== CSS 变量系统 (字体快捷引用) ===== */
:root {
    /* 中文字体 */
    --font-serif-cn: "Noto Serif SC", "Source Han Serif", serif;
    --font-script-cn: "Ma Shan Zheng", cursive;

    /* 英文字体 */
    --font-sans-en:
        "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --font-serif-en: Georgia, serif;

    /* 系统备用字体栈 */
    --font-fallback:
        -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;

    /* 完整字体栈 */
    --font-body: "Noto Serif SC", "Source Han Serif", Georgia, serif;
    --font-heading: "Noto Serif SC", "Source Han Serif", serif;
    --font-code: "Courier New", monospace;
    --font-art: "Ma Shan Zheng", cursive;
}

/* ===== 语义化元素字体定义 ===== */

/* 段落和基础文本 */
p,
li,
dd,
dt,
figcaption {
    font-family: var(--font-body);
    font-weight: 400;
}

/* 标题 */
h1,
h2,
h3,
h4,
h5,
h6 {
    font-family: var(--font-heading);
    font-weight: 700;
}

/* 次级标题（使用300权重） */
h2 {
    font-weight: 400;
}

/* 代码块 */
code,
pre,
kbd,
samp {
    font-family: var(--font-code);
    font-weight: 400;
}

/* 强调 */
strong,
b {
    font-weight: 700;
}

em,
i {
    font-style: italic;
}

/* 艺术字体（书法、装饰用） */
.font-art,
.artistic,
.script {
    font-family: var(--font-script-cn);
}

/* ===== 工具类样式 ===== */

/* 轻量级文本 */
.font-light {
    font-weight: 300;
}

/* 正常权重 */
.font-normal {
    font-weight: 400;
}

/* 加粗 */
.font-bold {
    font-weight: 700;
}

/* 无衬线英文 */
.font-sans {
    font-family: var(--font-sans-en);
}

/* 衬线 */
.font-serif {
    font-family: var(--font-serif-en);
}

/* 等宽字体 */
.font-mono {
    font-family: var(--font-code);
}

/* ===== 响应式字体调整 ===== */

/* 平板设备 (768px 及以上) */
@media (min-width: 768px) {
    body {
        font-size: 16px;
        line-height: 1.6;
    }

    h1 {
        font-size: 2.5rem;
    }

    h2 {
        font-size: 2rem;
    }

    h3 {
        font-size: 1.75rem;
    }
}

/* 手机设备 (小于 768px) */
@media (max-width: 767px) {
    body {
        font-size: 15px;
        line-height: 1.5;
    }

    h1 {
        font-size: 1.75rem;
    }

    h2 {
        font-size: 1.5rem;
    }

    h3 {
        font-size: 1.25rem;
    }
}

/* ===== 高对比度模式支持 ===== */
@media (prefers-contrast: more) {
    body {
        font-weight: 400;
        text-rendering: optimizeLegibility;
    }

    h1,
    h2,
    h3,
    h4,
    h5,
    h6 {
        font-weight: 700;
        letter-spacing: 0.02em;
    }
}

/* ===== 深色模式字体优化 ===== */
@media (prefers-color-scheme: dark) {
    body {
        /* 深色模式下字体稍微细一点更舒适 */
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }
}

/* ===== 打印样式 ===== */
@media print {
    body {
        font-family: Georgia, "Times New Roman", serif;
        font-size: 12pt;
        line-height: 1.5;
        color: #000;
    }

    h1,
    h2,
    h3,
    h4,
    h5,
    h6 {
        page-break-after: avoid;
        font-weight: 700;
    }

    code,
    pre {
        font-family: "Courier New", monospace;
        font-size: 10pt;
    }
}

/* ===== 无字体支持的备用方案 ===== */
@supports not (font-display: swap) {
    body {
        font-family: Georgia, "Times New Roman", serif;
    }
}

/* ===== 字体加载优化提示 ===== */
/*
   使用 font-display: swap 策略：
   - 立即使用系统备用字体显示文本
   - 字体加载完成后自动切换
   - 避免文本不可见(FOIT)问题
   - 提供最佳的用户体验
*/
