/*
 * gp-site-fix 1.3.0 — 第 5 批：舊文全站拉齊（build-site-audit/SPEC_ui-batch5-legacy-map.md 第三節對應表；2026-11-20【修訂二】M1–M5、H1 例外、B4①②）
 * 只在單篇文章頁載入（gp-site-fix.php：is_singular('post')，wp_head 優先度 104，排在 site-fix-3.css、site-fix-table.css 之後）；
 * 選擇器一律以 html body.single-post .entry-content 開頭，就算被別的頁面載入也只吃文章內文。
 * 舊文行內樣式（Facebook 匯入範本）用 style 屬性子字串辨識（規格第二節識別字串，不分大小寫）；行內樣式要 !important 才蓋得過。
 * 按鈕（.wp-block-button__link、.palyul-btn-*）、卡片樣板屬第 4 批，這裡不動。
 * 色、字型 token 沿用 site-fix-3.css 的 --gp-*；下面 --gp5-* 是 DESIGN-system-v1 的字級、間距、圓角值（type.body／type.meta／space／radius.card）。
 */

html body.single-post {
	--gp5-body: 16.8px;   /* type.body（<922 為 16） */
	--gp5-meta: 14px;     /* type.meta（<922 為 13） */
	--gp5-h-in: 20.8px;   /* 文章內小標＝type.h3（<922 為 17） */
	--gp5-s1: 4px;        /* S1 同一組：space.1 */
	--gp5-s2: 12px;       /* S2 同層：space.3（圖庫格距同值） */
	--gp5-s3: 32px;       /* S3 分組：space.6（<922 縮到 24＝space.5） */
	--gp5-radius: 8px;    /* radius.card */
	--gp5-col: 750px;     /* container.reading */
}
@media (max-width: 921px) {
	html body.single-post {
		--gp5-body: 16px;
		--gp5-meta: 13px;
		--gp5-h-in: 17px;
		--gp5-s3: 24px;
	}
}

/* ---------- 閱讀欄與單一外緣（規格第四節、6.1）
 * 區塊編輯器的新文：Astra 在內文欄加 data-ast-blocks-layout，每個直系子元素 max-width 750 置中（新文本來就在 345–1095）。
 * 傳統編輯器的舊文沒有這個屬性，子元素撐滿 944 欄（248–1192）。這裡給舊文同一條規則：直系子元素（含搬進來的上一篇／下一篇）
 * 寬 ≤ 閱讀欄、置中；新文不吃（:not([data-ast-blocks-layout])），版面不變。<922 欄本來就 ≤750（第 3 批頁邊公式），這條不起作用。
 * 行內 margin（圖庫 20px 0、資訊框 22px 0）會把左右外距寫成 0，所以要 !important。 */
html body.single-post .entry-content:not([data-ast-blocks-layout]) > * {
	max-width: var(--gp5-col) !important;
	margin-left: auto !important;
	margin-right: auto !important;
}

/* 區塊文章裡沒包進區塊的行內樣式表格（2026 資訊表 S19，例：8266；寫了 margin:20px 0，蓋掉 Astra 的置中）：
 * 跟其他直系子元素同一條外緣（寬＝閱讀欄、置中；DESIGN「表格 寬＝閱讀欄」）。site-fix-table.css 用 :not(#_#_) 把它設成 max-width 100%、margin 0，
 * 這裡權重再高一層，只改左右外距與寬上限（上下外距照資訊表規格）。 */
html body.single-post .entry-content > table:not(#_#_#_) {
	max-width: var(--gp5-col) !important;
	margin-left: auto !important;
	margin-right: auto !important;
}

/* ---------- F1 字型：行內 Noto Serif TC → font.body（標題不在這裡，維持 Iansui） ---------- */
html body.single-post .entry-content [style*="noto serif tc" i]:not(h1, h2, h3, h4, h5, h6) {
	font-family: var(--gp-font-body) !important;
}

/* ---------- P1 段落行高 1.9 → 1.8（段距維持全站值） ---------- */
html body.single-post .entry-content [style*="line-height:1.9" i],
html body.single-post .entry-content [style*="line-height: 1.9" i] {
	line-height: 1.8 !important;
}

