/**
 * Mux Offload front-end styles.
 *
 * Mostly fallbacks for older Safari and iOS, where the modern layout properties
 * the player relies on are either missing or behave differently.
 */

/* The custom element is undefined until its script executes. Without this it is
   treated as an inline element with no dimensions, so the page reflows when the
   script lands. Reserving the box prevents that layout shift. */
mux-player:not(:defined),
mux-video:not(:defined) {
	display: block;
	width: 100%;
	background: #000;
}

mux-player:not(:defined) {
	aspect-ratio: 16 / 9;
}

/* Safari before 15 has no aspect-ratio support. Fall back to the padding trick
   so the element still reserves vertical space instead of collapsing to zero. */
@supports not (aspect-ratio: 16 / 9) {
	mux-player:not(:defined) {
		height: 0;
		padding-bottom: 56.25%;
	}
	.muxoff-player:not(.muxoff-cover-video) {
		height: 0;
		padding-bottom: 56.25%;
		position: relative;
	}
}

/* Cover / hero mode.
   object-fit on the host element does not cascade into the shadow DOM, so the
   Mux CSS custom properties do the real work. These are belt and braces for
   builds that expose a ::part instead. */
.muxoff-cover {
	position: relative;
	overflow: hidden;
}

.muxoff-cover mux-video,
.muxoff-cover mux-player {
	--media-object-fit: cover;
	--media-object-position: center;
	object-fit: cover;
}

.muxoff-cover mux-video::part(video),
.muxoff-cover mux-player::part(video) {
	object-fit: cover;
}

/* iOS in Low Power Mode refuses to autoplay at all. The poster stays visible,
   so make sure it covers the same area rather than letterboxing. */
mux-video[poster],
mux-player[poster] {
	background-size: cover;
	background-position: center;
}

/* iOS Safari occasionally leaves a 1px seam under a video in a rounded
   container. Clipping the paint area removes it. */
.muxoff-cover {
	-webkit-mask-image: -webkit-radial-gradient(white, black);
}

/* Respect a user's reduced-motion preference: pause decorative background
   video rather than looping it forever. */
@media (prefers-reduced-motion: reduce) {
	.muxoff-cover mux-video,
	.muxoff-cover mux-player {
		animation: none;
	}
}

/* Keep the player from overflowing narrow phone viewports. */
.muxoff-player {
	max-width: 100%;
}
