/* ==========================================================================
   Typography Foundation（候选） · 2026-09-13
   仅提供全局 --type-* token 与显式 opt-in 语义类。
   不改 :root / body 的字体声明，旧页面不受影响；
   只有在 .typography-scope 内或使用 .type-* 类的元素才应用。

   已核对（2026-09-13，seed.line.me + google/fonts apache/ofl）：
   - LINE Seed JP 只有静态 Thin(100)/Regular(400)/Bold(700)/ExtraBold(800)，
     无 500/600，无 variable。本候选只交付 400 与 700；
     语义 500 → CSS 正常匹配到 400，语义 600 → 匹配到 700。
     禁止把 400 伪声明成其它 weight，font-synthesis: none 防止合成加粗。
   - Noto Sans SC 为 wght variable（100..900）。
   - Inter 为 opsz/wght variable（14..32 / 100..900），仅用于数字/英文角色。
   - Noto Serif JP 本阶段仅作为辅助栈预留（系统 serif 评估），不主动加载。
   ========================================================================== */

/* ---- 字体栈 token（仅变量定义，不产生任何渲染副作用） ---- */
:root {
  /* 日文：LINE Seed JP 自带 Latin，普通日文内的英文/数字不需额外 span */
  --type-font-ja: "LINE Seed JP", "Hiragino Sans", "Yu Gothic", "YuGothic",
    "Noto Sans CJK JP", system-ui, sans-serif;
  /* 中文：Noto Sans SC 优先；JP 字体不放在中文系统字体之前 */
  --type-font-zh: "Noto Sans SC", "PingFang SC", "Microsoft YaHei",
    "Noto Sans CJK SC", system-ui, sans-serif;
  /* 独立时间/数字/英文 metadata：Inter 优先；Inter 失败时回落 Arial。
     本机 Arial 的 auto kerning 会缩窄连续「11」；
     数字对齐角色（type-time/time-lg/countdown）另设 font-kerning:none，
     关闭 kerning 后同位数自然文本宽度一致（11:11 / 22:22 / 88:88，24px/600 实测均 61.3828125px），
     不依赖 PingFang 比例数字；kerning 仅在这些角色关闭，不全局关闭。
     CJK 兜底用中文栈（Noto Sans SC 在系统字体之前），不放 JP 字体，
     避免 Countdown 中文误用 JP 后备 */
  --type-font-latin: "Inter", Arial, "Noto Sans SC", "PingFang SC", "Microsoft YaHei",
    system-ui, "Noto Sans CJK SC", sans-serif;
  /* 辅助 Serif 预览：JA / SC 分栈，仅系统 serif，本阶段不加载 Noto Serif JP。
     "Noto Serif JP"/"Noto Serif SC" 仅为未来自托管预留的准确名称（未加载时跳过） */
  --type-font-serif-aux-ja: "YuMincho", "Hiragino Mincho ProN",
    "Noto Serif JP", "Noto Serif CJK JP", Georgia, serif;
  --type-font-serif-aux-zh: "Songti SC", "Noto Serif SC", "Noto Serif CJK SC",
    "SimSun", Georgia, serif;

  /* ---- 尺寸/行高/字重 token（rem，根 16px；weight 只允许 400/500/600/700） ---- */
  --type-display-size: 2.5rem;      /* 40 */
  --type-display-lh: 1.2;
  --type-page-title-size: 2rem;     /* 32 */
  --type-page-title-lh: 1.3;
  --type-section-title-size: 1.5rem;/* 24 */
  --type-section-title-lh: 1.35;
  --type-feature-title-size: 1.5rem;/* 24 */
  --type-feature-title-lh: 1.45;
  --type-card-title-size: 1.125rem; /* 18 */
  --type-card-title-lh: 1.5;
  --type-body-size: 1rem;           /* 16 */
  --type-body-lh: 1.8;
  --type-body-small-size: 0.875rem; /* 14 */
  --type-body-small-lh: 1.65;
  --type-metadata-size: 0.8125rem;  /* 13 */
  --type-metadata-lh: 1.45;
  --type-label-size: 0.75rem;       /* 12 */
  --type-label-lh: 1.35;
  --type-time-lg-size: 1.5rem;      /* 24 */
  --type-time-lg-lh: 1.2;
  --type-time-size: 1.125rem;       /* 18 */
  --type-time-lh: 1.3;
  --type-countdown-size: 1.5rem;    /* 24 */
  --type-countdown-lh: 1.25;
  --type-ui-size: 0.875rem;         /* 14 */
  --type-ui-lh: 1.4;
}

@media (max-width: 767px) {
  :root {
    --type-display-size: 2rem;         /* 32 */
    --type-page-title-size: 1.75rem;   /* 28 */
    --type-section-title-size: 1.375rem; /* 22 */
    --type-feature-title-size: 1.25rem;  /* 20 */
    --type-time-lg-size: 1.375rem;     /* 22 */
    --type-countdown-size: 1.375rem;   /* 22 */
    /* Card Title / Body / Body Small / Metadata / Label / Time Normal / UI
       桌面与移动同值，无需覆盖 */
  }
}