/* ---------- L1② 標題框 → 導言行；L2 第二行 → meta ---------- */
html body.single-post .entry-content div[style*="5px solid #8b6914" i] {
	background: transparent !important;
	border: 0 !important;
	border-radius: 0 !important;
	padding: 0 !important;
	margin-top: 0 !important;
	margin-bottom: var(--gp5-s2) !important;
	box-shadow: none !important;
}
html body.single-post .entry-content div[style*="5px solid #8b6914" i] > p {
	font-family: var(--gp-font-body) !important;
	font-size: var(--gp5-body) !important;
	font-weight: 700 !important;
	font-style: normal !important;
	line-height: 1.8 !important;
	color: var(--gp-strong) !important;
	margin: 0 !important;
	padding: 0 !important;
}
html body.single-post .entry-content div[style*="5px solid #8b6914" i] > p ~ p,
html body.single-post .entry-content div[style*="5px solid #8b6914" i] > p[style*="font-size:0.85em" i] {
	font-size: var(--gp5-meta) !important;
	font-weight: 400 !important;
	line-height: 1.6 !important;
	color: var(--gp-meta-warm) !important;
}
html body.single-post .entry-content div[style*="5px solid #8b6914" i] > p ~ p {
	margin-top: var(--gp5-s1) !important;
}

/* ---------- H1 文章內小標＝新文 h2.wp-block-heading 同一種（規格 2026-11-20 修訂：第三節 H1 列＋「選擇器範圍」【修訂】條）
 * 套的：H2 本身沒有 class 或只有 wp-block-heading（含舊文小標 S16、h3 被 SEO 外掛升成 h2 後沒有 class 的 2026 小標，原本吃主題 H2 的 25.6／20）；
 * 不套的：H2 帶別的 class（gp-section-title 由 H2 列管）、或 H2 到 .entry-content 之間有元件祖先——任何帶 class 的元素
 *   （只有 wp-block-group 的群組不算元件，照套）、.palyul-cta-box、資訊框、引言框、表格、figure。
 * 已知限制：wp-block-group 另外帶自訂 class（.palyul-cta-box 以外）時 CSS 分不出來，會照套（2026-11-20 抽樣 22 篇沒有這種）。 ---------- */
html body.single-post .entry-content h2:is(:not([class]), [class="wp-block-heading"]):not(:is(.entry-content [class]:not(.wp-block-group), .entry-content .palyul-cta-box, .entry-content div[style*="4px solid #d4a843" i], .entry-content blockquote, .entry-content table, .entry-content figure) h2) {
	font-family: var(--gp-font-heading) !important;
	font-size: var(--gp5-h-in) !important;
	font-weight: 700 !important;
	line-height: 1.45 !important;
	color: var(--gp-tx) !important;
	border-top: 1px solid var(--gp-border) !important;
	border-bottom: 0 !important;
	padding: 1.5rem 0 0 !important;
	margin-top: 2rem !important;
	margin-bottom: 1rem !important;
}
@media (max-width: 921px) {
	html body.single-post .entry-content h2:is(:not([class]), [class="wp-block-heading"]):not(:is(.entry-content [class]:not(.wp-block-group), .entry-content .palyul-cta-box, .entry-content div[style*="4px solid #d4a843" i], .entry-content blockquote, .entry-content table, .entry-content figure) h2) {
		line-height: 1.5 !important;
	}
}
/* H2【修訂二】.gp-post 裡的 h2.gp-section-title（8300「完整學程課目」）：完全同 H1（字級、字型、色、只留上方 1px 線、間距） */
html body.single-post .entry-content .gp-post :is(h2, h3).gp-section-title {
	font-family: var(--gp-font-heading) !important;
	font-size: var(--gp5-h-in) !important;
	font-weight: 700 !important;
	line-height: 1.45 !important;
	letter-spacing: normal !important;
	color: var(--gp-tx) !important;
	border-top: 1px solid var(--gp-border) !important;
	border-bottom: 0 !important;
	padding: 1.5rem 0 0 !important;
	margin-top: 2rem !important;
	margin-bottom: 1rem !important;
}
@media (max-width: 921px) {
	html body.single-post .entry-content .gp-post :is(h2, h3).gp-section-title {
		line-height: 1.5 !important;
	}
}

/* H1 例外【修訂二】：內文第一個內容就是小標（8292 開頭）→ 不畫上線、上內距與上外距 0（上面已有標題區的分隔線）。
 * 第 5 批 PHP 把「跟頁名相同的標題框」整個不輸出（L1①），所以「第一個看得到的」＝第一個元素。 */
html body.single-post .entry-content > h2:first-child:is(:not([class]), [class="wp-block-heading"]):not(#_#_) {
	border-top: 0 !important;
	padding-top: 0 !important;
	margin-top: 0 !important;
}

