/* ============================================================
   Japanese / CJK typography layer
   Loaded only on /ja/.

   The page was typeset for Space Grotesk and Plus Jakarta Sans,
   neither of which contains a single Japanese glyph. build.mjs
   swaps the font stacks to Noto Sans JP. This file fixes the
   metrics that were tuned for Latin and read badly in Japanese.

   As with rtl.css, !important is required because the original
   page sets these properties via inline style attributes.
   ============================================================ */

/* ---- 1. Letter-spacing -------------------------------------------
   The Latin headings use negative tracking down to -0.038em. Japanese
   glyphs are full-width and already visually tight; negative tracking
   makes them collide. Reset to zero and let `palt` handle the optical
   spacing of kana and punctuation instead.                            */

html[lang="ja"] h1,
html[lang="ja"] h2,
html[lang="ja"] h3,
html[lang="ja"] blockquote,
html[lang="ja"] .ai-h1,
html[lang="ja"] .ai-sec {
  letter-spacing: 0 !important;
}

html[lang="ja"] body,
html[lang="ja"] h1,
html[lang="ja"] h2,
html[lang="ja"] h3 {
  /* proportional alternate widths: tightens 、。「」（） optically */
  font-feature-settings: "palt" 1;
}

/* ---- 2. Line height ---------------------------------------------
   The hero h1 ships at line-height:1.02, which is fine for a tight
   Latin display face and unreadable for Japanese - kanji have no
   descender relief, so lines visually touch.                          */

html[lang="ja"] .ai-h1 {
  line-height: 1.34 !important;
}

html[lang="ja"] h2,
html[lang="ja"] .ai-sec {
  line-height: 1.4 !important;
}

html[lang="ja"] blockquote {
  line-height: 1.72 !important;
}

html[lang="ja"] p,
html[lang="ja"] .ai-lead {
  line-height: 1.9 !important;
}

/* ---- 3. Line breaking -------------------------------------------
   Japanese has no inter-word spaces, so the default breaking rules can
   strand punctuation at the start of a line. `strict` applies proper
   kinsoku shori (line-break prohibition rules).                        */

html[lang="ja"] {
  line-break: strict;
  word-break: normal;
  overflow-wrap: anywhere;
}

/* ---- 4. Weights -------------------------------------------------
   Latin hairline weights (200/300) are legible; the same weights in
   Japanese lose the fine strokes inside dense kanji at body sizes.
   Floor the light weights at 400 for small text.                       */

html[lang="ja"] p,
html[lang="ja"] .ai-lead,
html[lang="ja"] blockquote {
  font-weight: 400 !important;
}

/* ---- 5. Uppercase eyebrows --------------------------------------
   text-transform:uppercase does nothing to kana or kanji but the wide
   0.22em letter-spacing that accompanies it leaves gaping holes.        */

html[lang="ja"] [style*="text-transform:uppercase"] {
  letter-spacing: 0.08em !important;
}

/* ---- 6. Count-up statistics -------------------------------------
   The animated numerals stay Latin; keep them on a Latin face so the
   figures do not switch to full-width forms mid-animation.             */

html[lang="ja"] [data-count] {
  font-family: "Space Grotesk", "Noto Sans JP", sans-serif !important;
  letter-spacing: -0.03em !important;
}
