/* ── TVFL Media Widget ─────────────────────────────────────────────────────── */

.tvfl-media-grid {
	display: grid;
	grid-template-columns: repeat(6, 1fr); /* default; overridden per-instance by Elementor controls */
	gap: 16px;
}

.tvfl-media-item {
	display: flex;
	flex-direction: column;
	gap: 10px;
}

/* 16:9 aspect-ratio wrapper — padding-bottom overridden by aspect_ratio control */
.tvfl-media-video-wrap {
	position: relative;
	width: 100%;
	padding-bottom: 56.25%;
	height: 0;
	border-radius: 6px;
	overflow: hidden;
	background: #000;
	cursor: pointer;
}

.tvfl-media-thumb-wrap {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
}

.tvfl-media-thumb {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

/* ── Play button (YouTube-style) ─────────────────────────────────────────── */

.tvfl-media-play {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	display: flex;
	align-items: center;
	justify-content: center;
	background: transparent;
	border: none;
	padding: 0;
	cursor: pointer;
	-webkit-appearance: none;
	appearance: none;
}

.tvfl-media-play svg {
	width: 64px;
	height: 45px;
	filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.55));
	transition: transform 0.15s ease;
}

.tvfl-play-bg {
	fill: #ff0000;
	fill-opacity: 0.88;
	transition: fill-opacity 0.15s ease;
}

.tvfl-play-arrow {
	fill: #fff;
}

.tvfl-media-video-wrap:hover .tvfl-play-bg {
	fill-opacity: 1;
}

.tvfl-media-video-wrap:hover .tvfl-media-play svg {
	transform: scale(1.06);
}

/* ── Active / playing state ──────────────────────────────────────────────── */

.tvfl-media-thumb-wrap.is-playing {
	display: none;
}

.tvfl-media-video-wrap iframe {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	border: none;
}

/* ── Title ───────────────────────────────────────────────────────────────── */

.tvfl-media-title {
	margin: 0;
	font-size: 18px;
	font-weight: 600;
	line-height: 1.35;
	color: var(--e-global-color-secondary);
}

/* ── Empty state ─────────────────────────────────────────────────────────── */

.tvfl-media-empty {
	color: rgba(255, 255, 255, 0.55);
	font-size: 0.9rem;
}

/* ── Video Popup ─────────────────────────────────────────────────────────── */

.tvfl-media-popup {
	position: fixed;
	inset: 0;
	z-index: 999999;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 20px;
	box-sizing: border-box;
	opacity: 0;
	visibility: hidden;
	pointer-events: none;
	transition: opacity 0.25s ease, visibility 0.25s ease;
}

.tvfl-media-popup.open {
	opacity: 1;
	visibility: visible;
	pointer-events: auto;
}

.tvfl-media-popup-overlay {
	position: absolute;
	inset: 0;
	background: rgba(0, 0, 0, 0.88);
	cursor: pointer;
}

.tvfl-media-popup-dialog {
	position: relative;
	z-index: 1;
	width: min(90vw, 1280px);
	transform: scale(0.92);
	transition: transform 0.25s ease;
}

.tvfl-media-popup.open .tvfl-media-popup-dialog {
	transform: scale(1);
}

/* Close button — sits above the video */
.tvfl-media-popup-close {
	position: absolute;
	top: -44px;
	right: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 36px;
	height: 36px;
	padding: 0;
	border: none;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.15);
	color: #fff;
	cursor: pointer;
	transition: background-color 0.2s ease;
	-webkit-appearance: none;
	appearance: none;
}

.tvfl-media-popup-close:hover {
	background: rgba(255, 255, 255, 0.3);
}

.tvfl-media-popup-close svg {
	width: 18px;
	height: 18px;
	display: block;
}

/* 16:9 container (YouTube / raw video) */
.tvfl-media-popup-body {
	position: relative;
	width: 100%;
	padding-bottom: 56.25%;
	height: 0;
	background: #000;
	border-radius: 6px;
	overflow: hidden;
}

.tvfl-media-popup-body iframe,
.tvfl-media-popup-body video {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	border: none;
}

/* Image lightbox — no aspect-ratio trick; image sizes itself */
.tvfl-media-popup.open--image .tvfl-media-popup-body {
	padding-bottom: 0;
	height: auto;
	display: flex;
	align-items: center;
	justify-content: center;
	background: transparent;
}

.tvfl-media-popup.open--image .tvfl-media-popup-body img {
	display: block;
	width: 100%;
	height: auto;
	max-height: 85vh;
	object-fit: contain;
	border-radius: 6px;
}

/* Hide YouTube play button for image-type items */
.tvfl-media-video-wrap[data-type="image"] .tvfl-media-play {
	display: none;
}

/* Thumbnail placeholder for raw video with no custom thumbnail */
.tvfl-media-thumb-placeholder {
	position: absolute;
	inset: 0;
	background: #111;
}

@media (max-width: 600px) {
	.tvfl-media-popup {
		padding: 12px;
	}
	.tvfl-media-popup-close {
		top: -40px;
		width: 32px;
		height: 32px;
	}
	.tvfl-media-popup-close svg {
		width: 16px;
		height: 16px;
	}
}

/* ── Responsive fallbacks (when no Elementor controls override) ──────────── */

@media (max-width: 1024px) {
	.tvfl-media-grid {
		grid-template-columns: repeat(3, 1fr);
	}
	.tvfl-media-play svg {
		width: 52px;
		height: 37px;
	}
}

@media (max-width: 767px) {
	.tvfl-media-grid {
		grid-template-columns: repeat(2, 1fr);
		gap: 12px;
	}
	.tvfl-media-title {
		font-size: 14px;
	}
	.tvfl-media-play svg {
		width: 44px;
		height: 31px;
	}
}
