/*
 * gp-site-fix 1.1.0 — 第 3 批：統一色彩與基本字（build-site-audit/DESIGN-system-v1.md 草案「收斂順序 1」＋AUDIT_ui-2026-11-19 第五節第 3 批）
 * 全站每頁載入，排在所有內嵌樣式與「額外 CSS」之後（gp-site-fix.php 在 wp_head 優先度 102 輸出）。
 * 舊來源（snippet #20／#21／#23、額外 CSS、palyul-color-a11y）大量用 !important 與高權重選擇器，這裡同樣要 !important。
 * 本檔只做：token 一份、Astra global colors 改暖、停用色拉回 token、連結朱紅、手機內文 16 與標題階層、手機頁邊 20、
 * 彙整／搜尋／404 標題換標題字與暖色。版面（卡片、列表、H1 外框）屬第 4 批，舊文字型與排版屬第 5 批，這裡不動。
 */

/* ---------- 1. token：唯一一份（值＝DESIGN-system-v1 color.*；名稱沿用 --gp-*，舊名指到同一個值）
 * html:root 權重高過各來源的 :root，所以不管誰後印都以這裡為準。 */
html:root {
	--gp-cp: #8B1A1A;
	--gp-cg: #C9A060;
	--gp-bg: #F7F4EF;
	--gp-bg-card: #FAF6EE;
	--gp-bg-tantra: #F0EBE0;
	--gp-wh: #FDFCFA;
	--gp-tx: #2C2420;
	--gp-meta-warm: #6B5E4A;
	--gp-border: #E4DFDA;
	--gp-strong: #5A3D00;
	/* 停用值（DESIGN color.retired）：名字留著讓舊規則不壞，值改指到 token */
	--gp-cg-a11y: var(--gp-cp);       /* #9E7B3C → 朱紅（連結） */
	--gp-meta: var(--gp-meta-warm);   /* #736B64 → #6B5E4A */
	--gp-tx-dark: var(--gp-tx);       /* #2C2C2C → #2C2420 */
	--gp-dark: var(--gp-tx);
	--gp-cg-deep: var(--gp-strong);   /* #8B6914 當字用時 → 強調色 */
	/* 額外 CSS、snippet #20／#21 的舊名 */
	--cp: var(--gp-cp);
	--cg: var(--gp-cg);
	--cg-a11y: var(--gp-cp);
	--bg: var(--gp-bg);
	--wh: var(--gp-wh);
	--tx: var(--gp-tx);
	--meta: var(--gp-meta-warm);
	--border: var(--gp-border);
	--gp-font-heading: "Iansui", "Noto Serif TC", "Songti TC", serif;
	--gp-font-body: -apple-system, BlinkMacSystemFont, "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
}
/* Astra global colors 0–8（DESIGN color.astra_palette）。頁尾 gp-footer/footer.css 用 :root:not(#_#_)（1-1-0）＋!important
 * 把 0、1、5 寫死成 #8B1A1A／#A32525／#F7F4EF；這裡 html:root:not(#_#_)（1-1-1）＋!important 才蓋得過，1 改回品牌色（hover 不換色）。 */
html:root:not(#_#_) {
	/* 預設藍與冷灰藍 → 暖色 token；部署時也要把外觀設定的全域色改成同值（README）。
	 * 0 連結／強調、1 hover（同色）、2 標題、3 內文、4 主要底、5 次要底（＝頁面底）、6 深色、7 框線、8 深色 */
	--ast-global-color-0: var(--gp-cp) !important;
	--ast-global-color-1: var(--gp-cp) !important;
	--ast-global-color-2: var(--gp-tx) !important;
	--ast-global-color-3: var(--gp-tx) !important;
	--ast-global-color-4: var(--gp-wh) !important;
	--ast-global-color-5: var(--gp-bg) !important;
	--ast-global-color-6: var(--gp-tx) !important;
	--ast-global-color-7: var(--gp-border) !important;
	--ast-global-color-8: var(--gp-tx) !important;
}

/* ---------- 2. 舊文行內字色拉回 token（DESIGN「舊文章對應表」的色那幾列；字型、版面留給第 5 批） */
.entry-content [style*="color:#2c2c2c" i],
.entry-content [style*="color: #2c2c2c" i] {
	color: var(--gp-tx) !important;
}
.entry-content [style*="color:#8b6914" i],
.entry-content [style*="color: #8b6914" i] {
	color: var(--gp-strong) !important;
}
.entry-content [style*="color:#9e7b3c" i],
.entry-content [style*="color: #9e7b3c" i],
.entry-content [style*="color:#736b64" i],
.entry-content [style*="color: #736b64" i] {
	color: var(--gp-meta-warm) !important;
}

