/* WooCommerce YouTube Gallery Video - frontend style (เบา ไม่พึ่งพา framework ใดๆ) */

.ytg-video-slide {
	background: #000;
	position: relative;
}

/* กรอบสไลด์วิดีโอ: ความสูงเท่ารูปหลักของสินค้า (padding-top คำนวณจากฝั่ง PHP แล้วใส่เป็น inline style)
   พื้นดำ เหมือนแถบดำของเครื่องเล่นวิดีโอ เมื่อสลับรูป <-> วิดีโอ แกลลอรี่จึงไม่ยืด/หดความสูง */
.ytg-facade {
	position: relative;
	width: 100%;
	height: 0;
	padding-top: 100%; /* ค่าสำรอง ถูกทับด้วย inline style ที่ตรงกับรูปหลัก */
	background: #000;
	overflow: hidden;
	border-radius: var(--ll-radius, 0); /* ตามมุมโค้งของรูปสินค้าในธีม (Landio Lite) */
}

/* พื้นที่วิดีโอ 16:9 วางกึ่งกลางกรอบ ภาพตัวอย่างและ iframe อยู่ในนี้ ไม่ถูกยืดหรือตัดภาพ */
.ytg-stage {
	position: absolute;
	top: 50%;
	left: 0;
	width: 100%;
	aspect-ratio: 16 / 9;
	transform: translateY(-50%);
	background-size: cover;
	background-position: center center;
	background-repeat: no-repeat;
	cursor: pointer;
}

/* รูปจริง <img> ใต้ background-image เดิม ให้ธีม/สคริปต์แกลลอรี่ที่สร้างรูปเล็กด้วยการโคลน <img> หาเจอ
   (cover ใน 16:9 จะตัดแถบดำบน-ล่างของภาพ hqdefault ออกพอดี) */
.ytg-stage .ytg-thumb-img {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	max-width: none;
	margin: 0;
	border-radius: 0 !important; /* มุมโค้งให้กรอบ .ytg-facade จัดการ ไม่ให้ธีมโค้งเฉพาะภาพ */
	object-fit: cover;
	display: block;
	pointer-events: none;
	z-index: 0;
}

.ytg-stage::before {
	content: "";
	position: absolute;
	inset: 0;
	background: rgba(0, 0, 0, 0.1);
	transition: background 0.2s ease;
	z-index: 1;
}

.ytg-stage:hover::before {
	background: rgba(0, 0, 0, 0.2);
}

.ytg-stage .ytg-play-btn {
	position: absolute;
	top: 50%;
	left: 50%;
	width: 64px;
	height: 64px;
	transform: translate(-50%, -50%);
	border-radius: 50%;
	background: var(--ytg-play-color, #ff0000);
	display: flex;
	align-items: center;
	justify-content: center;
	box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
	transition: transform 0.2s ease;
	z-index: 2;
}

.ytg-stage .ytg-play-btn::after {
	content: "";
	display: block;
	margin-left: 5px;
	border-style: solid;
	border-width: 12px 0 12px 20px;
	border-color: transparent transparent transparent #fff;
}

.ytg-stage:hover .ytg-play-btn {
	transform: translate(-50%, -50%) scale(1.08);
}

.ytg-stage .ytg-play-btn:focus-visible {
	outline: 3px solid #fff;
	outline-offset: 3px;
}

/* ตอนกำลังเล่น: ซ่อนปุ่มกับเลเยอร์ดำ และเอาภาพตัวอย่างออก */
.ytg-facade.is-playing .ytg-stage {
	cursor: default;
	background-image: none !important;
}

.ytg-facade.is-playing .ytg-stage::before,
.ytg-facade.is-playing .ytg-play-btn {
	display: none;
}

.ytg-video-slide .zoomImg {
	display: none !important; /* กันเลเยอร์ซูมของ WooCommerce มาทับปุ่มเล่น/วิดีโอ */
}

.ytg-iframe {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	border: 0;
}

@media (max-width: 480px) {
	.ytg-stage .ytg-play-btn {
		width: 50px;
		height: 50px;
	}

	.ytg-stage .ytg-play-btn::after {
		border-width: 9px 0 9px 15px;
		margin-left: 4px;
	}
}

/* ปุ่มลัดไปดูวิดีโอ (badge) แบบจิ๋ว: เป็นวงกลมไอคอนเล่นขนาดเล็กที่มุมขวาล่างของ "รูปหลัก"
   ไม่บังรูปสินค้า (ไม่มีรูปตัวอย่าง ไม่มีข้อความ) เอาเมาส์ชี้/โฟกัสจึงค่อยขยายแสดงข้อความ
   และจะซ่อนตัวเองอัตโนมัติเมื่อกำลังดูสไลด์วิดีโออยู่แล้ว */
.woocommerce-product-gallery,
.woocommerce-product-gallery .flex-viewport {
	position: relative;
}

.ytg-jump-badge {
	position: absolute;
	bottom: 8px;
	right: 8px;
	z-index: 5;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 0;
	box-sizing: border-box;
	min-width: 28px;
	height: 28px;
	min-height: 0; /* ธีมหลายตัวตั้ง min-height ให้ button ทุกปุ่ม (เช่น 48px) ต้องรีเซ็ตกันปุ่มพอง */
	margin: 0;
	padding: 0 8px;
	border: 0;
	font-weight: 600;
	text-decoration: none;
	border-radius: 999px;
	background: rgba(0, 0, 0, 0.45);
	color: #fff;
	font-size: 12px;
	line-height: 1;
	cursor: pointer;
	opacity: 0.8;
	box-shadow: none;
	transition: opacity 0.2s ease, background 0.2s ease;
}

.ytg-jump-badge:hover,
.ytg-jump-badge:focus-visible {
	background: rgba(0, 0, 0, 0.8);
	border: 0;
	color: #fff;
	box-shadow: none;
	opacity: 1;
	gap: 6px;
}

/* ซ่อนรูปตัวอย่างในปุ่ม เพื่อไม่ให้ปุ่มใหญ่และบังรูปสินค้า */
.ytg-jump-badge img {
	display: none;
}

.ytg-jump-badge__play {
	display: inline-block;
	width: 0;
	height: 0;
	border-style: solid;
	border-width: 5px 0 5px 8px;
	border-color: transparent transparent transparent #fff;
	flex-shrink: 0;
}

.ytg-jump-badge__label {
	display: inline-block;
	max-width: 0;
	overflow: hidden;
	white-space: nowrap;
	transition: max-width 0.25s ease;
}

.ytg-jump-badge:hover .ytg-jump-badge__label,
.ytg-jump-badge:focus-visible .ytg-jump-badge__label {
	max-width: 120px;
}

/* กำลังดูสไลด์วิดีโออยู่ ไม่ต้องมีปุ่มลัด */
.woocommerce-product-gallery:has(.ytg-video-slide.flex-active-slide) .ytg-jump-badge,
.woocommerce-product-gallery:has(.ytg-facade.is-playing) .ytg-jump-badge {
	display: none;
}

@media (max-width: 480px) {
	.ytg-jump-badge {
		bottom: 6px;
		right: 6px;
		min-width: 24px;
		height: 24px;
		min-height: 0;
		padding: 0 6px;
	}

	.ytg-jump-badge__label {
		display: none;
	}
}

/* ทำเครื่องหมายรูปเล็กในแกลลอรี่ (thumbnail nav ของ WooCommerce) ว่าเป็นวิดีโอ
   เลือกรูปแบบไอคอนได้จากหน้าตั้งค่า (WooCommerce > การตั้งค่า > YouTube Gallery) */
.flex-control-nav .ytg-nav-thumb {
	position: relative;
}

/* รูปเล็กของวิดีโอเป็น 16:9 ส่วนรูปเล็กสินค้าเป็นสี่เหลี่ยมจัตุรัส ตัดให้ขนาดเท่ากันจะได้แถวรูปเล็กเรียบร้อย */
.flex-control-nav .ytg-nav-thumb img {
	aspect-ratio: 1 / 1;
	object-fit: cover;
}

/* แบบ 1: วงกลมเล่นสีแดง มุมขวาล่าง (ค่าเริ่มต้น) */
.flex-control-nav .ytg-nav-thumb.ytg-icon-style-circle::after {
	content: "";
	position: absolute;
	right: 2px;
	bottom: 2px;
	width: 16px;
	height: 16px;
	border-radius: 50%;
	background: #ff0000;
	box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.85);
	z-index: 1;
	pointer-events: none;
}

