/**
 * [hotel_gallery] — lưới ảnh + khung phóng to.
 */

.htb-gallery {
	--htb-gallery-cols: 4;
	--htb-gallery-cols-current: var(--htb-gallery-cols);
	--htb-gallery-cols-tablet: 3;
	--htb-gallery-cols-mobile: 2;
	--htb-gallery-gap: 14px;
	--htb-gallery-ratio: 4/3;
	--htb-gallery-row: clamp(84px, 9vw, 150px);

	margin: 0 0 24px;
}

.htb-gallery__item {
	margin: 0;
	min-width: 0;
}

.htb-gallery__link {
	display: block;
	width: 100%;
	padding: 0;
	border: 0;
	border-radius: 0;
	overflow: hidden;
	background: #eef2f4;
	cursor: pointer;
	position: relative;
	line-height: 0;
}

.htb-gallery__link--static {
	cursor: default;
}

.htb-gallery__img {
	display: block;
	width: 100%;
	transition: transform .35s ease;
}

/* ---------- masonry / editorial: CSS Grid tiles with varied spans ---------- */

.htb-gallery--masonry {
	display: grid;
	grid-template-columns: repeat(var(--htb-gallery-cols-current), minmax(0, 1fr));
	grid-auto-flow: dense;
	grid-auto-rows: var(--htb-gallery-row);
	gap: var(--htb-gallery-gap);
	align-items: stretch;
}

.htb-gallery--masonry .htb-gallery__item {
	display: flex;
	flex-direction: column;
	gap: 7px;
	grid-row: span 2;
	min-height: 0;
}

.htb-gallery--masonry .htb-gallery__link {
	flex: 1 1 auto;
	height: 100%;
	min-height: 0;
}

.htb-gallery--masonry .htb-gallery__img {
	height: 100%;
	object-fit: cover;
}

.htb-gallery--masonry .htb-gallery__caption {
	margin-top: 0;
}

.htb-gallery--masonry:where(.htb-gallery--cols-3, .htb-gallery--cols-4, .htb-gallery--cols-5, .htb-gallery--cols-6) .htb-gallery__item:nth-child(7n+1) {
	grid-column: span 2;
	grid-row: span 3;
}

.htb-gallery--masonry:where(.htb-gallery--cols-3, .htb-gallery--cols-4, .htb-gallery--cols-5, .htb-gallery--cols-6) .htb-gallery__item:nth-child(7n+3) {
	grid-row: span 3;
}

.htb-gallery--masonry:where(.htb-gallery--cols-4, .htb-gallery--cols-5, .htb-gallery--cols-6) .htb-gallery__item:nth-child(9n+5) {
	grid-column: span 2;
	grid-row: span 2;
}

.htb-gallery--masonry:where(.htb-gallery--cols-5, .htb-gallery--cols-6) .htb-gallery__item:nth-child(11n+8) {
	grid-row: span 4;
}

.htb-gallery--masonry.htb-gallery--cols-2 .htb-gallery__item:nth-child(4n+1) {
	grid-row: span 3;
}

.htb-gallery--masonry.htb-gallery--cols-1 {
	grid-auto-rows: auto;
}

.htb-gallery--masonry.htb-gallery--cols-1 .htb-gallery__item {
	grid-row: auto;
}

.htb-gallery--masonry.htb-gallery--cols-1 .htb-gallery__link {
	height: auto;
}

.htb-gallery--masonry.htb-gallery--cols-1 .htb-gallery__img {
	height: auto;
	object-fit: contain;
}

/* ---------- grid: mọi ảnh cắt về cùng một tỉ lệ ---------- */

.htb-gallery--grid {
	display: grid;
	grid-template-columns: repeat(var(--htb-gallery-cols-current), minmax(0, 1fr));
	gap: var(--htb-gallery-gap);
}

.htb-gallery--grid .htb-gallery__link {
	aspect-ratio: var(--htb-gallery-ratio);
}

.htb-gallery--grid .htb-gallery__img {
	height: 100%;
	object-fit: cover;
}

.htb-gallery__link:hover .htb-gallery__img,
.htb-gallery__link:focus-visible .htb-gallery__img {
	transform: scale(1.05);
}

.htb-gallery__link:focus-visible {
	outline: 2px solid #558D9C;
	outline-offset: 2px;
}

.htb-gallery__caption {
	margin-top: 7px;
	font-size: 13.5px;
	line-height: 1.45;
	color: #5a757d;
	text-align: center;
}

.htb-gallery__caption a {
	color: inherit;
	text-decoration: none;
}

.htb-gallery__caption a:hover {
	color: #558D9C;
	text-decoration: underline;
}

