/* ============================================================================
 * jp-typography-contract.css  —  KŌEN / 香苑 adaptation
 * ----------------------------------------------------------------------------
 * Adapted from _shared/jp-typography-contract.css (hirokaji/jp-ui-contracts,
 * MIT, commit 5700b944...). ONLY the --font-* placeholders are swapped for the
 * bundled Zen families; every G36 threshold below is unchanged. Self-hosted
 * fonts (SIL OFL) are declared here so the contract + faces travel together.
 * ==========================================================================*/

@font-face {
  font-family: "Zen Kaku Gothic New";
  src: url("../../_shared/fonts/ZenKakuGothicNew/ZenKakuGothicNew-Regular.ttf") format("truetype");
  font-style: normal; font-weight: 400; font-display: swap;
}
@font-face {
  font-family: "Zen Kaku Gothic New";
  src: url("../../_shared/fonts/ZenKakuGothicNew/ZenKakuGothicNew-Bold.ttf") format("truetype");
  font-style: normal; font-weight: 700; font-display: swap;
}
@font-face {
  font-family: "Zen Old Mincho";
  src: url("../../_shared/fonts/ZenOldMincho/ZenOldMincho-Regular.ttf") format("truetype");
  font-style: normal; font-weight: 400; font-display: swap;
}
@font-face {
  font-family: "Zen Old Mincho";
  src: url("../../_shared/fonts/ZenOldMincho/ZenOldMincho-Bold.ttf") format("truetype");
  font-style: normal; font-weight: 700; font-display: swap;
}

/* 1. Root Japanese text environment (font-feature-settings:normal — NO body-wide palt) */
html:lang(ja) {
  line-break: strict;
  word-break: normal;
  overflow-wrap: anywhere;
  font-kerning: auto;
  font-feature-settings: normal;
  text-autospace: normal;
}

/* 2. Font families — named modern JP family BEFORE the generic keyword */
:root {
  --font-body:          "Zen Kaku Gothic New", system-ui, sans-serif;
  --font-serif-display: "Zen Old Mincho", serif;
}

html:lang(ja) body {
  font-family: var(--font-body);
  text-rendering: optimizeLegibility;
}

/* 3. Japanese body — line-height 1.75 (G36 FAIL < 1.5); letter-spacing 0..0.02em, negative PROHIBITED */
:lang(ja) p,
:lang(ja) li,
:lang(ja) dd {
  line-height: 1.75;
  letter-spacing: 0;
  line-break: strict;
  word-break: normal;
  overflow-wrap: anywhere;
}

:where(article, .prose, .content):lang(ja) p,
:lang(ja) :where(article, .prose, .content) p {
  max-width: 42em;
}

/* 4. Japanese headings — h1 1.35 / h2 1.40 / h3 1.45; negative letter-spacing PROHIBITED */
:lang(ja) h1,
:lang(ja) h2,
:lang(ja) h3,
:lang(ja) h4 {
  line-break: strict;
  word-break: normal;
  overflow-wrap: anywhere;
  font-kerning: auto;
}

:lang(ja) h1,
:lang(ja) h2,
:lang(ja) h3 {
  word-break: auto-phrase;
  text-wrap: pretty;
}

:lang(ja) h1 { line-height: 1.35; letter-spacing: 0; }
:lang(ja) h2 { line-height: 1.40; letter-spacing: 0; }
:lang(ja) h3 { line-height: 1.45; letter-spacing: 0; }

:lang(ja) :where(h1, h2, h3).is-centered,
:lang(ja) :where(h1, h2, h3)[style*="text-align:center"],
:lang(ja) :where(h1, h2, h3)[style*="text-align: center"] {
  text-wrap: balance;
}

/* 5. palt — headings / short labels ONLY (body-wide = G36 FAIL) */
:lang(ja) :where(h1, h2, h3, .label, .eyebrow, .badge) {
  font-feature-settings: "palt";
}

/* 6. Forms — separated from body density */
:lang(ja) label,
:lang(ja) input,
:lang(ja) textarea,
:lang(ja) select,
:lang(ja) button {
  line-break: strict;
  word-break: normal;
}

:lang(ja) input,
:lang(ja) textarea,
:lang(ja) select {
  line-height: 1.5;
}
