/**
 * 黑田媽 · 分類頁區塊 CSS
 * by 卡卡東工作室 · Phase 3.4
 *
 * 對應檔案：inc/category-templates/*.php
 * 設計稿：黑田媽-食品分類頁-設計稿.html（桌機）
 *        黑田媽-食品子分類頁-海味乾貨-iPad版-設計稿.html
 *
 * 命名：kkd-* 前綴避開 Blocksy / WC 既有 class
 * 變數：一律用 design-system.css 的語意變數（--kkd-sumi 等），
 *       避開 Blocksy palette 編號跟「mockup 順序」對不上而搞錯
 *       （color-5 是 paper #FAF8F3 米白，不是 sumi）
 *
 * 載入：functions.php 條件式 enqueue（僅 food family）
 */

/* ==================================================================
 * 共用 — container, helpers, placeholders
 * ================================================================== */

/* 對齊 Blocksy ct-container（商品 grid 用的同款），讓左邊跟商品圖左邊對齊
   --theme-container-width = min(100%, calc(--theme-container-edge-spacing - frame*2))
   不再用固定 1200px + 24px padding，避免跟下方 ct-container 對不齊 */
.kkd-container {
	width: var(--theme-container-width, min(100%, 1200px));
	margin-inline: auto;
}

/* placeholder 樣式（沒設 term thumbnail 時的 fallback） */
.kkd-ph-cream  { background-color: var(--kkd-cream); position: relative; }
.kkd-ph-warm   { background-color: #ECE3D2; position: relative; }
.kkd-ph-stripe::before {
	content: "";
	position: absolute;
	inset: 0;
	background-image: repeating-linear-gradient(135deg, rgba(90,74,58,0.05) 0, rgba(90,74,58,0.05) 1px, transparent 1px, transparent 14px);
}

/* 共用 link / button */
.kkd-btn-ink {
	display: inline-flex;
	align-items: center;
	gap: 12px;
	background: var(--kkd-ink);
	color: var(--kkd-paper) !important;
	padding: 16px 28px;
	font-size: 14px;
	letter-spacing: 0.1em;
	text-decoration: none;
	transition: background .25s ease;
	border: 1px solid var(--kkd-ink);
}
.kkd-btn-ink:hover {
	background: var(--kkd-sumi);
	border-color: var(--kkd-sumi);
}

.kkd-lnk {
	color: var(--kkd-sumi);
	text-decoration: none;
	font-size: 13px;
	letter-spacing: 0.1em;
	transition: color .25s ease;
}
.kkd-lnk:hover { color: var(--kkd-matcha); }

/* ==================================================================
 * Category Hero（food parent）
 * ================================================================== */
.kkd-cat-hero { padding-top: 24px; }

.kkd-cat-hero__grid {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 32px;
	align-items: stretch;
	min-height: 360px;
}

.kkd-cat-hero__text {
	display: flex;
	flex-direction: column;
	justify-content: center;
	padding-right: 24px;
}

.kkd-cat-hero__eyebrow {
	font-size: 12px;
	color: var(--kkd-sumi);
	letter-spacing: 0.25em;
	margin-bottom: 20px;
	text-transform: uppercase;
}

.kkd-cat-hero__title {
	font-family: "Noto Serif TC", serif;
	font-size: 44px;
	line-height: 1.4;
	color: var(--kkd-ink);
	margin: 0 0 24px;
	font-weight: 400;
}

.kkd-cat-hero__desc {
	color: var(--kkd-inkgray);
	font-size: 15px;
	line-height: 1.9;
	max-width: 480px;
	margin-bottom: 40px;
}
.kkd-cat-hero__desc p { margin: 0 0 .5em; }

.kkd-cat-hero__cta {
	display: flex;
	align-items: center;
	gap: 32px;
	flex-wrap: wrap;
}

.kkd-cat-hero__image {
	height: 360px;
	overflow: hidden;
	background-color: var(--kkd-cream);
	position: relative;
}
.kkd-cat-hero__image img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}
.kkd-cat-hero__image .kkd-ph-cream {
	width: 100%;
	height: 100%;
}
.kkd-ph-text {
	position: absolute;
	bottom: 24px;
	right: 24px;
	text-align: right;
	font-family: "Noto Serif TC", serif;
	font-size: 22px;
	color: rgba(90,74,58,0.7);
}
.kkd-ph-text span {
	font-size: 14px;
	letter-spacing: 0.2em;
	color: rgba(90,74,58,0.5);
}

