/*
  site-slider.css
  สไลด์ภาพ (image slider) ที่เขียนขึ้นใช้เอง
  ใช้แทน LayerSlider ที่เลิกใช้แล้ว — ไม่พึ่ง jQuery และไม่พึ่งไลบรารีภายนอก

  สัดส่วนกรอบภาพกำหนดผ่านตัวแปร --site-slider-ratio (กว้าง / สูง)
  เพื่อกันหน้าเว็บกระตุกตอนภาพยังโหลดไม่เสร็จ
*/

.site-slider {
	--site-slider-ratio: 16 / 9;
	--site-slider-accent: #F04D2F;
	position: relative;
	width: 100%;
	margin: 0 auto;
	overflow: hidden;
	background: #11161d;
	-webkit-user-select: none;
	user-select: none;
}

/* กรอบภาพ : ล็อกสัดส่วนไว้ล่วงหน้า */
.site-slider__viewport {
	position: relative;
	width: 100%;
	aspect-ratio: var(--site-slider-ratio);
	overflow: hidden;
}

/* เบราว์เซอร์เก่าที่ยังไม่รู้จัก aspect-ratio */
@supports not (aspect-ratio: 1 / 1) {
	.site-slider__viewport {
		height: 0;
		padding-bottom: 56.25%;
	}
}

.site-slider__track {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
}

.site-slider__slide {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	overflow: hidden;
}

.site-slider__img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
	object-position: 50% 50%;
}

/* ---------- เอฟเฟกต์ fade (ค่าเริ่มต้น) ---------- */

.site-slider--fade .site-slider__slide {
	opacity: 0;
	visibility: hidden;
	transition: opacity .8s ease, visibility .8s ease;
	z-index: 1;
}

.site-slider--fade .site-slider__slide.is-active {
	opacity: 1;
	visibility: visible;
	z-index: 2;
}

/* ซูมช้า ๆ (Ken Burns) เฉพาะภาพที่กำลังแสดง */
.site-slider--kenburns .site-slider__slide.is-active .site-slider__img {
	animation: site-slider-kenburns 9s ease-out forwards;
}

@keyframes site-slider-kenburns {
	from { transform: scale(1); }
	to   { transform: scale(1.08); }
}

/* ---------- เอฟเฟกต์ slide (เลื่อนตามแนวนอน) ---------- */

.site-slider--slide .site-slider__track {
	display: flex;
	will-change: transform;
	transition: transform .6s cubic-bezier(.22, .61, .36, 1);
}

.site-slider--slide .site-slider__slide {
	position: relative;
	flex: 0 0 100%;
	width: 100%;
}

.site-slider--slide.is-dragging .site-slider__track {
	transition: none;
}

/* ---------- คำบรรยายบนสไลด์ ---------- */

.site-slider__caption {
	position: absolute;
	left: 50%;
	bottom: 5%;
	z-index: 3;
	width: 94%;
	max-width: 1100px;
	transform: translateX(-50%);
	padding: 22px 26px;
	box-sizing: border-box;
	border-radius: 10px;
	background: rgba(0, 0, 0, .6);
	color: #fff;
	text-align: center;
	font-weight: 400;
	line-height: 1.5;
	font-size: clamp(16px, 2.2vw, 34px);
}

/* ---------- ปุ่มก่อนหน้า / ถัดไป ---------- */

.site-slider__arrow {
	position: absolute;
	top: 50%;
	z-index: 6;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 48px;
	height: 48px;
	margin-top: -24px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: rgba(0, 0, 0, .4);
	color: #fff;
	font-size: 18px;
	line-height: 1;
	cursor: pointer;
	opacity: 0;
	-webkit-appearance: none;
	appearance: none;
	transition: opacity .25s ease, background .25s ease, transform .25s ease;
}

.site-slider__arrow--prev { left: 18px; }
.site-slider__arrow--next { right: 18px; }

.site-slider:hover .site-slider__arrow,
.site-slider:focus-within .site-slider__arrow {
	opacity: 1;
}

.site-slider__arrow:hover {
	background: var(--site-slider-accent);
	transform: scale(1.08);
}

.site-slider__arrow:focus-visible {
	opacity: 1;
	outline: 3px solid #fff;
	outline-offset: 2px;
}

/* บนจอสัมผัสให้ปุ่มแสดงตลอด เพราะไม่มีสถานะ hover */
@media (hover: none) {
	.site-slider__arrow { opacity: 1; }
}

/* ---------- จุดบอกตำแหน่ง ---------- */

.site-slider__dots {
	position: absolute;
	left: 0;
	right: 0;
	bottom: 14px;
	z-index: 6;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	padding: 0;
	margin: 0;
	list-style: none;
}

.site-slider__dot {
	width: 26px;
	height: 8px;
	padding: 0;
	border: 2px solid var(--site-slider-accent);
	border-radius: 10px;
	background: transparent;
	cursor: pointer;
	-webkit-appearance: none;
	appearance: none;
	transition: background .25s ease, width .25s ease;
}

.site-slider__dot.is-active {
	width: 40px;
	background: var(--site-slider-accent);
}

.site-slider__dot:focus-visible {
	outline: 3px solid #fff;
	outline-offset: 2px;
}

/* ---------- แถบความคืบหน้าของ autoplay ---------- */

.site-slider__progress {
	position: absolute;
	left: 0;
	right: 0;
	bottom: 0;
	z-index: 6;
	height: 3px;
	background: rgba(255, 255, 255, .18);
}

.site-slider__progress > span {
	display: block;
	width: 0;
	height: 100%;
	background: var(--site-slider-accent);
	transition: width .2s linear;
}

/* ---------- ก่อน JS ทำงาน : โชว์เฉพาะสไลด์แรก กันภาพซ้อนกัน ---------- */

.site-slider:not(.is-ready) .site-slider__slide:not(:first-child) {
	display: none;
}

.site-slider:not(.is-ready) .site-slider__arrow,
.site-slider:not(.is-ready) .site-slider__progress {
	display: none;
}

/* ---------- จอเล็ก ---------- */

@media (max-width: 767px) {
	.site-slider__arrow {
		width: 38px;
		height: 38px;
		margin-top: -19px;
		font-size: 15px;
	}
	.site-slider__arrow--prev { left: 8px; }
	.site-slider__arrow--next { right: 8px; }
	.site-slider__caption {
		padding: 14px 16px;
		bottom: 8%;
	}
	.site-slider__dots { bottom: 10px; }
	.site-slider__dot { width: 18px; height: 7px; }
	.site-slider__dot.is-active { width: 28px; }
}

/* ---------- เคารพการตั้งค่า "ลดการเคลื่อนไหว" ของผู้ใช้ ---------- */

@media (prefers-reduced-motion: reduce) {
	.site-slider--fade .site-slider__slide,
	.site-slider--slide .site-slider__track,
	.site-slider__arrow,
	.site-slider__dot,
	.site-slider__progress > span {
		transition: none !important;
	}
	.site-slider--kenburns .site-slider__slide.is-active .site-slider__img {
		animation: none;
	}
}
