/**
 * Frontend Styles
 */

/* Video Gallery Grid */
.rv-video-gallery {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
	gap: 15px;
	margin-bottom: 20px;
}

.rv-videos.rv-before-main,
.rv-videos.rv-after-main,
.rv-videos.rv-after-gallery,
.rv-videos.rv-section {
	margin-bottom: 20px;
}

/* Positions that need space ABOVE them */
.rv-videos.rv-before-main,
.rv-videos.rv-after-gallery {
	margin-top: 30px;
}

/* Positions that need space BELOW them */
.rv-videos.rv-after-main,
.rv-videos.rv-after-main-image,
.rv-videos.rv-section {
	margin-bottom: 30px;
}

.rv-videos.rv-section h3 {
	margin-bottom: 15px;
	font-size: 1.5em;
	color: #333;
}

/* Video Items - Container matches WooCommerce thumbnail size */
.rv-video-item {
	position: relative;
	aspect-ratio: var(--rv-thumbnail-aspect-ratio, 1);
	overflow: hidden;
	cursor: pointer;
	background: transparent;
	z-index: 0;
}

/* Video Thumbnails */
.rv-video-thumbnail {
	position: relative;
	width: 100%;
	height: 100%;
	display: flex;
	align-items: center;
	justify-content: center;
	background: transparent;
	overflow: hidden;
	z-index: 0;
}

/* Hide native video controls on all devices */
.rv-video-thumbnail video {
	pointer-events: none;
}

.rv-video-thumbnail video::-webkit-media-controls {
	display: none !important;
}

.rv-video-thumbnail video::-webkit-media-controls-enclosure {
	display: none !important;
}

.rv-video-thumbnail video::-webkit-media-controls-panel {
	display: none !important;
}

.rv-video-thumbnail video::-webkit-media-controls-play-button {
	display: none !important;
}

.rv-video-thumbnail video::-webkit-media-controls-start-playback-button {
	display: none !important;
}

/* Video maintains original aspect ratio - Fit mode (default) */
.rv-video-gallery.rv-video-fit-contain .rv-video-thumbnail video {
	width: 100%;
	height: 100%;
	object-fit: contain;
}

/* Video fills container - Cover mode (may crop) */
.rv-video-gallery.rv-video-fit-cover .rv-video-thumbnail video {
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.rv-video-overlay {
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	opacity: 0;
	transition: opacity 0.2s ease;
	pointer-events: none;
	z-index: 1;
}

.rv-video-item:hover .rv-video-overlay,
.rv-video-overlay.show-play-icon {
	opacity: 1;
}

.rv-play-icon {
	position: absolute;
	pointer-events: none;
	z-index: 2;
	opacity: 0;
	transition: opacity 0.2s ease;
	/* Center the triangle */
	left: 50%;
	top: 50%;
	transform: translate(-50%, -50%);
	/* Triangle styles directly on element */
	width: 0;
	height: 0;
	border-left: 24px solid white;
	border-top: 16px solid transparent;
	border-bottom: 16px solid transparent;
	filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5));
	margin-left: 4px; /* Slight offset to center visually */
	/* Hide any text content */
	font-size: 0;
	line-height: 0;
}

.rv-play-icon.visible {
	opacity: 1 !important;
}

.rv-expand-icon {
	position: absolute;
	top: 10px;
	right: 10px;
	font-size: 18px;
	color: white;
	background: rgba(0, 0, 0, 0.6);
	width: 32px;
	height: 32px;
	display: flex;
	align-items: center;
	justify-content: center;
	border-radius: 4px;
	cursor: pointer;
	z-index: 3;
	pointer-events: auto;
}

/* Lightbox */
.rv-lightbox {
	position: fixed;
	top: 0;
	left: 0;
	width: 100vw;
	height: 100vh;
	z-index: 999999;
	display: flex;
	align-items: center;
	justify-content: center;
}

.rv-lightbox-overlay {
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	background: rgba(0, 0, 0, 0.5);
}

.rv-lightbox-container {
	position: relative;
	max-width: 90vw;
	max-height: 90vh;
	z-index: 1;
}

.rv-lightbox-content {
	position: relative;
	background: black;
	overflow: hidden;
	display: flex;
	align-items: center;
	justify-content: center;
}

.rv-lightbox-content img,
.rv-lightbox-content video {
	max-width: 90vw;
	max-height: 90vh;
	width: auto;
	height: auto;
	display: block;
	object-fit: contain;
	transform: translateZ(0);
	-webkit-transform: translateZ(0);
}

/* Hide video until metadata loads to prevent glitch */
.rv-lightbox-content video.rv-lightbox-video-loading {
	opacity: 0;
	visibility: hidden;
}

