/*
 * 首頁改版 v1（方向 almanac-ledger）— 由 mu-plugin gp-home.php 只在新版首頁載入，排在 gp-calendar/calendar.css 之後。
 * 規格：build-home-redesign/SPEC_home-v1.md；文案：build-home-redesign/COPY_home-v1.md。
 *
 * 首頁不經 Astra 的頁面版型（gp-home/template.php），內容不在 .entry-content 裡，站上 body.page .entry-content 那組 !important 碰不到。
 * 會碰到的站上規則，這裡用 :not(#_#_) 拉到 id 層級再蓋（跟關於頁、行事曆頁同一個做法）：
 *   - snippet #20（baiyu-hero-grid，首頁才印）：body.home .ast-container 兩欄 grid＋側欄 280（!important）
 *   - baiyu-single-post／site-fix-3（body.page）：.site-content .ast-container 上限 1080、窄寬左右 20（!important）
 *   - palyul-color-a11y：a:hover 金色 #9E7B3C（!important）；wp-custom-css：a:not(#_#_)、a:hover:not(#_#_)、a:focus-visible:not(#_#_)
 * 色全部是站上既有 token（var(--gp-*, 備用值)），不新增色值、字型。
 *
 * 排法切換只看容器寬（SPEC 4、7.1；uiux 11-30 回看：三段寬排法門檻統一為版心 ≥ 882，視窗 1018 起）：
 *   開場段  版心 ≥ 882：身分欄｜近期欄並排；以下上下疊
 *   入口段  版心 ≥ 882：三欄；560–881：懸掛（標題在左）；< 560：直疊
 *   紀錄段  版心 ≥ 882：三張卡；以下：清單列（縮圖在左）；版心 < 300：縮圖在上
 *   尾列    版心 ≥ 600：連結在左、搜尋框在右；以下：連結在上、搜尋框撐滿；< 260：「搜尋」鈕換到輸入框下一行
 *   活動列  沿用行事曆 calendar.css 的 @container gpcl（600 切寬窄）；首頁另外在清單 < 300 時把日期改成列頂一行
 * 字級隨視窗 922 切換（站上同一條斷點，SPEC 3.4）。
 */

/* ---------- 版心與 Astra 外框 ---------- */
html body.gph-front:not(#_#_) #content > .ast-container {
	display: block !important;
	width: auto !important;
	max-width: none !important;
	margin: 0 !important;
	padding: 0 !important;
	grid-template-columns: none !important;
}

