/* Thai-only web fonts: Chinese and Latin retain the page's existing fallbacks. */
@font-face {
  font-family: "Thai Course Serif";
  src: url("./fonts/NotoSerifThai-thai-v28.woff2") format("woff2");
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  unicode-range: U+02D7, U+0303, U+0331, U+0E01-0E5B, U+200C-200D, U+25CC;
}

@font-face {
  font-family: "Thai Course Looped";
  src: url("./fonts/NotoSansThaiLooped-thai-v16.woff2") format("woff2");
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  unicode-range: U+02D7, U+0303, U+0331, U+0E01-0E5B, U+200C-200D, U+25CC;
}

@font-face {
  font-family: "Thai Course Sarabun";
  src: url("./fonts/Sarabun-thai-400-v17.woff2") format("woff2");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  unicode-range: U+02D7, U+0303, U+0331, U+0E01-0E5B, U+200C-200D, U+25CC;
}

@font-face {
  font-family: "Thai Course Sarabun";
  src: url("./fonts/Sarabun-thai-700-v17.woff2") format("woff2");
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  unicode-range: U+02D7, U+0303, U+0331, U+0E01-0E5B, U+200C-200D, U+25CC;
}

@font-face {
  font-family: "Thai Course Prompt";
  src: url("./fonts/Prompt-thai-400-v12.woff2") format("woff2");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  unicode-range: U+02D7, U+0303, U+0331, U+0E01-0E5B, U+200C-200D, U+25CC;
}

@font-face {
  font-family: "Thai Course Prompt";
  src: url("./fonts/Prompt-thai-700-v12.woff2") format("woff2");
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  unicode-range: U+02D7, U+0303, U+0331, U+0E01-0E5B, U+200C-200D, U+25CC;
}

:root { --thai-course-font: "Thai Course Serif"; }
:root[data-thai-font="looped"] { --thai-course-font: "Thai Course Looped"; }
:root[data-thai-font="sarabun"] { --thai-course-font: "Thai Course Sarabun"; }
:root[data-thai-font="prompt"] { --thai-course-font: "Thai Course Prompt"; }

html:not([data-thai-font="system"]) body {
  font-family: var(--thai-course-font), Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

html:not([data-thai-font="system"]) :is(
  [lang="th"], .transcript-line b, .thai-line, .thai-sentence,
  .word-item b, .example b, footer b, .thai-chip__main,
  .thai-chip b, .sentence-thai, .lexicon-thai, .review-thai,
  .prompt, .lesson-item strong, .thai
) {
  font-family: var(--thai-course-font), "Noto Sans Thai", "PingFang SC", "Microsoft YaHei", sans-serif;
}

html[data-thai-font="system"] :is(
  [lang="th"], .transcript-line b, .thai-line, .thai-sentence,
  .word-item b, .example b, footer b, .thai-chip__main,
  .thai-chip b, .sentence-thai, .lexicon-thai, .review-thai,
  .prompt, .lesson-item strong, .thai
) {
  font-family: system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
}

#thai-font-switcher { position: fixed; z-index: 9998; left: 12px; bottom: calc(88px + env(safe-area-inset-bottom, 0px)); font: 14px/1.4 system-ui, -apple-system, sans-serif; }
#thai-font-switcher * { box-sizing: border-box; }
#thai-font-switcher [hidden] { display: none !important; }
#thai-font-trigger { min-height: 42px; padding: 8px 13px; border: 1px solid #d3e0d4; border-radius: 999px; background: #fffdf8; color: #235743; box-shadow: 0 4px 16px #17392e25; font: 700 13px/1.4 system-ui, -apple-system, sans-serif; cursor: pointer; }
#thai-font-trigger { touch-action: none; user-select: none; -webkit-user-select: none; }
#thai-font-trigger::before { content: "⋮"; margin-right: 3px; opacity: .58; }
#thai-font-trigger:focus-visible, #thai-font-switcher button:focus-visible { outline: 3px solid #edac35; outline-offset: 2px; }
#thai-font-menu { position: absolute; left: 0; bottom: 50px; width: min(320px, calc(100vw - 24px)); max-height: min(65vh, 480px); overflow-y: auto; padding: 14px; border: 1px solid #dbe5d9; border-radius: 18px; background: #fffdf8; color: #1e3029; box-shadow: 0 14px 40px #17392e36; }
#thai-font-menu h2 { margin: 0 0 4px; font: 750 17px/1.4 system-ui, -apple-system, sans-serif; }
#thai-font-menu p { margin: 0 0 10px; color: #69766d; font-size: 12px; }
#thai-font-menu .thai-font-option { display: flex; align-items: center; justify-content: space-between; gap: 9px; width: 100%; min-height: 52px; margin-top: 6px; padding: 8px 10px; border: 1px solid #e2e9df; border-radius: 11px; background: #fff; color: #263a30; text-align: left; cursor: pointer; }
#thai-font-menu .thai-font-option[aria-pressed="true"] { border-color: #257054; background: #eaf4eb; }
#thai-font-menu .thai-font-option-name { flex: 1; font: 650 13px/1.3 system-ui, -apple-system, sans-serif; }
#thai-font-menu .thai-font-sample { font-size: 21px; white-space: nowrap; }
#thai-font-menu [data-font-option="serif"] .thai-font-sample { font-family: "Thai Course Serif", sans-serif; }
#thai-font-menu [data-font-option="looped"] .thai-font-sample { font-family: "Thai Course Looped", sans-serif; }
#thai-font-menu [data-font-option="sarabun"] .thai-font-sample { font-family: "Thai Course Sarabun", sans-serif; }
#thai-font-menu [data-font-option="prompt"] .thai-font-sample { font-family: "Thai Course Prompt", sans-serif; }
#thai-font-menu [data-font-option="system"] .thai-font-sample { font-family: system-ui, -apple-system, sans-serif; }