.flex-control-nav .ytg-nav-thumb.ytg-icon-style-circle::before {
	content: "";
	position: absolute;
	right: 6.5px;
	bottom: 6px;
	width: 0;
	height: 0;
	border-style: solid;
	border-width: 4px 0 4px 6px;
	border-color: transparent transparent transparent #fff;
	z-index: 2;
	pointer-events: none;
}

/* แบบ 2: ป้ายริบบิ้น "VDO" มุมซ้ายบน */
.flex-control-nav .ytg-nav-thumb.ytg-icon-style-ribbon::after {
	content: "VDO";
	position: absolute;
	top: 0;
	left: 0;
	background: #ff0000;
	color: #fff;
	font-size: 8px;
	font-weight: 700;
	letter-spacing: 0.02em;
	line-height: 1.5;
	padding: 1px 4px;
	border-bottom-right-radius: 4px;
	z-index: 1;
	pointer-events: none;
}

/* แบบ 3: โลโก้คล้าย YouTube มุมขวาล่าง */
.flex-control-nav .ytg-nav-thumb.ytg-icon-style-youtube::after {
	content: "";
	position: absolute;
	right: 2px;
	bottom: 2px;
	width: 20px;
	height: 14px;
	background: #ff0000;
	border-radius: 3px;
	box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.85);
	z-index: 1;
	pointer-events: none;
}

.flex-control-nav .ytg-nav-thumb.ytg-icon-style-youtube::before {
	content: "";
	position: absolute;
	right: 7px;
	bottom: 5.5px;
	width: 0;
	height: 0;
	border-style: solid;
	border-width: 3.5px 0 3.5px 6px;
	border-color: transparent transparent transparent #fff;
	z-index: 2;
	pointer-events: none;
}

/* แบบ 4: กรอบสีแดงรอบรูป + ไอคอนเล่นตรงกลาง */
.flex-control-nav .ytg-nav-thumb.ytg-icon-style-frame img {
	outline: 2px solid #ff0000;
	outline-offset: -2px;
}

.flex-control-nav .ytg-nav-thumb.ytg-icon-style-frame::after {
	content: "";
	position: absolute;
	top: 50%;
	left: 50%;
	width: 0;
	height: 0;
	transform: translate(-50%, -50%);
	border-style: solid;
	border-width: 5px 0 5px 8px;
	border-color: transparent transparent transparent #fff;
	filter: drop-shadow(0 0 2px rgba(0, 0, 0, 0.7));
	pointer-events: none;
	z-index: 1;
}
