/* ================================================================
   typography.css — 排版层（在 base / components / modules 之后加载）
   ----------------------------------------------------------------
   本版字体体系（2026-11 改版）：
     · 中英通用英文：Times New Roman
     · 中文标题 / 小标题：宋体（Songti SC / SimSun）
     · 中文正文 / 简介：楷体（LXGW WenKai 本地自托管，系统楷体优先）
     · 中文辅助（标签、按钮、导航、注释）：仿宋 → 本机缺失时降级宋体
     · 数字 / 公式：保留等宽（JetBrains Mono），因为 Times 的比例数字
       在表格里会左右跳动，音分与百分比必须等宽对齐

   为什么这样配对：
   Times New Roman 属于过渡体衬线，宋体、楷体、仿宋同属衬线骨架，
   三者与 Times 的重心、笔画收笔逻辑一致，中英混排不会出现
   "两种字体贴在一起"的断裂感。这是替代 Inter+苹方（无衬线撞衬线）
   与 Playfair+等线（高对比撞低对比）两种失败配对的正解。
   ================================================================ */

/* ================================================================
   1. 字体令牌
   ----------------------------------------------------------------
   注意顺序：Times New Roman 放最前，它只负责拉丁字母与数字；
   汉字没有对应字形，会自动落到后面的中文字体。这样一次声明
   同时管住中英两边，不需要给每个元素分别指定。
   ================================================================ */
:root {
    /* 标题 / 小标题 —— 宋体 */
    --font-serif: 'Times New Roman', Times, 'Songti SC', 'SimSun', 'STSong', serif;
    --font-display: 'Times New Roman', Times, 'Songti SC', 'SimSun', 'STSong', serif;

    /* 正文 / 简介 —— 楷体（LXGW WenKai 为跨机器保底，系统楷体优先） */
    --font-sans: 'Times New Roman', Times, 'LXGW WenKai', 'Kaiti SC', 'STKaiti', 'KaiTi', serif;

    /* 辅助：标签、按钮、导航、注释 —— 仿宋，缺失时降级宋体 */
    --font-ui: 'Times New Roman', Times, 'STFangsong', 'FangSong', 'Songti SC', 'SimSun', serif;

    /* 数字 / 公式：保持等宽，不跟随 Times */
    --font-mono: 'JetBrains Mono', 'SF Mono', Menlo, Consolas, monospace;
    --font-math: 'STIX Two Math', 'Latin Modern Roman', 'Times New Roman', serif;

    /* ---------- 字距 ---------- */
    --ls-tighter: -0.025em;  /* 宋体超大标题 */
    --ls-tight: -0.012em;    /* 宋体标题 */
    --ls-normal: 0;          /* 楷体正文 */
    --ls-wide: 0.06em;       /* 英文大写小标签 */
    --ls-wider: 0.12em;      /* 英文眉题 */

    /* ---------- 字重 ----------
       楷体只有 400 一个可用户重，写 500/600 会触发浏览器合成假粗，
       笔画糊成一团。所以凡楷体区域一律锁 400，靠字号与宋体标题拉开层次。 */
    --fw-regular: 400;
    --fw-medium: 400;
    --fw-semibold: 600;
    --fw-bold: 700;

    /* ---------- 行高 ----------
       楷体笔画细、字面小，行高要比黑体更松，否则整段看起来挤。 */
    --lh-display: 1.25;
    --lh-heading: 1.4;
    --lh-body: 1.85;
    --lh-dense: 1.7;
}

/* ================================================================
   2. 全局基线
   ================================================================ */
