/**
 * TikTok Elementor Feed Styles
 * Modern, clean UI/UX design
 */

.tef-container {
	width: 100%;
	max-width: 100%;
	margin: 0 auto;
	display: grid;
	grid-template-columns: 1fr;
	gap: 20px;
	padding: 0;
	overflow: visible;
	min-height: auto;
}

/* Desktop: 4 columns grid for staggered layout */
@media (min-width: 768px) {
	.tef-container {
		grid-template-columns: repeat(4, 1fr);
		gap: 20px;
		max-width: 100%;
		width: 100%;
		margin: 0 auto;
		align-items: start;
		display: grid;
		grid-auto-rows: auto;
		overflow: visible;
		min-height: auto;
	}
	
	/* Ensure all 4 videos are visible */
	.tef-video-item {
		display: block !important;
		visibility: visible !important;
		opacity: 1 !important;
		height: auto;
		min-height: 0;
	}
	
	/* Staggered/zigzag layout: 1 up, 2 down, 3 up, 4 down */
	/* Video 1 - top aligned */
	.tef-video-item:nth-child(1) {
		margin-top: 0;
		transform: translateY(0);
	}
	
	/* Video 2 - offset down */
	.tef-video-item:nth-child(2) {
		margin-top: 80px;
		transform: translateY(80px);
	}
	
	/* Video 3 - top aligned */
	.tef-video-item:nth-child(3) {
		margin-top: 0;
		transform: translateY(0);
	}
	
	/* Video 4 - offset down */
	.tef-video-item:nth-child(4) {
		margin-top: 80px;
		transform: translateY(80px);
	}
}

/* Tablet: 2 columns with staggered layout */
@media (min-width: 481px) and (max-width: 991px) {
	.tef-container {
		grid-template-columns: repeat(2, 1fr);
		gap: 20px;
	}
	
	/* Staggered layout for tablet - continuing pattern */
	.tef-video-item:nth-child(odd) {
		margin-top: 0;
		transform: translateY(0);
	}
	
	.tef-video-item:nth-child(even) {
		margin-top: 60px;
		transform: translateY(60px);
	}
}

/* TikTok official blockquote embed styles */
.tiktok-embed {
	margin: 0;
	width: 100%;
	min-width: 325px;
	max-width: 100%;
	position: relative;
}

.tiktok-embed iframe {
	width: 100%;
	height: 100%;
	border: none;
	position: absolute;
	top: 0;
	left: 0;
	border-radius: 8px;
}

/* Video embed container */
.tef-video-embed-container {
	position: relative;
	width: 100%;
	padding-bottom: 177.78%; /* 9:16 aspect ratio */
	height: 0;
	overflow: hidden;
	background: transparent; /* No background */
	border-radius: 12px;
}

.tef-video-embed-container .tiktok-embed {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
}

.tef-video-embed-container .tiktok-embed iframe {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	border-radius: 12px;
	border: none;
}

.tef-video-embed-container .tef-iframe-fallback {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	border-radius: 12px 12px 0 0;
}

/* Hide TikTok's related videos section */
/* TikTok shows related videos in an overlay after video ends */
/* We'll use CSS to hide the related videos container */
.tef-hide-related {
	overflow: hidden;
	position: relative;
	/* Limit container height to video only (9:16 aspect ratio) */
	max-height: 100%;
}

/* Limit iframe to video height only, hide overflow */
/* TikTok videos are 9:16 aspect ratio, so height = width * 1.7778 */
.tef-hide-related iframe {
	/* Force iframe to maintain aspect ratio and hide overflow */
	object-fit: contain;
	/* Clip any content that extends beyond video bounds */
	clip-path: inset(0 0 0 0);
}

/* Mask overlay to hide related videos that appear at bottom */
.tef-hide-related::after {
	content: '';
	position: absolute;
	bottom: 0;
	left: 0;
	right: 0;
	height: 0;
	background: #f8f9fa;
	z-index: 10;
	pointer-events: none;
	transition: height 0.3s ease;
}

