/**
 * YouTube Floating Video — frontend styles.
 *
 * All selectors are prefixed with ytfvp_ to avoid theme/plugin conflicts.
 *
 * @package YouTube_Floating_Video
 */

/* -------------------------------------------------------------------------
 * Floating container
 * ---------------------------------------------------------------------- */
.ytfvp_container {
	/* Desktop. */
	--ytfvp-width: 360px;
	--ytfvp-height: 200px;
	--ytfvp-bottom: 20px;
	/* Mobile (<= 600px). */
	--ytfvp-width-m: 340px;
	--ytfvp-height-m: 190px;
	--ytfvp-bottom-m: 90px;
	/* Shared. */
	--ytfvp-radius: 14px;
	--ytfvp-margin: 20px;
	--ytfvp-shadow: 0 12px 40px rgba( 0, 0, 0, 0.32 );
	--ytfvp-shadow-hover: 0 20px 55px rgba( 0, 0, 0, 0.45 );
	--ytfvp-bg: rgba( 255, 255, 255, 0.08 );
	--ytfvp-border: rgba( 255, 255, 255, 0.18 );

	position: fixed;
	bottom: var( --ytfvp-bottom );
	z-index: 999999;
	width: var( --ytfvp-width );
	max-width: calc( 100vw - ( var( --ytfvp-margin ) * 2 ) );
	margin: 0;
	padding: 0;
	opacity: 0;
	transform: translateY( 24px ) scale( 0.96 );
	pointer-events: none;
	box-sizing: border-box;
	-webkit-tap-highlight-color: transparent;
}

.ytfvp_container * {
	box-sizing: border-box;
}

.ytfvp_bottom_right {
	right: var( --ytfvp-margin );
}

.ytfvp_bottom_left {
	left: var( --ytfvp-margin );
}

.ytfvp_container.ytfvp_visible {
	opacity: 1;
	transform: translateY( 0 ) scale( 1 );
	pointer-events: auto;
	animation: ytfvpScale 0.55s cubic-bezier( 0.16, 1, 0.3, 1 ) both;
}

/* -------------------------------------------------------------------------
 * Wrapper / player
 * ---------------------------------------------------------------------- */
.ytfvp_wrapper {
	position: relative;
	border-radius: var( --ytfvp-radius );
	overflow: hidden;
	background: var( --ytfvp-bg );
	border: 1px solid var( --ytfvp-border );
	box-shadow: var( --ytfvp-shadow );
	-webkit-backdrop-filter: blur( 12px ) saturate( 130% );
	backdrop-filter: blur( 12px ) saturate( 130% );
	transition: transform 0.3s ease, box-shadow 0.3s ease;
	will-change: transform;
}

.ytfvp_wrapper:hover {
	transform: translateY( -4px ) scale( 1.02 );
	box-shadow: var( --ytfvp-shadow-hover );
}

.ytfvp_player {
	position: relative;
	width: 100%;
	/* Never taller than the room above the bottom margin; never below 80px. */
	height: max( 80px, min( var( --ytfvp-height ), calc( 100vh - var( --ytfvp-bottom ) - 16px ) ) );
	background: #000;
}

.ytfvp_iframe {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	border: 0;
	display: block;
}

/* -------------------------------------------------------------------------
 * Click-catcher + play hint
 * ---------------------------------------------------------------------- */
.ytfvp_hit {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	display: flex;
	align-items: center;
	justify-content: center;
	margin: 0;
	padding: 0;
	border: 0;
	background: transparent;
	cursor: pointer;
	z-index: 2;
	color: #fff;
	transition: background 0.3s ease;
}

.ytfvp_hit:hover,
.ytfvp_hit:focus-visible {
	background: rgba( 0, 0, 0, 0.18 );
	outline: none;
}

.ytfvp_play_icon {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 56px;
	height: 56px;
	border-radius: 50%;
	color: #fff;
	background: rgba( 20, 20, 25, 0.45 );
	border: 1px solid rgba( 255, 255, 255, 0.25 );
	-webkit-backdrop-filter: blur( 6px );
	backdrop-filter: blur( 6px );
	opacity: 0;
	transform: scale( 0.8 );
	transition: opacity 0.3s ease, transform 0.3s ease;
	pointer-events: none;
}

.ytfvp_play_icon svg {
	margin-left: 3px;
}

.ytfvp_hit:hover .ytfvp_play_icon,
.ytfvp_hit:focus-visible .ytfvp_play_icon {
	opacity: 1;
	transform: scale( 1 );
}

/* -------------------------------------------------------------------------
 * Modal
 * ---------------------------------------------------------------------- */
.ytfvp_modal {
	position: fixed;
	inset: 0;
	z-index: 1000000;
	display: none;
	align-items: center;
	justify-content: center;
	padding: 24px;
	box-sizing: border-box;
}

.ytfvp_modal * {
	box-sizing: border-box;
}

