/**
 * The video player.
 *
 * Matches the site rather than the browser: navy glass, gold progress,
 * Nunito. Controls sit over the picture and fade out while playing, so
 * the video is the thing you look at.
 *
 * Falls back to the browser's own controls if the script does not run,
 * because .msat-player--custom is only added by JavaScript.
 */

.msat-player--custom {
	position: relative;
	background: #000;
	--msat-gold: var(--gold, #d9a441);
}

.msat-player--custom video {
	display: block;
	width: 100%;
	aspect-ratio: 16 / 9;
	cursor: pointer;
}

/* ---- The big play button over the poster ----------------------------- */

.msat-big {
	position: absolute;
	inset: 0;
	margin: auto;
	width: 86px;
	height: 86px;
	display: grid;
	place-items: center;
	padding: 0;
	border: 0;
	border-radius: 50%;
	cursor: pointer;
	color: #fff;
	background: rgb(15 42 86 / 62%);
	-webkit-backdrop-filter: blur(10px) saturate(130%);
	backdrop-filter: blur(10px) saturate(130%);
	box-shadow:
		0 2px 6px rgb(10 29 61 / 35%),
		0 14px 40px rgb(10 29 61 / 45%),
		inset 0 0 0 1px rgb(255 255 255 / 18%);
	transition: transform .35s cubic-bezier(.16, 1, .3, 1), opacity .3s ease, background-color .3s ease;
}

.msat-big svg { width: 34px; height: 34px; margin-left: 4px; }

.msat-big:hover,
.msat-big:focus-visible {
	transform: scale(1.07);
	background: rgb(217 164 65 / 85%);
}

/* Once it is playing the overlay would only be in the way. */
.msat-player--custom.is-playing .msat-big {
	opacity: 0;
	pointer-events: none;
	transform: scale(.85);
}

/* ---- Buffering ------------------------------------------------------- */

.msat-player--custom.is-waiting .msat-big {
	opacity: 1;
	pointer-events: none;
	background: rgb(15 42 86 / 62%);
	animation: msat-pulse 1.1s ease-in-out infinite;
}

@keyframes msat-pulse {
	50% { transform: scale(.92); opacity: .55; }
}

/* ---- The control bar -------------------------------------------------- */

.msat-ctl {
	position: absolute;
	left: 0;
	right: 0;
	bottom: 0;
	display: flex;
	align-items: center;
	gap: .55rem;
	padding: 2.6rem .85rem .7rem;
	font-family: var(--font-sans, "Nunito", sans-serif);
	color: #fff;
	/* A gradient rather than a solid bar: the controls stay readable over
	   a bright frame without boxing off the bottom of the picture. */
	background: linear-gradient(to top, rgb(5 14 30 / 88%), rgb(5 14 30 / 55%) 45%, transparent);
	opacity: 1;
	transition: opacity .3s ease, transform .3s ease;
}

/* Hide while playing; bring back on any sign of attention. */
.msat-player--custom.is-playing .msat-ctl {
	opacity: 0;
	transform: translateY(6px);
}

.msat-player--custom:hover .msat-ctl,
.msat-player--custom:focus-within .msat-ctl,
.msat-player--custom.is-waiting .msat-ctl {
	opacity: 1;
	transform: none;
}

.msat-ctl__btn {
	flex: 0 0 auto;
	display: grid;
	place-items: center;
	width: 36px;
	height: 36px;
	padding: 0;
	border: 0;
	border-radius: 9px;
	cursor: pointer;
	color: #fff;
	background: transparent;
	font: 700 .82rem/1 var(--font-sans, "Nunito", sans-serif);
	transition: background-color .2s ease, color .2s ease;
}

.msat-ctl__btn svg { width: 20px; height: 20px; }

.msat-ctl__btn:hover,
.msat-ctl__btn:focus-visible {
	background: rgb(255 255 255 / 16%);
	color: var(--msat-gold);
}

.msat-ctl__rate { width: auto; min-width: 42px; padding: 0 .45rem; }

.msat-ctl__time {
	flex: 0 0 auto;
	font-size: .78rem;
	font-weight: 600;
	font-variant-numeric: tabular-nums; /* stops the bar twitching each second */
	color: rgb(255 255 255 / 86%);
	white-space: nowrap;
}

/* ---- Seek bar --------------------------------------------------------- */

.msat-ctl__seek-wrap {
	position: relative;
	flex: 1 1 auto;
	display: flex;
	align-items: center;
	min-width: 60px;
	height: 20px;
}

.msat-ctl__buffered {
	position: absolute;
	left: 0;
	height: 5px;
	width: 0;
	border-radius: 999px;
	background: rgb(255 255 255 / 26%);
	pointer-events: none;
}

.msat-ctl__seek,
.msat-ctl__vol {
	-webkit-appearance: none;
	appearance: none;
	width: 100%;
	height: 5px;
	margin: 0;
	border-radius: 999px;
	background: rgb(255 255 255 / 18%);
	cursor: pointer;
	position: relative;
}

.msat-ctl__seek {
	background:
		linear-gradient(var(--msat-gold), var(--msat-gold)) 0 / var(--played, 0%) 100% no-repeat,
		rgb(255 255 255 / 18%);
}

.msat-ctl__vol {
	flex: 0 0 72px;
	width: 72px;
	background: rgb(255 255 255 / 30%);
}

.msat-ctl__seek::-webkit-slider-thumb,
.msat-ctl__vol::-webkit-slider-thumb {
	-webkit-appearance: none;
	appearance: none;
	width: 13px;
	height: 13px;
	border-radius: 50%;
	background: #fff;
	box-shadow: 0 1px 4px rgb(0 0 0 / 45%);
	transition: transform .2s ease;
}

.msat-ctl__seek::-moz-range-thumb,
.msat-ctl__vol::-moz-range-thumb {
	width: 13px;
	height: 13px;
	border: 0;
	border-radius: 50%;
	background: #fff;
	box-shadow: 0 1px 4px rgb(0 0 0 / 45%);
}

.msat-ctl__seek:hover::-webkit-slider-thumb { transform: scale(1.25); }
.msat-ctl__seek:active::-webkit-slider-thumb { transform: scale(1.35); }

.msat-ctl__seek:focus-visible,
.msat-ctl__vol:focus-visible {
	outline: 2px solid var(--msat-gold);
	outline-offset: 4px;
}

/* ---- Resume offer ------------------------------------------------------ */

.msat-resume {
	position: absolute;
	right: 1rem;
	bottom: 4.2rem;
	padding: .6rem 1rem;
	border: 0;
	border-radius: 999px;
	cursor: pointer;
	font: 700 .82rem/1 var(--font-sans, "Nunito", sans-serif);
	color: #0a1d3d;
	background: var(--msat-gold);
	box-shadow: 0 8px 24px rgb(10 29 61 / 45%);
	animation: msat-resume-in .5s cubic-bezier(.16, 1, .3, 1) both;
}

.msat-resume:hover { filter: brightness(1.06); }
.msat-resume.is-going { opacity: 0; transition: opacity .55s ease; }

@keyframes msat-resume-in {
	from { opacity: 0; transform: translateY(10px); }
	to   { opacity: 1; transform: none; }
}

/* ---- Small screens ------------------------------------------------------ */

@media (max-width: 600px) {
	/* The volume slider is the first thing to go: phones have hardware
	   buttons for it, and the seek bar needs the room far more. */
	.msat-ctl__vol { display: none; }
	.msat-big { width: 64px; height: 64px; }
	.msat-big svg { width: 26px; height: 26px; }
	.msat-ctl { gap: .3rem; padding: 2.2rem .5rem .55rem; }
	.msat-ctl__time { font-size: .72rem; }
}

@media (prefers-reduced-motion: reduce) {
	.msat-big,
	.msat-ctl,
	.msat-resume,
	.msat-ctl__seek::-webkit-slider-thumb {
		transition: none;
		animation: none;
	}
}

/* Browsers without backdrop-filter get a solid button rather than a
   washed-out transparent one. */
@supports not (backdrop-filter: blur(4px)) {
	.msat-big { background: rgb(15 42 86 / 92%); }
}