/* 舊文行內的金色框線（左框提示 5px #8B6914、原文框以外的 2px／4px #D4A843）→ 裝飾金 token；框的形狀留給第 5 批 */
.entry-content [style*="#8b6914" i],
.entry-content [style*="#d4a843" i] {
	border-color: var(--gp-cg) !important;
}

/* ---------- 3. 連結：朱紅＋1px 底線，滑過 2px（DESIGN component.link）
 * 只管「沒有 class 的文字連結」：按鈕、卡片、圖示連結都有自己的 class，不會被改成紅字。 */
html body .entry-content a:not([class]):not(nav a),
html body .entry-content a:not([class]):not(nav a):visited {
	color: var(--gp-cp) !important;
	text-decoration-line: underline !important;
	text-decoration-thickness: 1px !important;
	text-underline-offset: 0.2em !important;
}
html body .entry-content a:not([class]):not(nav a):hover {
	color: var(--gp-cp) !important;
	text-decoration-thickness: 2px !important;
}
html body .entry-content a:not([class]):not(nav a):focus-visible {
	outline: 2px solid var(--gp-cp) !important;
	outline-offset: 2px !important;
}
/* 側欄（搜尋、分類）與文章 meta 裡的連結 */
html body #secondary .widget a:not([class]),
html body .entry-meta a {
	color: var(--gp-cp) !important;
}

/* ---------- 4. 日期與 meta：只剩日期（作者由 gp-site-fix.php 不輸出），色 meta、≥13px */
html body .entry-meta,
html body .entry-meta * {
	color: var(--gp-meta-warm) !important;
}
/* 字級照 DESIGN type.meta：文章與頁面桌機 14、<922 為 13。snippet #21 用 body.single-post .entry-meta *（0-2-1）＋.88rem!important
 * 把子元素（span.published）壓到 12.84px（手機 rem＝14.59），所以容器定值、子元素一律 inherit，權重拉到 id 層級。
 * 彙整卡片（首頁、分類、標籤、搜尋）的 meta 固定 13：卡片版面屬第 4 批，13 跟改前 Astra 給子元素的字級一樣，
 * 卡片封面圖連結與分類徽章的間距維持改前（14 會把徽章撐高，1024 寬間距從 8.34 變 7.75 <8）。 */
html body:not(#_#_) .entry-meta {
	font-size: 13px !important;
	font-weight: 400 !important;
}
html body:not(#_#_) .entry-meta * {
	font-size: inherit !important;
	font-weight: inherit !important;
}
html body:is(.single-post, .page):not(#_#_) .entry-meta {
	font-size: 14px !important;
}
@media (max-width: 921px) {
	html body:is(.single-post, .page):not(#_#_) .entry-meta {
		font-size: 13px !important;
	}
}

/* ---------- 5. 標題字與暖色：彙整、搜尋、404 的 H1 也用標題字 700（外框與對齊屬第 4 批） */
html body .ast-archive-title,
html body .ast-archive-description .page-title,
html body.error404 .page-title,
html body.search .page-title {
	font-family: var(--gp-font-heading) !important;
	font-weight: 700 !important;
	color: var(--gp-tx) !important;
}
/* 404 的說明句（Astra 用 h3.page-sub-title 輸出）是說明文字，不是標題：照內文字（不然手機上它跟 H1 只差 1.19 倍） */
html body.error404 .page-sub-title {
	font-family: var(--gp-font-body) !important;
	font-weight: 400 !important;
	font-size: 16.8px !important;
	line-height: 1.8 !important;
	color: var(--gp-tx) !important;
}
/* 斷行看句子（DESIGN 元件清單「頁面標題下的說明句」）：gp-site-fix.php 把每一句包成 .gp-sub-line、句內逗號段包成 .gp-sub-clause。
 * 一句一行；一句放不下時只在逗號後斷（相鄰不斷行段的交界）。不用 text-wrap: balance（390 寬會把「已經」拆開）。 */
