/**
 * i18n-cjk.css — CJK typography layer (Korean / Simplified Chinese).
 *
 * Loaded ONLY by pages under /ko/ and /zh/, after base.css. English pages never
 * download these fonts. Both families are self-hosted, SIL OFL 1.1, and subset
 * to the glyphs this site actually uses — see assets/fonts/OFL-Pretendard.txt
 * and assets/fonts/OFL-NotoSansSC.txt, and tools/subset-cjk-fonts.sh for how
 * the .woff2 files are regenerated when copy changes.
 *
 * Strategy: Latin stays Inter everywhere (product names, $39, "TaskHolder"),
 * and the CJK face only fills in the glyphs Inter lacks. That is what
 * `font-family: 'Inter', 'Pretendard', …` achieves — the browser falls through
 * per-glyph, not per-element. Pretendard is metrically compatible with Inter,
 * so mixed-script lines keep one baseline and the existing layout holds.
 */

/* ---------- Korean: Pretendard Variable (OFL 1.1) ---------- */
@font-face {
  font-family: 'Pretendard';
  src: url('../assets/fonts/pretendard-kr-wght-subset.woff2') format('woff2-variations');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
  /* Hangul syllables + Jamo + CJK punctuation. Latin is served by Inter. */
  unicode-range: U+1100-11FF, U+3000-303F, U+3130-318F, U+A960-A97F,
                 U+AC00-D7A3, U+D7B0-D7FF, U+FF01-FF60;
}

/* ---------- Simplified Chinese: Noto Sans SC Variable (OFL 1.1) ---------- */
@font-face {
  font-family: 'Noto Sans SC';
  src: url('../assets/fonts/noto-sans-sc-wght-subset.woff2') format('woff2-variations');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
  /* CJK Unified Ideographs + punctuation/fullwidth forms. Latin → Inter. */
  unicode-range: U+2E80-2EFF, U+3000-303F, U+3200-33FF, U+4E00-9FFF,
                 U+F900-FAFF, U+FE30-FE4F, U+FF01-FF60, U+FFE0-FFE6;
}

/* ---------- Cross-script fallback ----------
   Reality check on the two families: Pretendard contains Hangul but NO Han
   ideographs; Noto Sans SC contains Han but NO Hangul. The language switcher
   is on every page and always names all three languages in their own scripts
   ("한국어", "中文"), so each page necessarily renders a few glyphs its own
   webfont cannot provide. Subsetting cannot fix this — the glyphs simply are
   not in the source font.

   So the body stacks below list BOTH webfonts plus the platform CJK faces.
   A Korean page renders "中文" from Noto Sans SC if it happens to be cached,
   otherwise from PingFang/YaHei/system — correct glyphs either way, and the
   `unicode-range` on each @font-face means neither font is ever downloaded
   for a script it does not serve. Two switcher words in a system face is an
   invisible difference; tofu boxes would not be. */

/* ---------- Per-language body stacks ----------
   Inter is listed FIRST on purpose: it wins for Latin glyphs it has, and the
   CJK face picks up everything else. System faces trail as the offline/blocked
   fallback so text is never invisible while a font loads or fails. */
:root:lang(ko) body,
html[lang="ko"] body {
  font-family: 'Inter', 'Pretendard', 'Apple SD Gothic Neo', 'Malgun Gothic',
               'PingFang SC', 'Microsoft YaHei', system-ui, sans-serif;
  /* Hangul has no ascenders/descenders to hang on; a touch more leading keeps
     dense Korean paragraphs from looking cramped at the same font-size. */
  line-height: 1.75;
  /* Korean does not use inter-word letter-spacing the way Latin display type
     does; the -0.02em heading tracking below is neutralised in headings. */
  word-break: keep-all;       /* never split a Korean word across lines */
  overflow-wrap: break-word;  /* but long URLs/IDs may still wrap */
}

html[lang="zh-Hans"] body,
html[lang="zh"] body {
  font-family: 'Inter', 'Noto Sans SC', 'PingFang SC', 'Microsoft YaHei',
               'Apple SD Gothic Neo', 'Malgun Gothic', system-ui, sans-serif;
  line-height: 1.8;           /* Han glyphs are dense; give them room */
  overflow-wrap: break-word;
}

/* ---------- Headings ----------
   base.css sets letter-spacing:-0.02em, tuned for Inter's Latin forms. Applied
   to Hangul or Han it visibly crushes the glyphs together, so reset it and let
   the CJK face use its own designed advance widths. */
html[lang="ko"] h1, html[lang="ko"] h2, html[lang="ko"] h3, html[lang="ko"] h4,
html[lang="zh-Hans"] h1, html[lang="zh-Hans"] h2,
html[lang="zh-Hans"] h3, html[lang="zh-Hans"] h4 {
  letter-spacing: normal;
  line-height: 1.3;           /* 1.15 is too tight for full-height CJK glyphs */
  font-weight: 600;           /* 550 reads thin in Hangul/Han at display sizes */
}

html[lang="ko"] h1, html[lang="ko"] h2,
html[lang="zh-Hans"] h1, html[lang="zh-Hans"] h2 {
  /* text-wrap:balance + keep-all can produce a lonely trailing word; pretty
     gives better ragging for CJK without the orphan risk. */
  text-wrap: pretty;
}

/* ---------- Mono ----------
   JetBrains Mono has no CJK coverage. Where a .mono element contains CJK
   (version strings, trust lines), fall through to the CJK face rather than to
   an arbitrary system default that would break the monospace rhythm midline. */
html[lang="ko"] .mono {
  font-family: 'JetBrains Mono', 'Pretendard', ui-monospace, 'SF Mono', monospace;
}
html[lang="zh-Hans"] .mono {
  font-family: 'JetBrains Mono', 'Noto Sans SC', ui-monospace, 'SF Mono', monospace;
}

/* ---------- Layout tolerance ----------
   Korean and Chinese renderings of the same UI string differ in length from
   English — CJK is often shorter, but Korean compounds can be longer. These
   guard the two places where the design assumes English metrics. */
html[lang="ko"] .btn,
html[lang="zh-Hans"] .btn {
  white-space: nowrap;        /* CTA labels must never wrap mid-button */
}

html[lang="ko"] .nav__link,
html[lang="zh-Hans"] .nav__link {
  white-space: nowrap;
}

/* The hero H1 breaks at a <br> chosen for English phrasing. In CJK the natural
   break falls elsewhere, so the translated markup drops the <br> and lets the
   line box break — this keeps the block from growing a third line on desktop. */
html[lang="ko"] .hero h1,
html[lang="zh-Hans"] .hero h1 {
  max-width: 22em;
  margin-inline: auto;
}

/* ---------- Symbol glyphs not present in either CJK webfont ----------
   Neither Pretendard nor Noto Sans SC carries U+2715 (✕), used by the app-help
   banner's dismiss button (that markup is shared with the English pages, so it
   is not something the translations introduced). Inter does not have it either.
   Point these buttons at the system UI stack, which does, so the control never
   renders as a tofu box on a Korean or Chinese page. */
html[lang="ko"] [data-app-banner-dismiss],
html[lang="zh-Hans"] [data-app-banner-dismiss] {
  font-family: system-ui, -apple-system, 'Segoe UI Symbol', 'Apple Symbols', sans-serif;
}