html {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

body {
    font-family: var(--font-sans);
    font-weight: 400;
    letter-spacing: var(--ls-normal);
    line-height: var(--lh-body);
    font-variant-numeric: tabular-nums;
}

/* ================================================================
   3. 标题层级 —— 全部宋体
   ----------------------------------------------------------------
   宋体在屏显上笔画有粗细对比，大字号才撑得住；小字号会显得单薄。
   所以标题保持字号与字重的双重区分，但字距不要放开（放开就散）。
   ================================================================ */
h1 {
    font-family: var(--font-display);
    font-weight: var(--fw-bold);
    letter-spacing: var(--ls-tighter);
    line-height: var(--lh-display);
}

h2 {
    font-family: var(--font-serif);
    font-weight: var(--fw-bold);
    letter-spacing: var(--ls-tight);
    line-height: var(--lh-heading);
}

h3 {
    font-family: var(--font-serif);
    font-weight: var(--fw-semibold);
    letter-spacing: var(--ls-tight);
    line-height: var(--lh-heading);
}

h4, h5, h6 {
    font-family: var(--font-serif);
    font-weight: var(--fw-semibold);
    letter-spacing: var(--ls-normal);
}

/* ================================================================
   4. 页面实际使用的标题类
   ================================================================ */
.sec-title,
.title,
.card-title,
.module-title {
    font-family: var(--font-serif);
    font-weight: var(--fw-bold);
    letter-spacing: var(--ls-tight);
    line-height: var(--lh-heading);
}

.hero-module-title {
    font-family: var(--font-serif);
    font-weight: var(--fw-semibold);
    letter-spacing: var(--ls-tight);
    line-height: 1.45;
}

/* 副标题：宋体常规，与主标题同族但减重 */
.sub-title {
    font-family: var(--font-serif);
    font-weight: 400;
    letter-spacing: var(--ls-normal);
    line-height: var(--lh-dense);
}

/* ================================================================
   5. 正文与简介 —— 楷体
   ----------------------------------------------------------------
   楷体是这套体系的"阅读层"。所有说明性文字走这里。
   字号不再压到 13px：楷体在 13px 会发糊，正文底线 16px。
   ================================================================ */
p,
.lead,
.description,
.desc,
.card-desc,
.module-desc,
.subtitle,
.intro,
.hint,
.note-text,
.prose,
.article-body {
    font-family: var(--font-sans);
    font-weight: 400;
    letter-spacing: var(--ls-normal);
    line-height: var(--lh-dense);
}

/* 长段落放宽行高，楷体读起来才不费劲 */
p,
.prose,
.article-body {
    line-height: var(--lh-body);
}

/* ================================================================
   6. 辅助层 —— 仿宋（本机缺失，降级宋体）
   ----------------------------------------------------------------
   标签、按钮、导航这类短文本，楷体会显得软，宋体/仿宋的骨架更立得住。
   ================================================================ */
button,
.btn,
.btn-primary,
.btn-secondary,
.nav-link,
.navbar-link,
.nav-item,
.tag,
.badge,
.chip,
.label,
.caption,
figcaption,
.readout-label,
details summary {
    font-family: var(--font-ui);
    letter-spacing: var(--ls-normal);
}

.tag,
.badge,
.chip,
.label {
    font-weight: 400;
    letter-spacing: var(--ls-wide);
}

/* 图注 / 注释：更小更轻，用仿宋栈区分于正文楷体 */
.caption,
figcaption,
.readout-label,
.note {
    font-weight: 400;
    line-height: 1.6;
}

/* ================================================================
   7. 数字与数据 —— 等宽，不跟随 Times
   ----------------------------------------------------------------
   Times 的数字是比例宽度，"1" 与 "8" 宽度不同，表格里会左右跳。
   所有数值类强制等宽 + tabular-nums。
   ================================================================ */
.hero-module-num {
    font-family: var(--font-mono);
    font-weight: 600;
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
}

.metric,
.metric-value,
.score,
.stat-value,
.kpi,
.progress-value,
[data-numeric] {
    font-variant-numeric: tabular-nums;
}

.metric-value,
.stat-value,
.kpi {
    font-family: var(--font-mono);
    letter-spacing: -0.01em;
}

/* 公式区保持 STIX / Latin Modern，这是学术排版正确性，不能改成 Times */
.formula,
.math,
.katex,
.equation {
    font-family: var(--font-math);
}

/* ================================================================
   8. 字距归一（高优先级）
   ----------------------------------------------------------------
   modules.css 里 26 处正字距（0.06~0.16em）本是给英文大写眉题用的，
   却被大量套在中文标题上，导致"字与字漏风"。中文标题一律收紧，
   英文眉题反向保持宽字距，两者形成节奏对比。
   ================================================================ */
h1,
h2,
h3,
h4,
.sec-title,
.title,
.card-title,
.hero-module-title,
#view-home h1,
#view-home h2,
#view-garden h2,
#view-garden h3,
#view-garden h4,
#view-garden .mb-8 h2,
#view-maze h2,
#view-anchor h2,
#view-study h2,
#view-duallab h2 {
    letter-spacing: var(--ls-tight) !important;
}

