/* PALANG Album Slider */
.mas {
	--mas-accent: #111;
	--mas-bg: #f4f4f2;
	--mas-radius: 12px;
	--mas-speed: 500ms;
	--mas-fit: cover;
	--mas-ratio: 16/9;
	--mas-ease: cubic-bezier(.22, .61, .36, 1);
	--mas-ui: rgba(255, 255, 255, .9);
	--mas-ui-ink: #111;
	position: relative;
	margin: 1.75em auto;
	padding: 0;
	width: 100%;
	box-sizing: border-box;
	outline: none;
	-webkit-tap-highlight-color: transparent;
}
.mas *, .mas *::before, .mas *::after { box-sizing: border-box; }

/* ป้องกันธีมทับสไตล์ปุ่ม */
.mas button {
	all: unset;
	box-sizing: border-box;
	cursor: pointer;
	-webkit-tap-highlight-color: transparent;
}
.mas button:focus-visible {
	outline: 2px solid var(--mas-accent) !important;
	outline-offset: 2px;
}
.mas svg {
	width: 18px; height: 18px;
	fill: none; stroke: currentColor;
	stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round;
	display: block;
}

/* ---------- เวที ---------- */
.mas__stage {
	position: relative;
	aspect-ratio: var(--mas-ratio);
	overflow: hidden;
	overflow: clip;
	border-radius: var(--mas-radius);
	background: var(--mas-bg);
	isolation: isolate;
	touch-action: pan-y;
	user-select: none;
}
.mas__track {
	position: absolute; inset: 0;
	display: flex;
	will-change: transform;
}
.mas__slide {
	position: relative;
	flex: 0 0 100%;
	width: 100%; height: 100%;
	margin: 0;
}
.mas__slide img {
	position: absolute; inset: 0;
	width: 100% !important; height: 100% !important;
	max-width: none !important;
	margin: 0 !important; padding: 0 !important;
	border: 0 !important; border-radius: 0 !important; box-shadow: none !important;
	object-fit: var(--mas-fit);
	-webkit-user-drag: none;
}

/* slide */
.mas--slide .mas__track { transition: transform var(--mas-speed) var(--mas-ease); }
.mas--slide.is-dragging .mas__track { transition: none; }

/* fade */
.mas--fade .mas__slide {
	position: absolute; inset: 0;
	opacity: 0;
	transition: opacity var(--mas-speed) ease;
}
.mas--fade .mas__slide.is-active { opacity: 1; z-index: 1; }
.mas--fade .mas__slide img { transform: scale(1.015); transition: transform calc(var(--mas-speed) * 6) ease-out; }
.mas--fade .mas__slide.is-active img { transform: scale(1); }