html body.error404 .page-sub-title .gp-sub-line {
	display: block;
}
html body.error404 .page-sub-title .gp-sub-clause {
	white-space: nowrap;
}
@media (max-width: 921px) {
	html body.error404 .page-sub-title {
		font-size: 16px !important;
	}
}
html body .entry-title,
html body .entry-title a,
html body .entry-content :is(h1, h2, h3, h4, h5, h6) {
	color: var(--gp-tx) !important;
}

/* ---------- 6. 手機（Astra 頁首切成手機版的寬度 <922）
 * 內文 16px；標題階層 H1 26／H2 20／H3 17（每級 ≥1.25／≥1.15／≥1.05 倍，DESIGN type 的階層規則）；
 * 頁邊（DESIGN container.page_inset_mobile，2026-11-19 裁定）：內文欄寬＝min(該頁欄上限, 視窗寬−40)，置中；
 *   手機算出來左右各 20＝頁首 logo 左緣，平板上欄上限比視窗窄時欄置中，不貼左。 */
@media (max-width: 921px) {
	/* 頁面專用元件（關於頁導言 .gpa-lead 等，有 class 的段落）自己定字級，不動 */
	html body.single-post .entry-content,
	html body.page .entry-content,
	html body.single-post .entry-content p:not([class]),
	html body.page .entry-content p:not([class]) {
		font-size: 16px !important;
		line-height: 1.8 !important;
	}
	html body.single-post .entry-title,
	html body.page .entry-title,
	html body .ast-archive-title,
	html body.error404 .page-title {
		font-size: 26px !important;
		line-height: 1.4 !important;
	}
	/* 關於、聯絡頁的 gpa-h2／gp-h2 也照這組（DESIGN：H2 20、H3 17，H2 要 ≥1.15×H3 才分得開） */
	html body.single-post .entry-content h2,
	html body.page .entry-content h2 {
		font-size: 20px !important;
		line-height: 1.45 !important;
	}
	html body.single-post .entry-content :is(h3, h4),
	html body.page .entry-content :is(h3, h4),
	/* 文章內小標：palyul-seo-perf 把 H3 升成 H2、桌機畫成 H3 尺寸（它的選擇器 0-3-2 比上面那條高）；
	 * 手機也照 H3 角色＝17（DESIGN type 註記）。選擇器照它的寫法再加 html 拉高權重。 */
	html body.single-post .entry-content > h2.wp-block-heading,
	html body.single-post .entry-content h2.gp-section-title {
		font-size: 17px !important;
		line-height: 1.5 !important;
	}

	/* 頁邊：容器左右 20（＝視窗寬−40 的那一側），內層（#primary、內文欄）不再另加內距；
	 * 文章（含頁名、內文、上一篇／下一篇）整欄＝min(欄上限, 可用寬)，置中。 */
	html body.single-post .site-content .ast-container,
	html body.page .site-content .ast-container {
		padding-left: 20px !important;
		padding-right: 20px !important;
	}
	html body.single-post #primary,
	html body.page #primary,
	html body.single-post .entry-content,
	html body.page .entry-content {
		padding-left: 0 !important;
		padding-right: 0 !important;
		margin-left: 0 !important;
		margin-right: 0 !important;
	}
	/* 欄上限：文章＝閱讀欄 750（DESIGN container.reading）；一般頁面＝frame_page 944；
	 * 關於頁單欄時正文段落上限 38em（about-page.css，字 16px＝608px），欄跟著它 */
	html body.single-post {
		--gp-col-max: 750px;
	}
	html body.page {
		--gp-col-max: 944px;
	}
	html body.page:has(.entry-content > .gpa) {
		--gp-col-max: 608px;
	}
	html body.single-post #primary article.post,
	html body.page #primary article.page {
		width: 100% !important;
		max-width: var(--gp-col-max) !important;
		padding-left: 0 !important;
		padding-right: 0 !important;
		margin-left: auto !important;
		margin-right: auto !important;
	}
}
/* 關於頁頂端跳轉列：about-page.css 讓每個連結左右各加 6px 可點範圍、整列往外退 6px（字左緣對齊段落）。
 * 頁邊不到 22 時（欄 608 置中：視窗 <652；更窄時欄＝視窗寬−40、頁邊 20），往外退 6 會讓可點範圍離視窗邊不到 16（最少 14）；
 * 改退 4，可點範圍離邊 ≥16、字仍在頁邊。
 * 連結之間的字距照原公式（欄距＝1.25em−2×可點內距）不變。 */
@media (max-width: 651px) {
	html body .entry-content .gpa {
		--gpa-jump-pad: 4px;
	}
}