.ytfvp_overlay {
	position: absolute;
	inset: 0;
	/* Near-opaque so page content never bleeds through behind the video. */
	background: rgba( 7, 9, 14, 0.94 );
	-webkit-backdrop-filter: blur( 14px );
	backdrop-filter: blur( 14px );
	opacity: 0;
	transition: opacity 0.32s ease;
}

.ytfvp_dialog {
	position: relative;
	width: min( 1100px, 92vw );
	/* Never taller than the viewport in landscape. */
	max-width: calc( 88vh * 16 / 9 );
	opacity: 0;
	transform: scale( 0.92 );
	transition: opacity 0.32s ease, transform 0.32s cubic-bezier( 0.16, 1, 0.3, 1 );
}

.ytfvp_modal_open .ytfvp_overlay {
	opacity: 1;
}

.ytfvp_modal_open .ytfvp_dialog {
	opacity: 1;
	transform: scale( 1 );
}

.ytfvp_modal_stage {
	position: relative;
	width: 100%;
	aspect-ratio: 16 / 9;
	border-radius: 16px;
	overflow: hidden;
	background: #000;
	/* Subtle edge only — no heavy drop-shadow halo on the dark backdrop. */
	box-shadow: 0 0 0 1px rgba( 255, 255, 255, 0.06 );
}

.ytfvp_modal_iframe {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	border: 0;
	display: block;
}

/* -------------------------------------------------------------------------
 * Close button
 * ---------------------------------------------------------------------- */
.ytfvp_close {
	position: absolute;
	top: -18px;
	right: -18px;
	width: 44px;
	height: 44px;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 0;
	border: 1px solid rgba( 255, 255, 255, 0.25 );
	border-radius: 50%;
	color: #fff;
	background: rgba( 25, 27, 34, 0.65 );
	-webkit-backdrop-filter: blur( 10px );
	backdrop-filter: blur( 10px );
	cursor: pointer;
	box-shadow: 0 8px 24px rgba( 0, 0, 0, 0.4 );
	transition: transform 0.25s ease, background 0.25s ease;
	z-index: 3;
}

.ytfvp_close:hover,
.ytfvp_close:focus-visible {
	background: rgba( 235, 70, 70, 0.92 );
	transform: rotate( 90deg ) scale( 1.05 );
	outline: none;
}

/* -------------------------------------------------------------------------
 * Scroll lock
 * ---------------------------------------------------------------------- */
html.ytfvp_no_scroll,
body.ytfvp_no_scroll {
	overflow: hidden !important;
	overscroll-behavior: none;
}

/* -------------------------------------------------------------------------
 * Animations
 * ---------------------------------------------------------------------- */
@keyframes ytfvpFade {
	from {
		opacity: 0;
	}

	to {
		opacity: 1;
	}
}

@keyframes ytfvpScale {
	from {
		opacity: 0;
		transform: translateY( 24px ) scale( 0.92 );
	}

	to {
		opacity: 1;
		transform: translateY( 0 ) scale( 1 );
	}
}

/* -------------------------------------------------------------------------
 * Responsive — phones / small screens
 * ---------------------------------------------------------------------- */
@media ( max-width: 600px ) {
	.ytfvp_container {
		width: var( --ytfvp-width-m );
		/* Never wider than the screen minus the side margins. */
		max-width: calc( 100vw - ( var( --ytfvp-margin ) * 2 ) );
		bottom: var( --ytfvp-bottom-m );
	}

	.ytfvp_player {
		height: max( 80px, min( var( --ytfvp-height-m ), calc( 100vh - var( --ytfvp-bottom-m ) - 16px ) ) );
	}

	.ytfvp_close {
		top: -14px;
		right: -6px;
	}

	.ytfvp_hide_mobile {
		display: none !important;
	}

	/* Bigger modal video on phones — use almost the full screen width. */
	.ytfvp_modal {
		padding: 12px;
	}

	.ytfvp_dialog {
		width: 95vw;
		max-width: 95vw;
	}
}

/* -------------------------------------------------------------------------
 * Landscape phones — keep the modal inside the viewport
 * ---------------------------------------------------------------------- */
@media ( max-height: 480px ) and ( orientation: landscape ) {
	.ytfvp_dialog {
		width: min( 92vw, calc( 80vh * 16 / 9 ) );
	}

	.ytfvp_modal {
		padding: 16px;
	}
}

/* -------------------------------------------------------------------------
 * Reduced motion
 * ---------------------------------------------------------------------- */
@media ( prefers-reduced-motion: reduce ) {
	.ytfvp_container,
	.ytfvp_container.ytfvp_visible,
	.ytfvp_wrapper,
	.ytfvp_play_icon,
	.ytfvp_overlay,
	.ytfvp_dialog,
	.ytfvp_close {
		transition: none !important;
		animation: none !important;
	}
}
