/*
 * Theme video player (assets/js/player.js).
 *
 * The box takes the file's own shape (set in content-video-player.php) and
 * keeps the full width of the page, so a portrait video sits in a tall black
 * box and the controls stay as wide as the screen. It is never taller than
 * most of the screen: the title must stay reachable.
 */

.responsive-player.ut-player-box {
	aspect-ratio: var(--ut-video-ratio, 16 / 9);
	width: 100%;
	max-height: 80vh;
	max-height: 80svh;
	background: #000;
}

@media (min-width: 992px) {
	.responsive-player.ut-player-box {
		max-height: min(80vh, 760px);
	}
}

.ut-player {
	--ut-player-accent: var(--ut-accent, #a60c0b);
	--ut-player-accent-text: var(--ut-accent-text, #ef3c39);
	position: absolute;
	inset: 0;
	overflow: hidden;
	background: #000;
	color: #fff;
	font-family: var(--ut-font, sans-serif);
	line-height: 1;
	outline: none;
	touch-action: manipulation;
	-webkit-user-select: none;
	user-select: none;
	-webkit-tap-highlight-color: transparent;
}

.ut-player:focus-visible {
	box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.8);
}

.ut-player.is-playing:not(.show-controls):not(.is-touch) {
	cursor: none;
}

/* Picture: the poster and the video sit in the same place with the same fit,
   so the first frame replaces the poster without moving. */
.ut-player__video,
.ut-player__poster,
.ut-player__surface {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
}

.ut-player__video,
.ut-player__poster {
	object-fit: contain;
	background: #000;
}

.ut-player__poster {
	z-index: 1;
	pointer-events: none;
}

.ut-player.has-started .ut-player__poster {
	display: none;
}

.ut-player__surface {
	z-index: 2;
	cursor: pointer;
}

/* Big center button */
.ut-player button.ut-player__big {
	position: absolute;
	top: 50%;
	left: 50%;
	z-index: 3;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 68px;
	height: 68px;
	margin: -34px 0 0 -34px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: rgba(0, 0, 0, 0.55) !important;
	color: #fff;
	cursor: pointer;
	transition: opacity 0.2s, transform 0.2s, background-color 0.2s;
}

.ut-player:not(.has-started) button.ut-player__big {
	background: var(--ut-player-accent) !important;
}

.ut-player button.ut-player__big:hover {
	transform: scale(1.06);
}

.ut-player__big svg {
	width: 34px;
	height: 34px;
	fill: currentColor;
}

/* Playing: hidden with a mouse (click anywhere pauses), shown with the
   other controls on touch. */
.ut-player.is-playing button.ut-player__big,
.ut-player.is-waiting button.ut-player__big,
.ut-player.has-error button.ut-player__big {
	opacity: 0;
	visibility: hidden;
	pointer-events: none;
}

.ut-player.is-touch.is-playing.show-controls:not(.is-waiting) button.ut-player__big {
	opacity: 1;
	visibility: visible;
	pointer-events: auto;
}

/* Spinner */
.ut-player__spinner {
	position: absolute;
	top: 50%;
	left: 50%;
	z-index: 3;
	width: 48px;
	height: 48px;
	margin: -24px 0 0 -24px;
	border: 4px solid rgba(255, 255, 255, 0.25);
	border-top-color: #fff;
	border-radius: 50%;
	opacity: 0;
	visibility: hidden;
	pointer-events: none;
}

.ut-player.is-waiting .ut-player__spinner {
	opacity: 1;
	visibility: visible;
	animation: ut-player-spin 0.8s linear infinite;
}

@keyframes ut-player-spin {
	to {
		transform: rotate(360deg);
	}
}

/* Double tap seek hints */
.ut-player__hint {
	position: absolute;
	top: 50%;
	z-index: 3;
	padding: 12px 16px;
	border-radius: 999px;
	background: rgba(0, 0, 0, 0.55);
	font-size: 14px;
	font-weight: 600;
	white-space: nowrap;
	transform: translateY(-50%);
	opacity: 0;
	transition: opacity 0.2s;
	pointer-events: none;
}

.ut-player__hint--back {
	left: 8%;
}

.ut-player__hint--forward {
	right: 8%;
}

.ut-player__hint.is-visible {
	opacity: 1;
}

/* Control bar */
.ut-player__controls {
	position: absolute;
	right: 0;
	bottom: 0;
	left: 0;
	z-index: 4;
	padding: 28px 10px 4px;
	background: linear-gradient(rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.72));
	opacity: 0;
	visibility: hidden;
	transition: opacity 0.25s, visibility 0s 0.25s;
	pointer-events: none;
}

