/*!
 * Mai Thu Video Embed — frontend styles
 * v0.1.0
 */

/* ---- Wrapper responsive ---- */
.mtve-responsive {
	width: 100%;
	margin: 1em auto;
}

.mtve-responsive iframe {
	width: 100%;
	height: auto;
	display: block;
	border: 0;
	/* !important: đè width/height inline mà YouTube oEmbed chèn cứng trên iframe gốc. */
	max-width: 100% !important;
}

.mtve-responsive.mtve-16-9 iframe {
	aspect-ratio: 16 / 9;
}

.mtve-responsive.mtve-9-16 {
	max-width: 360px;
}

.mtve-responsive.mtve-9-16 iframe {
	aspect-ratio: 9 / 16;
}

/* YouTube Shorts: khung 16:9 + nền mờ thumbnail, iframe portrait căn giữa (desktop). */
.mtve-responsive.mtve-9-16-framed {
	position: relative;
	aspect-ratio: 16 / 9;
	overflow: hidden;
	background: #000;
	border-radius: 12px; /* đồng nhất với TikTok framed */
}

.mtve-frame-bg {
	position: absolute;
	inset: 0;
	background-size: cover;
	background-position: center;
	z-index: 0;
}

/* TikTok framed: thumbnail TikTok 9:16 raw → cần blur + làm tối + scale che mép.
   (YT Shorts thumb đã có pattern player sẵn nên không áp filter — xem Lite_Player.) */
.mtve-responsive.mtve-tiktok-framed .mtve-frame-bg {
	filter: blur(6px) brightness(0.55);
	transform: scale(1.05);
}

.mtve-responsive.mtve-9-16-framed iframe {
	position: absolute;
	top: 0;
	left: 50%;
	transform: translateX(-50%);
	height: 100%;
	width: auto;
	aspect-ratio: 9 / 16;
	z-index: 1;
}

/* Mobile: bỏ khung 16:9, video Shorts về 9:16 full để không phí diện tích. */
@media (max-width: 599px) {
	.mtve-responsive.mtve-9-16-framed {
		aspect-ratio: auto;
		max-width: 360px;
		background: transparent;
		border-radius: 0; /* mobile: vuông góc — đồng nhất TikTok mobile */
	}

	.mtve-frame-bg {
		display: none;
	}

	.mtve-responsive.mtve-9-16-framed iframe {
		position: static;
		transform: none;
		width: 100%;
		height: auto;
		aspect-ratio: 9 / 16;
	}
}

/* ---- TikTok fallback card (redesign "player-like") ---- */

/* Desktop: bọc khung 16:9 + nền mờ thumbnail (tái dùng .mtve-frame-bg). Mobile CSS bỏ khung. */
.mtve-responsive.mtve-tiktok-framed {
	position: relative;
	aspect-ratio: 16 / 9;
	overflow: hidden;
	background: #000;
	border-radius: 12px;
}

.mtve-responsive.mtve-tiktok-framed .mtve-tiktok-card {
	position: absolute;
	top: 0;
	left: 50%;
	transform: translateX(-50%);
	height: 100%;
	aspect-ratio: 9 / 16;
	max-width: 100%;
	margin: 0;
	z-index: 1;
	border-radius: 0; /* desktop: bỏ bo tròn (mobile khôi phục bên dưới). */
}

.mtve-tiktok-card {
	position: relative;
	display: block;
	max-width: 360px;
	margin: 1em auto;
	background: #111;
	border-radius: 12px;
	overflow: hidden;
	aspect-ratio: 9 / 16;
	color: #fff;
	font-family: inherit;
}

.mtve-tiktok-card__thumb {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	object-fit: cover;
	z-index: 0;
	display: block;
}

/* Cover anchor phủ toàn card → click vùng trống/thumb/play đều mở video. */
.mtve-tiktok-card__cover {
	position: absolute;
	inset: 0;
	z-index: 1;
	text-decoration: none;
}

