/* Block Thẻ ảnh xếp chồng (Figma "Detail page → Our responsibility" → Frame 82: 1920 × 1194, nền gradient trắng → trong suốt;
   chữ nền "PEOPLE & PLANET" tràn 2 mép; thẻ trước 1200 × 640 top 395, thẻ sau 900 rộng top 355, 700 rộng top 313) */

.block-card-stack {
	position: relative;
	padding: clamp(80px, 16.3vw, 313px) var(--gutter) clamp(64px, 8.28vw, 159px);
	overflow-x: clip;
	background: linear-gradient(180deg, #fff, rgba(255, 255, 255, 0));
	isolation: isolate;
}

.block-card-stack__decor {
	position: absolute;
	top: clamp(16px, 2.86vw, 55px);
	left: 50%;
	z-index: -1;
	font-size: calc(clamp(56px, 10.31vw, 198px) * var(--fit, 1)); /* site.js co cho vừa bề ngang khung (FIT) */
	transform: translateX(-50%);
}

/* Khung chứa: rộng bằng thẻ trước (62.5%), cao = phần ló của 2 thẻ sau (82) + thẻ trước (640). */
.card-stack {
	position: relative;
	margin-inline: auto;
	aspect-ratio: 1200 / 722;
}

@media (min-width: 1024px) {
	.card-stack {
		width: 62.5vw;
	}
}

.stack-card {
	--w: 58.33%;            /* 700 / 1200 */
	--top: 0%;
	--z: 1;
	position: absolute;
	top: var(--top);
	left: 50%;
	z-index: var(--z);
	width: var(--w);
	overflow: hidden;
	border-radius: var(--radius-md);
	aspect-ratio: 1200 / 640;
	transform: translateX(-50%);
	container-type: inline-size;
	transition: width 0.45s ease, top 0.45s ease, translate 0.2s ease, box-shadow 0.45s ease, opacity 0.4s ease;
}

.stack-card[data-pos="0"] {
	--w: 100%;
	--top: 11.36%;          /* 82 / 722 */
	--z: 3;
	box-shadow: 0 16px 40px rgba(0, 0, 0, 0.18);
}

.stack-card[data-pos="1"] {
	--w: 75%;               /* 900 / 1200 */
	--top: 5.82%;           /* 42 / 722 */
	--z: 2;
}

/* Từ thẻ thứ 4 trở đi nằm khuất sau thẻ thứ 3. */
.stack-card:not([data-pos="0"], [data-pos="1"], [data-pos="2"]) {
	visibility: hidden;
}

.stack-card__image {
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.stack-card > picture {
	display: contents;
}

.stack-card__title {
	position: absolute;
	inset: 0;
	display: grid;
	place-items: center;
	padding: 16px;
	/* Theo bề ngang thẻ (~110 / 1200), nhỏ lại theo từ dài nhất để chữ luôn cách mép thẻ (Community, Environment, bản VI). */
	font-size: min(9.2cqi, 86cqi / var(--title-chars, 9));
	font-weight: 900;
	line-height: 1;
	text-align: center;
	text-transform: uppercase;
	color: #fff;
	text-shadow: 0 2px 24px rgba(0, 0, 0, 0.25);
	transition: opacity 0.3s;
}

/* Tiêu đề thẻ phía sau: ẩn trên giao diện, vẫn có trong HTML. */
.stack-card:not([data-pos="0"]) .stack-card__title {
	opacity: 0;
}

/* Có JS: thẻ phía sau bấm được để đưa lên trước. */
.is-stack-ready .stack-card:not([data-pos="0"]) {
	cursor: pointer;
}

.is-stack-ready .stack-card:not([data-pos="0"]):is(:hover, :focus-visible) {
	translate: 0 -8px;
}

.stack-card:focus-visible {
	outline: 3px solid var(--color-primary);
	outline-offset: 3px;
}

/* Chú thích của thẻ đang ở trước (theo ref: dòng chữ nhỏ dưới chồng thẻ). Không có JS: hiện mọi chú thích. */
.card-stack__captions {
	display: grid;
	max-width: 640px;
	margin: clamp(20px, 1.67vw, 32px) auto 0;
	text-align: center;
}

.card-stack__caption {
	font-size: clamp(14px, 0.94vw, 18px);
	line-height: 1.5;
	color: var(--color-text-muted);
}

.card-stack__caption + .card-stack__caption {
	margin-top: 12px;
}

.card-stack__caption[hidden] {
	display: none;
}

.card-stack__caption strong {
	display: block;
	margin-bottom: 4px;
	font-family: var(--font-display);
	font-size: clamp(13px, 0.83vw, 16px);
	font-weight: 800;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: var(--color-text);
}

.is-stack-ready .card-stack__caption:not([hidden]) {
	animation: caption-in 0.5s ease;
}

@keyframes caption-in {
	from { opacity: 0; transform: translateY(8px); }
}

/* Tự rơi lặp vô hạn (card-stack.js gắn .is-looping): thẻ nào cũng rộng và đặt như thẻ trước; JS đặt transform (dời, xoay,
   thu nhỏ quanh mép trên), độ mờ, --z và độ rõ tiêu đề --title theo thời gian. Mỗi khung hình chỉ đổi transform / opacity
   (GPU, không tính lại bố cục) nên mượt; tắt transition. Thẻ rơi bị cắt ở mép dưới section (đã mờ dần trước đó), không đè
   lên phần dưới trang. */
.block-card-stack.is-looping {
	overflow: clip;
}

.is-looping .stack-card {
	--w: 100%;
	--top: 11.36%;
	visibility: visible;
	box-shadow: 0 16px 40px rgba(0, 0, 0, 0.18);
	transform-origin: 50% 0;
	transition: none;
	will-change: transform, opacity;
}

/* Thẻ tự đổi, không bấm – bỏ hiệu ứng nhấc thẻ khi rê chuột. */
.block-card-stack.is-looping.is-stack-ready .stack-card {
	translate: none;
	cursor: default;
}

.block-card-stack.is-looping .stack-card__title {
	opacity: var(--title, 1);
	transition: none;
}

@media (prefers-reduced-motion: reduce) {
	.stack-card,
	.stack-card__title {
		transition: none;
	}
}
