/*
 * inscribe Pali fonts
 *
 * Thai Pali (พินทุ ฺ, นิคหิต ํ, สระซ้อน): Sarabun.
 * Web body (weight 400) uses Sarabun Light so Thai reads more open.
 * LuaLaTeX printing still uses Sarabun-Regular.ttf. Bold stays Sarabun Bold.
 * Roman Pali (ā ī ū ṅ ñ ṭ ḍ ṇ ḷ ṃ ṁ ḥ ś ṣ): Gentium 7 — SIL scholarly Latin.
 *
 * "inscribe Pali" splits by unicode-range: Thai → Sarabun; everything else → Gentium.
 * The page language does not choose the face. A Thai character uses Sarabun
 * and a Latin character uses Gentium on the same page.
 * .inscribe-thai forces Sarabun. .inscribe-roman / [lang="pi-Latn"] force Gentium.
 */

@font-face {
  font-family: "Sarabun";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../../fonts/Sarabun-Light.c80028171f09.ttf") format("truetype");
}

@font-face {
  font-family: "Sarabun";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("../../fonts/Sarabun-Bold.69b0b84bbe65.ttf") format("truetype");
}

@font-face {
  font-family: "Sarabun";
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url("../../fonts/Sarabun-LightItalic.af04d15290da.ttf") format("truetype");
}

@font-face {
  font-family: "Sarabun";
  font-style: italic;
  font-weight: 700;
  font-display: swap;
  src: url("../../fonts/Sarabun-BoldItalic.e01d2eba0f2e.ttf") format("truetype");
}

@font-face {
  font-family: "Gentium";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../../fonts/Gentium-Regular.72eed903f486.woff2") format("woff2"),
    url("../../fonts/Gentium-Regular.f957acf5341c.ttf") format("truetype");
}

@font-face {
  font-family: "Gentium";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("../../fonts/Gentium-Bold.7b986d61d604.woff2") format("woff2"),
    url("../../fonts/Gentium-Bold.fdb456ffdb9c.ttf") format("truetype");
}

@font-face {
  font-family: "Gentium";
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url("../../fonts/Gentium-Italic.7b8f542bdd92.woff2") format("woff2"),
    url("../../fonts/Gentium-Italic.8732d83b88d8.ttf") format("truetype");
}

@font-face {
  font-family: "Gentium";
  font-style: italic;
  font-weight: 700;
  font-display: swap;
  src: url("../../fonts/Gentium-BoldItalic.c1241cd253ed.woff2") format("woff2"),
    url("../../fonts/Gentium-BoldItalic.012d155963eb.ttf") format("truetype");
}

/* Mixed family: Thai from Sarabun; all other scripts from Gentium (same as Roman Pāli). */
@font-face {
  font-family: "inscribe Pali";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../../fonts/Sarabun-Light.c80028171f09.ttf") format("truetype");
  unicode-range: U+0E00-0E7F, U+25CC;
}

@font-face {
  font-family: "inscribe Pali";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("../../fonts/Sarabun-Bold.69b0b84bbe65.ttf") format("truetype");
  unicode-range: U+0E00-0E7F, U+25CC;
}

@font-face {
  font-family: "inscribe Pali";
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url("../../fonts/Sarabun-LightItalic.af04d15290da.ttf") format("truetype");
  unicode-range: U+0E00-0E7F, U+25CC;
}

@font-face {
  font-family: "inscribe Pali";
  font-style: italic;
  font-weight: 700;
  font-display: swap;
  src: url("../../fonts/Sarabun-BoldItalic.e01d2eba0f2e.ttf") format("truetype");
  unicode-range: U+0E00-0E7F, U+25CC;
}

@font-face {
  font-family: "inscribe Pali";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../../fonts/Gentium-Regular.72eed903f486.woff2") format("woff2"),
    url("../../fonts/Gentium-Regular.f957acf5341c.ttf") format("truetype");
  unicode-range: U+0000-00FF, U+0100-024F, U+1E00-1EFF, U+0300-036F, U+2000-206F,
    U+200B-200D;
}

@font-face {
  font-family: "inscribe Pali";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("../../fonts/Gentium-Bold.7b986d61d604.woff2") format("woff2"),
    url("../../fonts/Gentium-Bold.fdb456ffdb9c.ttf") format("truetype");
  unicode-range: U+0000-00FF, U+0100-024F, U+1E00-1EFF, U+0300-036F, U+2000-206F,
    U+200B-200D;
}