/* Title overlay top — gradient tối, line-clamp 2 dòng. pointer-events:none → click xuyên xuống cover. */
.mtve-tiktok-card__title {
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	padding: 12px 14px 38px;
	background: linear-gradient(to bottom, rgba(0, 0, 0, 0.78), rgba(0, 0, 0, 0.2) 75%, rgba(0, 0, 0, 0));
	color: #fff;
	font-size: 15px;
	line-height: 1.35;
	font-weight: 600;
	z-index: 2;
	pointer-events: none;
	display: -webkit-box;
	-webkit-line-clamp: 4;
	-webkit-box-orient: vertical;
	overflow: hidden;
	transition: padding 0.25s ease, background 0.25s ease;
}

/* Hover card → title nở ra (mở rộng line-clamp + bg đậm). Chỉ desktop có hover thật. */
@media (hover: hover) {
	.mtve-tiktok-card:hover .mtve-tiktok-card__title {
		padding-bottom: 60px;
		background: linear-gradient(to bottom, rgba(0, 0, 0, 0.92), rgba(0, 0, 0, 0.5) 80%, rgba(0, 0, 0, 0));
		-webkit-line-clamp: 10; /* caption + hashtag thường 6-9 dòng */
	}
}

/* Play giữa (SVG tam giác trong tròn tối). pointer-events:none → click xuyên xuống cover. */
.mtve-tiktok-card__play {
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	width: 64px;
	height: 64px;
	z-index: 2;
	pointer-events: none;
	display: block;
	transition: transform 0.15s ease;
}

.mtve-tiktok-card__play svg {
	width: 100%;
	height: 100%;
	display: block;
}

.mtve-tiktok-card__play svg circle {
	transition: fill-opacity 0.15s ease;
}

/* Hover card → play to nhẹ + nền đậm hơn. */
@media (hover: hover) {
	.mtve-tiktok-card:hover .mtve-tiktok-card__play {
		transform: translate(-50%, -50%) scale(1.08);
	}

	.mtve-tiktok-card:hover .mtve-tiktok-card__play svg circle {
		fill-opacity: 0.6;
	}
}

/* Active (click/tap) → play co lại + nền đậm rõ ("ấn nhả"). */
.mtve-tiktok-card:active .mtve-tiktok-card__play {
	transform: translate(-50%, -50%) scale(0.92);
}

.mtve-tiktok-card:active .mtve-tiktok-card__play svg circle {
	fill-opacity: 0.85;
}

/* Meta dưới: container chứa channel + cta. pointer-events:none để click vùng trống xuyên cover. */
.mtve-tiktok-card__meta {
	position: absolute;
	left: 0;
	right: 0;
	bottom: 0;
	padding: 14px 14px 16px;
	background: linear-gradient(to top, rgba(0, 0, 0, 0.85), rgba(0, 0, 0, 0));
	z-index: 3;
	display: flex;
	flex-direction: column;
	gap: 10px;
	pointer-events: none;
}

.mtve-tiktok-card__channel,
.mtve-tiktok-card__cta {
	pointer-events: auto;
}

.mtve-tiktok-card__channel {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	color: #fff;
	text-decoration: none;
	font-size: 13px;
	font-weight: 600;
	align-self: flex-start;
	max-width: 100%;
}

.mtve-tiktok-card__channel:hover {
	text-decoration: underline;
	color: #fff; /* đè theme (Flatsome) a:hover color khác. */
}

.mtve-tiktok-card__avatar {
	width: 28px;
	height: 28px;
	border-radius: 50%;
	overflow: hidden;
	flex-shrink: 0;
	display: inline-block;
}

.mtve-tiktok-card__avatar img {
	width: 100%;
	height: 100%;
	display: block;
	object-fit: cover;
}

.mtve-tiktok-card__channel-name {
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	min-width: 0;
}

