/*
 * 一功最新消息卡片
 *
 * 版型:圖片在上,下方一列為「日期區塊 + 標題」。
 * 色彩沿用站上既有的 CIS:
 *   深藍 #1F3A5F(標題帶同色) / 主金 #C1AC73 / 深棕 #7B3F00 / 炭黑 #242424
 *
 * RWD 一律以「容器寬度」為準,不看視窗寬度 —— 這個列表可能被放進
 * 窄版型或側欄,視窗 1280px 不代表容器有 1280px。
 */

.ybc-news {
	--ybc-navy: #1f3a5f;
	--ybc-gold: #c1ac73;
	--ybc-brown: #7b3f00;
	--ybc-ink: #242424;
	--ybc-muted: rgba(36, 36, 36, 0.58);
	--ybc-line: rgba(28, 28, 28, 0.13);
	--ybc-gap: 26px;
	--ybc-ease: cubic-bezier(0.22, 0.61, 0.36, 1);

	container-type: inline-size;
	container-name: ybc;
	box-sizing: border-box;
	font-family: "Noto Serif TC", "Songti TC", serif;
	color: var(--ybc-ink);
}

.ybc-news *,
.ybc-news *::before,
.ybc-news *::after {
	box-sizing: inherit;
}

/* 篩選列 */

.ybc-filter {
	display: flex;
	flex-wrap: wrap;
	gap: 6px 22px;
	align-items: center;
	margin: 0 0 clamp(22px, 3vw, 34px);
	padding-bottom: 14px;
	border-bottom: 1px solid var(--ybc-line);
}

.ybc-news .ybc-filter__btn {
	appearance: none;
	background: none;
	border: 0;
	margin: 0;
	padding: 10px 2px;
	min-height: 44px;
	font-family: inherit;
	font-size: 15px;
	letter-spacing: 0.06em;
	color: var(--ybc-muted);
	cursor: pointer;
	position: relative;
	transition: color 0.24s var(--ybc-ease);
}

.ybc-news .ybc-filter__btn::after {
	content: "";
	position: absolute;
	left: 0;
	right: 0;
	bottom: 8px;
	height: 2px;
	background: var(--ybc-gold);
	transform: scaleX(0);
	transform-origin: left center;
	transition: transform 0.3s var(--ybc-ease);
}

.ybc-news .ybc-filter__btn:hover,
.ybc-news .ybc-filter__btn:focus-visible {
	color: var(--ybc-brown);
}

.ybc-news .ybc-filter__btn.is-active {
	color: var(--ybc-brown);
	font-weight: 600;
}

.ybc-news .ybc-filter__btn.is-active::after {
	transform: scaleX(1);
}

.ybc-news .ybc-filter__btn:focus-visible,
.ybc-news .ybc-card__link:focus-visible,
.ybc-news .ybc-more__btn:focus-visible {
	outline: 2px solid var(--ybc-brown);
	outline-offset: 3px;
}

/* 卡片格線
   基準用 auto-fill,讓不支援 container query 的瀏覽器也能依容器寬度自動折行;
   下方的 @container 再把欄數鎖成參考版型的 3 / 2 / 1。 */

.ybc-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(min(100%, 262px), 1fr));
	gap: var(--ybc-gap);
	align-items: stretch;
}

@container ybc (min-width: 840px) {
	.ybc-grid {
		grid-template-columns: repeat(3, minmax(0, 1fr));
	}
}

@container ybc (min-width: 560px) and (max-width: 839px) {
	.ybc-grid {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}
}

@container ybc (max-width: 559px) {
	.ybc-news {
		--ybc-gap: 16px;
	}

	.ybc-grid {
		grid-template-columns: minmax(0, 1fr);
	}
}

/* 卡片 */

.ybc-card {
	margin: 0;
	min-width: 0;
}

.ybc-news .ybc-card__link {
	display: grid;
	grid-template-columns: 78px minmax(0, 1fr);
	grid-template-areas:
		"media media"
		"date  title";
	height: 100%;
	align-content: start;
	background: #fff;
	border: 1px solid var(--ybc-line);
	text-decoration: none;
	color: inherit;
	overflow: hidden;
	transition: border-color 0.3s var(--ybc-ease);
}

.ybc-news .ybc-card__link:hover {
	border-color: var(--ybc-gold);
}

.ybc-card__media {
	grid-area: media;
	position: relative;
	width: 100%;
	aspect-ratio: 16 / 10;
	overflow: hidden;
	background: rgba(28, 28, 28, 0.05);
}