/* ---------- B1–B4 提示框元件：surface_alt 底、左 4px 裝飾金、右側圓角 8、無投影、無上框線、前後 S3 ---------- */
html body.single-post .entry-content div[style*="4px solid #d4a843" i],
html body.single-post .entry-content blockquote[style*="#d4a843" i],
html body.single-post .entry-content p[style*="#0284c7" i],
html body.single-post .entry-content .palyul-cta-box,
html body.single-post .entry-content .gp-post :is(.gp-info-table, .gp-fb-footer) {
	background: var(--gp-bg-card) !important;
	border: 0 !important;
	border-left: 4px solid var(--gp-cg) !important;
	border-radius: 0 var(--gp5-radius) var(--gp5-radius) 0 !important;
	box-shadow: none !important;
	margin-top: var(--gp5-s3) !important;
	margin-bottom: var(--gp5-s3) !important;
}
/* B4 是內文最後一塊、緊接上一篇／下一篇時，site-fix.css 拿掉它的下內距（原本看不見的空白）；
 * 現在框有底色，下內距看得見，照提示框補回 16（下外距仍是 0，框→上一篇／下一篇只由 nav 的上外距決定）。 */
html body.single-post .entry-content > .palyul-cta-box:has(+ nav.gp-post-nav):not(#_) {
	padding-bottom: 16px !important;
}
/* 內距照資訊表規格（16／22，框寬 <372 時 16；site-fix-table.css 已給資訊框 S12，這裡給其他三種同一條算式） */
html body.single-post .entry-content blockquote[style*="#d4a843" i],
html body.single-post .entry-content p[style*="#0284c7" i],
html body.single-post .entry-content .palyul-cta-box,
html body.single-post .entry-content .gp-post :is(.gp-info-table, .gp-fb-footer) {
	padding-top: 16px !important;
	padding-bottom: 16px !important;
	padding-left: calc(16px + clamp(0px, (100% - 371.99px) * 1000, 6px)) !important;
	padding-right: calc(16px + clamp(0px, (100% - 371.99px) * 1000, 6px)) !important;
}
/* B4①【修訂二】框裡只有按鈕、沒有任何文字（8621「立即報名」）→ 不畫框：沒有底色、沒有左線、內距 0；前後外距仍是 S3。
 * 權重壓過上面「緊接上一篇／下一篇補回下內距 16」那條（:not(#_)）。 */
html body.single-post .entry-content .palyul-cta-box:has(> .wp-block-buttons):not(:has(> :not(.wp-block-buttons))):not(#_#_) {
	background: transparent !important;
	border-left: 0 !important;
	border-radius: 0 !important;
	padding: 0 !important;
}
/* B4②【修訂二】提示框裡第一個元素是 H2（8300「招生說明會」）→ 當框標題：上線、上內距、上外距 0；字級、顏色不動 */
html body.single-post .entry-content :is(div[style*="4px solid #d4a843" i], blockquote[style*="#d4a843" i], .palyul-cta-box, .gp-info-table, .gp-fb-footer) > h2:first-child:not(#_#_) {
	border-top: 0 !important;
	padding-top: 0 !important;
	margin-top: 0 !important;
}
/* 框內上下視覺空白相等：框裡最後一個元素不帶下外距（REVIEW「之後再說」第 2 條，併在 M2／M5 驗） */
html body.single-post .entry-content .gp-post :is(.gp-info-table, .gp-fb-footer) > :last-child,
html body.single-post .entry-content .gp-post :is(.gp-info-table, .gp-fb-footer) > :last-child > :last-child {
	margin-bottom: 0 !important;
}

/* M1【修訂二】.gp-post 外層（8300 整篇）＝舊文內文外層 S5：不畫框；裡面所有字換 font.body（標題 h1–h6 不在內，維持 Iansui）；
 * M4 課程卡 .gp-card 的字也在這條裡，卡的底色、左線、圓角、膠囊形狀與各自字級、字重、顏色不動。 */
html body.single-post .entry-content .gp-post {
	background: transparent !important;
	border: 0 !important;
	box-shadow: none !important;
	padding: 0 !important;
}
html body.single-post .entry-content .gp-post :not(h1, h2, h3, h4, h5, h6, :is(h1, h2, h3, h4, h5, h6) *) {
	font-family: var(--gp-font-body) !important;
}
/* P1：段落行高 1.8、段落之間＝新文同一個值（實量新文 8621 段後 20／21＝1.25em；.gp-post 自己寫的 14px 拿掉） */
html body.single-post .entry-content .gp-post p {
	line-height: 1.8 !important;
}
html body.single-post .entry-content .gp-post > p,
html body.single-post .entry-content .gp-post > div:not([class]) > p {
	margin-bottom: 1.25em !important;
}
/* M2【修訂二】.gp-banner → 導言行（同 L1②）：透明、無線、黑體 700、neutral.strong、字級＝內文、左緣＝內文、到下一塊 S2 */
html body.single-post .entry-content .gp-post .gp-banner {
	background: transparent !important;
	border: 0 !important;
	border-radius: 0 !important;
	box-shadow: none !important;
	padding: 0 !important;
	margin: 0 0 var(--gp5-s2) !important;
}
html body.single-post .entry-content .gp-post .gp-banner,
html body.single-post .entry-content .gp-post .gp-banner p {
	font-size: var(--gp5-body) !important;
	font-weight: 700 !important;
	font-style: normal !important;
	line-height: 1.8 !important;
	color: var(--gp-strong) !important;
}
html body.single-post .entry-content .gp-post .gp-banner p {
	margin: 0 !important;
	padding: 0 !important;
}