.ut-player__controls > * {
	pointer-events: auto;
}

.ut-player.has-started.show-controls .ut-player__controls,
.ut-player.has-started:not(.is-playing) .ut-player__controls,
.ut-player.is-scrubbing .ut-player__controls,
.ut-player.menu-open .ut-player__controls {
	opacity: 1;
	visibility: visible;
	transition: opacity 0.15s;
}

.ut-player.has-error .ut-player__controls {
	display: none;
}

/* Seek bar: thin line, tall hit area */
.ut-player__progress {
	position: relative;
	height: 24px;
	margin: 0 2px;
	cursor: pointer;
	touch-action: none;
	outline: none;
}

.ut-player.is-touch .ut-player__progress {
	height: 30px;
}

.ut-player__rail {
	position: absolute;
	top: 50%;
	right: 0;
	left: 0;
	height: 4px;
	margin-top: -2px;
	overflow: hidden;
	border-radius: 2px;
	background: rgba(255, 255, 255, 0.25);
	transition: height 0.1s, margin-top 0.1s;
}

.ut-player__progress:hover .ut-player__rail,
.ut-player__progress:focus-visible .ut-player__rail,
.ut-player.is-scrubbing .ut-player__rail {
	height: 6px;
	margin-top: -3px;
}

.ut-player__buffered,
.ut-player__played {
	position: absolute;
	inset: 0;
	transform-origin: 0 50%;
}

.ut-player__buffered {
	background: rgba(255, 255, 255, 0.35);
	transform: scaleX(var(--buffered, 0));
}

.ut-player__played {
	background: var(--ut-player-accent-text);
	transform: scaleX(var(--played, 0));
}

.ut-player__handle {
	position: absolute;
	top: 50%;
	left: calc(var(--played, 0) * 100%);
	width: 14px;
	height: 14px;
	margin: -7px 0 0 -7px;
	border-radius: 50%;
	background: var(--ut-player-accent-text);
	transform: scale(0);
	transition: transform 0.1s;
}

.ut-player.is-touch .ut-player__handle,
.ut-player__progress:hover .ut-player__handle,
.ut-player__progress:focus-visible .ut-player__handle,
.ut-player.is-scrubbing .ut-player__handle {
	transform: scale(1);
}

.ut-player.is-scrubbing .ut-player__handle {
	transform: scale(1.3);
}

.ut-player__tip {
	position: absolute;
	bottom: 100%;
	padding: 4px 7px;
	border-radius: 4px;
	background: rgba(0, 0, 0, 0.8);
	font-size: 12px;
	font-variant-numeric: tabular-nums;
	white-space: nowrap;
	transform: translateX(-50%);
	opacity: 0;
	pointer-events: none;
}

.ut-player:not(.is-touch) .ut-player__progress:hover .ut-player__tip,
.ut-player.is-scrubbing .ut-player__tip {
	opacity: 1;
}

.ut-player__bar {
	display: flex;
	align-items: center;
	gap: 2px;
	height: 44px;
}

.ut-player__spacer {
	flex: 1;
}

.ut-player button.ut-player__button {
	display: flex;
	flex: none;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: none !important;
	box-shadow: none;
	color: #fff;
	cursor: pointer;
	opacity: 0.92;
}

.ut-player.is-touch button.ut-player__button {
	width: 44px;
	height: 44px;
}

.ut-player button.ut-player__button:hover {
	opacity: 1;
	background: rgba(255, 255, 255, 0.12) !important;
}

.ut-player button.ut-player__button:focus-visible,
.ut-player__progress:focus-visible,
.ut-player__menu-item:focus-visible {
	outline: 2px solid #fff;
	outline-offset: -2px;
}

.ut-player__button svg {
	width: 26px;
	height: 26px;
	fill: currentColor;
}

.ut-player__settings svg {
	width: 22px;
	height: 22px;
	transition: transform 0.2s;
}

.ut-player.menu-open .ut-player__settings svg {
	transform: rotate(45deg);
}

.ut-player__time {
	margin: 0 6px;
	font-size: 13px;
	font-variant-numeric: tabular-nums;
	white-space: nowrap;
	text-shadow: 0 0 2px rgba(0, 0, 0, 0.6);
}