.gph {
	container: gph / inline-size;
	--gph-ink: var(--gp-tx, #2C2420);
	--gph-meta: var(--gp-meta-warm, #6B5E4A);
	--gph-act: var(--gp-cp, #8B1A1A);
	--gph-line: var(--gp-border, #E4DFDA);
	--gph-gold: var(--gp-cg, #C9A060);
	--gph-hover: var(--gp-bg-card, #FAF6EE);
	--gph-press: var(--gp-bg-tantra, #F0EBE0);
	--gph-wh: var(--gp-wh, #FDFCFA);
	--gph-serif: Iansui, "Noto Serif TC", "Songti TC", serif;
	--gph-sans: -apple-system, BlinkMacSystemFont, "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
	/* 間距（SPEC 6；1440 基準：S4＝64、S3 32–48；窄寬只縮 S3、S4） */
	--gph-s1: 8px;
	--gph-s2: 16px;
	--gph-s3: 40px;
	--gph-s4: 64px;
	--gph-hit: 10px; /* 獨立連結點擊區 44 − 字行 24 的一半：算在間距裡，不另外疊（SPEC 6） */
	/* 字級（SPEC 3.4，≥ 922） */
	--gph-fs: 16.8px;
	--gph-h1: 19px;
	--gph-lede: 27px; /* 內文 1.6 倍；H1 的 1.42 倍。27 × 14 字＝378，1024／1440 的身分欄（386／412）放得下兩行 */
	--gph-h2: 25.6px;
	--gph-h3: 20.8px;
	--gph-rt: 17px;
	--gph-inset: 68px; /* 1440 → 944、1024 → 888（同關於頁版心） */
	--gph-max: 944px;
	--gph-fast: 150ms;
	--gph-ease: cubic-bezier(0.2, 0, 0, 1);
	box-sizing: border-box;
	width: min(var(--gph-max), 100% - 2 * var(--gph-inset));
	margin: 0 auto;
	padding: var(--gph-s4) 0;
	color: var(--gph-ink);
	font-family: var(--gph-sans);
	font-size: var(--gph-fs);
	line-height: 1.8;
	font-weight: 400;
}
@media (max-width: 921.98px) {
	.gph {
		--gph-s3: 32px;
		--gph-s4: 56px; /* 量到的字框間距約 59，是 S3（約 35）的 1.5 倍以上（SPEC 6） */
		--gph-fs: 16px;
		--gph-h1: 17px;
		--gph-lede: 24px;
		--gph-h2: 20px;
		--gph-h3: 17px;
		--gph-rt: 16px;
		--gph-inset: 20px; /* 版心＝視窗寬 − 40（同關於頁實量；uiux 11-30 回看拿掉 824 上限）。921 寬＝881、922 寬＝786，都在 882 以下，切換只發生一次 */
		padding-top: var(--gph-s3);
	}
}
.gph *,
.gph *::before,
.gph *::after {
	box-sizing: border-box;
}
.gph :is(h1, h2, h3, p, ul, li, form):not(#_#_) {
	margin: 0;
	padding: 0;
}
.gph ul {
	list-style: none;
}
.gph-vh {
	position: absolute !important;
	width: 1px !important;
	height: 1px !important;
	padding: 0 !important;
	margin: -1px !important;
	overflow: hidden !important;
	clip: rect(0 0 0 0) !important;
	white-space: nowrap !important;
	border: 0 !important;
}

/* ---------- 標題 ---------- */
.gph .gph-h1:not(#_#_) {
	font-family: var(--gph-serif) !important;
	font-size: var(--gph-h1);
	line-height: 1.3;
	font-weight: 400; /* 不准合成粗體（SPEC 3.3） */
	color: var(--gph-ink);
	letter-spacing: normal;
	margin-top: -2px; /* 字頂對齊右欄 h2 頂細線（SPEC 4.2：差 ≤ 4） */
}
.gph .gph-h2:not(#_#_) {
	/* 外觀同站上頁面 h2（baiyu-single-post body.page .entry-content h2）：Iansui、頂細線、上內距 1.5rem */
	font-family: var(--gph-serif) !important;
	font-size: var(--gph-h2);
	line-height: 1.4;
	font-weight: 700;
	color: var(--gph-ink);
	letter-spacing: normal;
	border-top: 1px solid var(--gph-line);
	padding-top: 24px;
	margin: 0 0 var(--gph-s2);
}
.gph .gph-h3:not(#_#_) {
	font-family: var(--gph-serif) !important;
	font-size: var(--gph-h3);
	line-height: 1.4;
	font-weight: 700;
	color: var(--gph-ink);
	letter-spacing: normal;
}

/* ---------- 內文與獨立連結 ---------- */
.gph-text {
	font-size: var(--gph-fs);
	line-height: 1.8;
}
.gph .gph-link:not(#_#_) {
	display: inline-flex;
	align-items: center;
	min-height: 44px;
	color: var(--gph-act) !important;
	font-size: 16px;
	line-height: 1.5;
	text-decoration: underline;
	text-decoration-thickness: 1px;
	text-underline-offset: 0.2em;
	text-spacing-trim: space-all; /* 行尾「）」不壓半寬，底線不會多出半格 */
	transition: text-decoration-thickness var(--gph-fast) var(--gph-ease);
}
.gph .gph-link:hover:not(#_#_) {
	color: var(--gph-act) !important;
	text-decoration-thickness: 2px;
}
.gph :is(a, button, input):focus-visible:not(#_#_) {
	outline: 2px solid var(--gph-act) !important;
	outline-offset: 2px;
	border-radius: 4px;
}
.gph .gph-more {
	margin-top: calc(var(--gph-s2) - var(--gph-hit) - 6px) !important; /* 上一段內文行距約 6–7 */
	margin-bottom: calc(0px - var(--gph-hit)) !important;
}
/* 活動列之後的「打開中心行事曆」：列有底色與點擊框，和連結的框之間留 S1（quality 12-01：原本 0）。
   字框間距約 26，介於列距（S2 約 16–19）和組間 S3（32–43）之間，層級不顛倒 */
.gph .gph-cal + .gph-more:not(#_#_) {
	margin-top: var(--gph-s1) !important;
}

/* ---------- 開場段 ---------- */
.gph-intro {
	display: grid;
	row-gap: var(--gph-s3);
	align-items: start;
}
@container gph (min-width: 882px) {
	.gph-intro {
		/* 身分欄 ≥ 340、近期欄 ≥ 440、欄距 48（SPEC 4.2）；身分欄約佔版心 40–45%（944 → 412） */
		grid-template-columns: minmax(340px, 46fr) minmax(440px, 54fr);
		column-gap: 48px;
	}
}
.gph .gph-lede:not(#_#_) {
	margin-top: 0; /* H1 與定位句兩邊的行距合起來約 6–7＝S1（字框間距） */
	font-family: var(--gph-serif);
	font-size: var(--gph-lede);
	line-height: 1.45;
	font-weight: 400;
	color: var(--gph-ink);
}
/* 定位句（SPEC 5.1，uiux 11-30 回看）：第一段（到第一個「，」）自成一行；之後每段（到「、」為止）一個 inline-block，
   欄寬放不下時才在段與段之間換行；某段比欄寬還長時（放大 200%）才在段內換行 */
.gph-seg {
	display: inline-block;
	max-width: 100%;
}
.gph-seg--l1 {
	display: block;
}
/* 補充句：專有名詞、年份不跨行（render.php gph_intro_sub_html）。用 inline-block 整塊換行（同定位句的段）；
   只有名詞本身比欄寬還長時（放大 200%）才在名詞內換行，不撐破版心 */
.gph-nb {
	display: inline-block;
	max-width: 100%;
}
.gph .gph-sub:not(#_#_) {
	margin-top: calc(var(--gph-s2) - 4px); /* 字框間距：扣掉兩邊行距 */
	max-width: 26em; /* 每行 ≤ 26 字（SPEC 5.1） */
}

/* 公告列（SPEC 5.2）：後台有置頂文章才出現 */
.gph .gph-notice:not(#_#_) {
	margin-top: var(--gph-s3);
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	column-gap: 12px;
	padding: 0 16px;
	border-left: 4px solid var(--gph-gold);
	border-radius: 0 8px 8px 0;
	background: var(--gph-hover);
}
.gph-notice__label {
	font-size: 13px;
	line-height: 1.5;
	font-weight: 600;
	color: var(--gph-meta);
	white-space: nowrap;
}
.gph .gph-notice__a:not(#_#_) {
	min-width: 0;
	overflow-wrap: anywhere;
	padding-block: 10px;
}

/* ---------- 近期組（活動列沿用行事曆元件，SPEC 5.3） ---------- */
.gph-msg {
	font-size: var(--gph-fs);
	line-height: 1.8;
}
.gph .gph-cal:not(#_#_) {
	font-size: 16px;
	line-height: 1.55;
}
.gph-ev + .gph-ev {
	border-top: 1px solid var(--gph-line);
}
.gph .gph-ev__a:not(#_#_) {
	display: grid;
	grid-template-columns: max-content minmax(0, 1fr);
	column-gap: var(--gpcl-dgap);
	align-items: start;
	min-height: 44px;
	--gpcl-pady: 6px; /* 列距比行事曆頁緊：相鄰兩列的字框間距約 19，組間 S3 才拉得開 1.5 倍（SPEC 6） */
	padding: var(--gpcl-pady) var(--gpcl-padx) var(--gpcl-pady) 0;
	border-radius: var(--gpcl-r);
	color: var(--gph-ink) !important;
	text-decoration: none !important;
	transition: background-color var(--gph-fast) var(--gph-ease);
}
.gph .gph-ev__a:hover:not(#_#_) {
	background: var(--gph-hover);
	color: var(--gph-ink) !important;
}
.gph .gph-ev__a:active:not(#_#_) {
	background: var(--gph-press);
}
.gph .gpcl .gph-ev__a:focus-visible:not(#_#_) {
	outline: 2px solid var(--gph-act) !important;
	outline-offset: -2px; /* 列和列緊鄰（同行事曆 v1 7.5） */
}
.gph .gph-ev__a:hover .gpcl-title {
	text-decoration: underline;
	text-decoration-thickness: 1px;
	text-underline-offset: 0.2em;
}
.gph .gph-ev__a:hover .gpcl-chev {
	border-color: var(--gph-ink);
}
/* 日期欄：「月/日」＋星期（跨年時上方多一行年份）；欄寬＝「12/25」實寬＋8（SPEC 5.3：8–12） */
.gph-ev__date {
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: var(--gpcl-t1);
	padding-right: 8px;
	color: var(--gph-ink);
}
.gph-ev__y {
	font-size: 13px;
	line-height: 1.2;
	color: var(--gph-meta);
	font-variant-numeric: tabular-nums;
}
.gph-ev__md,
.gph-ev__ruler {
	display: block;
	font-size: var(--gpcl-num-fs);
	line-height: 1.1;
	font-weight: 600;
	font-variant-numeric: tabular-nums;
	white-space: nowrap;
}
.gph-ev__ruler {
	height: 0;
	overflow: hidden;
	visibility: hidden;
}
.gph-ev__wd {
	display: block;
	font-size: 14px;
	line-height: 1.3;
	color: var(--gph-meta);
	white-space: nowrap;
}
/* 列內：點擊區與底色交給外層連結，摘要本身不再加內距與底色 */
.gph .gph-ev__sum:not(#_#_) {
	min-height: 0;
	padding: 0;
	background: transparent;
	border-radius: 0;
}
/* 標題右側：行事曆用半個字的內距＋負外距收住行尾被壓半寬的「）」；首頁列右邊只有 4 的內距，改成 4，標題盒不超出版心（SPEC 15 第 7 條） */
.gph .gph-ev__a .gpcl-title {
	padding-inline-end: 4px;
	margin-inline-end: -4px;
}
.gph-ev__chev {
	transform: rotate(-45deg); /* 「›」：8px 線條、次要字色（SPEC 5.3 第 2 點） */
}
@container gpcl (max-width: 599.98px) {
	.gph-ev__a {
		--gpcl-dgap: 4px;
		--gpcl-padx: 4px; /* 首頁列左邊不留內距（日期貼齊版心左緣），右邊只留 4，390 寬時第一行放得下時間＋兩顆標籤＋箭頭 */
		--gpcl-pady: 6px;
		--gpcl-num-fs: 24px;
		--gpcl-title-fs: 16px;
	}
}
/* 清單 < 300：右欄放不下 13 個標題字（同行事曆 v1 10.2 的判斷），日期改成列頂一行 */
@container gpcl (max-width: 299.98px) {
	.gph .gph-ev__a:not(#_#_) {
		display: block;
	}
	.gph-ev__date {
		flex-direction: row;
		flex-wrap: wrap;
		align-items: baseline;
		gap: 0 8px;
		padding-right: 0;
		margin-bottom: var(--gpcl-t1);
	}
	.gph-ev__md {
		font-size: 20px;
		line-height: 1.3;
	}
	.gph-ev__ruler {
		display: none;
	}
}

/* ---------- 入口段（SPEC 5.4） ---------- */
.gph-sec {
	margin-top: var(--gph-s4);
}
.gph-paths__grid {
	display: grid;
	row-gap: var(--gph-s3);
}
.gph-path {
	border-top: 2px solid var(--gph-gold); /* 裝飾線，不承載意義 */
	padding-top: var(--gph-s2);
}
.gph-path__body {
	margin-top: 0; /* h3 與入口句的行距合起來約 8＝S1 */
}
.gph .gph-path__links:not(#_#_) {
	display: flex;
	flex-wrap: wrap;
	column-gap: 24px;
	margin-top: calc(var(--gph-s2) - var(--gph-hit) - 6px);
	margin-bottom: calc(0px - var(--gph-hit));
}
@container gph (min-width: 882px) {
	.gph-paths__grid {
		grid-template-columns: repeat(3, minmax(0, 1fr));
		column-gap: 36px;
	}
}
@container gph (min-width: 560px) and (max-width: 881.98px) {
	.gph-path {
		display: grid;
		grid-template-columns: 30% minmax(0, 1fr);
		column-gap: 24px;
		align-items: start;
	}
	.gph-path__body {
		margin-top: 0;
	}
}

/* ---------- 紀錄段（SPEC 5.5） ---------- */
.gph-recs__list {
	display: grid;
	row-gap: var(--gph-s2);
}
.gph .gph-rec__a:not(#_#_) {
	display: grid;
	grid-template-columns: clamp(96px, 32%, 200px) minmax(0, 1fr);
	column-gap: var(--gph-s2);
	align-items: start;
	min-height: 44px;
	border-radius: 8px;
	color: var(--gph-ink) !important;
	text-decoration: none !important;
}
.gph .gph-rec--noimg .gph-rec__a:not(#_#_) {
	grid-template-columns: minmax(0, 1fr);
}
/* 沒有精選圖的空圖位：清單列不留（字從左緣開始）；三卡時才出現（見下方 @container ≥ 882） */
.gph .gph-rec__ph--empty:not(#_#_) {
	display: none;
}
.gph .gph-rec__a:hover:not(#_#_) {
	color: var(--gph-ink) !important;
}
.gph-rec__ph {
	display: block;
	flex: 0 0 auto;
	aspect-ratio: 3 / 2;
	border-radius: 8px;
	overflow: hidden;
	background: var(--gph-press);
}
.gph .gph-rec__img:not(#_#_) {
	display: block;
	width: 100%;
	height: 100%;
	max-width: none;
	object-fit: cover;
	object-position: center;
	border-radius: 0;
}
.gph-rec__txt {
	display: flex;
	flex-direction: column;
	gap: 2px; /* 加上兩行行距約 8＝S1 */
	min-width: 0;
}
.gph-rec__t {
	display: -webkit-box;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 3; /* 第 3 行結尾「…」（SPEC 5.5、7.2）；讀屏名稱是完整標題（連結的 aria-label） */
	line-clamp: 3;
	overflow: hidden;
	font-size: var(--gph-rt);
	line-height: 1.5;
	font-weight: 600;
	overflow-wrap: anywhere;
}
.gph-rec__d {
	font-size: 14px;
	line-height: 1.5;
	color: var(--gph-meta);
	font-variant-numeric: tabular-nums;
}
.gph .gph-rec__a:hover .gph-rec__t {
	text-decoration: underline;
	text-decoration-thickness: 1px;
	text-underline-offset: 0.2em;
}
@container gph (min-width: 882px) {
	.gph-recs__list {
		grid-template-columns: repeat(3, minmax(0, 1fr));
		column-gap: 32px;
	}
	.gph .gph-rec__a:not(#_#_) {
		display: flex;
		flex-direction: column;
		height: 100%;
		overflow: hidden;
		border: 1px solid var(--gph-line);
		background: var(--gph-wh);
		transition: border-color var(--gph-fast) var(--gph-ease);
	}
	.gph .gph-rec__a:hover:not(#_#_) {
		border-color: var(--gph-act);
	}
	.gph-rec__ph {
		border-radius: 0; /* 卡片 overflow 收掉：只剩上方兩角圓角 8 */
	}
	.gph .gph-rec__ph--empty:not(#_#_) {
		display: block; /* 沒有精選圖：三卡時保留 3:2 圖位，填 --gp-bg-tantra（uiux 11-30 回看） */
		align-self: stretch; /* 卡片沿用 align-items: start，空的 span 不撐開就會是 0 寬 */
	}
	.gph-rec__txt {
		padding: var(--gph-s2) var(--gph-s2) 20px;
	}
}

/* 版心 < 260（390 寬放大 200% 這類情況）：縮圖下限 96＋欄距 16 之後文字欄不到 9 個字，改成縮圖在上、字在下（SPEC 7.4「全部直疊」）；
   320 寬（版心 280）仍是縮圖在左 */
@container gph (max-width: 259.98px) {
	.gph .gph-rec__a:not(#_#_) {
		grid-template-columns: minmax(0, 1fr);
		row-gap: var(--gph-s1);
	}
	.gph-rec__ph {
		max-width: 200px;
	}
}

/* ---------- 尾列（SPEC 5.6） ---------- */
.gph-tail {
	margin-top: calc(var(--gph-s3) - var(--gph-hit));
	display: flex;
	flex-direction: column;
	align-items: stretch;
	row-gap: var(--gph-s2);
}
.gph-tail .gph-more {
	margin: 0 !important;
}
.gph-search {
	display: flex;
	gap: 8px;
}
@container gph (min-width: 600px) {
	.gph-tail {
		flex-direction: row;
		flex-wrap: wrap;
		align-items: center;
		justify-content: space-between;
		column-gap: 32px;
	}
	.gph-search {
		flex: 0 1 400px;
	}
}
@container gph (max-width: 259.98px) {
	.gph-search {
		flex-direction: column;
	}
}
.gph .gph-search__in:not(#_#_) {
	flex: 1 1 auto;
	min-width: 0;
	width: 100%;
	height: 44px;
	margin: 0;
	padding: 0 12px;
	border: 1px solid var(--gph-line);
	border-radius: 4px;
	background: var(--gph-wh);
	color: var(--gph-ink);
	font-family: inherit;
	font-size: 16px;
	line-height: 1.5;
	box-shadow: none;
}
.gph .gph-search__in:not(#_#_)::placeholder {
	color: var(--gph-meta);
	opacity: 1;
}
.gph .gph-search__btn:not(#_#_) {
	flex: 0 0 auto;
	min-height: 44px;
	min-width: 44px;
	margin: 0;
	padding: 0 20px;
	border: 0;
	border-radius: 6px;
	background: var(--gph-act);
	color: var(--gph-wh);
	font-family: inherit;
	font-size: 16px;
	line-height: 1.5;
	font-weight: 600;
	letter-spacing: normal;
	text-transform: none;
	box-shadow: none;
	cursor: pointer;
}
.gph .gph-search__btn:hover:not(#_#_),
.gph .gph-search__btn:focus:not(#_#_) {
	background: var(--gph-act);
	color: var(--gph-wh);
	text-decoration: underline;
	text-underline-offset: 0.2em;
}

/* ---------- 減少動態（SPEC 11） ---------- */
@media (prefers-reduced-motion: reduce) {
	.gph *,
	.gph *::before,
	.gph *::after {
		transition-duration: 0s !important;
		animation-duration: 0s !important;
	}
}
