/* ==========================================================
 * 歡喜緣 新品上市輪播
 * 依 Figma「3-商品分類」新品上市 node 1457:8503
 * 一排 4 張：卡片最大 416px、間距 24px（4×416+3×24 = 1736px 置中）
 * 名稱 32px、價格 20px 燙金、原價 20px 60%
 * hover（960:28812）：圖片 1px 古銅金框 + 金色光暈 + 40% 古銅金遮罩，
 *        「加入購物車」浮現（244×54），名稱降為 60%
 * 左右箭頭：白框圓圈 50px，內圈木墨黑 42px，距兩側 40px
 * ========================================================== */
.twh-na {
	--twh-na-per-view: 4;       /* 一次顯示幾張 */
	--twh-na-max: 1736px;       /* 4 張的總寬 */
	--twh-na-gap: 24px;
	--twh-na-btn-h: 54px;
	--twh-na-white: #ffffff;
	--twh-na-ink: #292421;
	--twh-na-gold-gradient: linear-gradient(180deg, #b67b19 0%, #d1a64f 50%, #a96f14 100%);
	--twh-na-font: "Noto Serif TC", serif;

	position: relative;
	width: 100%;
	font-family: var(--twh-na-font);
}

/* ---------- 橫向捲動軌道 ---------- */
.twh-na ul.products.twh-na__track {
	display: flex !important;
	flex-wrap: nowrap !important;
	gap: var(--twh-na-gap) !important;
	max-width: var(--twh-na-max);
	margin: 0 auto !important;
	padding: 0 !important;
	overflow-x: auto;
	overflow-y: hidden;
	scroll-snap-type: x mandatory;
	scroll-behavior: smooth;
	scrollbar-width: none;
	-webkit-overflow-scrolling: touch;
	list-style: none;
}

.twh-na ul.products.twh-na__track::-webkit-scrollbar {
	display: none;
}

.twh-na ul.products.twh-na__track::before,
.twh-na ul.products.twh-na__track::after {
	display: none !important;
}

/* 商品不多時置中（超出時 auto margin 自動變 0，可正常捲動） */
.twh-na ul.products.twh-na__track > li.product:first-child {
	margin-left: auto !important;
}

.twh-na ul.products.twh-na__track > li.product:last-child {
	margin-right: auto !important;
}

/* ---------- 卡片 ---------- */
.twh-na ul.products li.product {
	position: relative;
	display: flex !important;
	flex: 0 0 calc((100% - (var(--twh-na-per-view) - 1) * var(--twh-na-gap)) / var(--twh-na-per-view)) !important;
	flex-direction: column;
	gap: 8px;
	width: auto !important;
	container-type: inline-size;
	margin: 0 !important;
	padding: 0 !important;
	text-align: center;
	float: none !important;
	scroll-snap-align: start;
}

.twh-na ul.products li.product .astra-shop-summary-wrap {
	display: flex;
	flex-direction: column;
	gap: 8px;
	padding: 0 !important;
}

/* 圖片外層：hover 金框、光暈、遮罩 */
.twh-na ul.products li.product .astra-shop-thumbnail-wrap {
	position: relative;
	margin: 0 !important;
	border: 1px solid transparent;
	transition: border-color 0.25s ease, box-shadow 0.25s ease;
}

.twh-na ul.products li.product .astra-shop-thumbnail-wrap::after {
	content: "";
	position: absolute;
	inset: 0;
	z-index: 3;
	background: rgba(181, 138, 69, 0.4);
	opacity: 0;
	pointer-events: none;
	transition: opacity 0.25s ease;
}

.twh-na ul.products li.product a.woocommerce-LoopProduct-link {
	display: flex;
	flex-direction: column;
	gap: 8px;
	color: inherit;
	text-decoration: none;
}

.twh-na ul.products li.product img {
	display: block;
	width: 100% !important;
	height: auto !important;
	aspect-ratio: 1 / 1;
	margin: 0 !important;
	object-fit: cover;
	border: 0 !important;
	box-shadow: none !important;
}

/* 商品名稱：32px Bold 白字 */
.twh-na ul.products li.product .woocommerce-loop-product__title {
	display: -webkit-box;
	margin: 0 !important;
	padding: 0 !important;
	overflow: hidden;
	font-family: var(--twh-na-font) !important;
	font-size: clamp(20px, 7.7cqw, 32px) !important;
	font-weight: 700 !important;
	line-height: 1.4 !important;
	color: var(--twh-na-white) !important;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	transition: opacity 0.25s ease;
}

/* 價格：售價燙金在上、原價刪除線在下，20px */
.twh-na ul.products li.product .price {
	display: flex !important;
	flex-direction: column-reverse;
	align-items: center;
	gap: 8px;
	margin: 0 !important;
	font-family: var(--twh-na-font) !important;
	font-size: 20px !important;
	font-weight: 700 !important;
	line-height: 1.4 !important;
	color: transparent !important;
	background: var(--twh-na-gold-gradient);
	-webkit-background-clip: text;
	background-clip: text;
	-webkit-text-fill-color: transparent !important;
}

.twh-na ul.products li.product .price .woocommerce-Price-amount {
	color: inherit !important;
	-webkit-text-fill-color: inherit !important;
}

.twh-na ul.products li.product .price del {
	opacity: 1;
	color: rgba(255, 255, 255, 0.6) !important;
	-webkit-text-fill-color: rgba(255, 255, 255, 0.6) !important;
}

.twh-na ul.products li.product .price ins {
	text-decoration: none;
	background: none;
}

/* 卡片不顯示：分類、加入購物車、特價標籤 */
.twh-na ul.products li.product .ast-woo-product-category,
.twh-na ul.products li.product .button:not(.twh-card-cart),
.twh-na ul.products li.product .added_to_cart,
.twh-na ul.products li.product .onsale {
	display: none !important;
}

/* 追蹤愛心：40px（twh-wishlist 卡片愛心放大），疊在遮罩上方 */
.twh-na ul.products li.product .twh-wl-btn--icon {
	z-index: 5;
	top: calc(100cqw * 0.12) !important;
	right: calc(100cqw * 0.11) !important;
	width: 40px !important;
	height: 40px !important;
}

.twh-na ul.products li.product .twh-wl-btn--icon .twh-wl-btn__icon {
	width: 20px !important;
	height: 20px !important;
}

/* ---------- hover 加入購物車按鈕 ---------- */
.twh-na ul.products li.product .twh-card-cart {
	position: absolute !important;
	top: calc(100cqw * 0.81);
	left: 50%;
	z-index: 4;
	display: inline-flex !important;
	align-items: center;
	justify-content: center;
	min-width: 58%;
	height: var(--twh-na-btn-h);
	margin: 0 !important;
	padding: 9px 24px !important;
	font-family: var(--twh-na-font) !important;
	font-size: 20px !important;
	font-weight: 700 !important;
	line-height: 1.4 !important;
	color: var(--twh-na-white) !important;
	white-space: nowrap;
	background: var(--twh-na-ink) !important;
	border: 1px solid var(--twh-na-white) !important;
	border-radius: 0 !important;
	box-shadow: none !important;
	opacity: 0;
	pointer-events: none;
	transform: translate(-50%, -50%);
	transition: opacity 0.25s ease, background-color 0.2s ease;
}

.twh-na ul.products li.product .twh-card-cart:hover {
	background: #3a332f !important;
}

.twh-na ul.products li.product .twh-card-cart.loading {
	opacity: 0.6 !important;
}

.twh-na ul.products li.product .twh-card-cart.added::after {
	content: " ✓";
	margin-left: 4px;
}

@media (hover: hover) {
	.twh-na ul.products li.product:hover .astra-shop-thumbnail-wrap {
		border-color: #b58a45;
		box-shadow: 0 4px 40px #b58a45;
	}

	.twh-na ul.products li.product:hover .astra-shop-thumbnail-wrap::after {
		opacity: 1;
	}

	.twh-na ul.products li.product:hover .woocommerce-loop-product__title {
		opacity: 0.6;
	}

	.twh-na ul.products li.product:hover .twh-card-cart,
	.twh-na ul.products li.product .twh-card-cart:focus-visible {
		opacity: 1;
		pointer-events: auto;
	}
}

/* 金色光暈會超出卡片，軌道上下留空間避免被裁切 */
.twh-na ul.products.twh-na__track {
	padding-top: 40px !important;
	padding-bottom: 40px !important;
	margin-top: -40px !important;
	margin-bottom: -40px !important;
}

/* ---------- 左右箭頭 ---------- */
.twh-na .twh-na__arrow {
	position: absolute;
	/* 對齊圖片中線（JS 會依實際卡片寬度更新 --twh-na-img） */
	top: calc(var(--twh-na-img, 416px) / 2);
	margin-top: 0;
	z-index: 5;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 52px;
	height: 52px;
	margin: 0;
	padding: 4px;
	color: var(--twh-na-white);
	background: transparent;
	border: 1px solid var(--twh-na-white);
	border-radius: 999px;
	box-shadow: 0 2px 20px #000;
	cursor: pointer;
	transform: translateY(-50%);
	transition: opacity 0.2s ease;
}

.twh-na .twh-na__arrow:hover,
.twh-na .twh-na__arrow:focus {
	color: var(--twh-na-white);
	background: transparent;
}

.twh-na .twh-na__arrow:focus-visible {
	outline: 2px solid #d1a64f;
	outline-offset: 2px;
}

.twh-na .twh-na__arrow--prev {
	left: 40px;
}

.twh-na .twh-na__arrow--next {
	right: 40px;
}

.twh-na__arrow-inner {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 42px;
	height: 42px;
	background: var(--twh-na-ink);
	border-radius: 100px;
	filter: drop-shadow(0 6px 8px rgba(0, 0, 0, 0.12));
}

.twh-na .twh-na__arrow:disabled {
	opacity: 0.3;
	cursor: default;
}

/* 商品沒超出畫面：不需要箭頭 */
.twh-na.is-static .twh-na__arrow {
	display: none;
}

/* ---------- RWD ---------- */
@media (max-width: 1280px) {
	.twh-na {
		--twh-na-per-view: 3;
		--twh-na-gap: 20px;
	}
}

@media (max-width: 1024px) {
	.twh-na {
		--twh-na-per-view: 2;
	}

	.twh-na ul.products.twh-na__track {
		padding-left: 70px !important;
		padding-right: 70px !important;
		scroll-padding: 0 70px;
	}

	.twh-na .twh-na__arrow--prev {
		left: 16px;
	}

	.twh-na .twh-na__arrow--next {
		right: 16px;
	}
}

@media (max-width: 768px) {
	.twh-na {
		--twh-na-per-view: 1.3;
		--twh-na-gap: 16px;
	}

	.twh-na ul.products.twh-na__track {
		padding-left: 16px !important;
		padding-right: 16px !important;
		scroll-padding: 0 16px;
	}

	.twh-na ul.products li.product .price {
		font-size: 16px !important;
	}

	/* 手機用手指滑，箭頭縮小 */
	.twh-na .twh-na__arrow {
		width: 40px;
		height: 40px;
		padding: 3px;
	}

	.twh-na__arrow-inner {
		width: 32px;
		height: 32px;
	}

	.twh-na .twh-na__arrow--prev {
		left: 8px;
	}

	.twh-na .twh-na__arrow--next {
		right: 8px;
	}
}