/* CTA pill — kiểu "Watch on YouTube". */
.mtve-tiktok-card__cta {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 8px 14px;
	background: rgba(0, 0, 0, 0.6);
	color: #fff;
	text-decoration: none;
	border-radius: 999px;
	font-size: 13px;
	font-weight: 600;
	align-self: flex-start;
	border: 1px solid rgba(255, 255, 255, 0.15);
}

.mtve-tiktok-card__cta:hover {
	background: rgba(0, 0, 0, 0.85);
	color: #fff; /* đè theme (Flatsome) a:hover color khác → tránh chữ chìm vào nền. */
}

.mtve-tiktok-card__cta-icon {
	width: 14px;
	height: 14px;
	flex-shrink: 0;
	display: inline-flex;
}

.mtve-tiktok-card__cta-icon svg {
	width: 100%;
	height: 100%;
	display: block;
}

.mtve-tiktok-card--no-thumb {
	background: #111;
}

/* Mobile: bỏ khung 16:9 cho TikTok, card 9:16 full. */
@media (max-width: 599px) {
	.mtve-responsive.mtve-tiktok-framed {
		aspect-ratio: auto;
		background: transparent;
		max-width: 360px;
		border-radius: 0; /* mobile: wrapper cũng vuông góc (desktop có 12px ở rule chính). */
	}

	.mtve-responsive.mtve-tiktok-framed .mtve-frame-bg {
		display: none;
	}

	.mtve-responsive.mtve-tiktok-framed .mtve-tiktok-card {
		position: static;
		transform: none;
		height: auto;
		width: auto;
		max-width: 360px;
		margin: 0 auto;
		border-radius: 0; /* mobile cũng vuông góc — đồng nhất desktop. */
	}
}

/* ---- Caption + fallback link ---- */
.mtve-caption {
	font-size: 0.9em;
	color: #666;
	text-align: center;
	margin-top: 0.5em;
}

.mtve-fallback-link {
	display: inline-block;
	color: #0073aa;
	word-break: break-all;
}

/* ============================================================
   Lite player (YouTube) v0.2 — fake card + click → iframe
   ============================================================ */

/* Wrapper 16:9 — set aspect-ratio trực tiếp lên container vì lite player KHÔNG có
   iframe ban đầu (rule .mtve-responsive.mtve-16-9 iframe chỉ áp dụng cho iframe wrap v0.1). */
.mtve-responsive.mtve-lite-player-wrap {
	aspect-ratio: 16 / 9;
}

/* Card chính — fill wrapper (.mtve-lite-player-wrap cho 16:9, hoặc .mtve-lite-player-framed cho 9:16) */
.mtve-lite-player {
	position: relative;
	width: 100%;
	height: 100%;
	overflow: hidden;
	background: #000;
}

/* Thumbnail làm nền */
.mtve-lite-player__thumb {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
	z-index: 0;
}

/* Cover button phủ toàn card — click trigger JS replace bằng iframe */
.mtve-lite-player__cover {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	border: 0;
	background: transparent;
	padding: 0;
	margin: 0;
	cursor: pointer;
	z-index: 2;
	display: flex;
	align-items: center;
	justify-content: center;
}

.mtve-lite-player__cover:focus-visible {
	outline: 3px solid #fff;
	outline-offset: -3px;
}

/* Play SVG center — pill rounded-rect đỏ (YT brand asset). */
.mtve-lite-player__play {
	display: block;
	width: 68px;
	height: 48px;
	pointer-events: none;
	filter: drop-shadow(0 1px 4px rgba(0, 0, 0, 0.35)); /* shadow nhẹ — tránh halo trên nền đen */
	transition: transform 0.2s ease, filter 0.2s ease;
}

.mtve-lite-player__play svg {
	display: block;
	width: 100%;
	height: 100%;
}

.mtve-lite-player__cover:hover .mtve-lite-player__play {
	transform: scale(1.12);
	filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.6));
}

