@charset "UTF-8";

/**
 * Page-side half of `<han-console>`'s module switches.
 *
 * `console-config.js` § applyModules撥三個模組的 han.css 旗標（semantics /
 * lines / prose），並把每個模組的開關狀態鏡射成 `<html>` 上的
 * `data-han-module-*="off"`。旗標寫得到 `:root` 的模組在那邊就結束了；寫不到
 * 的落在這裡。
 *
 * 兩條。`prose.css` 刻意把 `--han-prose: on` 種在
 * `:where(article)` 而不是 `:root`（讓作者能用 `section.prose { --han-prose:
 * on }` 擴充、用 `.demo { --han-prose: off }` 退出），所以 `:root` 上的
 * `off` 傳不進 `<article>` —— 必須在 `article` 這一層蓋掉。特異性
 * (0,1,1) > `:where(article)` 的 (0,0,0)，穩定勝出。
 *
 * 兩邊都要 import（home.css 與 manual.css）：兩種頁面都掛得起
 * `<han-console>`（_home.html 的 form="side"、_layout.html 的 form="top"）。
 * 照 manual.css 檔頭的規矩，兩張表各自 import 共用 partial，不互相 import。
 */

:root[data-han-module-prose='off'] article {
  --han-prose: off;
}

/**
 * lines：把擠壓交還給瀏覽器,而不是連它一起關掉。
 *
 * 開關撥的 `--han-punctuation-refinement: none` 在 han.css 裡會落到
 * `text-spacing-trim: space-all` —— 那對公開 API 是對的（作者說「完全不要
 * 擠壓」),但拿來當「這行 import 不存在」就關過頭了:Chromium 的 UA 預設是
 * `normal`,本來就會擠。實測 12 字探針（`「東京」（都）、〈甲〉。`,100px）:
 * 沒 import 1000px、`space-all` 1200px、han.css 的 `trim-start` 950px。
 * 少了這條,預覽會把瀏覽器原生做的事也算進 han.css 的功勞裡。
 *
 * `revert` 而不是硬寫 `normal`:語意就是「移除 author origin」,正是開關要
 * 表達的東西,也不押注 Chromium 今天的預設值。
 *
 * `&` 那半不可省 —— 這是實測踩出來的。`text-spacing-trim` 是繼承屬性,而
 * `:root[…] :where(*)` 是後代選擇器,`<html>` 不是自己的後代:少了 `&`,
 * `:root` 會留著 han.css 的 `trim-start`,後代的 `revert` 對繼承屬性等於
 * 「回到父層的值」,於是整棵樹又把 `trim-start` 繼承回去（量到 950px,比
 * 不補還糟）。補上 `&` 之後 `<html>` 先 revert 成 UA 的 `normal`,後代再
 * revert 就繼承到 `normal`。
 */
:root[data-han-module-lines='off'] {
  &,
  :where(*) {
    text-spacing-trim: revert;
  }
}

/* These reading surfaces have editorial faces until the reader chooses roles.
   Scope the overrides to the live pages so the reader dialog and type samples
   can continue to demonstrate their selected faces independently. */
:root[data-font-roles] {
  main,
  .ManualPage main > article,
  .ManualPage main > article > h1,
  .Dispatch > :is([data-prose], article),
  .Dispatch > [data-part='lead'] > [data-prose],
  .PassageView .Specimen,
  .Galley {
    font-family: var(--han-font-default);
  }
}