@font-face {
  font-family: "inscribe Pali";
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url("../../fonts/Gentium-Italic.7b8f542bdd92.woff2") format("woff2"),
    url("../../fonts/Gentium-Italic.8732d83b88d8.ttf") format("truetype");
  unicode-range: U+0000-00FF, U+0100-024F, U+1E00-1EFF, U+0300-036F, U+2000-206F,
    U+200B-200D;
}

@font-face {
  font-family: "inscribe Pali";
  font-style: italic;
  font-weight: 700;
  font-display: swap;
  src: url("../../fonts/Gentium-BoldItalic.c1241cd253ed.woff2") format("woff2"),
    url("../../fonts/Gentium-BoldItalic.012d155963eb.ttf") format("truetype");
  unicode-range: U+0000-00FF, U+0100-024F, U+1E00-1EFF, U+0300-036F, U+2000-206F,
    U+200B-200D;
}

:root {
  --inscribe-font-thai: "Sarabun", "Thonburi", "Leelawadee UI", sans-serif;
  --inscribe-font-roman: "Gentium", "Times New Roman", Times, serif;
  --inscribe-font: "inscribe Pali", "Gentium", "Sarabun", serif;
  --inscribe-form-text-font-size: 1rem;
  /* Sarabun Thai at 1rem is optically larger than Latin. These match that body. */
  --inscribe-form-english-font-size: 1.0625rem;
  --inscribe-form-roman-font-size: 1.125rem;
  --w-font-sans: var(--inscribe-font);
}

html,
body,
button,
input,
select,
textarea {
  font-family: var(--inscribe-font);
}

/* Thai and English share line-height on every page. Letter-spacing stays normal. */
html:lang(th),
html:lang(en) {
  letter-spacing: normal;
  line-height: 1.8;
}

html:lang(th) :is(b, strong, h1, h2, h3, h4, h5, h6),
html:lang(en) :is(b, strong, h1, h2, h3, h4, h5, h6),
:lang(en),
:lang(pi-Latn),
.inscribe-roman {
  letter-spacing: normal;
  line-height: 1.8;
}

.Draftail-Editor,
.public-DraftEditor-content,
.w-field__input,
[contenteditable="true"] {
  font-family: var(--inscribe-font);
  line-height: 1.7;
}

/* ช่อง Body ใช้ขนาดเดียวกัน ทั้งตัวบทใน Draftail และเชิงอรรถใน textarea
   ห้ามใช้ em — Draftail ตั้ง 1.1875rem ที่ .DraftEditor-root ส่วน textarea สืบทอดจาก body 85% */
.w-field__input :is(textarea, [contenteditable="true"]),
.w-field__input .Draftail-Editor .DraftEditor-root {
  font-size: var(--inscribe-form-text-font-size);
}

/* Wagtail sets font-family on .DraftEditor-root. Name the mixed family here so
   rich text keeps Sarabun for Thai, the same stack as input and textarea. */
.w-field__input .Draftail-Editor .DraftEditor-root,
.w-field__input [contenteditable="true"] {
  font-family: var(--inscribe-font);
}

.inscribe-thai {
  font-family: var(--inscribe-font-thai);
}

/* Gentium only where the field opts in. Do not select every textarea via the
   admin document language (en-gb): that forced Gentium onto subheading,
   description, and other TextBlocks, and Gentium has no Thai glyphs. */
.w-field__input textarea.inscribe-roman,
.w-field__input textarea:lang(pi-Latn),
textarea#id_english,
textarea#id_pali_roman {
  font-family: var(--inscribe-font-roman);
  font-size: var(--inscribe-form-roman-font-size);
  line-height: 1.8;
}

.inscribe-roman,
:lang(pi-Latn) {
  font-family: var(--inscribe-font-roman);
}

@media print {
  html,
  body,
  button,
  input,
  select,
  textarea,
  .Draftail-Editor,
  .public-DraftEditor-content,
  [contenteditable="true"] {
    font-family: var(--inscribe-font);
  }

  .inscribe-thai {
    font-family: var(--inscribe-font-thai);
  }

  textarea.inscribe-roman,
  textarea:lang(pi-Latn),
  .inscribe-roman,
  :lang(pi-Latn) {
    font-family: var(--inscribe-font-roman);
  }
}
