/* 中国大陆用户优化的中文字体方案 */

/* 基础字体设置 - 优先使用系统内置中文字体 */
:root {
    /* 主要字体栈 - 针对中文优化 */
    --font-primary: 'PingFang SC', 'Microsoft YaHei', '微软雅黑', 'Helvetica Neue', Helvetica, 'Hiragino Sans GB', 'WenQuanYi Micro Hei', sans-serif;
    
    /* 备用字体栈 */
    --font-fallback: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', sans-serif;
    
    /* 最终字体栈 */
    --font-stack: var(--font-primary), var(--font-fallback);
    
    /* 等宽字体 */
    --font-mono: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', 'Consolas', 'Courier New', monospace;
}

/* 全局字体应用 */
* {
    font-family: var(--font-stack);
}

/* 为不同元素优化字体 */
body {
    font-family: var(--font-stack);
    font-size: 16px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

/* 标题字体优化 */
h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-stack);
    font-weight: 600;
    line-height: 1.3;
}

/* 正文字体优化 */
p, span, div, li, td, th {
    font-family: var(--font-stack);
}

/* 按钮字体 */
button, .button, input[type="submit"], input[type="button"] {
    font-family: var(--font-stack);
}

/* 输入框字体 */
input, textarea, select {
    font-family: var(--font-stack);
}

/* 代码字体 */
code, pre, kbd, samp {
    font-family: var(--font-mono);
}

/* 中文环境下的字重优化 */
@media (min-width: 0) {
    /* Windows系统优化 */
    @media screen and (-webkit-min-device-pixel-ratio: 1) {
        body {
            -webkit-font-smoothing: antialiased;
            text-shadow: 0 0 1px rgba(0,0,0,0.01);
        }
    }
    
    /* Mac系统优化 */
    @media screen and (-webkit-min-device-pixel-ratio: 2) {
        body {
            -webkit-font-smoothing: subpixel-antialiased;
        }
    }
}

/* 不同字重的字体设置 */
.font-light {
    font-family: var(--font-stack);
    font-weight: 300;
}

.font-normal {
    font-family: var(--font-stack);
    font-weight: 400;
}

.font-medium {
    font-family: var(--font-stack);
    font-weight: 500;
}

.font-semibold {
    font-family: var(--font-stack);
    font-weight: 600;
}

.font-bold {
    font-family: var(--font-stack);
    font-weight: 700;
}

.font-black {
    font-family: var(--font-stack);
    font-weight: 900;
}

/* 中文排版优化 */
.chinese-optimized {
    font-family: 'PingFang SC', 'Microsoft YaHei', '微软雅黑', sans-serif;
    text-align: justify;
    text-justify: inter-ideograph;
    word-wrap: break-word;
    word-break: break-all;
}

/* 标题中文优化 */
.chinese-title {
    font-family: 'PingFang SC', 'Microsoft YaHei', '微软雅黑', sans-serif;
    font-weight: 600;
    letter-spacing: 0.02em;
}

/* 防止字体闪烁 */
.font-loaded body {
    font-family: var(--font-stack);
}

/* 系统检测字体回退 */
@supports (font: -apple-system-body) {
    :root {
        --font-primary: -apple-system, 'PingFang SC', 'Microsoft YaHei', sans-serif;
    }
}

/* Windows系统专用 */
@media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) {
    :root {
        --font-primary: 'Microsoft YaHei', 'SimHei', 'PingFang SC', sans-serif;
    }
}