/* TaiJian 太简语言学习平台 - 字体配置 */
/* 本地化字体，避免Google Fonts依赖 */

/* 
 * 优先使用系统字体，为中国大陆用户提供更好的加载体验
 * 如果您有本地字体文件，可以将它们放在这个文件夹中并通过@font-face引入
 */

/* 主要字体族 - 中文优化 */
.font-primary-cn {
    font-family: 
        "PingFang SC",           /* macOS 系统中文字体 */
        "Microsoft YaHei",       /* Windows 系统中文字体 */
        "Source Han Sans CN",    /* Adobe 思源黑体 */
        "Noto Sans SC",          /* Google Noto 字体 */
        "Hiragino Sans GB",      /* macOS 较老版本中文字体 */
        "WenQuanYi Micro Hei",   /* Linux 中文字体 */
        "Droid Sans Fallback",   /* Android 中文字体 */
        "SimHei",                /* Windows 黑体 */
        sans-serif;
}

/* 英文字体族 */
.font-primary-en {
    font-family: 
        -apple-system,           /* macOS 系统字体 */
        BlinkMacSystemFont,      /* Chrome on macOS */
        "Segoe UI",              /* Windows 系统字体 */
        "SF Pro Display",        /* iOS/macOS UI 字体 */
        "SF Pro Text",           /* iOS/macOS 文本字体 */
        Roboto,                  /* Android 字体 */
        "Helvetica Neue",        /* 经典 Helvetica */
        Helvetica,
        Arial,
        sans-serif;
}

/* 代码字体族 */
.font-mono {
    font-family: 
        "SF Mono",               /* macOS 等宽字体 */
        "Monaco",                /* macOS 经典等宽字体 */
        "Cascadia Code",         /* Windows Terminal 字体 */
        "Roboto Mono",           /* Google 等宽字体 */
        "Fira Code",             /* 流行的编程字体 */
        "Courier New",           /* 经典等宽字体 */
        Courier,
        monospace;
}

/* 根据语言自动应用合适的字体 */
:root {
    --font-family-primary: "PingFang SC", "Microsoft YaHei", "Source Han Sans CN", sans-serif;
    --font-family-en: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-family-mono: "SF Mono", "Monaco", "Cascadia Code", monospace;
}

/* 根据html的lang属性应用不同字体 */
html[lang="zh-CN"] body,
html[lang="zh-TW"] body,
html[lang="zh-HK"] body {
    font-family: var(--font-family-primary);
}

html[lang="en"] body,
html[lang^="en-"] body {
    font-family: var(--font-family-en);
}

html[lang="ja"] body {
    font-family: 
        "Hiragino Kaku Gothic ProN",
        "Hiragino Sans",
        "Yu Gothic Medium",
        "Meiryo",
        "MS PGothic",
        sans-serif;
}

html[lang="ko"] body {
    font-family: 
        "Apple SD Gothic Neo",
        "Malgun Gothic",
        "Nanum Gothic",
        "Dotum",
        sans-serif;
}

/* 
 * 如果需要引入本地字体文件，使用以下格式：
 * 
 * @font-face {
 *     font-family: 'CustomFont';
 *     src: url('./CustomFont.woff2') format('woff2'),
 *          url('./CustomFont.woff') format('woff');
 *     font-weight: normal;
 *     font-style: normal;
 *     font-display: swap; // 优化字体加载性能
 * }
 */

/* 字体加载优化 */
@supports (font-display: swap) {
    @font-face {
        font-family: 'fallback';
        src: local('');
        font-display: swap;
    }
}

/* 防止字体闪烁 */
.font-loading {
    font-display: swap;
    visibility: hidden;
}

.font-loaded {
    visibility: visible;
}

/* 响应式字体大小 */
@media screen and (max-width: 768px) {
    body {
        font-size: 14px;
    }
}

@media screen and (min-width: 769px) {
    body {
        font-size: 16px;
    }
}

/* 高DPI屏幕字体优化 */
@media (-webkit-min-device-pixel-ratio: 2),
       (min-resolution: 192dpi) {
    body {
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }
}
