/*
 * สไลด์รูป + แกลเลอรี่ + ดูรูปเต็มจอ ของเว็บ (แทน layerslider และ unitegallery)
 * ทำงานคู่กับ js/ds-media.js
 */
.ds-slider, .ds-gallery, .ds-lightbox { --ds-accent: #00914d; }

/* ===================== สไลด์ ===================== */
.ds-slider {
	position: relative; width: 100%; margin: 0 auto; overflow: hidden;
	aspect-ratio: var(--ds-ratio, 16 / 9); background: #1b1b1b;
	isolation: isolate; user-select: none; -webkit-user-select: none; touch-action: pan-y;
}
.ds-slider:focus-visible { outline: 3px solid var(--ds-accent); outline-offset: 3px; }

.ds-slide {
	position: absolute; inset: 0; display: block; color: #fff;
	opacity: 0; visibility: hidden;
	transition: opacity .7s ease, visibility 0s linear .7s;
}
.ds-slide.is-active { z-index: 1; opacity: 1; visibility: visible; transition: opacity .7s ease; }
.ds-slide img {
	display: block; width: 100%; height: 100%; object-fit: cover;
	transform: scale(1.04); transition: transform 6s ease-out;
}
.ds-slide.is-active img { transform: scale(1); }
.ds-slide, .ds-slide:hover, .ds-slide:focus { color: #fff; text-decoration: none; }

/* คำบรรยายบนสไลด์ข่าว */
.ds-slide-caption {
	position: absolute; left: 0; right: 0; bottom: 0;
	padding: clamp(40px, 8%, 72px) clamp(16px, 3%, 32px) clamp(16px, 3%, 26px);
	background: linear-gradient(to top, rgba(0,0,0,.85) 0%, rgba(0,0,0,.5) 55%, rgba(0,0,0,0) 100%);
	font-family: 'Prompt', sans-serif;
}
.ds-slide-title {
	display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
	max-width: 88%; margin: 0 0 6px;
	font-size: clamp(16px, 2.3vw, 28px); line-height: 1.35; font-weight: 500;
	text-shadow: 0 1px 3px rgba(0,0,0,.45);
}
.ds-slide-meta { display: block; font-size: clamp(12px, 1.35vw, 15px); opacity: .88; }
.ds-slide-meta i { margin-right: 6px; }

/* ปุ่มก่อนหน้า / ถัดไป */
.ds-slider-btn {
	position: absolute; top: 50%; z-index: 3;
	display: grid; place-items: center; width: 44px; height: 44px; margin-top: -22px; padding: 0;
	border: 0; border-radius: 50%; background: rgba(255,255,255,.92); color: #1f1f1f;
	font-size: 16px; cursor: pointer; box-shadow: 0 2px 12px rgba(0,0,0,.28);
	opacity: 0; transition: opacity .25s ease, transform .2s ease, background-color .2s ease;
}
.ds-slider-prev { left: 14px; }
.ds-slider-next { right: 14px; }
.ds-slider:hover .ds-slider-btn, .ds-slider:focus-within .ds-slider-btn { opacity: 1; }
.ds-slider-btn:hover { background: #fff; transform: scale(1.07); }
.ds-slider-btn:focus-visible { opacity: 1; outline: 3px solid var(--ds-accent); outline-offset: 2px; }
@media (hover: none) {
	.ds-slider-btn { opacity: .9; width: 36px; height: 36px; margin-top: -18px; font-size: 13px; }
}
/* แบนเนอร์บนสุดบนจอเล็กเตี้ยมาก ซ่อนลูกศรไว้ (ยังปัดนิ้วและกดจุดได้) */
@media (max-width: 575px) {
	.ds-slider--banner .ds-slider-btn { display: none; }
	.ds-slider--banner .ds-slider-dots { bottom: 6px; }
	.ds-slider--banner .ds-slider-dot { width: 7px; height: 7px; }
	.ds-slider--banner .ds-slider-dot[aria-current="true"] { width: 18px; }
}

/* จุดบอกตำแหน่งสไลด์ */
.ds-slider-dots {
	position: absolute; z-index: 3; left: 0; right: 0; bottom: 12px;
	display: flex; justify-content: center; gap: 7px; pointer-events: none;
}
.ds-slider--hero .ds-slider-dots { left: auto; right: clamp(14px, 3%, 30px); bottom: clamp(14px, 3%, 26px); }
.ds-slider-dot {
	width: 9px; height: 9px; padding: 0; border: 0; border-radius: 99px;
	background: rgba(255,255,255,.55); cursor: pointer; pointer-events: auto;
	box-shadow: 0 0 0 1px rgba(0,0,0,.15); transition: width .3s ease, background-color .3s ease;
}
.ds-slider-dot:hover { background: rgba(255,255,255,.85); }
.ds-slider-dot[aria-current="true"] { width: 26px; background: #fff; }
.ds-slider-dot:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

/* แถบเวลานับถอยหลังของสไลด์อัตโนมัติ (ใช้เป็นตัวจับเวลาด้วย) */
.ds-slider-progress {
	position: absolute; z-index: 3; left: 0; bottom: 0; width: 100%; height: 3px;
	background: var(--ds-accent); transform: scaleX(0); transform-origin: left center;
}
.ds-slider.is-playing .ds-slider-progress { animation: ds-progress var(--ds-interval, 5000ms) linear forwards; }
.ds-slider.is-paused .ds-slider-progress { animation-play-state: paused; }
@keyframes ds-progress { to { transform: scaleX(1); } }

/* ===================== แกลเลอรี่ ===================== */
.ds-gallery {
	display: grid; gap: 10px;
	grid-template-columns: repeat(auto-fill, minmax(min(var(--ds-tile, 220px), 100%), 1fr));
}
.ds-gallery-item {
	position: relative; display: block; overflow: hidden; border-radius: 8px;
	aspect-ratio: var(--ds-tile-ratio, 1); background: #e9ecef; cursor: zoom-in;
}
.ds-gallery-item img {
	display: block; width: 100%; height: 100%; object-fit: cover; transition: transform .45s ease;
}
.ds-gallery-item::after {
	content: "\f00e"; font-family: "Font Awesome 6 Free"; font-weight: 900;
	position: absolute; inset: 0; display: grid; place-items: center;
	font-size: 22px; color: #fff; background: rgba(0,0,0,.42);
	opacity: 0; transition: opacity .3s ease;
}
.ds-gallery-item:hover img { transform: scale(1.07); }
.ds-gallery-item:hover::after, .ds-gallery-item:focus-visible::after { opacity: 1; }
.ds-gallery-item:focus-visible { outline: 3px solid var(--ds-accent); outline-offset: 2px; }

/* ===================== ดูรูปเต็มจอ ===================== */
body.ds-lightbox-open { overflow: hidden; }
.ds-lightbox {
	position: fixed; inset: 0; z-index: 2000;
	display: flex; align-items: center; justify-content: center;
	background: rgba(12,12,12,.94); opacity: 0; transition: opacity .25s ease;
	touch-action: pan-y;
}
.ds-lightbox[hidden] { display: none; }
.ds-lightbox.is-open { opacity: 1; }
.ds-lightbox-figure {
	display: flex; flex-direction: column; align-items: center; max-width: 92vw; margin: 0;
}
.ds-lightbox-img {
	display: block; max-width: 92vw; max-height: 82vh; object-fit: contain; border-radius: 4px;
	box-shadow: 0 12px 48px rgba(0,0,0,.55); transition: opacity .2s ease;
}
.ds-lightbox-img.is-loading { opacity: .2; }
.ds-lightbox-caption {
	margin-top: 12px; color: #d6d6d6; font: 14px/1.5 'Prompt', sans-serif; text-align: center;
}
.ds-lightbox-caption:empty { display: none; }
.ds-lightbox-counter {
	position: absolute; top: 22px; left: 24px; color: #bdbdbd; font: 14px 'Prompt', sans-serif;
	letter-spacing: .5px;
}
.ds-lightbox-btn {
	position: absolute; display: grid; place-items: center; width: 48px; height: 48px; padding: 0;
	border: 0; border-radius: 50%; background: rgba(255,255,255,.12); color: #fff;
	font-size: 19px; cursor: pointer; transition: background-color .2s ease, transform .2s ease;
}
.ds-lightbox-btn:hover { background: rgba(255,255,255,.26); }
.ds-lightbox-btn:focus-visible { outline: 3px solid var(--ds-accent); outline-offset: 2px; }
.ds-lightbox-close { top: 14px; right: 14px; }
.ds-lightbox-prev, .ds-lightbox-next { top: 50%; margin-top: -24px; }
.ds-lightbox-prev { left: 16px; }
.ds-lightbox-next { right: 16px; }
.ds-lightbox.is-single .ds-lightbox-prev,
.ds-lightbox.is-single .ds-lightbox-next,
.ds-lightbox.is-single .ds-lightbox-counter { display: none; }
@media (max-width: 575px) {
	.ds-lightbox-prev, .ds-lightbox-next { top: auto; bottom: 18px; margin-top: 0; }
	.ds-lightbox-img { max-height: 74vh; }
}

/* ผู้ใช้ที่ตั้งค่าลดการเคลื่อนไหว */
@media (prefers-reduced-motion: reduce) {
	.ds-slide, .ds-slide img, .ds-gallery-item img, .ds-gallery-item::after,
	.ds-lightbox, .ds-lightbox-img, .ds-slider-btn, .ds-slider-dot { transition: none !important; }
	.ds-slide img, .ds-slide.is-active img { transform: none; }
	.ds-slider.is-playing .ds-slider-progress { animation: none; }
}