/* ==================================================================
 * 4-col 子分類入口（food parent）
 * ================================================================== */
.kkd-subcat-grid { padding-top: 96px; }

.kkd-subcat-grid__inner {
	display: grid;
	grid-template-columns: repeat(4, 1fr);
	gap: 20px;
}

.kkd-subcat-card {
	display: block;
	background: var(--kkd-paper);
	border: 1px solid var(--kkd-rule);
	padding: 28px;
	text-decoration: none;
	color: inherit;
	transition: border-color .25s ease;
}
.kkd-subcat-card:hover {
	border-color: var(--kkd-sumi);
}

.kkd-subcat-card__accent {
	display: block;
	width: 48px;
	height: 6px;
	margin-bottom: 24px;
}

.kkd-subcat-card__title {
	font-family: "Noto Serif TC", serif;
	font-size: 18px;
	color: var(--kkd-ink);
	margin: 0 0 12px;
	font-weight: 400;
}

.kkd-subcat-card__desc {
	color: var(--kkd-inkgray);
	font-size: 13px;
	line-height: 1.7;
	margin: 0 0 24px;
}

.kkd-subcat-card__more {
	color: var(--kkd-sumi);
	font-size: 12px;
	letter-spacing: 0.1em;
}

/* ==================================================================
 * KURODA SELECT
 * ================================================================== */
.kkd-kuroda-select { padding-top: 96px; }

.kkd-kuroda-select__grid {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 40px;
	align-items: stretch;
}

.kkd-kuroda-select__visual {
	min-height: 440px;
	position: relative;
	overflow: hidden;
}
.kkd-kuroda-select__visual > .kkd-ph-cream {
	width: 100%;
	height: 100%;
	position: relative;
}
.kkd-kuroda-select__visual > img {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}
.kkd-kuroda-select__visual-text {
	position: absolute;
	bottom: 32px;
	left: 32px;
}
.kkd-kuroda-select__visual-jp {
	font-family: "Noto Serif TC", serif;
	font-size: 18px;
	color: rgba(90,74,58,0.7);
	line-height: 1.4;
}

.kkd-kuroda-select__text {
	display: flex;
	flex-direction: column;
	justify-content: center;
}

.kkd-kuroda-select__eyebrow {
	font-size: 12px;
	color: var(--kkd-sumi);
	letter-spacing: 0.25em;
	margin-bottom: 20px;
	text-transform: uppercase;
}

.kkd-kuroda-select__title {
	font-family: "Noto Serif TC", serif;
	font-size: 28px;
	color: var(--kkd-ink);
	line-height: 1.4;
	margin: 0 0 24px;
	font-weight: 400;
}

.kkd-kuroda-select__intro {
	color: var(--kkd-inkgray);
	font-size: 14px;
	line-height: 1.9;
	margin: 0 0 40px;
}

.kkd-kuroda-select__points {
	display: grid;
	grid-template-columns: repeat(3, 1fr);
	gap: 24px;
	padding-top: 24px;
	border-top: 1px solid var(--kkd-rule);
}

.kkd-kuroda-select__point-num {
	font-family: "Noto Serif TC", serif;
	font-size: 20px;
	color: var(--kkd-ink);
	margin-bottom: 8px;
}

.kkd-kuroda-select__point-label {
	font-size: 13px;
	color: var(--kkd-sumi);
}

/* ==================================================================
 * Section header（Repeat Favorites + Archive grid 共用）
 * ================================================================== */
.kkd-section-header {
	display: flex;
	align-items: flex-end;
	justify-content: space-between;
	margin-bottom: 48px;
}
.kkd-section-header__eyebrow {
	font-size: 12px;
	color: var(--kkd-sumi);
	letter-spacing: 0.25em;
	margin-bottom: 12px;
	text-transform: uppercase;
}
.kkd-section-header__title {
	font-family: "Noto Serif TC", serif;
	font-size: 30px;
	color: var(--kkd-ink);
	margin: 0;
	font-weight: 400;
}
.kkd-section-header__sub {
	color: var(--kkd-inkgray);
	font-size: 14px;
	margin: 8px 0 0;
}

/* ==================================================================
 * This Week New 3-col 直長卡（食品 parent 用）
 * ================================================================== */
