/* 移动端字体和排版优化 */

/* 基础字体设置 */
:root {
    /* 响应式字体大小 */
    --font-size-root: 16px;
    --font-size-h1: clamp(1.75rem, 4vw, 2.5rem);
    --font-size-h2: clamp(1.5rem, 3.5vw, 2rem);
    --font-size-h3: clamp(1.25rem, 3vw, 1.75rem);
    --font-size-body: clamp(0.875rem, 2.5vw, 1rem);
    --font-size-small: clamp(0.75rem, 2vw, 0.875rem);
    
    /* 行高设置 */
    --line-height-heading: 1.2;
    --line-height-body: 1.6;
    --line-height-tight: 1.4;
    
    /* 字重设置 */
    --font-weight-normal: 400;
    --font-weight-medium: 500;
    --font-weight-semibold: 600;
    --font-weight-bold: 700;
}

/* 大屏幕字体优化 */
@media (min-width: 1200px) {
    :root {
        --font-size-root: 18px;
        --font-size-h1: 2.75rem;
        --font-size-h2: 2.25rem;
        --font-size-h3: 1.875rem;
    }
}

/* 平板设备字体优化 */
@media (min-width: 769px) and (max-width: 1199px) {
    :root {
        --font-size-root: 17px;
        --font-size-h1: 2.25rem;
        --font-size-h2: 1.875rem;
        --font-size-h3: 1.625rem;
    }
}

/* 移动端字体优化 */
@media (max-width: 768px) {
    :root {
        --font-size-root: 16px;
        --font-size-h1: 2rem;
        --font-size-h2: 1.75rem;
        --font-size-h3: 1.5rem;
        --font-size-body: 1rem;
    }
    
    /* 增加行高以提高可读性 */
    body {
        line-height: var(--line-height-body);
        font-size: var(--font-size-body);
    }
    
    h1, h2, h3, h4, h5, h6 {
        line-height: var(--line-height-heading);
        margin-top: 1.5em;
        margin-bottom: 0.75em;
    }
    
    h1 {
        font-size: var(--font-size-h1);
        font-weight: var(--font-weight-bold);
    }
    
    h2 {
        font-size: var(--font-size-h2);
        font-weight: var(--font-weight-semibold);
    }
    
    h3 {
        font-size: var(--font-size-h3);
        font-weight: var(--font-weight-medium);
    }
    
    p {
        margin-bottom: 1em;
        line-height: var(--line-height-tight);
    }
    
    /* 产品展示标题优化 */
    .product-display h2,
    .contact-display h2 {
        font-size: var(--font-size-h2);
        line-height: var(--line-height-heading);
        margin: 0;
        padding: 0.75em 0;
    }
    
    /* 按钮文字优化 */
    .goods-item,
    .contact-content div:first-of-type {
        font-size: 1.1em;
        line-height: 1.3;
    }
    
    /* 联系信息文字优化 */
    .contact-content div:last-of-type {
        font-size: 0.95em;
        line-height: 1.5;
    }
}

/* 小屏手机字体优化 */
@media (max-width: 480px) {
    :root {
        --font-size-root: 15px;
        --font-size-h1: 1.75rem;
        --font-size-h2: 1.5rem;
        --font-size-h3: 1.375rem;
        --font-size-body: 0.9375rem;
    }
    
    body {
        font-size: var(--font-size-body);
        line-height: 1.65;
    }
    
    h1 {
        font-size: var(--font-size-h1);
    }
    
    h2 {
        font-size: var(--font-size-h2);
    }
    
    h3 {
        font-size: var(--font-size-h3);
    }
    
    /* 进一步优化触摸目标文字 */
    .goods-item {
        font-size: 1em;
        padding: 0.75em 1em;
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .contact-content div:first-of-type {
        font-size: 1.05em;
    }
    
    .contact-content div:last-of-type {
        font-size: 0.9em;
    }
}

/* 极小屏设备优化 */
@media (max-width: 375px) {
    :root {
        --font-size-root: 14px;
        --font-size-h1: 1.625rem;
        --font-size-h2: 1.375rem;
        --font-size-h3: 1.25rem;
        --font-size-body: 0.875rem;
    }
    
    body {
        font-size: var(--font-size-body);
        line-height: 1.7;
    }
    
    /* 确保最小可读性 */
    * {
        font-size-adjust: 0.5;
    }
}

/* 高分辨率屏幕优化 */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    body {
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
        text-rendering: optimizeLegibility;
    }
    
    h1, h2, h3 {
        -webkit-font-smoothing: antialiased;
        font-weight: 600;
    }
}