.rv-lightbox-content video:not(.rv-lightbox-video-loading) {
	opacity: 1;
	visibility: visible;
	transition: opacity 0.2s ease;
}

.rv-lightbox-close {
	position: absolute;
	top: 15px;
	right: 15px;
	background: none;
	border: none;
	color: white;
	font-size: 30px;
	font-weight: bold;
	width: auto;
	height: auto;
	cursor: pointer;
	z-index: 2;
	padding: 10px;
	line-height: 1;
}

.rv-lightbox-close:hover {
	color: #ccc;
}

.rv-lightbox-prev,
.rv-lightbox-next {
	position: absolute;
	top: 50%;
	background: rgba(255, 255, 255, 0.9);
	border: none;
	color: black;
	font-size: 24px;
	font-weight: bold;
	width: 50px;
	height: 50px;
	border-radius: 50%;
	cursor: pointer;
	z-index: 2;
	transition: background 0.2s ease;
	transform: translateY(-50%);
}

.rv-lightbox-prev {
	left: 15px;
}

.rv-lightbox-next {
	right: 15px;
}

.rv-lightbox-prev:hover,
.rv-lightbox-next:hover {
	background: white;
}

/* Responsive */
@media (max-width: 768px) {
	.rv-video-gallery {
		grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
		gap: 10px;
	}

	.rv-play-icon {
		/* Smaller triangle on mobile - same style, just smaller */
		border-left-width: 16px;
		border-top-width: 11px;
		border-bottom-width: 11px;
		margin-left: 3px; /* Slight offset to center visually */
		/* Remove shadow on mobile for better appearance */
		filter: none !important;
	}

	.rv-expand-icon {
		font-size: 16px;
		padding: 4px;
	}

	/* Ensure custom play icon is visible on mobile when video is paused (not just on hover) */
	.rv-video-overlay.show-play-icon {
		opacity: 1 !important;
		pointer-events: auto !important;
	}

	.rv-play-icon.visible {
		opacity: 1 !important;
	}

	/* Make the thumbnail container clickable on mobile */
	.rv-video-thumbnail {
		pointer-events: auto;
		cursor: pointer;
	}

	/* Additional rules to hide native controls on mobile */
	.rv-video-thumbnail video {
		-webkit-appearance: none;
		-moz-appearance: none;
		appearance: none;
	}

	/* Prevent iOS from showing native controls - aggressive hiding */
	.rv-video-thumbnail video[controls] {
		pointer-events: none !important;
		position: relative;
		z-index: 0;
	}

	.rv-video-thumbnail video[controls]::-webkit-media-controls {
		display: none !important;
		opacity: 0 !important;
		visibility: hidden !important;
		pointer-events: none !important;
	}

	.rv-video-thumbnail video[controls]::-webkit-media-controls-enclosure {
		display: none !important;
		opacity: 0 !important;
		visibility: hidden !important;
		pointer-events: none !important;
	}

	.rv-video-thumbnail video[controls]::-webkit-media-controls-panel {
		display: none !important;
		opacity: 0 !important;
		visibility: hidden !important;
		pointer-events: none !important;
	}

	.rv-video-thumbnail video[controls]::-webkit-media-controls-play-button {
		display: none !important;
		opacity: 0 !important;
		visibility: hidden !important;
		pointer-events: none !important;
	}

	.rv-video-thumbnail video[controls]::-webkit-media-controls-start-playback-button {
		display: none !important;
		opacity: 0 !important;
		visibility: hidden !important;
		pointer-events: none !important;
	}

	/* Ensure video doesn't overlay thumbnail area after fullscreen exit */
	.rv-video-thumbnail video {
		position: relative !important;
		z-index: 0 !important;
		pointer-events: none !important;
		width: 100% !important;
		height: 100% !important;
		max-width: 100% !important;
		max-height: 100% !important;
		object-fit: contain;
	}

	/* Ensure overlay and icons stay on top after fullscreen */
	.rv-video-overlay {
		position: absolute;
		z-index: 10 !important;
		pointer-events: auto;
	}

	.rv-expand-icon {
		z-index: 11 !important;
		pointer-events: auto;
	}

	.rv-play-icon {
		z-index: 12 !important;
		pointer-events: none;
	}

	/* Hide lightbox completely on mobile - use native fullscreen instead */
	.rv-lightbox {
		display: none !important;
	}

	/* Prevent glitch in lightbox on mobile */
	.rv-lightbox-content video {
		max-width: 100%;
		max-height: 100%;
		width: auto;
		height: auto;
		object-fit: contain;
	}
}