.kkd-this-week-new { padding-top: 96px; }

.kkd-this-week-new__list {
	list-style: none;
	margin: 0;
	padding: 0;
	display: grid;
	grid-template-columns: repeat(3, 1fr);
	gap: 32px;
}

.kkd-tw-card__link {
	display: block;
	text-decoration: none;
	color: inherit;
}

.kkd-tw-card__img {
	position: relative;
	aspect-ratio: 1 / 1;
	background: #FFFFFF;
	border: 1px solid var(--kkd-rule);
	overflow: hidden;
	transition: border-color .25s ease;
}
.kkd-tw-card__link:hover .kkd-tw-card__img { border-color: var(--kkd-matcha); }
.kkd-tw-card__img img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
	transition: transform .5s ease;
}
.kkd-tw-card__link:hover .kkd-tw-card__img img { transform: scale(1.02); }

.kkd-tw-card__body { padding-top: 20px; }

.kkd-tw-card__date {
	font-size: 12px;
	color: var(--kkd-inkgray);
	margin-bottom: 8px;
}

.kkd-tw-card__title {
	font-size: 16px;
	color: var(--kkd-ink);
	line-height: 1.4;
	margin-bottom: 8px;
}

.kkd-tw-card__desc {
	font-size: 13px;
	color: var(--kkd-inkgray);
	line-height: 1.6;
	margin-bottom: 12px;
}

.kkd-tw-card__price {
	font-size: 18px;
	font-weight: 500;
	color: var(--kkd-ink);
}
.kkd-tw-card__price .woocommerce-Price-amount { font-weight: 500; }

/* ==================================================================
 * Repeat Favorites 6-col 横列
 * ================================================================== */
.kkd-repeat-favorites { padding-top: 96px; }

.kkd-repeat-favorites__list {
	list-style: none;
	margin: 0;
	padding: 0;
	display: grid;
	grid-template-columns: repeat(6, 1fr);
	gap: 20px;
}

.kkd-repeat-fav__link {
	display: block;
	text-decoration: none;
	color: inherit;
}

.kkd-repeat-fav__img {
	aspect-ratio: 1 / 1;
	background: #FFFFFF;
	border: 1px solid var(--kkd-rule);
	overflow: hidden;
}
.kkd-repeat-fav__img img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

.kkd-repeat-fav__body { padding-top: 12px; }

.kkd-repeat-fav__title {
	font-size: 13px;
	color: var(--kkd-ink);
	line-height: 1.4;
	margin-bottom: 4px;
}

.kkd-repeat-fav__price {
	font-size: 14px;
	font-weight: 500;
	color: var(--kkd-ink);
}
.kkd-repeat-fav__price .woocommerce-Price-amount { font-weight: 500; }

/* ==================================================================
 * Archive grid 4 欄（覆寫 Blocksy --shop-columns）
 * specificity (0,2,1) > [data-products] (0,1,0)
 * ================================================================== */
body.kkd-food-archive [data-products] {
	--shop-columns: repeat(4, minmax(0, 1fr));
}

/* ==================================================================
 * Archive grid section header（全部商品 grid 之前）
 * ================================================================== */
.kkd-archive-loop-section { padding-top: 96px; }

.kkd-archive-loop-header {
	display: flex;
	align-items: flex-end;
	justify-content: space-between;
	padding-bottom: 24px;
	border-bottom: 1px solid var(--kkd-rule);
	margin-bottom: 40px;
}

.kkd-archive-loop-header__title {
	font-family: "Noto Serif TC", serif;
	font-size: 26px;
	color: var(--kkd-ink);
	margin: 0 0 8px;
	font-weight: 400;
}

.kkd-archive-loop-header__count {
	font-size: 12px;
	color: var(--kkd-inkgray);
	letter-spacing: 0.1em;
}

/* ==================================================================
 * Sub-category Hero（簡化版）
 * ================================================================== */
.kkd-subcat-hero { padding-top: 24px; }

.kkd-subcat-hero__grid {
	display: grid;
	grid-template-columns: 7fr 5fr;
	gap: 24px;
	align-items: stretch;
	min-height: 240px;
}

.kkd-subcat-hero__text {
	display: flex;
	flex-direction: column;
	justify-content: center;
	padding-right: 16px;
}