/* 横屏模式优化 */
@media (max-width: 768px) and (orientation: landscape) {
    :root {
        --font-size-h1: 1.875rem;
        --font-size-h2: 1.625rem;
        --font-size-h3: 1.375rem;
    }
    
    body {
        font-size: 0.9375rem;
        line-height: 1.55;
    }
    
    /* 横屏时减少垂直间距 */
    .product-display,
    .contact-display {
        margin: 15px auto;
        padding: 10px 0;
    }
    
    .goods-items {
        margin: 15px 0;
        gap: 8px;
    }
    
    .contact {
        margin: 20px 0;
        gap: 15px;
    }
}

/* 夜间模式/深色模式字体优化 */
@media (prefers-color-scheme: dark) {
    body {
        color: #e0e0e0;
    }
    
    h1, h2, h3, h4, h5, h6 {
        color: #ffffff;
    }
    
    p, li, td, th {
        color: #cccccc;
    }
    
    a {
        color: #64b5f6;
    }
    
    a:hover {
        color: #90caf9;
    }
}

/* 高对比度模式字体优化 */
@media (prefers-contrast: more) {
    body {
        color: #000000;
    }
    
    h1, h2, h3, h4, h5, h6 {
        color: #000000;
        font-weight: 700;
    }
    
    p, li, td, th {
        color: #000000;
    }
    
    a {
        color: #0000EE;
        text-decoration: underline;
    }
    
    /* 增加字体粗细以提高可读性 */
    body, p {
        font-weight: 500;
    }
}

/* 减少动画偏好下的字体优化 */
@media (prefers-reduced-motion: reduce) {
    * {
        transition: none !important;
        animation: none !important;
    }
    
    /* 确保字体清晰度 */
    body {
        text-rendering: optimizeSpeed;
    }
}

/* 可访问性字体缩放支持 */
@media (max-width: 768px) {
    /* 支持用户自定义字体大小 */
    body {
        font-size: max(14px, 1rem);
    }
    
    h1 {
        font-size: max(24px, 1.75rem);
    }
    
    h2 {
        font-size: max(20px, 1.5rem);
    }
    
    h3 {
        font-size: max(18px, 1.25rem);
    }
}

/* 中文排版优化 */
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 
                 'Microsoft YaHei', 'Helvetica Neue', Helvetica, Arial, sans-serif;
    font-feature-settings: "liga" 1;
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
}

/* 中英文混排优化 */
.en-text {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 
                 'Open Sans', 'Helvetica Neue', sans-serif;
}

/* 数字显示优化 */
.number {
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum";
}

/* 引用文本优化 */
blockquote {
    font-style: italic;
    line-height: var(--line-height-tight);
    margin: 1.5em 0;
    padding: 0 1em;
    border-left: 4px solid #ccc;
}

/* 列表项目优化 */
ul, ol {
    line-height: var(--line-height-tight);
    margin-bottom: 1em;
}

li {
    margin-bottom: 0.5em;
}

/* 代码文本优化 */
code, pre {
    font-family: 'Menlo', 'Monaco', 'Consolas', 'Courier New', monospace;
    font-size: 0.9em;
    line-height: 1.4;
}

/* 表格文字优化 */
table {
    font-size: 0.9em;
    line-height: 1.4;
}

th, td {
    padding: 0.5em;
    text-align: left;
}

/* 表单元素文字优化 */
input, textarea, select, button {
    font-family: inherit;
    font-size: 1rem;
    line-height: 1.5;
}

@media (max-width: 768px) {
    input, textarea, select {
        font-size: 16px; /* 防止iOS Safari自动缩放 */
    }
}