/* =========================================================
 * Morrison Express 手機 / 平板 字級與間距
 * 桌機（≥1200px）完全不動，只調整 1199px 以下
 *
 * 原則：
 * - 中文內文行高 1.75，標題 1.3 左右，讀起來不擁擠
 * - 同一層級標題大小統一（含 WordPress 字級預設 class，例如 has-x-large-font-size）
 * - 段落、標題的上下間距固定比例，版面節奏一致
 * - 只作用在 <main> 與頁尾，不影響頁首選單；表單不動
 *
 * 權重說明：
 * - WordPress 字級預設 class 使用 !important，所以標題字級需要 !important
 *   並以 :not(#mex-x) 提高權重（#mex-x 不存在於頁面，只用來加權，不影響比對結果）
 * - 段落字級維持低權重，主題對特定元件（小標、年份等）的字級設定仍然有效；
 *   行高則用較高權重統一，避免中文多行段落擠在一起
 * ========================================================= */

/* ---------- 平板：768px ～ 1199px ---------- */
@media (min-width: 768px) and (max-width: 1199.98px) {

	/* 內文段落：一般段落字級（低權重，元件專屬字級優先） */
	main p:not(form p),
	main li:not(form li) {
		font-size: 17px;
	}
	/* 行高統一（高權重） */
	main p:not(form p):not(#mex-x),
	main li:not(form li):not(#mex-x) {
		line-height: 1.75;
	}
	main p:not(form p) {
		margin-bottom: 1em;
	}
	main p:not(form p):last-child {
		margin-bottom: 0;
	}

	/* 標題 */
	main h1:not(#mex-x) {
		font-size: 52px !important;
		line-height: 1.2 !important;
	}
	main h2:not(#mex-x) {
		font-size: 34px !important;
		line-height: 1.3 !important;
	}
	main h3:not(#mex-x) {
		font-size: 22px !important;
		line-height: 1.4 !important;
	}
	main h4:not(#mex-x) {
		font-size: 19px !important;
		line-height: 1.45 !important;
	}
	main h1 {
		margin-bottom: 24px;
	}
	main h2 {
		margin-bottom: 20px;
	}

	/* 導言：超過 4 行的大標題改用較小字級（.mex-lead 由 mex-responsive.js 加上） */
	main .mex-lead:not(#mex-x) {
		font-size: 28px !important;
		line-height: 1.5 !important;
	}

	/* 輪播內容框（例如歷史沿革）高度固定：字級、行高略收，避免框內出現捲軸 */
	main .bs-slider-content p:not(#mex-x) {
		font-size: 17px;
		line-height: 1.65;
	}

	/* 區塊間的空白：最多 72px，避免平板上出現大片空白 */
	main .wp-block-spacer {
		max-height: 72px;
	}
}

/* ---------- 手機：767px 以下 ---------- */
@media (max-width: 767.98px) {

	/* 內文段落 */
	main p:not(form p),
	main li:not(form li) {
		font-size: 16px;
	}
	main p:not(form p):not(#mex-x),
	main li:not(form li):not(#mex-x) {
		line-height: 1.75;
	}
	main p:not(form p) {
		margin-bottom: 1em;
	}
	main p:not(form p):last-child {
		margin-bottom: 0;
	}

	/* 標題 */
	main h1:not(#mex-x) {
		font-size: 34px !important;
		line-height: 1.25 !important;
	}
	main h2:not(#mex-x) {
		font-size: 26px !important;
		line-height: 1.35 !important;
	}
	main h3:not(#mex-x) {
		font-size: 20px !important;
		line-height: 1.4 !important;
	}
	main h4:not(#mex-x) {
		font-size: 18px !important;
		line-height: 1.45 !important;
	}
	main h1 {
		margin-bottom: 20px;
	}
	main h2 {
		margin-bottom: 16px;
	}

	/* 中文標題字距微開，手機小螢幕上比較透氣 */
	html:lang(zh) main h1,
	html:lang(zh) main h2 {
		letter-spacing: .02em;
	}

	/* 長篇置中文字整組改靠左（.mex-align-left 由 mex-responsive.js 依行數加上） */
	main .mex-align-left > h1:not(#mex-x),
	main .mex-align-left > h2:not(#mex-x),
	main .mex-align-left > h3:not(#mex-x),
	main .mex-align-left > h4:not(#mex-x),
	main .mex-align-left > p:not(#mex-x) {
		text-align: left;
	}
	main .mex-align-left > .wp-block-buttons:not(#mex-x) {
		justify-content: flex-start;
	}

	/* 導言：在手機上超過 4 行的大標題改用較小字級（.mex-lead 由 JS 加上） */
	main .mex-lead:not(#mex-x) {
		font-size: 21px !important;
		line-height: 1.6 !important;
		letter-spacing: .01em;
	}

	/* 左右留白 20px（原本 30px），讓手機每行能放更多字 */
	main .container {
		padding-left: 20px;
		padding-right: 20px;
	}

	/* 區塊間的空白：最多 48px */
	main .wp-block-spacer {
		max-height: 48px;
	}
}

/* ---------- 手機 / 平板共用 ---------- */
@media (max-width: 1199.98px) {

	/* 中文標題的手動換行不套用：
	 * 編輯器裡為桌機排版手動加的 <br>，在窄螢幕會切出「綜／合」這種只剩一個字的行。
	 * 只對中文頁面生效：英文字之間靠空白分隔，拿掉 <br> 會黏字 */
	html:lang(zh) main h1 br,
	html:lang(zh) main h2 br,
	html:lang(zh) main h3 br {
		display: none;
	}

	/* 頁尾連結行高，方便手指點擊 */
	footer p,
	footer li {
		line-height: 1.7;
	}
}