.kkd-subcat-hero__eyebrow {
	font-size: 12px;
	color: var(--kkd-sumi);
	letter-spacing: 0.25em;
	margin-bottom: 12px;
	display: flex;
	align-items: center;
	gap: 12px;
	text-transform: uppercase;
}

.kkd-subcat-hero__accent {
	display: inline-block;
	width: 14px;
	height: 3px;
	background: #ECE3D2;
}

.kkd-subcat-hero__title {
	font-family: "Noto Serif TC", serif;
	font-size: 32px;
	line-height: 1.4;
	color: var(--kkd-ink);
	margin: 0 0 12px;
	font-weight: 400;
}

.kkd-subcat-hero__desc {
	color: var(--kkd-inkgray);
	font-size: 14px;
	line-height: 1.9;
	max-width: 480px;
	margin-bottom: 20px;
}
.kkd-subcat-hero__desc p { margin: 0 0 .4em; }

.kkd-subcat-hero__meta {
	display: flex;
	align-items: center;
	gap: 20px;
	font-size: 12px;
	color: var(--kkd-inkgray);
	letter-spacing: 0.1em;
}
.kkd-subcat-hero__sep { color: var(--kkd-rule); }

.kkd-subcat-hero__image {
	height: 240px;
	overflow: hidden;
	background-color: #ECE3D2;
	position: relative;
}
.kkd-subcat-hero__image img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}
.kkd-subcat-hero__image .kkd-ph-warm {
	width: 100%;
	height: 100%;
}
.kkd-subcat-hero__ph-text {
	position: absolute;
	bottom: 16px;
	right: 16px;
	text-align: right;
	font-family: "Noto Serif TC", serif;
	font-size: 18px;
	color: rgba(90,74,58,0.7);
}
.kkd-subcat-hero__ph-sub {
	font-size: 12px;
	letter-spacing: 0.2em;
	color: rgba(90,74,58,0.5);
}

/* ==================================================================
 * Sibling chips（sub-cat 用）
 * ================================================================== */
.kkd-sibling-chips {
	padding-top: 32px;
	padding-bottom: 8px;
}

.kkd-sibling-chips__label {
	font-size: 11px;
	letter-spacing: 0.2em;
	color: var(--kkd-sumi);
	margin-bottom: 12px;
	text-transform: uppercase;
}

.kkd-sibling-chips__list {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
}

/* a.kkd-sibling-chip 提高 specificity 跟 Blocksy 的
   a:not(.button):not(.wp-block-button__link):not(.ct-button) 對齊 */
.kkd-sibling-chips a.kkd-sibling-chip {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	padding: 8px 14px;
	border: 1px solid var(--kkd-rule);
	font-size: 13px;
	color: var(--kkd-sumi);
	text-decoration: none;
	transition: border-color .25s ease, color .25s ease;
}
.kkd-sibling-chips a.kkd-sibling-chip:hover {
	border-color: var(--kkd-sumi);
	color: var(--kkd-ink);
}
.kkd-sibling-chip__dot {
	width: 6px;
	height: 6px;
	display: inline-block;
}
.kkd-sibling-chip--all {
	color: var(--kkd-inkgray);
}

/* ==================================================================
 * 商品卡 eyebrow（取代 .kkd-card-date 在 archive 的位置）
 * ================================================================== */
.kkd-card-eyebrow {
	font-size: 11px;
	letter-spacing: 0.15em;
	color: var(--kkd-sumi);
	margin-bottom: 6px;
	text-transform: uppercase;
}

/* ==================================================================
 * Responsive — iPad portrait (≤820px) / Mobile (≤640px)
 * ================================================================== */

@media (max-width: 1024px) {
	.kkd-cat-hero__grid {
		grid-template-columns: 1fr;
		gap: 24px;
		min-height: auto;
	}
	.kkd-cat-hero__text { padding-right: 0; }
	.kkd-cat-hero__title { font-size: 36px; }
	.kkd-cat-hero__image { height: 280px; order: -1; }  /* stack 時圖在上、文字在下 */

	.kkd-subcat-grid__inner { grid-template-columns: repeat(2, 1fr); }

	.kkd-kuroda-select__grid {
		grid-template-columns: 1fr;
		gap: 24px;
	}
	.kkd-kuroda-select__visual { min-height: 280px; }

	.kkd-repeat-favorites__list {
		grid-template-columns: repeat(3, 1fr);
	}

	.kkd-this-week-new__list { grid-template-columns: repeat(2, 1fr); gap: 24px; }

	.kkd-subcat-hero__title { font-size: 28px; }
}