#view-home h1,
#view-garden .mb-8 h2 {
    letter-spacing: var(--ls-tighter) !important;
}

/* 英文大写眉题：反向处理 */
.academic-subtitle-en,
.gh-head-label,
.en-label {
    letter-spacing: var(--ls-wider) !important;
}

/* ================================================================
   9. 导航（导览层）统一宋体
   ----------------------------------------------------------------
   顶部 13 个模块入口属于"导览"，与页内标题同族，读起来才是一套系统。
   字距收到 0.02em：导航项短，放开会显得松散且挤占宽度。
   ================================================================ */
.nav-link,
.navbar-link,
.nav-item,
.nav-desktop .navbar-nav .navbar-link,
.nav-mobile a,
.nav-mobile .navbar-link {
    font-family: var(--font-serif) !important;
    font-weight: 400 !important;
    letter-spacing: 0.02em !important;
}

/* ================================================================
   10. 页脚：宽扁页脚条
   ----------------------------------------------------------------
   原样式为 inline-block + max-width 880px，宽度被最长英文行撑住，
   高度又被 padding 与 40px 外边距堆高，结果是"窄而高"的一块卡片，
   在页面上占地很多但信息量很小。
   改为定宽条状容器（block + 居中 + 1180px），左右内边距加大、
   上下压扁，四行文字间距收紧，整体比例才像页脚而不是说明卡。
   ================================================================ */
.footer-glass {
    display: block !important;
    width: min(94vw, 1180px) !important;
    max-width: min(94vw, 1180px) !important;
    margin: 0 auto !important;
    padding: 18px 56px !important;
    border-radius: 14px !important;
}

/* 主标题：一行撑住，字号略提 */
.footer-main-text {
    font-size: 15px !important;
    font-weight: 500 !important;
    letter-spacing: 0.04em !important;
    line-height: 1.55 !important;
    margin: 0 !important;
}

/* 副信息：小一号，与主标题留出层次但不要大空隙 */
.footer-sub-text {
    font-size: 12.5px !important;
    letter-spacing: 0.06em !important;
    line-height: 1.6 !important;
    margin-top: 7px !important;
}

/* 英文行：宽容器下可收为一行，行高压到 1.7 */
.footer-en-text {
    font-size: 11.5px !important;
    line-height: 1.75 !important;
    letter-spacing: 0.01em !important;
    margin-top: 7px !important;
}

/* ================================================================
   11. 楷体最小字号与对比度保障
   ----------------------------------------------------------------
   楷体笔画比黑体细约 30%，在 12px 屏幕上会糊成一片灰。
   实测首页卡片描述只有 12px、颜色 #7a7a7a，这是"看起来旧、不清楚"
   的实测来源。楷体正文底线 14px，主段落 16px，同时把灰压深一档。
   ================================================================ */
.hero-module-desc,
.hero-subtitle-text,
.he-relate,
.card-desc,
.module-desc {
    font-size: 14px !important;
    line-height: 1.75 !important;
    color: #5b5b5b !important;
}

.hero-body-text,
.description,
.lead,
.he-desc {
    font-size: 16px !important;
    line-height: 1.9 !important;
}

/* 主段落正文：楷体 16px 才撑得住"大气"，小字号衬线永远是廉价感来源 */
p:not(.caption):not(figcaption):not(.readout-label) {
    font-size: max(16px, 1em);
}

