/**
 * PlugeTune frontend video styles.
 *
 * @package PlugeTune
 */

/* Wrapper - full width at the top of the page. */
.plugetune-wrapper {
	width: 100%;
	max-width: 100%;
	margin-bottom: 25px;
	border-radius: 10px;
	overflow: hidden;
	background: #000;
	position: relative;
}

/* Container - 16:9 aspect ratio. */
.plugetune-container {
	position: relative;
	width: 100%;
	padding-bottom: 56.25%; /* 16:9 */
	height: 0;
	overflow: hidden;
	background: #0a0a0a;
}

/* Overlay - featured image on top of the video. */
.plugetune-overlay {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	cursor: pointer;
	z-index: 10;
	background: #000;
	transition: opacity 0.5s ease, visibility 0.5s ease;
}

/* Featured image displayed as the overlay. */
.plugetune-overlay-image {
	width: 100%;
	height: 100%;
	object-fit: cover;
	transition: transform 0.4s ease;
}

.plugetune-container:hover .plugetune-overlay-image {
	transform: scale(1.05);
}

/* Play button - centered on the overlay. */
.plugetune-play-button {
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	width: 80px;
	height: 80px;
	background: rgba(255, 0, 0, 0.85);
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: all 0.3s ease;
	box-shadow: 0 0 40px rgba(0, 0, 0, 0.6);
	pointer-events: none;
	z-index: 15;
}

.plugetune-play-button svg {
	width: 40px;
	height: 40px;
	fill: #ffffff;
	margin-left: 5px;
}

/* Play button hover effect. */
.plugetune-container:hover .plugetune-play-button {
	transform: translate(-50%, -50%) scale(1.1);
	background: rgba(255, 0, 0, 1);
	box-shadow: 0 0 60px rgba(255, 0, 0, 0.4);
}

/* Play button pulse animation. */
.plugetune-play-button::after {
	content: '';
	position: absolute;
	top: -10px;
	left: -10px;
	right: -10px;
	bottom: -10px;
	border-radius: 50%;
	border: 3px solid rgba(255, 255, 255, 0.2);
	animation: pulse 2s infinite;
}

@keyframes pulse {
	0% {
		transform: scale(1);
		opacity: 1;
	}
	100% {
		transform: scale(1.5);
		opacity: 0;
	}
}

/* Video - hidden behind the overlay initially. */
.plugetune-video {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	background: #000;
	z-index: 5;
}

.plugetune-video iframe {
	width: 100%;
	height: 100%;
	border: 0;
}

/* Playing state: hide the overlay and show the video. */
.plugetune-container.playing .plugetune-overlay {
	display: none !important;
	opacity: 0 !important;
	visibility: hidden !important;
	pointer-events: none !important;
	z-index: 1 !important;
}

.plugetune-container.playing .plugetune-video {
	display: block !important;
	z-index: 20 !important;
}

/* ------------------------------------------------------------------
 * Facade (click-to-play) player
 * ------------------------------------------------------------------ */

/* Facade container. */
.plugetune-video-facade {
	position: relative;
	width: 100%;
	padding-bottom: 56.25%; /* 16:9 aspect ratio */
	background: #000;
	cursor: pointer;
	overflow: hidden;
	border-radius: 8px;
}

/* Iframe is created on click and sits under the thumbnail until loaded. */
.plugetune-facade-iframe {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	border: 0;
	z-index: 1;
}

/* Thumbnail covers the iframe until the video is ready. */
.plugetune-facade-thumbnail {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	z-index: 2;
	transition: opacity 0.25s ease;
}

.plugetune-facade-thumbnail img {
	width: 100%;
	height: 100%;
	object-fit: cover;
}

/* Overlay. */
.plugetune-facade-overlay {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	background: rgba(0, 0, 0, 0.1);
	display: flex;
	align-items: center;
	justify-content: center;
}

.plugetune-facade-play-btn {
	width: 68px;
	height: 48px;
	background-color: #f00;
	border-radius: 12px;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: opacity 0.15s ease;
}

/* Spinner (shown while the iframe is loading). */
.plugetune-facade-spinner {
	position: absolute;
	top: 50%;
	left: 50%;
	width: 48px;
	height: 48px;
	margin: -24px 0 0 -24px;
	border: 4px solid rgba(255, 255, 255, 0.35);
	border-top-color: #ffffff;
	border-radius: 50%;
	opacity: 0;
	visibility: hidden;
	animation: plugetune-facade-spin 0.8s linear infinite;
}

@keyframes plugetune-facade-spin {
	to {
		transform: rotate(360deg);
	}
}

.plugetune-video-facade.is-loading .plugetune-facade-play-btn {
	opacity: 0;
}

.plugetune-video-facade.is-loading .plugetune-facade-spinner {
	opacity: 1;
	visibility: visible;
}

/* Hide the thumbnail once the iframe is ready. */
.plugetune-video-facade.is-playing .plugetune-facade-thumbnail {
	opacity: 0;
	pointer-events: none;
	visibility: hidden;
}

/* Responsive design. */

/* Tablet. */
@media (max-width: 768px) {
	.plugetune-play-button {
		width: 65px;
		height: 65px;
	}

	.plugetune-play-button svg {
		width: 32px;
		height: 32px;
	}

	.plugetune-wrapper {
		margin-bottom: 20px;
		border-radius: 8px;
	}
}

/* Mobile. */
@media (max-width: 480px) {
	.plugetune-play-button {
		width: 55px;
		height: 55px;
	}

	.plugetune-play-button svg {
		width: 26px;
		height: 26px;
	}

	.plugetune-wrapper {
		margin-bottom: 15px;
		border-radius: 6px;
	}
}

/* Small mobile. */
@media (max-width: 360px) {
	.plugetune-play-button {
		width: 45px;
		height: 45px;
	}

	.plugetune-play-button svg {
		width: 20px;
		height: 20px;
	}
}

/* Dark mode support. */
@media (prefers-color-scheme: dark) {
	.plugetune-container {
		background: #1a1a1a;
	}

	.plugetune-play-button {
		background: rgba(255, 0, 0, 0.9);
	}
}