/* ---- 语言作用域：只在显式 opt-in 的容器内生效 ----
   关键设计：语言规则只匹配「语言边界」元素（自身带 lang 属性），
   不用会沿语言继承命中每个后代的 :lang()——否则边界规则直命中每个后代，
   会盖过从 .type-time 等角色类继承下来的 Inter。
   - 语言块在自身根元素设 family，内部 a/span 纯继承；
   - 边界规则为属性选择器（specificity 0-1-0），与角色类（0-1-0）同级；
     角色类声明在后：同元素同时命中时（如 <p class="type-time" lang="ja">）
     角色类按源码顺序胜出；嵌套后代上角色类直命中恒高于边界的继承值，
     数字角色内嵌套保持 Inter。 */
.typography-scope {
  font-family: var(--type-font-zh);
  font-size: var(--type-body-size);
  line-height: var(--type-body-lh);
  font-synthesis: none;
  /* 标题/正文自然换行：CJK 严格断行，不全局 anywhere 拆字 */
  line-break: strict;
  word-break: normal;
}
/* 作用域自身带 lang 也生效（块内文本经继承取字）。
   选择器 specificity (0,1,0)：与基类同级但声明在后 → 覆盖基类；
   与后文的角色类同级但声明在前 → 角色类（.type-time 等）在同元素上胜出。 */
:where(.typography-scope)[lang="ja"],
:where(.typography-scope) [lang="ja"] {
  font-family: var(--type-font-ja);
}
:where(.typography-scope)[lang|="zh"],
:where(.typography-scope) [lang|="zh"] {
  font-family: var(--type-font-zh);
}
:where(.typography-scope)[lang="en"],
:where(.typography-scope) [lang="en"] {
  font-family: var(--type-font-latin);
}

/* ---- 语义角色类（可独立用于任何元素，颜色/布局一律不管） ---- */
.type-display {
  font-size: var(--type-display-size);
  line-height: var(--type-display-lh);
  font-weight: 700;
}
.type-page-title {
  font-size: var(--type-page-title-size);
  line-height: var(--type-page-title-lh);
  font-weight: 700;
}
.type-section-title {
  font-size: var(--type-section-title-size);
  line-height: var(--type-section-title-lh);
  font-weight: 700;
}
.type-feature-title {
  font-size: var(--type-feature-title-size);
  line-height: var(--type-feature-title-lh);
  font-weight: 700;
}
.type-card-title {
  font-size: var(--type-card-title-size);
  line-height: var(--type-card-title-lh);
  font-weight: 600;
}
.type-body {
  font-size: var(--type-body-size);
  line-height: var(--type-body-lh);
  font-weight: 400;
}
.type-body-small {
  font-size: var(--type-body-small-size);
  line-height: var(--type-body-small-lh);
  font-weight: 400;
}
.type-metadata {
  font-size: var(--type-metadata-size);
  line-height: var(--type-metadata-lh);
  font-weight: 500;
}
.type-label {
  font-size: var(--type-label-size);
  line-height: var(--type-label-lh);
  font-weight: 600;
}

/* 真正需要对齐的数字角色才 tnum + lining-nums；不做全 body tnum。
   Arial 回落下 auto kerning 会缩窄「11」，仅在这些数字角色关闭 kerning */
.type-time-lg,
.type-time,
.type-countdown {
  font-family: var(--type-font-latin);
  font-variant-numeric: tabular-nums lining-nums;
  font-feature-settings: "tnum" 1, "lnum" 1;
  font-kerning: none;
}
.type-time-lg {
  font-size: var(--type-time-lg-size);
  line-height: var(--type-time-lg-lh);
  font-weight: 600;
}
.type-time {
  font-size: var(--type-time-size);
  line-height: var(--type-time-lh);
  font-weight: 600;
}
.type-countdown {
  font-size: var(--type-countdown-size);
  line-height: var(--type-countdown-lh);
  font-weight: 600;
}
.type-ui {
  font-size: var(--type-ui-size);
  line-height: var(--type-ui-lh);
  font-weight: 500;
}

/* 短英文标签允许的极少量字距；普通英文 metadata 不 uppercase、不加距 */
.type-label-en {
  letter-spacing: 0.04em;
}

/* 辅助 Serif 预览：JA/SC 分栈，仅系统 serif，供评估，不代表已加载 Noto Serif JP。
   默认中文栈（不优先 YuMincho）；lang=ja 边界元素用日文栈。 */
.type-serif-aux {
  font-family: var(--type-font-serif-aux-zh);
}
.type-serif-aux[lang="ja"],
.type-serif-aux [lang="ja"] {
  font-family: var(--type-font-serif-aux-ja);
}

/* 极长 URL 等异常内容局部防溢出（不全局 anywhere） */
.type-break-anywhere {
  overflow-wrap: anywhere;
}
