/* ============================================================
   slider.css
   ------------------------------------------------------------
   สไลด์ภาพแบนเนอร์ เขียนขึ้นเองแทน LayerSlider / Revolution Slider

   ทำไมต้องเขียนเอง
   - rs-plugin (Revolution Slider) ที่ใช้อยู่เดิมหนักกว่า 500 KB
     และเป็นปลั๊กอินรุ่นเก่าที่มีประวัติช่องโหว่ถูกยึดเว็บมาแล้วหลายครั้ง
     (ที่สำคัญ : เราเจอ webshell ซ่อนอยู่ในโฟลเดอร์ของมันจริง ๆ)
   - ของใหม่เป็น CSS + JavaScript ธรรมดา ไม่ถึง 8 KB

   ข้อกำหนด : ภาพต้องไม่ pan และไม่ zoom
   -> ใช้วิธี "ค่อย ๆ จางสลับภาพ" (crossfade) อย่างเดียว
      ไม่มี transform: scale() และไม่มี Ken Burns effect ใด ๆ
   ============================================================ */

.cs-slider {
	position: relative;
	width: 100%;
	overflow: hidden;
	background: #202020;
	/* กันหน้าเว็บกระตุกตอนภาพโหลด (คะแนน CLS ของ Google) */
	line-height: 0;
}

/* ---------- ตัวภาพ ---------- */
.cs-slider__track {
	position: relative;
	width: 100%;
}

.cs-slide {
	position: absolute;
	inset: 0;
	opacity: 0;
	transition: opacity .7s ease-in-out;
	pointer-events: none;
	z-index: 1;
}

.cs-slide.is-active {
	opacity: 1;
	pointer-events: auto;
	z-index: 2;
}

/* ภาพแรกไม่ใช้ position:absolute เพื่อให้มันเป็นตัวกำหนดความสูงของกรอบ
   ทำให้ไม่ต้องกำหนดความสูงเป็นตัวเลขตายตัว รองรับภาพทุกสัดส่วน */
.cs-slide--sizer {
	position: relative;
	inset: auto;
}

.cs-slide img,
.cs-slider__single img {
	width: 100%;
	height: auto;
	display: block;
	/* ไม่มีการซูมหรือเลื่อนภาพ ตามที่กำหนด */
	transform: none !important;
	object-fit: contain;
}

/* ---------- ปุ่มเลื่อนซ้าย/ขวา ---------- */
.cs-nav {
	position: absolute;
	top: 50%;
	transform: translateY(-50%);
	width: 48px;
	height: 48px;
	border: 0;
	border-radius: 50%;
	background: rgba(0,0,0,.4);
	color: #fff;
	font-size: 18px;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	z-index: 10;
	opacity: 0;
	transition: opacity .25s ease, background .25s ease;
	backdrop-filter: blur(4px);
}

.cs-slider:hover .cs-nav,
.cs-slider:focus-within .cs-nav { opacity: 1; }

.cs-nav:hover { background: #FCDF15; color: #202020; }
.cs-nav:focus-visible { opacity: 1; outline: 3px solid #FCDF15; outline-offset: 2px; }

.cs-nav--prev { left: 14px; }
.cs-nav--next { right: 14px; }

/* บนมือถือให้เห็นปุ่มตลอด เพราะไม่มีการ hover */
@media (max-width: 991px) {
	.cs-nav { opacity: .85; width: 40px; height: 40px; font-size: 15px; }
	.cs-nav--prev { left: 8px; }
	.cs-nav--next { right: 8px; }
}

/* ---------- จุดบอกตำแหน่งสไลด์ ---------- */
.cs-dots {
	position: absolute;
	left: 0;
	right: 0;
	bottom: 14px;
	display: flex;
	justify-content: center;
	gap: 9px;
	z-index: 10;
	line-height: 0;
}

.cs-dot {
	width: 11px;
	height: 11px;
	padding: 0;
	border: 2px solid rgba(255,255,255,.85);
	border-radius: 50%;
	background: transparent;
	cursor: pointer;
	transition: all .25s ease;
}

.cs-dot:hover { background: rgba(255,255,255,.6); }
.cs-dot:focus-visible { outline: 3px solid #FCDF15; outline-offset: 2px; }

.cs-dot.is-active {
	background: #FCDF15;
	border-color: #FCDF15;
	width: 28px;
	border-radius: 6px;
}

@media (max-width: 575px) {
	.cs-dots { bottom: 8px; gap: 7px; }
	.cs-dot { width: 9px; height: 9px; }
	.cs-dot.is-active { width: 22px; }
}

/* ---------- แถบเวลาบาง ๆ ด้านล่าง บอกว่าใกล้เปลี่ยนภาพแล้ว ---------- */
.cs-progress {
	position: absolute;
	left: 0;
	bottom: 0;
	height: 3px;
	width: 100%;
	background: rgba(255,255,255,.18);
	z-index: 9;
}

.cs-progress__bar {
	height: 100%;
	width: 0;
	background: #FCDF15;
	transition: width .2s linear;
}

/* ---------- ปิดการเคลื่อนไหวถ้าผู้ใช้ตั้งเครื่องไว้ว่าไม่ชอบ ---------- */
@media (prefers-reduced-motion: reduce) {
	.cs-slide { transition: none; }
	.cs-progress { display: none; }
}