/* B2 引言框：不斜體、內文色、內文字級 */
html body.single-post .entry-content blockquote[style*="#d4a843" i],
html body.single-post .entry-content blockquote[style*="#d4a843" i] * {
	font-style: normal !important;
	color: var(--gp-tx) !important;
}
html body.single-post .entry-content blockquote[style*="#d4a843" i] {
	font-size: var(--gp5-body) !important;
}
/* B3 2026 藍色提示：冷藍三色拿掉，字 text 600 */
html body.single-post .entry-content p[style*="#0284c7" i] {
	color: var(--gp-tx) !important;
	font-weight: 600 !important;
}

/* ---------- I1、I2 圖片：圓角 8、無投影、寬不超過閱讀欄；emoji 不套 ---------- */
html body.single-post .entry-content img:not(.emoji) {
	border-radius: var(--gp5-radius) !important;
	box-shadow: none !important;
	max-width: 100% !important;
}
html body.single-post .entry-content figure {
	max-width: 100% !important;
}
/* 單張圖（行內樣式的舊文圖，不在圖庫裡）：前後 S3 */
html body.single-post .entry-content figure:has(> img[style*="border-radius:4px" i]):not(div[style*="minmax(280px" i] figure) {
	margin-top: var(--gp5-s3) !important;
	margin-bottom: var(--gp5-s3) !important;
}

/* ---------- I3 圖說：黑體 400、meta 字級與色、不斜體、置中；圖→圖說 S1 ---------- */
html body.single-post .entry-content figcaption[style*="italic" i] {
	font-family: var(--gp-font-body) !important;
	font-size: var(--gp5-meta) !important;
	font-weight: 400 !important;
	font-style: normal !important;
	line-height: 1.6 !important;
	color: var(--gp-meta-warm) !important;
	text-align: center !important;
	padding: 0 !important;
	margin: var(--gp5-s1) 0 0 !important;
}

/* ---------- G1–G3 圖庫：寬＝閱讀欄、每欄 ≥280、格距 12、前後 S3；內嵌的 .wp-block-gallery 併進同一組格子 ---------- */
html body.single-post .entry-content div[style*="minmax(280px" i] {
	display: grid !important;
	grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr)) !important;
	gap: var(--gp5-s2) !important;
	align-items: start !important;
	width: auto !important;
	margin-top: var(--gp5-s3) !important;
	margin-bottom: var(--gp5-s3) !important;
}
/* G2：包在舊圖庫裡的 .wp-block-gallery 不再自成一格，它的照片直接排進外層格子 */
html body.single-post .entry-content div[style*="minmax(280px" i] > .wp-block-gallery {
	display: contents !important;
}
/* G3：單獨的 .wp-block-gallery 用同一組格子 */
html body.single-post .entry-content .wp-block-gallery:not(div[style*="minmax(280px" i] > .wp-block-gallery) {
	display: grid !important;
	grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr)) !important;
	gap: var(--gp5-s2) !important;
	align-items: start !important;
	margin-top: var(--gp5-s3) !important;
	margin-bottom: var(--gp5-s3) !important;
}
html body.single-post .entry-content :is(div[style*="minmax(280px" i], .wp-block-gallery) figure {
	width: auto !important;
	max-width: 100% !important;
	min-width: 0 !important;
	flex: none !important;
	margin: 0 !important;
	align-self: start !important;
}
html body.single-post .entry-content :is(div[style*="minmax(280px" i], .wp-block-gallery) figure img {
	width: 100% !important;
	height: auto !important;
}

/* ---------- K1 紅底狀態標章：顏色不變；字型跟段落（黑體）；字級下限 13 ---------- */
html body.single-post .entry-content span[style*="background:#c00" i],
html body.single-post .entry-content span[style*="background: #c00" i] {
	font-family: var(--gp-font-body) !important;
}
html body.single-post .entry-content span[style*="#c00020" i][style*="0.78em" i] {
	font-size: max(13px, 0.78em) !important;
}
html body.single-post .entry-content span[style*="#c00020" i][style*="0.88em" i] {
	font-size: max(13px, 0.88em) !important;
}

/* 圖→圖說 S1：舊文單張圖的 img 被 snippet #21 給了上下 1.5em 外距（圖說離圖 25），有圖說的舊文圖拿掉；圖的上下空間由 figure 的 S3 決定 */
html body.single-post .entry-content figure:has(> figcaption[style*="italic" i]) > img {
	margin-top: 0 !important;
	margin-bottom: 0 !important;
}
