/* ============================================================
   YT Featured Player — fullscreen modal
   Mobile-first: 100vw × 100vh including safe areas (iOS notch).
   Video centered vertically as 16:9 (no letterboxing on portrait phones).
   ============================================================ */

.ytfp-modal[hidden] {
	display: none;
}

.ytfp-modal {
	position: fixed;
	inset: 0;
	z-index: 999999;
	width: 100vw;
	height: 100vh;
	height: 100dvh; /* dynamic viewport height — accounts for mobile browser chrome */
	display: flex;
	align-items: center;
	justify-content: center;

	/* iOS safe-area-aware padding so the close button doesn't sit under the notch */
	padding-top: env(safe-area-inset-top, 0);
	padding-right: env(safe-area-inset-right, 0);
	padding-bottom: env(safe-area-inset-bottom, 0);
	padding-left: env(safe-area-inset-left, 0);
	box-sizing: border-box;

	font-family: inherit;
}

/* Background fill */
.ytfp-modal--dark { background: rgba(0, 0, 0, 0.95); }
.ytfp-modal--light { background: rgba(20, 20, 20, 0.85); }

.ytfp-modal-backdrop {
	position: absolute;
	inset: 0;
	cursor: pointer;
	z-index: 1;
}

/* Close button — top right, big enough for thumb on mobile */
.ytfp-modal-close {
	position: absolute;
	top: max(12px, env(safe-area-inset-top, 0));
	right: max(12px, env(safe-area-inset-right, 0));
	z-index: 3;
	background: rgba(0, 0, 0, 0.5);
	color: #fff;
	border: 1px solid rgba(255, 255, 255, 0.2);
	border-radius: 999px;
	width: 44px;
	height: 44px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	padding: 0;
	transition: background-color .15s ease, transform .15s ease;
}

.ytfp-modal-close:hover,
.ytfp-modal-close:focus-visible {
	background: rgba(0, 0, 0, 0.85);
	transform: scale(1.08);
}

.ytfp-modal-close:focus-visible {
	outline: 2px solid #fff;
	outline-offset: 2px;
}

/* Stage — flex container that centers the frame */
.ytfp-modal-stage {
	position: relative;
	z-index: 2;
	width: 100%;
	height: 100%;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 16px;
	box-sizing: border-box;
}

/* Frame — sized to fit the largest 16:9 rectangle inside the stage */
.ytfp-modal-frame {
	width: 100%;
	max-width: min(95vw, calc((100vh - 80px) * 16 / 9));
	max-height: calc(100vh - 80px);
	aspect-ratio: 16 / 9;
	background: #000;
	border-radius: 8px;
	overflow: hidden;
	box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}

/* The player slot — iframe injected on open */
.ytfp-modal-player {
	width: 100%;
	height: 100%;
}

.ytfp-modal-player iframe {
	width: 100%;
	height: 100%;
	border: 0;
	display: block;
}

/* "Open on YouTube" fallback link — sits below the frame, small and subtle.
   Visible always — gives users an escape hatch if the iframe shows Error 153
   or any other playback failure. */
.ytfp-modal-fallback {
	position: absolute;
	left: 50%;
	bottom: max(8px, env(safe-area-inset-bottom, 0));
	transform: translateX(-50%);
	color: rgba(255, 255, 255, 0.7);
	font-size: 13px;
	text-decoration: none;
	background: rgba(0, 0, 0, 0.6);
	border: 1px solid rgba(255, 255, 255, 0.15);
	padding: 6px 14px;
	border-radius: 999px;
	z-index: 4;
	transition: background-color .15s ease, color .15s ease;
}

.ytfp-modal-fallback:hover,
.ytfp-modal-fallback:focus-visible {
	background: rgba(0, 0, 0, 0.85);
	color: #fff;
}

/* ============================================================
   Mobile portrait — phones held upright
   Video stays 16:9 but uses full width; centered vertically with
   black bars top/bottom (which is the modal's own background).
   ============================================================ */
@media (max-width: 768px) and (orientation: portrait) {
	.ytfp-modal-stage {
		padding: 0;
	}
	.ytfp-modal-frame {
		width: 100vw;
		max-width: 100vw;
		max-height: none;
		border-radius: 0;
		/* Let aspect-ratio dictate height; vertical centering handled by flex parent */
	}
	.ytfp-modal-close {
		top: max(8px, env(safe-area-inset-top, 0));
		right: max(8px, env(safe-area-inset-right, 0));
		width: 40px;
		height: 40px;
	}
}

/* Landscape phones — fill horizontally, video might bleed full width */
@media (max-width: 900px) and (orientation: landscape) {
	.ytfp-modal-stage {
		padding: 8px;
	}
	.ytfp-modal-frame {
		max-width: calc(100vh * 16 / 9);
		max-height: calc(100vh - 16px);
		border-radius: 4px;
	}
}

/* Prevent body scroll while modal is open. Class is applied by JS. */
html.ytfp-modal-open,
body.ytfp-modal-open {
	overflow: hidden;
	/* iOS: also prevent overscroll bounce */
	overscroll-behavior: none;
}