/* ================================================================
   13. 文字对比度修正（浅底可读性）
   ----------------------------------------------------------------
   本项目主体是浅色背景（米白 / 薄荷 / 淡紫），但大量文字沿用了
   Tailwind 的 slate 色阶 —— 那套色阶是为深色背景设计的：
     slate-200 #e2e8f0  在 #fafafa 上对比度约 1.2:1（几乎不可见）
     slate-300 #cbd5e1  约 1.6:1（不可见）
     slate-400 #94a3b8  约 2.4:1（不合格，WCAG AA 要求 4.5:1）
   最荒谬的一处：正文用 slate-400，而"加粗强调"用 slate-200，
   强调比正文还浅，等于强调失效。

   这里按"浅底 + 小字号"重新映射一组值，全部达到 4.5:1 以上。
   传递关系保持原设计意图：200 本来就是"最强调"，改后仍是最深。
   ================================================================ */
.text-slate-200 { color: #1e293b !important; }  /* 强调 -> 最深 */
.text-slate-300 { color: #334155 !important; }  /* 次级强调 */
.text-slate-400 { color: #4b5563 !important; }  /* 正文 / 说明 */
.text-slate-500 { color: #556070 !important; }  /* 辅助说明 */
.text-slate-600 { color: #3f4956 !important; }  /* 保持偏深 */

/* 同系列的 gray 阶，一并兜住 */
.text-gray-200 { color: #1e293b !important; }
.text-gray-300 { color: #334155 !important; }
.text-gray-400 { color: #4b5563 !important; }
.text-gray-500 { color: #556070 !important; }

/* ================================================================
   14. 中文正文可读宽度
   ----------------------------------------------------------------
   宋体/楷体的字宽均匀，一行超过约 38 字眼睛回扫就累。 */
.prose,
.article-body,
.paragraph-block {
    max-width: 38em;
}

/* ================================================================
   说明：原 Inter / Playfair Display 的 @font-face 已移除不再引用，
   字体文件仍保留在 assets/fonts/（154KB，不会被下载）。
   若要切回"现代无衬线 + 高对比衬线"风格，把上面的令牌改回：
     --font-sans: 'Inter', 'PingFang SC', 'Microsoft YaHei', sans-serif;
     --font-serif: 'Playfair Display', 'Songti SC', 'SimSun', serif;
   并在本文件顶部补回 @font-face 声明即可。
   ================================================================ */

/* ================================================================
   15. 模块标识行（"模块一 · Module 01 / Voice Lab"）
   ----------------------------------------------------------------
   中文「模块一」走 .module-tag（楷体）；
   英文 "Module 0X / XXX" 独立成 .module-en，用 Times New Roman。
   原来这行是 JetBrains Mono 等宽体 —— 等宽是为代码和数字对齐
   设计的，字形机械、字距散开，放在学术视觉里很像工程日志。
   ================================================================ */
.module-en {
    font-family: var(--font-serif);      /* Times New Roman 在第一顺位 */
    font-size: 12.5px;
    font-weight: 400;
    letter-spacing: 0.06em;
    color: #556070;
    white-space: nowrap;
}

/* 卡片内的同款英文徽标（js 生成） */
.va-hub-badge,
.module-badge-en {
    font-family: var(--font-serif) !important;
    letter-spacing: 0.05em;
}

/* ----------------------------------------------------------------
   各视图对 .module-tag 有自己的 ID 级覆盖（#view-garden 3 处、
   #view-island 1 处），全部把字体拽回等宽。ID 选择器优先级高于
   类名，所以这里必须用 !important 收口。
   ---------------------------------------------------------------- */
.module-tag,
[id^="view-"] .module-tag {
    font-family: var(--font-sans) !important;   /* Times + 霞鹜文楷 */
    font-size: 12.5px !important;
    font-weight: 400 !important;
    letter-spacing: 0.02em !important;
    text-transform: none !important;
}

/* ----------------------------------------------------------------
   深色画布上的空态提示：原来用主题青 #0d9488 压在深绿底上，
   对比度不足 1.5:1，等于隐形。这里反转为浅色（浅色底用深字，
   深色底用浅字，才是同一套逻辑）。
   ---------------------------------------------------------------- */
#view-garden .canvas-idle-hint .idle-main-text {
    color: #eef7f3 !important;
    letter-spacing: 0.06em !important;
    font-weight: 400 !important;
}
#view-garden .canvas-idle-hint .idle-sub-text {
    color: rgba(238, 247, 243, 0.78) !important;
}

/* ============================================================
   16. 弹窗可读性加固
   实测（声景花园麦克风权限弹窗）：
   · 弹窗底 rgba(255,255,255,.75) 叠在页面浅底上 → 正文发虚
   · 「允许使用麦克风」白字压 #0d9488 = 3.0:1（14px 需 4.5:1）
   · 「没有麦克风？上传音频文件替代」#2DD4BF = 1.85:1，几乎不可读
   · 图标描边 #FCD34D 在浅黄底上 ≈ 1.5:1
   仅作用于浅色主题，深色主题维持原值
   ============================================================ */

/* 16.1 弹窗底：实白，去掉半透明 */
html:not([data-theme="dark"]) .modal-dialog {
    background: #FFFFFF !important;
    border: 1px solid #E2DFD6 !important;
    box-shadow: 0 18px 48px rgba(31, 41, 45, 0.14) !important;
}

/* 16.2 标题与正文：拉开层级 */
html:not([data-theme="dark"]) .modal-dialog h3 {
    color: #111827 !important;
    font-weight: 700 !important;
    letter-spacing: 0.01em;
}

html:not([data-theme="dark"]) .modal-dialog p {
    color: #374151 !important;
    font-weight: 500 !important;
    font-size: 14.5px !important;
    line-height: 1.9 !important;
}

/* 16.3 主按钮：白字对比 3.0:1 → 5.3:1 */
html:not([data-theme="dark"]) .modal-dialog .ctrl-btn-primary {
    background: #0F766E !important;
    border-color: #0F766E !important;
    color: #FFFFFF !important;
    font-weight: 600 !important;
}

html:not([data-theme="dark"]) .modal-dialog .ctrl-btn-primary:hover {
    background: #115E59 !important;
    border-color: #115E59 !important;
}

/* 16.4 次要按钮：补浅底与深描边，避免"幽灵按钮" */
html:not([data-theme="dark"]) .modal-dialog .ctrl-btn-ghost {
    background: #FAFAF7 !important;
    border-color: #C9C5BA !important;
    color: #1F2937 !important;
    font-weight: 500 !important;
}

html:not([data-theme="dark"]) .modal-dialog .ctrl-btn-ghost:hover {
    background: #F1EFE9 !important;
    color: #111827 !important;
}

/* 16.5 「上传音频文件替代」：浅青 → 深青，字号 12 → 13 */
html:not([data-theme="dark"]) :is(#mic-permission-modal, #audio-upload-modal) button[onclick*="showAudioUploadFallback"] {
    color: #0F766E !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    letter-spacing: 0.02em;
}

html:not([data-theme="dark"]) :is(#mic-permission-modal, #audio-upload-modal) button[onclick*="showAudioUploadFallback"]:hover {
    color: #115E59 !important;
}

/* 16.6 弹窗图标描边压深 */
html:not([data-theme="dark"]) .modal-dialog .modal-icon-amber svg { color: #B45309 !important; }
html:not([data-theme="dark"]) .modal-dialog .modal-icon-teal svg { color: #0F766E !important; }

/* 16.7 浅底琥珀色标题：#FCD34D 在米白/浅绿底上 ≈1.5:1，压深到 #B45309（5.4:1）
   作用于「我的声景花园」「公式卡标题」等浅底卡片，深色主题不受影响 */
html:not([data-theme="dark"]) .text-amber-light {
    color: #B45309 !important;
}