.mtve-lite-player__cover:active .mtve-lite-player__play {
	transform: scale(0.94);
}

/* Header top overlay: avatar + title + channel (giống YouTube real). pointer-events:none → click xuyên cover. */
.mtve-lite-player__header {
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	padding: 14px 14px 32px;
	background: linear-gradient(to bottom, rgba(0, 0, 0, 0.82), rgba(0, 0, 0, 0));
	z-index: 3;
	pointer-events: none;
	display: flex;
	align-items: flex-start;
	gap: 10px;
	color: #fff;
}

.mtve-lite-player__avatar {
	width: 36px;
	height: 36px;
	border-radius: 50%;
	object-fit: cover;
	flex-shrink: 0;
	display: block;
}

.mtve-lite-player__meta {
	display: flex;
	flex-direction: column;
	gap: 3px;
	min-width: 0; /* cho ellipsis work trong flex */
	flex: 1;
}

.mtve-lite-player__title {
	font-size: 18px;
	line-height: 1.3;
	font-weight: 600;
	color: #fff;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

.mtve-lite-player__channel {
	font-size: 14px;
	font-weight: 500;
	color: rgba(255, 255, 255, 0.9);
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

/* CTA "Watch on YouTube" góc dưới phải — giống real YouTube paused overlay. */
.mtve-lite-player__cta {
	position: absolute;
	bottom: 14px;
	right: 14px;
	z-index: 3;
	display: inline-flex;
	align-items: center;
	gap: 8px;
	padding: 8px 14px;
	background: rgba(0, 0, 0, 0.72);
	color: #fff;
	text-decoration: none;
	border-radius: 4px;
	font-size: 15px;
	font-weight: 500;
	pointer-events: auto;
}

.mtve-lite-player__cta:hover {
	background: rgba(0, 0, 0, 0.9);
	color: #fff; /* đè theme a:hover */
}

.mtve-lite-player__cta-icon {
	width: 28px;
	height: 20px;
	flex-shrink: 0;
	display: inline-flex;
}

.mtve-lite-player__cta-icon svg {
	width: 100%;
	height: 100%;
	display: block;
}

/* Iframe sau khi JS replace — fill .mtve-lite-player container */
.mtve-lite-player iframe {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	border: 0;
	display: block;
	max-width: 100% !important; /* đè base rule iframe width 100% */
}

/* Shorts framed mode: card 9:16 absolute giữa khung 16:9 */
.mtve-responsive.mtve-9-16-framed.mtve-lite-player-framed .mtve-lite-player {
	position: absolute;
	top: 0;
	left: 50%;
	transform: translateX(-50%);
	height: 100%;
	width: auto;
	aspect-ratio: 9 / 16;
	z-index: 1;
}

/* Mobile (Shorts framed): bỏ khung, card 9:16 full */
@media (max-width: 599px) {
	.mtve-responsive.mtve-9-16-framed.mtve-lite-player-framed {
		aspect-ratio: auto;
		background: transparent;
		max-width: 360px;
		border-radius: 0;
	}

	.mtve-responsive.mtve-9-16-framed.mtve-lite-player-framed .mtve-frame-bg {
		display: none;
	}

	.mtve-responsive.mtve-9-16-framed.mtve-lite-player-framed .mtve-lite-player {
		position: static;
		transform: none;
		height: auto;
		width: auto;
		max-width: 360px;
		margin: 0 auto;
		aspect-ratio: 9 / 16;
	}
}

/* Mobile: title 1 dòng (tránh title dài che play button giữa card)
   + ẩn CTA "Watch on YouTube" cho thoáng (user vẫn click thumbnail play inline). */
@media (max-width: 599px) {
	.mtve-lite-player__title {
		-webkit-line-clamp: 1;
	}

	.mtve-lite-player__cta {
		display: none;
	}
}

