/* 字体优化和排版CSS文件 */
/* 基础字体设置 - 使用系统字体栈，确保最佳性能和可读性 */

/* 定义CSS自定义属性（CSS变量）用于字体管理 */
:root {
  /* 中文字体栈 - 优先使用系统默认中文字体 */
  --font-family-chinese: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "WenQuanYi Micro Hei", sans-serif;
  
  /* 英文字体栈 - 优先使用系统默认英文字体 */
  --font-family-english: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  
  /* 混合字体栈 - 同时支持中英文 */
  --font-family-base: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "WenQuanYi Micro Hei", sans-serif;
  
  /* 等宽字体栈 */
  --font-family-mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  
  /* 字体大小基准 */
  --font-size-root: 16px;
  --font-size-xs: 0.75rem;    /* 12px */
  --font-size-sm: 0.875rem;   /* 14px */
  --font-size-base: 1rem;     /* 16px */
  --font-size-lg: 1.125rem;   /* 18px */
  --font-size-xl: 1.25rem;    /* 20px */
  --font-size-2xl: 1.5rem;    /* 24px */
  --font-size-3xl: 1.875rem;  /* 30px */
  --font-size-4xl: 2.25rem;   /* 36px */
  --font-size-5xl: 3rem;      /* 48px */
  
  /* 行高设置 */
  --line-height-xs: 1.2;
  --line-height-sm: 1.33;
  --line-height-base: 1.5;
  --line-height-lg: 1.6;
  --line-height-xl: 1.75;
}

/* 基础重置和优化 */
* {
  /* 防止字体大小在移动端被自动调整 */
  -webkit-text-size-adjust: 100%;
  -moz-text-size-adjust: 100%;
  -ms-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

/* 文档根元素字体设置 */
html {
  font-family: var(--font-family-base);
  font-size: var(--font-size-root);
  line-height: var(--line-height-base);
  /* 启用抗锯齿渲染 */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  /* 设置文本渲染优化 */
  text-rendering: optimizeLegibility;
}

/* 基础文本元素样式 */
body {
  font-family: var(--font-family-base);
  font-size: var(--font-size-base);
  line-height: var(--line-height-base);
  color: var(--text-strong, #0f1419);
  background-color: #ffffff;
}

/* 标题字体设置 */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-family-base);
  font-weight: 600;
  line-height: var(--line-height-base);
  margin-top: 0;
  margin-bottom: 0.5em;
  color: var(--text-strong, #0f1419);
}

h1 { font-size: var(--font-size-4xl); line-height: var(--line-height-lg); }
h2 { font-size: var(--font-size-3xl); line-height: var(--line-height-lg); }
h3 { font-size: var(--font-size-2xl); line-height: var(--line-height-base); }
h4 { font-size: var(--font-size-xl); line-height: var(--line-height-base); }
h5 { font-size: var(--font-size-lg); line-height: var(--line-height-sm); }
h6 { font-size: var(--font-size-base); line-height: var(--line-height-sm); font-weight: 600; }

/* 段落和文本元素 */
p {
  margin-top: 0;
  margin-bottom: 1em;
  font-size: var(--font-size-base);
  line-height: var(--line-height-base);
}

small {
  font-size: var(--font-size-sm);
}

/* 链接样式 */
a {
  font-family: var(--font-family-base);
  color: #0051a8;
  text-decoration: none;
  transition: color 0.2s ease-in-out;
}

a:hover {
  color: #003d7a;
  text-decoration: underline;
}

/* 代码和等宽文本 */
code,
kbd,
pre,
samp {
  font-family: var(--font-family-mono);
  font-size: var(--font-size-sm);
}

pre {
  font-size: var(--font-size-base);
  line-height: var(--line-height-base);
  overflow-x: auto;
}

/* 列表样式 */
ul,
ol {
  font-size: var(--font-size-base);
  line-height: var(--line-height-base);
}

/* 表单元素字体 */
input,
textarea,
select,
button {
  font-family: var(--font-family-base);
  font-size: var(--font-size-base);
}

/* 响应式字体大小 */
@media (max-width: 768px) {
  :root {
    --font-size-root: 14px;
  }
  
  h1 { font-size: var(--font-size-3xl); }
  h2 { font-size: var(--font-size-2xl); }
  h3 { font-size: var(--font-size-xl); }
}

@media (max-width: 480px) {
  :root {
    --font-size-root: 13px;
  }
  
  h1 { font-size: var(--font-size-2xl); }
  h2 { font-size: var(--font-size-xl); }
  h3 { font-size: var(--font-size-lg); }
}

/* 高对比度模式支持 */
@media (prefers-contrast: high) {
  body {
    color: #000000;
    background-color: #ffffff;
  }
  
  a {
    color: #0000ee;
  }
}

/* 减少动画偏好支持 */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* 深色模式支持 */
@media (prefers-color-scheme: dark) {
  body {
    color: #e0e0e0;
    background-color: #121212;
  }
  
  h1, h2, h3, h4, h5, h6 {
    color: #ffffff;
  }
  
  a {
    color: #4da6ff;
  }
  
  a:hover {
    color: #80ccff;
  }
}

/* 实用工具类 */
.font-serif {
  font-family: Georgia, "Times New Roman", Times, serif;
}

.font-mono {
  font-family: var(--font-family-mono);
}

.font-weight-light {
  font-weight: 300;
}

.font-weight-normal {
  font-weight: 400;
}

.font-weight-medium {
  font-weight: 500;
}

.font-weight-semibold {
  font-weight: 600;
}

.font-weight-bold {
  font-weight: 700;
}

.text-xs { font-size: var(--font-size-xs); }
.text-sm { font-size: var(--font-size-sm); }
.text-base { font-size: var(--font-size-base); }
.text-lg { font-size: var(--font-size-lg); }
.text-xl { font-size: var(--font-size-xl); }
.text-2xl { font-size: var(--font-size-2xl); }
.text-3xl { font-size: var(--font-size-3xl); }
.text-4xl { font-size: var(--font-size-4xl); }
.text-5xl { font-size: var(--font-size-5xl); }

.leading-xs { line-height: var(--line-height-xs); }
.leading-sm { line-height: var(--line-height-sm); }
.leading-base { line-height: var(--line-height-base); }
.leading-lg { line-height: var(--line-height-lg); }
.leading-xl { line-height: var(--line-height-xl); }

/* 文本对齐工具类 */
.text-left { text-align: left; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-justify { text-align: justify; }

/* 文本装饰工具类 */
.text-underline { text-decoration: underline; }
.text-overline { text-decoration: overline; }
.text-line-through { text-decoration: line-through; }
.text-no-underline { text-decoration: none; }

/* 文本转换工具类 */
.uppercase { text-transform: uppercase; }
.lowercase { text-transform: lowercase; }
.capitalize { text-transform: capitalize; }
.normal-case { text-transform: none; }