/* ---------- ลูกศร ---------- */
.mas .mas__arrow {
	position: absolute; top: 50%; z-index: 3;
	width: 40px; height: 40px;
	display: grid; place-items: center;
	border-radius: 50%;
	background: var(--mas-ui) !important;
	color: var(--mas-ui-ink) !important;
	box-shadow: 0 1px 2px rgba(0, 0, 0, .08), 0 4px 16px rgba(0, 0, 0, .08);
	backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
	opacity: 0;
	transform: translateY(-50%) scale(.92);
	transition: opacity .25s ease, transform .25s var(--mas-ease), background .2s;
}
.mas .mas__arrow--prev { left: 14px; }
.mas .mas__arrow--next { right: 14px; }
.mas:hover .mas__arrow, .mas:focus-within .mas__arrow { opacity: 1; transform: translateY(-50%) scale(1); }
.mas .mas__arrow:hover { background: #fff !important; }
.mas .mas__arrow:active { transform: translateY(-50%) scale(.94); }
.mas .mas__arrow[disabled] { opacity: 0 !important; pointer-events: none; }
@media (hover: none) {
	.mas .mas__arrow { opacity: .85; transform: translateY(-50%) scale(.85); }
}

/* ---------- เครื่องมือมุมล่าง ---------- */
.mas__tools {
	position: absolute; left: 12px; right: 12px; bottom: 12px; z-index: 3;
	display: flex; align-items: center; gap: 6px;
	pointer-events: none;
}
.mas .mas__tools > * { pointer-events: auto !important; }
.mas .mas__counter {
	margin-right: auto;
	padding: 4px 10px;
	border-radius: 999px;
	background: rgba(0, 0, 0, .45);
	color: #fff !important;
	font-size: 12px; line-height: 1.5; letter-spacing: .04em;
	font-variant-numeric: tabular-nums;
	backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.mas__sep { opacity: .55; margin: 0 4px; }
.mas .mas__tool {
	margin-left: auto;
	width: 32px; height: 32px;
	display: grid; place-items: center;
	border-radius: 50%;
	background: rgba(0, 0, 0, .45) !important;
	color: #fff !important;
	backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
	transition: background .2s;
}
.mas .mas__tool + .mas__tool { margin-left: 0; }
.mas .mas__tool:hover { background: rgba(0, 0, 0, .7) !important; }
.mas .mas__tool svg { width: 15px; height: 15px; }
.mas [data-mas-play] .i-play { display: none; }
.mas.is-paused [data-mas-play] .i-play { display: block; }
.mas.is-paused [data-mas-play] .i-pause { display: none; }

/* แถบเวลาเล่นอัตโนมัติ */
.mas__progress {
	position: absolute; left: 0; right: 0; bottom: 0; z-index: 4;
	height: 2px; background: rgba(255, 255, 255, .25);
}
.mas__progress span {
	display: block; height: 100%; width: 100%;
	background: var(--mas-accent);
	transform: scaleX(0); transform-origin: left;
}
.mas.is-running .mas__progress span { animation: mas-progress var(--mas-interval, 5000ms) linear forwards; }
.mas.is-paused .mas__progress span, .mas.is-hover .mas__progress span { animation-play-state: paused; }
@keyframes mas-progress { to { transform: scaleX(1); } }

/* ---------- คำบรรยาย ---------- */
.mas .mas__caption {
	margin: 10px 2px 0 !important;
	padding: 0 !important;
	min-height: 1.5em;
	font-size: .875em; line-height: 1.6;
	color: inherit; opacity: .68;
	text-align: left;
	font-style: normal;
	transition: opacity .3s ease;
}
.mas .mas__caption:empty { min-height: 0; margin: 0 !important; }
.mas .mas__caption.is-changing { opacity: 0; }

/* ---------- จุด ---------- */
.mas__dots { display: flex; justify-content: center; gap: 6px; margin-top: 12px; }
.mas .mas__dot {
	width: 6px; height: 6px; border-radius: 999px;
	background: currentColor !important; opacity: .2;
	transition: width .3s var(--mas-ease), opacity .3s, background .3s;
}
.mas .mas__dot:hover { opacity: .45; }
.mas .mas__dot.is-active { width: 20px; opacity: 1; background: var(--mas-accent) !important; }

/* ---------- ภาพย่อ ---------- */
.mas__thumbs {
	display: flex; gap: 8px;
	margin-top: 10px;
	overflow-x: auto;
	scroll-behavior: smooth;
	scrollbar-width: none;
	padding: 2px;
}
.mas__thumbs::-webkit-scrollbar { display: none; }
.mas .mas__thumb {
	position: relative;
	flex: 0 0 auto;
	width: 64px; aspect-ratio: 1;
	border-radius: max(4px, calc(var(--mas-radius) * .5));
	overflow: hidden;
	opacity: .5;
	transition: opacity .25s ease;
}
.mas .mas__thumb::after {
	content: ""; position: absolute; inset: 0;
	border-radius: inherit;
	box-shadow: inset 0 0 0 2px transparent;
	transition: box-shadow .25s ease;
}
.mas .mas__thumb:hover { opacity: .85; }
.mas .mas__thumb.is-active { opacity: 1; }
.mas .mas__thumb.is-active::after { box-shadow: inset 0 0 0 2px var(--mas-accent); }
.mas .mas__thumb img {
	width: 100% !important; height: 100% !important;
	max-width: none !important; margin: 0 !important;
	object-fit: cover; display: block; border-radius: 0 !important;
}

/* รูปเดียว */
.mas--single .mas__tools .mas__counter { display: none; }

/* ---------- เต็มจอ ---------- */
.mas:fullscreen, .mas.is-fs {
	margin: 0 !important; max-width: none !important;
	display: flex; flex-direction: column; justify-content: center;
	background: #0b0b0b; color: #f2f2f2;
	padding: 2vh 2vw;
}
.mas:fullscreen .mas__stage, .mas.is-fs .mas__stage {
	flex: 1 1 auto; aspect-ratio: auto; background: transparent; border-radius: 0;
}
.mas:fullscreen .mas__slide img, .mas.is-fs .mas__slide img { object-fit: contain; }
.mas:fullscreen .mas__thumbs, .mas.is-fs .mas__thumbs { justify-content: center; }
.mas:fullscreen .mas__caption, .mas.is-fs .mas__caption { text-align: center; opacity: .8; }
.mas.is-fs {
	position: fixed !important; inset: 0 !important; z-index: 2147483000 !important;
	width: 100vw !important; height: 100vh !important; height: 100dvh !important;
	transform: none !important;
}
html.mas-fs-lock, html.mas-fs-lock body { overflow: hidden !important; }

/* ---------- จอเล็ก ---------- */
@media (max-width: 600px) {
	.mas .mas__arrow { width: 34px; height: 34px; }
	.mas .mas__arrow--prev { left: 8px; }
	.mas .mas__arrow--next { right: 8px; }
	.mas__tools { left: 8px; right: 8px; bottom: 8px; }
	.mas .mas__thumb { width: 52px; }
}

/* align wide/full ในบล็อก */
.mas-align.alignfull .mas { --mas-radius: 0px; }

@media (prefers-reduced-motion: reduce) {
	.mas--slide .mas__track, .mas--fade .mas__slide, .mas--fade .mas__slide img { transition: none !important; }
	.mas__progress { display: none; }
}

.mas-empty { padding: 1em; border: 1px dashed #ccc; border-radius: 8px; color: #777; }

/* ปุ่มบนพื้นดำตอนเต็มจอ */
.mas:fullscreen .mas__tool, .mas.is-fs .mas__tool,
.mas:fullscreen .mas__counter, .mas.is-fs .mas__counter { background: rgba(255, 255, 255, .16) !important; }
.mas:fullscreen .mas__tool:hover, .mas.is-fs .mas__tool:hover { background: rgba(255, 255, 255, .28) !important; }