/* Trình duyệt cũ không có aspect-ratio: chừa chiều cao bằng padding (chỉ layout grid) */
@supports not (aspect-ratio: 1) {
	.htb-gallery--grid .htb-gallery__link {
		height: 0;
		padding-bottom: 75%;
	}

	.htb-gallery--grid .htb-gallery__img {
		position: absolute;
		inset: 0;
	}
}

@media (max-width: 900px) {
	.htb-gallery {
		--htb-gallery-cols-current: var(--htb-gallery-cols-tablet);
		--htb-gallery-row: clamp(82px, 15vw, 136px);
	}
}

@media (max-width: 640px) {
	.htb-gallery {
		--htb-gallery-cols-current: var(--htb-gallery-cols-mobile);
		--htb-gallery-gap: 10px;
		--htb-gallery-row: clamp(74px, 22vw, 116px);
	}

	.htb-gallery__caption {
		font-size: 12.5px;
	}

	.htb-gallery--masonry .htb-gallery__item:nth-child(n) {
		grid-column: auto;
		grid-row: span 2;
	}

	.htb-gallery--masonry:where(.htb-gallery--cols-2, .htb-gallery--cols-3, .htb-gallery--cols-4, .htb-gallery--cols-5, .htb-gallery--cols-6) .htb-gallery__item:nth-child(5n+1) {
		grid-column: span 2;
		grid-row: span 3;
	}

	.htb-gallery--masonry.htb-gallery--cols-1 .htb-gallery__item:nth-child(n) {
		grid-row: auto;
	}

	.htb-gallery--masonry.htb-gallery--cols-1 .htb-gallery__link {
		height: auto;
	}

	.htb-gallery--masonry.htb-gallery--cols-1 .htb-gallery__img {
		height: auto;
		object-fit: contain;
	}
}

@media (max-width: 430px) {
	.htb-gallery {
		--htb-gallery-cols-current: 1;
	}

	.htb-gallery--masonry {
		grid-auto-rows: auto;
	}

	.htb-gallery--masonry .htb-gallery__item:nth-child(n) {
		grid-column: auto;
		grid-row: auto;
	}

	.htb-gallery--masonry .htb-gallery__link {
		height: auto;
	}

	.htb-gallery--masonry .htb-gallery__img {
		height: auto;
		object-fit: contain;
	}
}

/* ---------- Khung phóng to ---------- */

.htb-lightbox {
	position: fixed;
	inset: 0;
	z-index: 100000;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 40px 16px;
	background: rgba(12, 22, 26, .92);
	animation: htb-lightbox-in .16s ease;
}

.htb-lightbox[hidden] {
	display: none;
}

.htb-lightbox__stage {
	margin: 0;
	max-width: 100%;
	max-height: 100%;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 12px;
}

.htb-lightbox__stage img {
	display: block;
	max-width: 100%;
	max-height: calc(100vh - 140px);
	width: auto;
	height: auto;
	border-radius: 0;
	box-shadow: 0 20px 50px rgba(0, 0, 0, .5);
}

.htb-lightbox__stage figcaption {
	color: #dfe9ec;
	font-size: 14px;
	text-align: center;
}

.htb-lightbox__close,
.htb-lightbox__nav {
	position: absolute;
	border: 0;
	background: rgba(255, 255, 255, .12);
	color: #fff;
	cursor: pointer;
	border-radius: 0;
	line-height: 1;
	transition: background .15s ease;
}

.htb-lightbox__close:hover,
.htb-lightbox__nav:hover {
	background: rgba(255, 255, 255, .24);
}

.htb-lightbox__close {
	top: 16px;
	right: 16px;
	width: 42px;
	height: 42px;
	font-size: 26px;
}

.htb-lightbox__nav {
	top: 50%;
	transform: translateY(-50%);
	width: 48px;
	height: 48px;
	font-size: 30px;
}

.htb-lightbox__nav--prev { left: 16px; }
.htb-lightbox__nav--next { right: 16px; }

/* Chỉ có một ảnh thì hai nút chuyển ảnh là thừa */
.htb-lightbox.is-single .htb-lightbox__nav {
	display: none;
}

@keyframes htb-lightbox-in {
	from { opacity: 0; }
	to   { opacity: 1; }
}

@media (max-width: 640px) {
	.htb-lightbox {
		padding: 56px 8px;
	}

	.htb-lightbox__nav {
		width: 40px;
		height: 40px;
		font-size: 24px;
	}

	.htb-lightbox__nav--prev { left: 6px; }
	.htb-lightbox__nav--next { right: 6px; }
}

body.htb-lightbox-open {
	overflow: hidden;
}
