/*
 * Slider ảnh dự án — reti/project-gallery
 *
 * WordPress chỉ nạp file này khi khối có mặt trên trang (cơ chế của block.json),
 * nên xoá khối là CSS biến mất theo.
 *
 * Dải ảnh là scroll-snap THUẦN CSS: không có JavaScript vẫn vuốt/cuộn được từng
 * ảnh. view.js chỉ thêm mũi tên, thumbnail và phím mũi tên khi đã chạy xong và
 * gắn class `is-ready` — chưa có class đó thì các điều khiển ấy ẩn, không có nút
 * chết nằm trên trang.
 *
 * Màu lấy từ biến của theme, giá trị sau dấu phẩy là lưới an toàn.
 *
 * VỀ ĐỘ TƯƠNG PHẢN: chữ trắng trên cam #ef532d đạt 3,53:1 — đủ cho chữ lớn,
 * chưa đủ cho chữ thường (cần 4,5:1). Nút hành động dùng cam đúng như thiết kế;
 * muốn đạt 4,5:1 thì đặt --reti-pg-action-bg thành #d23606 (brand-hover).
 */

.wp-block-reti-project-gallery {
	--reti-pg-ratio: 4 / 3;
	--reti-pg-action-bg: var(--wp--preset--color--brand, #ef532d);
	--reti-pg-action-bg-hover: var(--wp--custom--color--brand-hover, #d23606);
	--reti-pg-action-fg: var(--wp--preset--color--fg-on-brand, #ffffff);
	--reti-pg-focus: var(--wp--custom--color--focus, #ef532d);
	--reti-pg-radius: var(--wp--custom--radius--md, 0.5rem);

	max-inline-size: 100%;
}

/* ---- Khung ảnh lớn ---- */

.wp-block-reti-project-gallery .reti-pg__stage {
	position: relative;
	overflow: hidden;
	border-radius: var(--reti-pg-radius);
	background: var(--wp--preset--color--surface, #f2f6f7);
}

.wp-block-reti-project-gallery .reti-pg__track {
	display: flex;
	overflow-x: auto;
	aspect-ratio: var(--reti-pg-ratio);
	scroll-snap-type: x mandatory;
	overscroll-behavior-x: contain;
	scrollbar-width: none;
}

.wp-block-reti-project-gallery .reti-pg__track::-webkit-scrollbar {
	display: none;
}

.wp-block-reti-project-gallery .reti-pg__track:focus-visible {
	outline: 2px solid var(--reti-pg-focus);
	outline-offset: -2px;
}

.wp-block-reti-project-gallery .reti-pg__slide {
	flex: 0 0 100%;
	min-inline-size: 0;
	scroll-snap-align: start;
	scroll-snap-stop: always;
}

.wp-block-reti-project-gallery .reti-pg__slide img {
	display: block;
	inline-size: 100%;
	block-size: 100%;
	max-inline-size: none;
	object-fit: cover;
}

/* ---- Nhãn nổi bật ---- */

.wp-block-reti-project-gallery .reti-pg__badges {
	position: absolute;
	inset-block-start: 0.75rem;
	inset-inline-start: 0.75rem;
	z-index: 2;
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: 0.5rem;
	margin: 0;
	padding: 0;
	list-style: none;
	pointer-events: none;
}

.wp-block-reti-project-gallery .reti-pg__badge {
	display: inline-flex;
	align-items: center;
	gap: 0.375rem;
	margin: 0;
	padding: 0.25rem 0.5rem;
	border-radius: var(--wp--custom--radius--sm, 0.25rem);
	font-size: 0.75rem;
	font-weight: 700;
	line-height: 1.2;
	letter-spacing: 0.02em;
	text-transform: uppercase;
	color: #ffffff;
	background: var(--wp--preset--color--accent, #196572);
}

.wp-block-reti-project-gallery .reti-pg__badge.is-tone-success {
	background: var(--wp--custom--color--success, #138145);
}

.wp-block-reti-project-gallery .reti-pg__badge.is-tone-brand {
	background: var(--wp--preset--color--brand, #ef532d);
}

.wp-block-reti-project-gallery .reti-pg__badge.is-tone-warm {
	color: var(--wp--preset--color--fg-strong, #000000);
	background: var(--wp--preset--color--brand-warm, #f8bf4b);
}

.wp-block-reti-project-gallery .reti-pg__badge.is-tone-neutral {
	background: var(--wp--preset--color--fg, #3f4140);
}

.wp-block-reti-project-gallery .reti-pg__badge .reti-pb-icon {
	flex: none;
	inline-size: 1em;
	block-size: 1em;
}

/* ---- Mũi tên: chỉ hiện khi JS đã sẵn sàng ---- */

.wp-block-reti-project-gallery .reti-pg__arrow {
	position: absolute;
	inset-block-start: 50%;
	z-index: 2;
	display: none;
	align-items: center;
	justify-content: center;
	inline-size: 2.5rem;
	block-size: 2.5rem;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 50%;
	font-size: 1.5rem;
	color: var(--wp--preset--color--accent, #196572);
	background: rgb(255 255 255 / 0.72);
	cursor: pointer;
	transform: translateY(-50%);
	transition: background-color 0.15s ease, opacity 0.15s ease;
}

.wp-block-reti-project-gallery.is-ready .reti-pg__arrow {
	display: inline-flex;
}

.wp-block-reti-project-gallery .reti-pg__arrow:hover:not(:disabled) {
	background: #ffffff;
}

.wp-block-reti-project-gallery .reti-pg__arrow:focus-visible {
	outline: 2px solid var(--reti-pg-focus);
	outline-offset: 2px;
}

.wp-block-reti-project-gallery .reti-pg__arrow:disabled {
	opacity: 0.4;
	cursor: default;
}

.wp-block-reti-project-gallery .reti-pg__arrow--prev {
	inset-inline-start: 0.75rem;
}

.wp-block-reti-project-gallery .reti-pg__arrow--next {
	inset-inline-end: 0.75rem;
}

[dir="rtl"] .wp-block-reti-project-gallery .reti-pg__arrow .reti-pb-icon {
	transform: scaleX(-1);
}

/* ---- Thanh dưới: thumbnail bên trái, hai nút bên phải ---- */

.wp-block-reti-project-gallery .reti-pg__bar {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 1rem;
	margin-block-start: 0.75rem;
}

.wp-block-reti-project-gallery .reti-pg__thumbs {
	position: relative; /* để offsetLeft của thumbnail tính từ dải này. */
	display: none;
	flex: 1 1 auto;
	gap: 0.5rem;
	min-inline-size: 0;
	padding: 2px;
	overflow-x: auto;
	scrollbar-width: thin;
}

.wp-block-reti-project-gallery.is-ready .reti-pg__thumbs {
	display: flex;
}

.wp-block-reti-project-gallery .reti-pg__thumb {
	flex: 0 0 auto;
	inline-size: 4.625rem;
	aspect-ratio: 74 / 68;
	margin: 0;
	padding: 0;
	overflow: hidden;
	border: 2px solid transparent;
	border-radius: var(--wp--custom--radius--sm, 0.25rem);
	background: var(--wp--preset--color--surface, #f2f6f7);
	opacity: 0.7;
	cursor: pointer;
	transition: opacity 0.15s ease, border-color 0.15s ease;
}

.wp-block-reti-project-gallery .reti-pg__thumb:hover,
.wp-block-reti-project-gallery .reti-pg__thumb[aria-current="true"] {
	opacity: 1;
}

.wp-block-reti-project-gallery .reti-pg__thumb[aria-current="true"] {
	border-color: var(--wp--preset--color--brand, #ef532d);
}

.wp-block-reti-project-gallery .reti-pg__thumb:focus-visible {
	outline: 2px solid var(--reti-pg-focus);
	outline-offset: 2px;
}

.wp-block-reti-project-gallery .reti-pg__thumb img {
	display: block;
	inline-size: 100%;
	block-size: 100%;
	object-fit: cover;
}

.wp-block-reti-project-gallery .reti-pg__actions {
	display: flex;
	flex: 0 0 auto;
	gap: 0.5rem;
	margin-inline-start: auto;
}

.wp-block-reti-project-gallery .reti-pg__action {
	display: inline-flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 0.25rem;
	inline-size: 5.5rem;
	block-size: 4.25rem;
	padding: 0.25rem;
	border-radius: var(--wp--custom--radius--sm, 0.25rem);
	font-size: 0.8125rem;
	font-weight: 600;
	line-height: 1.2;
	text-align: center;
	text-decoration: none;
	color: var(--reti-pg-action-fg);
	background: var(--reti-pg-action-bg);
	transition: background-color 0.15s ease;
}

.wp-block-reti-project-gallery .reti-pg__action:hover {
	color: var(--reti-pg-action-fg);
	background: var(--reti-pg-action-bg-hover);
}

.wp-block-reti-project-gallery .reti-pg__action:focus-visible {
	outline: 2px solid var(--reti-pg-focus);
	outline-offset: 2px;
}

.wp-block-reti-project-gallery .reti-pg__action .reti-pb-icon {
	flex: none;
	inline-size: 1.5rem;
	block-size: 1.5rem;
}

/* Chữ cho trình đọc màn hình, ẩn khỏi mắt. Tự khai vì theme không đảm bảo có. */
.wp-block-reti-project-gallery .reti-pg__sr {
	position: absolute;
	inline-size: 1px;
	block-size: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	border: 0;
	clip-path: inset(50%);
	white-space: nowrap;
}

/*
 * Dưới 782px thanh dưới xếp dọc: thumbnail trên, hai nút dưới và chia đều bề
 * ngang để dễ chạm. 782px trùng ngưỡng core dùng để xếp chồng wp:columns.
 */
@media (max-width: 781px) {
	.wp-block-reti-project-gallery .reti-pg__bar {
		flex-direction: column;
		align-items: stretch;
	}

	.wp-block-reti-project-gallery .reti-pg__actions {
		margin-inline-start: 0;
	}

	.wp-block-reti-project-gallery .reti-pg__action {
		flex: 1 1 0;
		flex-direction: row;
		inline-size: auto;
		block-size: 3rem;
		gap: 0.5rem;
	}

	.wp-block-reti-project-gallery .reti-pg__thumb {
		inline-size: 3.75rem;
	}
}

@media (prefers-reduced-motion: reduce) {
	.wp-block-reti-project-gallery .reti-pg__arrow,
	.wp-block-reti-project-gallery .reti-pg__thumb,
	.wp-block-reti-project-gallery .reti-pg__action {
		transition: none;
	}
}
