/* ============================================================
   Image Slider / Carousel / Gallery / Lightbox
   (เขียนขึ้นใหม่แทน LayerSlider และ Unite Gallery — ทำงานคู่กับ js/gallery.js)
   ============================================================ */

/* ---------------- Image Slider (_slider.php) ---------------- */
.site-slider {
	position: relative;
	width: 100%;
	overflow: hidden;
	background: #0a1929;
	touch-action: pan-y;
	-webkit-user-select: none;
	user-select: none;
}
.site-slider-track {
	position: absolute;
	inset: 0;
}
.site-slide {
	position: absolute;
	inset: 0;
	visibility: hidden;
	transform: translateX(100%);
}
.site-slide.is-active {
	visibility: visible;
	transform: none;
	z-index: 1;
}
.site-slide img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
	-webkit-user-drag: none;
}

.site-slider-arrow {
	position: absolute;
	top: 50%;
	z-index: 3;
	width: 50px;
	height: 50px;
	margin-top: -25px;
	border: 0;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.22);
	color: #fff;
	font-size: 20px;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	backdrop-filter: blur(4px);
	-webkit-backdrop-filter: blur(4px);
	transition: background 0.25s ease, transform 0.25s ease, opacity 0.25s ease;
	opacity: 0.75;
}
.site-slider-prev { left: 18px; }
.site-slider-next { right: 18px; }
.site-slider:hover .site-slider-arrow { opacity: 1; }
.site-slider-arrow:hover,
.site-slider-arrow:focus-visible {
	background: #0DA7F6;
	transform: scale(1.06);
	opacity: 1;
}
.site-slider-arrow:focus-visible,
.site-slider-dot:focus-visible {
	outline: 3px solid #fff;
	outline-offset: 2px;
}

.site-slider-dots {
	position: absolute;
	left: 0;
	right: 0;
	bottom: 16px;
	z-index: 3;
	display: flex;
	justify-content: center;
	gap: 8px;
}
.site-slider-dot {
	width: 10px;
	height: 10px;
	padding: 0;
	border: 0;
	border-radius: 10px;
	background: rgba(255, 255, 255, 0.6);
	box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
	cursor: pointer;
	transition: width 0.3s ease, background 0.3s ease;
}
.site-slider-dot.is-active {
	width: 28px;
	background: #0DA7F6;
}

.site-slider-progress {
	position: absolute;
	left: 0;
	right: 0;
	bottom: 0;
	z-index: 3;
	height: 4px;
	background: rgba(255, 255, 255, 0.25);
}
.site-slider-progress span {
	display: block;
	width: 0;
	height: 100%;
	background: #0DA7F6;
}

@media (max-width: 767px) {
	.site-slider-arrow { width: 36px; height: 36px; margin-top: -18px; font-size: 15px; }
	.site-slider-prev { left: 8px; }
	.site-slider-next { right: 8px; }
	.site-slider-dots { bottom: 10px; }
	.site-slider-dot { width: 8px; height: 8px; }
	.site-slider-dot.is-active { width: 20px; }
	.site-slider-progress { height: 3px; }
}

/* ---------------- Gallery item (ใช้ร่วมกันทั้ง carousel และ grid) ---------------- */
.gallery-item {
	position: relative;
	display: block;
	overflow: hidden;
	background: #e9eef3;
	cursor: zoom-in;
}
.gallery-item img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
	transition: transform 0.5s ease;
}
.gallery-item::before {
	content: "";
	position: absolute;
	inset: 0;
	z-index: 1;
	background: rgba(0, 0, 0, 0.6);
	opacity: 0;
	transition: opacity 0.3s ease;
}
.gallery-item::after {
	content: "\f00e"; /* Font Awesome: search-plus */
	font-family: "Font Awesome 5 Free";
	font-weight: 900;
	position: absolute;
	top: 50%;
	left: 50%;
	z-index: 2;
	width: 46px;
	height: 46px;
	margin: -23px 0 0 -23px;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.95);
	color: #0DA7F6;
	font-size: 18px;
	display: flex;
	align-items: center;
	justify-content: center;
	box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25);
	opacity: 0;
	transform: scale(0.6);
	transition: opacity 0.3s ease, transform 0.3s ease;
}
.gallery-item:hover::before,
.gallery-item:focus-visible::before,
.gallery-item:hover::after,
.gallery-item:focus-visible::after {
	opacity: 1;
}
.gallery-item:hover::after,
.gallery-item:focus-visible::after { transform: scale(1); }
.gallery-item:hover img,
.gallery-item:focus-visible img { transform: scale(1.08); }
.gallery-item:focus-visible {
	outline: 3px solid #0DA7F6;
	outline-offset: 2px;
}

