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

/* Ảnh trong KHỐI VIDEO (avatar/thumbnail/frame-bg) KHÔNG phải ảnh nội dung → gỡ mọi style mà rule ảnh
   nội dung (.pdp-content img / .prose img …) bleed vào: margin auto, cursor zoom-in, border-radius, con trỏ
   lightbox. (Lightbox JS đã loại qua .ve-embed; đây là phần CSS còn sót — Triều 24/07 bắt được.) */
:is(.pdp-content, .prose, .archive-desc) .ve-embed img {
	margin: 0;
	cursor: default;
}
/* re-assert border-radius avatar (rule .pdp-content img specificity cao hơn .ve-lite-player__avatar
   đã ghi đè mất tròn) — :is()+class thắng .pdp-content img */
:is(.pdp-content, .prose, .archive-desc) .ve-lite-player__avatar {
	border-radius: 50%;
}

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

.ve-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;
}

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

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

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

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

.ve-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.) */
.ve-responsive.ve-tiktok-framed .ve-frame-bg {
	filter: blur(6px) brightness(0.55);
	transform: scale(1.05);
}

.ve-responsive.ve-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) {
	.ve-responsive.ve-9-16-framed {
		aspect-ratio: auto;
		max-width: 360px;
		background: transparent;
		border-radius: 0; /* mobile: vuông góc — đồng nhất TikTok mobile */
	}

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

	.ve-responsive.ve-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 .ve-frame-bg). Mobile CSS bỏ khung. */
.ve-responsive.ve-tiktok-framed {
	position: relative;
	aspect-ratio: 16 / 9;
	overflow: hidden;
	background: #000;
	border-radius: 0; /* vuông góc đồng bộ với YouTube lite player. */
}

.ve-responsive.ve-tiktok-framed .ve-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). */
}

.ve-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;
}

.ve-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. */
.ve-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. */
.ve-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) {
	.ve-tiktok-card:hover .ve-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. */
.ve-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;
}

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

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

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

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

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

.ve-tiktok-card:active .ve-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. */
.ve-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;
}

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

.ve-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%;
}

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

/* Avatar kênh: ảnh + border-radius 50% → hình tròn (đơn giản như web cũ). */
.ve-tiktok-card__avatar {
	width: 28px;
	height: 28px;
	border-radius: 50%;
	overflow: hidden;
	flex-shrink: 0;
	display: inline-block;
}

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

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

/* CTA pill — kiểu "Watch on YouTube". */
.ve-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);
}

.ve-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. */
}

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

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

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

/* Mobile: bỏ khung 16:9 cho TikTok, card 9:16 full. */
@media (max-width: 599px) {
	.ve-responsive.ve-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). */
	}

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

	.ve-responsive.ve-tiktok-framed .ve-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 ---- */
.ve-figure {
	margin: 0 0 1.5em; /* reset default <figure> margin (1em 40px); chừa khoảng cách dưới tách nội dung kế. */
}

/* Liền PA3: ép video sát caption (bỏ margin dưới 1em) + bỏ bo 2 góc dưới player để khớp caption. */
.ve-figure .ve-responsive {
	margin-bottom: 0;
	border-bottom-left-radius: 0;
	border-bottom-right-radius: 0;
}

/* Caption (PA3): nền sáng liền dưới video + icon play đỏ. */
.ve-caption {
	margin: 0;
	padding: 0.7em 1em;
	background: #f3f4f6;
	font-size: 1em;
	font-style: italic;
	line-height: 1.45;
	color: #4b5563;
	text-align: center;
}

.ve-caption::before {
	content: "\25B6"; /* ▶ play */
	margin-right: 0.45em;
	font-size: 0.72em;
	color: #ef4444;
	vertical-align: middle;
}

.ve-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 .ve-responsive.ve-16-9 iframe chỉ áp dụng cho iframe wrap v0.1). */
.ve-responsive.ve-lite-player-wrap {
	aspect-ratio: 16 / 9;
}

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

/* Thumbnail làm nền */
.ve-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 */
.ve-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;
}

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

/* Play SVG center — pill rounded-rect đỏ (YT brand asset). */
.ve-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;
}

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

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

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

/* Header top overlay: avatar + title + channel (giống YouTube real). pointer-events:none → click xuyên cover. */
.ve-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;
}

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

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

.ve-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;
}

.ve-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. */
.ve-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;
}

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

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

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

/* Iframe sau khi JS replace — fill .ve-lite-player container */
.ve-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 */
.ve-responsive.ve-9-16-framed.ve-lite-player-framed .ve-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) {
	.ve-responsive.ve-9-16-framed.ve-lite-player-framed {
		aspect-ratio: auto;
		background: transparent;
		max-width: 360px;
		border-radius: 0;
	}

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

	.ve-responsive.ve-9-16-framed.ve-lite-player-framed .ve-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) {
	.ve-lite-player__title {
		-webkit-line-clamp: 1;
	}

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