@media (max-width: 640px) {
	/* 手機下 Blocksy ct-container 會自動轉成 88vw，跟著走即可 */

	.kkd-cat-hero__title { font-size: 28px; }
	.kkd-cat-hero__cta { gap: 16px; }

	/* 品類入口 2 欄（設計稿） */
	.kkd-subcat-grid__inner { grid-template-columns: repeat(2, 1fr); gap: 12px; }
	.kkd-subcat-card { padding: 16px; }
	.kkd-subcat-card__title { font-size: 15px; margin-bottom: 8px; }
	.kkd-subcat-card__desc { font-size: 12px; margin-bottom: 16px; }

	.kkd-kuroda-select__title { font-size: 22px; }
	.kkd-kuroda-select__points { gap: 12px; }

	/* 本週新品 2 欄（設計稿） */
	.kkd-this-week-new__list { grid-template-columns: repeat(2, 1fr); gap: 12px; }
	.kkd-tw-card__body { padding-top: 12px; }
	.kkd-tw-card__date { font-size: 11px; margin-bottom: 4px; }
	.kkd-tw-card__title { font-size: 13px; margin-bottom: 4px; }
	.kkd-tw-card__desc { font-size: 11px; margin-bottom: 8px; }
	.kkd-tw-card__price { font-size: 14px; }

	/* 熱門回購：horizontal scroll slider（設計稿 mobile pattern）
	   左邊有 padding，右邊讓內容自然流出 viewport 表示「可滑」 */
	.kkd-repeat-favorites__list {
		display: flex;
		grid-template-columns: none;
		gap: 12px;
		overflow-x: auto;
		overflow-y: hidden;
		scroll-snap-type: x mandatory;
		-webkit-overflow-scrolling: touch;
		scrollbar-width: none;
		/* 讓最後一張卡可以滾到貼齊 container 左邊 */
		scroll-padding-inline-start: 0;
		/* 讓右側可滾出 viewport 邊（增加 trailing padding） */
		padding-right: 16px;
		/* 把右邊 negative margin 還原一些，讓 list 自然超出 container */
		margin-right: calc(-1 * (100vw - 100%) / 2);
	}
	.kkd-repeat-favorites__list::-webkit-scrollbar { display: none; }
	.kkd-repeat-fav {
		flex: 0 0 140px;
		scroll-snap-align: start;
	}
	.kkd-repeat-fav__title { font-size: 12px; }
	.kkd-repeat-fav__price { font-size: 13px; }

	.kkd-section-header { flex-direction: column; align-items: flex-start; gap: 16px; }
	.kkd-section-header__title { font-size: 20px; }
	.kkd-section-header__eyebrow { font-size: 11px; }
	.kkd-section-header__sub { font-size: 12px; }

	.kkd-subcat-hero__grid { grid-template-columns: 1fr; }
	.kkd-subcat-hero__image { order: -1; }  /* mobile 圖在上、文字在下 */
	.kkd-subcat-hero__title { font-size: 24px; }

	/* WC 商品 grid 手機 2 欄 — 跟「本週食品新品」一模一樣：
	   - gap: 12px 兩向（this-week-new__list 用的就是這個值）
	   - L/R: 強制限制到 .kkd-container 同款寬度
	     根因：ul.products 跟 woo-listing-top 直接掛在 main > ct-container 下，
	          mobile 下 ct-container 寬度 ≠ .kkd-container；要 manually 收窄它們 */
	body.kkd-food-archive [data-products] {
		--shop-columns: repeat(2, minmax(0, 1fr));
		--grid-columns-gap: 12px;
		--grid-rows-gap: 12px;
	}
	body.kkd-food-archive ul.products,
	body.kkd-food-archive .woo-listing-top,
	body.kkd-food-archive .woocommerce-notices-wrapper {
		max-width: var(--theme-container-width);
		margin-inline: auto;
	}

	/* li.product 內 padding 清掉（Blocksy 預設 0 20px 20px 讓圖片實際寬比本週新品窄 40px）
	   清掉後圖片寬 = 159px，跟 .kkd-tw-card 內圖完全一致 */
	body.kkd-food-archive ul.products > li.product {
		padding: 0;
	}
}