.ybc-news .ybc-card__img {
	display: block;
	width: 100%;
	height: 100%;
	max-width: none;
	object-fit: cover;
	transform: scale(1);
	transition: transform 0.55s var(--ybc-ease);
}

.ybc-news .ybc-card__link:hover .ybc-card__img {
	transform: scale(1.05);
}

.ybc-card__img--empty {
	background: linear-gradient(135deg, #f3efe4 0%, #e8e2d2 100%);
}

.ybc-card__cat {
	position: absolute;
	left: 0;
	bottom: 0;
	padding: 5px 13px;
	background: rgba(31, 58, 95, 0.9);
	color: #faf3e0;
	font-size: 12px;
	letter-spacing: 0.08em;
	line-height: 1.6;
}

/* 日期 + 標題 */

.ybc-card__body {
	grid-area: date / date / title / title;
	display: grid;
	grid-template-columns: subgrid;
	grid-column: 1 / -1;
}

/* subgrid 不支援時的退路:自己再切一次欄 */
@supports not (grid-template-columns: subgrid) {
	.ybc-card__body {
		display: grid;
		grid-template-columns: 78px minmax(0, 1fr);
	}
}

.ybc-card__date {
	padding: 22px 0 24px 22px;
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	line-height: 1;
	min-width: 0;
}

.ybc-card__day {
	font-size: 30px;
	font-weight: 700;
	color: var(--ybc-navy);
	letter-spacing: 0.01em;
}

.ybc-card__ym {
	margin-top: 7px;
	font-size: 12.5px;
	font-weight: 400;
	color: rgba(31, 58, 95, 0.62);
	letter-spacing: 0.05em;
	white-space: nowrap;
}

.ybc-news .ybc-card__title {
	margin: 0;
	padding: 22px 22px 24px 14px;
	font-family: inherit;
	font-size: 16.5px;
	font-weight: 500;
	line-height: 1.62;
	color: var(--ybc-ink);
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
	transition: color 0.25s var(--ybc-ease);
}

.ybc-news .ybc-card__link:hover .ybc-card__title {
	color: var(--ybc-brown);
}

@container ybc (max-width: 559px) {
	.ybc-news .ybc-card__link {
		grid-template-columns: 68px minmax(0, 1fr);
	}

	@supports not (grid-template-columns: subgrid) {
		.ybc-card__body {
			grid-template-columns: 68px minmax(0, 1fr);
		}
	}

	.ybc-card__date {
		padding: 18px 0 20px 16px;
	}

	.ybc-card__day {
		font-size: 26px;
	}

	.ybc-news .ybc-card__title {
		padding: 18px 16px 20px 12px;
		font-size: 15.5px;
	}
}

/* 載入更多 */

.ybc-more {
	display: flex;
	justify-content: center;
	margin-top: clamp(26px, 4vw, 44px);
}

.ybc-more[hidden] {
	display: none;
}

.ybc-news .ybc-more__btn {
	appearance: none;
	display: inline-flex;
	align-items: center;
	gap: 10px;
	min-height: 48px;
	padding: 12px 42px;
	font-family: inherit;
	font-size: 15px;
	letter-spacing: 0.14em;
	color: var(--ybc-brown);
	background: transparent;
	border: 1px solid var(--ybc-gold);
	border-radius: 0;
	cursor: pointer;
	transition: background-color 0.28s var(--ybc-ease), color 0.28s var(--ybc-ease);
}

.ybc-news .ybc-more__btn:hover:not(:disabled) {
	background: var(--ybc-brown);
	border-color: var(--ybc-brown);
	color: #faf3e0;
}

.ybc-news .ybc-more__btn:disabled {
	opacity: 0.45;
	cursor: default;
}

.ybc-more__spinner {
	display: none;
	width: 14px;
	height: 14px;
	border: 2px solid currentColor;
	border-right-color: transparent;
	border-radius: 50%;
	animation: ybc-spin 0.7s linear infinite;
}

.ybc-more__btn.is-loading .ybc-more__spinner {
	display: inline-block;
}

@keyframes ybc-spin {
	to {
		transform: rotate(360deg);
	}
}

.ybc-status {
	margin: 18px 0 0;
	text-align: center;
	font-size: 14px;
	letter-spacing: 0.08em;
	color: var(--ybc-muted);
	min-height: 1em;
}

@media (prefers-reduced-motion: reduce) {
	.ybc-news *,
	.ybc-news *::after {
		transition-duration: 0.01ms !important;
		animation-duration: 0.01ms !important;
	}

	.ybc-news .ybc-card__link:hover .ybc-card__img {
		transform: none;
	}
}