/* ---------------- Grid gallery ---------------- */
.site-gallery {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(min(175px, calc(50% - 5px)), 1fr));
	gap: 10px;
}
.site-gallery .gallery-item {
	aspect-ratio: 1 / 1;
	border-radius: 5px;
}
.site-gallery-wide .gallery-item { aspect-ratio: 176 / 140; }

/* ---------------- Carousel ---------------- */
.site-carousel {
	position: relative;
}
.site-carousel-track {
	display: flex;
	gap: 14px;
	overflow-x: auto;
	overscroll-behavior-x: contain;
	scroll-snap-type: x mandatory;
	scroll-behavior: smooth;
	scrollbar-width: none;
	-webkit-overflow-scrolling: touch;
	padding: 12px 4px 26px; /* เผื่อพื้นที่ให้เงาและเอฟเฟกต์ลอยตอน hover */
}
.site-carousel-track::-webkit-scrollbar { display: none; }
.site-carousel-item {
	flex: 0 0 180px;
	aspect-ratio: 1 / 1;
	scroll-snap-align: start;
	border-radius: 14px;
	box-shadow: 0 6px 18px rgba(28, 53, 82, 0.10), 0 2px 4px rgba(28, 53, 82, 0.06);
	transition: transform 0.35s cubic-bezier(.34, 1.56, .64, 1), box-shadow 0.3s ease;
}
.site-carousel-item:hover {
	transform: translateY(-6px) scale(1.02);
	box-shadow: 0 16px 32px rgba(13, 167, 246, 0.22), 0 6px 10px rgba(28, 53, 82, 0.12);
}
.site-carousel-item::before {
	background: linear-gradient(135deg, rgba(13, 167, 246, 0.55) 0%, rgba(24, 119, 242, 0.65) 100%);
}

.site-carousel-arrow {
	position: absolute;
	top: 50%;
	z-index: 3;
	width: 42px;
	height: 42px;
	margin-top: -28px;
	border: 0;
	border-radius: 50%;
	background: #fff;
	color: #0DA7F6;
	font-size: 16px;
	display: flex;
	align-items: center;
	justify-content: center;
	box-shadow: 0 6px 18px rgba(28, 53, 82, 0.18);
	cursor: pointer;
	transition: background 0.25s ease, color 0.25s ease, transform 0.25s ease;
}
.site-carousel-prev { left: -10px; }
.site-carousel-next { right: -10px; }
.site-carousel-arrow:hover,
.site-carousel-arrow:focus-visible {
	background: #0DA7F6;
	color: #fff;
	transform: scale(1.06);
}
.site-carousel-arrow:focus-visible {
	outline: 3px solid #1877F2;
	outline-offset: 2px;
}
/* รูปน้อยจนไม่ต้องเลื่อน: ซ่อนลูกศรและจัดกึ่งกลาง */
.site-carousel.is-static .site-carousel-arrow { display: none; }
.site-carousel.is-static .site-carousel-track { justify-content: center; }

@media (max-width: 767px) {
	.site-carousel-item { flex-basis: 150px; }
	.site-carousel-arrow { width: 36px; height: 36px; margin-top: -24px; font-size: 14px; }
	.site-carousel-prev { left: -4px; }
	.site-carousel-next { right: -4px; }
}

/* ---------------- Lightbox ---------------- */
html.site-lightbox-open,
html.site-lightbox-open body { overflow: hidden; }