.ut-player__sep,
.ut-player__duration {
	opacity: 0.75;
}

/* Volume: slider for mice only, phones use their own buttons */
.ut-player__volume {
	display: flex;
	align-items: center;
}

.ut-player input.ut-player__volume-range {
	width: 0;
	height: 4px;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 2px;
	background: linear-gradient(to right, #fff calc(var(--volume, 1) * 100%), rgba(255, 255, 255, 0.3) 0);
	opacity: 0;
	cursor: pointer;
	transition: width 0.2s, opacity 0.2s, margin 0.2s;
	-webkit-appearance: none;
	appearance: none;
}

.ut-player .ut-player__volume:hover .ut-player__volume-range,
.ut-player .ut-player__volume:focus-within .ut-player__volume-range {
	width: 64px;
	margin: 0 8px 0 2px;
	opacity: 1;
}

.ut-player__volume-range::-webkit-slider-thumb {
	width: 12px;
	height: 12px;
	border: 0;
	border-radius: 50%;
	background: #fff;
	-webkit-appearance: none;
	appearance: none;
}

.ut-player__volume-range::-moz-range-thumb {
	width: 12px;
	height: 12px;
	border: 0;
	border-radius: 50%;
	background: #fff;
}

.ut-player.is-touch input.ut-player__volume-range {
	display: none;
}

/* Settings menu */
.ut-player__menu {
	position: absolute;
	right: 8px;
	bottom: 82px; /* above the seek bar */
	z-index: 5;
	min-width: 168px;
	max-height: calc(100% - 94px);
	padding: 6px 0;
	overflow-y: auto;
	border-radius: 10px;
	background: rgba(24, 24, 24, 0.94);
	box-shadow: 0 4px 18px rgba(0, 0, 0, 0.5);
	overscroll-behavior: contain;
}

.ut-player__menu[hidden] {
	display: none;
}

.ut-player__menu-group + .ut-player__menu-group {
	margin-top: 4px;
	padding-top: 4px;
	border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.ut-player__menu-title {
	padding: 8px 16px 6px;
	color: rgba(255, 255, 255, 0.6);
	font-size: 12px;
}

.ut-player button.ut-player__menu-item {
	display: flex;
	align-items: center;
	width: 100%;
	min-height: 38px;
	margin: 0;
	padding: 0 16px 0 36px;
	border: 0;
	border-radius: 0;
	background: none !important;
	box-shadow: none;
	color: #fff;
	font-size: 14px;
	text-align: left;
	cursor: pointer;
	position: relative;
}

.ut-player button.ut-player__menu-item:hover {
	background: rgba(255, 255, 255, 0.1) !important;
}

.ut-player__menu-item[aria-checked='true']::before {
	content: '';
	position: absolute;
	top: 50%;
	left: 15px;
	width: 10px;
	height: 5px;
	margin-top: -4px;
	border-bottom: 2px solid var(--ut-player-accent-text);
	border-left: 2px solid var(--ut-player-accent-text);
	transform: rotate(-45deg);
}

/* Error (file missing, blocked, unsupported) */
.ut-player__error {
	position: absolute;
	inset: 0;
	z-index: 6;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	padding: 16px;
	background: rgba(0, 0, 0, 0.78);
	text-align: center;
	-webkit-user-select: text;
	user-select: text;
}

.ut-player__error p {
	max-width: 30em;
	margin: 0 0 14px;
	color: #fff;
	font-size: 15px;
	line-height: 1.6;
}

.ut-player__error a {
	display: inline-block;
	padding: 10px 22px;
	border-radius: 6px;
	background: var(--ut-player-accent);
	color: #fff !important;
	font-size: 14px;
	font-weight: 600;
	text-decoration: none !important;
}

.ut-player__error a:hover {
	opacity: 0.88;
}

/* Full screen */
.ut-player.is-fullscreen .ut-player__controls {
	padding: 40px 18px max(10px, env(safe-area-inset-bottom));
}

.ut-player.is-fullscreen .ut-player__time {
	font-size: 14px;
}

/* Narrow players (portrait in a small box): keep every control reachable */
@media (max-width: 359.98px) {
	.ut-player__controls {
		padding-right: 4px;
		padding-left: 4px;
	}

	.ut-player__time {
		margin: 0 2px;
		font-size: 12px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.ut-player *,
	.ut-player {
		transition: none !important;
		animation-duration: 1.6s !important;
	}
}