/* When video ends, TikTok shows related videos at bottom */
/* JavaScript will handle hiding them by limiting iframe height */

/* Additional styling for better UX - removed gradient overlay */

/* Fallback iframe wrapper */
.tef-iframe-fallback-wrapper {
	position: relative;
	width: 100%;
	padding-bottom: 177.78%; /* 9:16 aspect ratio for TikTok */
	height: 0;
	overflow: hidden;
	background: #000;
	border-radius: 8px;
}

.tef-iframe-fallback-wrapper iframe {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	border: none;
}

.tef-video-item {
	position: relative;
	width: 100%;
	opacity: 1;
	transition: all 0.3s ease;
	display: block;
	flex-direction: column;
	border-radius: 12px;
	overflow: visible;
	background: transparent; /* No white background */
	box-shadow: none; /* No shadow */
	transition: transform 0.3s ease;
	visibility: visible;
	height: auto;
	min-height: 0;
}

.tef-video-item:hover {
	transform: translateY(-2px) scale(1.02);
}

.tef-video-item.tef-active {
	opacity: 1;
}

.tef-video-wrapper {
	position: relative;
	width: 100%;
	padding-bottom: 177.78%; /* 9:16 aspect ratio for TikTok videos (portrait) */
	height: 0;
	overflow: hidden;
	background: transparent; /* No background */
	border-radius: 12px;
	box-shadow: none;
}

/* Desktop: Keep 9:16 aspect ratio but in grid */
@media (min-width: 768px) {
	.tef-video-wrapper {
		padding-bottom: 177.78%; /* Keep 9:16 for TikTok videos */
		max-width: 100%;
		margin: 0;
	}
}

.tef-video-wrapper iframe {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	border: none;
}

.tef-video-placeholder {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	background: #f5f5f5; /* Changed from #1a1a1a to lighter gray */
	background-size: cover;
	background-position: center;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	transition: opacity 0.3s ease;
	border-radius: 8px;
}

.tef-video-placeholder:hover {
	opacity: 0.9;
}

.tef-play-button {
	width: 64px;
	height: 64px;
	background: rgba(0, 0, 0, 0.6);
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: transform 0.2s ease, background 0.2s ease;
}

.tef-video-placeholder:hover .tef-play-button {
	transform: scale(1.1);
	background: rgba(0, 0, 0, 0.8);
}

.tef-play-button svg {
	width: 32px;
	height: 32px;
	margin-left: 4px; /* Offset for play icon visual balance */
}

/* Placeholder and error messages */
.tef-placeholder,
.tef-error {
	padding: 20px;
	text-align: center;
	background: #f5f5f5;
	border-radius: 8px;
	color: #666;
	font-size: 14px;
}

.tef-error {
	background: #fee;
	color: #c33;
	border: 1px solid #fcc;
}

/* Responsive adjustments */
@media (max-width: 767px) {
	.tef-video-wrapper {
		padding-bottom: 177.78%; /* 9:16 aspect ratio for mobile */
		border-radius: 12px;
	}
	
	/* Mobile: Single column, full width - no stagger */
	.tef-container {
		grid-template-columns: 1fr;
		gap: 20px;
		padding: 0;
	}
	
	/* Reset transforms on mobile */
	.tef-video-item {
		margin-top: 0 !important;
		transform: translateY(0) !important;
	}
}

/* Loading state */
.tef-video-item.loading .tef-video-placeholder {
	opacity: 0.5;
}

/* Smooth transitions */
.tef-video-item,
.tef-video-wrapper,
.tef-video-placeholder {
	transition: all 0.3s ease;
}

/* Elementor editor adjustments */
.elementor-editor-active .tef-video-item {
	opacity: 1;
}

.elementor-editor-active .tef-video-wrapper {
	cursor: pointer;
}
