/* ---------------------------------------------------------------------------
 * 客戶提供字型（自架）。前後台共用同一份。
 *
 * 前台：後台「網站設定 → Css」貼一行 <link> 引用本檔（_Layout.cshtml:154 會原樣輸出）
 * 後台：Startup.cs 以 Manager Module Styles 註冊，讓編輯器所見即所得
 *
 * 字型來源：NotoSansCJK.ttc face[15]/face[27]（Noto Sans CJK TC Regular/Bold）
 *           BarlowSemiCondensed-Medium.ttf
 * 授權：兩者皆為 SIL Open Font License 1.1（字型檔 nameID 13）
 * 子集：Big5 甲表常用國字 5,401 字 + 標點/英數/注音/全形符號（共 6,049 字碼）
 *
 * family name 刻意與站上既有的 Google Fonts 'Noto Sans TC' 區隔，兩者不同 build。
 * ------------------------------------------------------------------------- */

/* === 1. 中文：Noto Sans CJK TC ============================================
 * 本身含完整拉丁字母，套在中英混排上英文不會掉字，不必補 fallback。
 * ------------------------------------------------------------------------- */
@font-face {
    font-family: 'Noto Sans CJK TC';
    src: url('../fonts/NotoSansCJKtc/NotoSansCJKtc-Regular.woff2') format('woff2');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Noto Sans CJK TC';
    src: url('../fonts/NotoSansCJKtc/NotoSansCJKtc-Bold.woff2') format('woff2');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

/* === 2. 英文：Barlow Semi Condensed =======================================
 * 依主管指定，內文字重使用 Medium（usWeightClass 500），宣告為 CSS 400。
 *
 * 客戶另外提供的 Regular（usWeightClass 400）已一併轉為 woff2 備妥於
 * fonts/BarlowSemiCondensed/BarlowSemiCondensed-Regular.woff2，目前未啟用。
 * 要改用 Regular 當內文只需把下面的 src 換成該檔。
 *
 * 已知限制：沒有 700 的真字面，編輯器按粗體時是瀏覽器合成的假粗體。
 * 正解是向客戶索取 -SemiBold / -Bold，補上一組 font-weight: 700 的 @font-face。
 * ------------------------------------------------------------------------- */
@font-face {
    font-family: 'Barlow Semi Condensed';
    src: url('../fonts/BarlowSemiCondensed/BarlowSemiCondensed-Medium.woff2') format('woff2');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

/* === 3. 子元素繼承修正 ====================================================
 * assets/sass/inc/_share.sass:9 有一條 `*{ font-family:'Noto Sans TC',… }`。
 * 編輯器產生的是 <span style="font-family:…">，span 本身靠 inline style 取勝，
 * 但 span 內的 <strong>/<a>/<em> 會被 `*` 打回預設字體。這條讓子元素繼承父層。
 *
 * :not([style*="font-family"]) 是必要的 —— 否則巢狀、且自己另外指定字型的
 * 子元素會被強制吃掉父層字型。
 *
 * 刻意不綁容器 class：編輯器內容散佈在 14 個 block 樣板（HtmlBlock、BoxBlock、
 * CardBlock 1~3、CustomColumnBlock、Slider* …），外層 class 各不相同，沒有共同
 * 祖先可以 scope。改鎖 inline style 屬性本身 —— 帶 inline font-family 的元素
 * 只有後台編輯器會產生，不會誤傷版型。
 * ------------------------------------------------------------------------- */
[style*="font-family"] *:not([style*="font-family"]) {
    font-family: inherit !important;
}

/* === 4. 英文字型的中文 fallback ===========================================
 * Barlow Semi Condensed 是純拉丁字型（僅 335 個字碼，無任何中文字形）。
 * 編輯器只會寫出單一 family：font-family: "Barlow Semi Condensed";
 * 中文字因此會掉到瀏覽器預設 CJK 字體（細明體 / PingFang），很難看。
 *
 * 這裡用屬性選擇器攔截，補上 CSS 標準的逐字元 fallback 鏈：
 * 英數 → Barlow，中文 → Noto Sans CJK TC。
 *
 * 不把堆疊直接寫進 Summernote 下拉選單的原因（summernote-bs4.js）：
 *   5505 行 選單預覽把整個字串用單引號包住，逗號堆疊會讓預覽失效
 *   5483 行 工具列重繪時會把 font-family 拆逗號、逐段塞回選單，造成選單長垃圾
 *   5924 行 只取堆疊第一個名字比對，打勾狀態永遠對不上
 *
 * 必須排在第 3 節之後：兩者特異性相同，讓本規則勝出，
 * 使「自己帶字型的子元素」仍能取得完整 fallback 鏈。
 * ------------------------------------------------------------------------- */
[style*="Barlow Semi Condensed"] {
    font-family: "Barlow Semi Condensed", "Noto Sans CJK TC", sans-serif !important;
}