.site-lightbox {
	position: fixed;
	inset: 0;
	z-index: 100000;
	display: flex;
	align-items: center;
	justify-content: center;
	opacity: 0;
	transition: opacity 0.25s ease;
}
.site-lightbox[hidden] { display: none; }
.site-lightbox.is-visible { opacity: 1; }
.site-lightbox-backdrop {
	position: absolute;
	inset: 0;
	background: rgba(10, 25, 41, 0.92);
}
.site-lightbox-stage {
	position: relative;
	z-index: 1;
	margin: 0;
	max-width: calc(100vw - 140px);
	max-height: calc(100vh - 120px);
	display: flex;
	flex-direction: column;
	align-items: center;
	touch-action: pan-y;
}
.site-lightbox-img {
	display: block;
	max-width: 100%;
	max-height: calc(100vh - 160px);
	width: auto;
	height: auto;
	border-radius: 12px;
	box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
	transform: scale(0.96);
	transition: transform 0.3s ease, opacity 0.2s ease;
	-webkit-user-drag: none;
	-webkit-user-select: none;
	user-select: none;
}
.site-lightbox.is-visible .site-lightbox-img { transform: none; }
.site-lightbox.is-loading .site-lightbox-img { opacity: 0.25; }
.site-lightbox-caption {
	margin-top: 14px;
	color: #fff;
	font-family: 'Prompt', sans-serif;
	font-size: 15px;
	text-align: center;
	opacity: 0.9;
}
.site-lightbox-counter {
	position: absolute;
	top: 22px;
	left: 24px;
	z-index: 2;
	color: #fff;
	font-family: 'Prompt', sans-serif;
	font-size: 15px;
	opacity: 0.85;
}
.site-lightbox-spinner {
	position: absolute;
	top: 50%;
	left: 50%;
	z-index: 2;
	width: 42px;
	height: 42px;
	margin: -21px 0 0 -21px;
	border: 3px solid rgba(255, 255, 255, 0.25);
	border-top-color: #0DA7F6;
	border-radius: 50%;
	animation: site-lightbox-spin 0.8s linear infinite;
	display: none;
}
.site-lightbox.is-loading .site-lightbox-spinner { display: block; }
@keyframes site-lightbox-spin { to { transform: rotate(360deg); } }

.site-lightbox-btn {
	position: absolute;
	z-index: 2;
	width: 48px;
	height: 48px;
	border: 0;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.14);
	color: #fff;
	font-size: 20px;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	transition: background 0.25s ease, transform 0.25s ease;
}
.site-lightbox-btn:hover,
.site-lightbox-btn:focus-visible {
	background: #0DA7F6;
	transform: scale(1.06);
}
.site-lightbox-btn:focus-visible {
	outline: 3px solid #fff;
	outline-offset: 2px;
}
.site-lightbox-close { top: 16px; right: 18px; }
.site-lightbox-prev { left: 20px; top: 50%; margin-top: -24px; }
.site-lightbox-next { right: 20px; top: 50%; margin-top: -24px; }
.site-lightbox.is-single .site-lightbox-prev,
.site-lightbox.is-single .site-lightbox-next,
.site-lightbox.is-single .site-lightbox-counter { display: none; }

@media (max-width: 767px) {
	.site-lightbox-stage { max-width: calc(100vw - 20px); }
	.site-lightbox-img { max-height: calc(100vh - 190px); border-radius: 8px; }
	.site-lightbox-prev,
	.site-lightbox-next { top: auto; bottom: 24px; margin-top: 0; }
	.site-lightbox-prev { left: calc(50% - 64px); }
	.site-lightbox-next { right: calc(50% - 64px); }
	.site-lightbox-counter { top: 26px; left: 18px; }
}

@media (prefers-reduced-motion: reduce) {
	.site-carousel-track { scroll-behavior: auto; }
	.site-slider-dot,
	.site-carousel-item,
	.gallery-item img,
	.gallery-item::before,
	.gallery-item::after,
	.site-lightbox,
	.site-lightbox-img { transition: none; }
}
