/* Video play button on listing cards and its player dialog (TCT-9874). */

.tct-video-card {
	position: relative;
}

/* The theme styles every button gold; the extra specificity keeps this one its own. */
body .tct-video-card button.tct-video-play {
	position: absolute;
	top: 8px;
	left: 8px;
	z-index: 5;
	display: flex;
	align-items: center;
	justify-content: center;
	box-sizing: border-box;
	width: 44px;
	height: 44px;
	min-height: 0;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: rgba(36, 38, 41, 0.9);
	color: #fff;
	cursor: pointer;
	/* White ring keeps the button visible on dark photos too. */
	box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.9), 0 2px 8px rgba(0, 0, 0, 0.35);
	transition: background-color 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

body .tct-video-card button.tct-video-play:hover,
body .tct-video-card button.tct-video-play:focus-visible {
	background: #d98f00;
	color: #242629;
	transform: scale(1.06);
}

body .tct-video-card button.tct-video-play:focus-visible {
	outline: 2px solid #fff;
	outline-offset: 3px;
}

/* The triangle's centre of mass sits on the circle's centre (see the path in the PHP). */
.tct-video-play__icon {
	display: block;
	width: 100%;
	height: 100%;
	fill: currentColor;
}

/* On the narrowest phones the Compare badge leaves no room beside it, so drop to the bottom corner. */
@media (max-width: 340px) {
	body .tct-video-card button.tct-video-play {
		top: auto;
		bottom: 8px;
	}
}

@media (prefers-reduced-motion: reduce) {
	body .tct-video-card button.tct-video-play {
		transition: none;
	}

	body .tct-video-card button.tct-video-play:hover,
	body .tct-video-card button.tct-video-play:focus-visible {
		transform: none;
	}
}

.tct-video-dialog {
	width: min(94vw, 960px);
	max-width: none;
	padding: 0;
	border: 0;
	border-radius: 6px;
	background: #000;
	color: #fff;
	overflow: visible;
}

.tct-video-dialog::backdrop {
	background: rgba(0, 0, 0, 0.8);
}

body .tct-video-dialog button.tct-video-dialog__close {
	position: absolute;
	top: -40px;
	right: 0;
	width: 36px;
	height: 36px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: #fff;
	color: #000;
	font-size: 24px;
	line-height: 36px;
	text-align: center;
	cursor: pointer;
}

.tct-video-dialog__player {
	position: relative;
	aspect-ratio: 16 / 9;
	background: #000;
}

.tct-video-dialog__player iframe,
.tct-video-dialog__player video {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	border: 0;
}

.tct-video-dialog__message {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 24px;
	text-align: center;
	font-size: 16px;
}

.tct-video-dialog__links {
	display: flex;
	flex-wrap: wrap;
	gap: 8px 24px;
	margin: 0;
	padding: 10px 16px;
	background: #242629;
	font-size: 14px;
}

.tct-video-dialog__links a {
	color: #d98f00;
}

/* Muted autoplay preview over the card image (TCT-11648). Shown only once the player reports
   that it is playing; clicks pass through to the card link underneath. */
.tct-video-card__preview {
	position: absolute;
	inset: 0;
	/* No z-index: the card's own overlays (slider arrows, Compare and favourite badges, the play
	   button) all sit above it, and it sits above the photo because it comes later in the markup. */
	overflow: hidden;
	container-type: size;
	background: #000;
	opacity: 0;
	pointer-events: none;
	transition: opacity 0.25s ease;
}

.tct-video-card__preview.is-playing {
	opacity: 1;
}

.tct-video-card__preview video {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	object-fit: cover;
	pointer-events: none;
}

/* A YouTube frame is 16:9 and cannot object-fit, so size it to cover the card instead. */
.tct-video-card__preview iframe {
	position: absolute;
	top: 50%;
	left: 50%;
	width: 100%;
	height: 100%;
	border: 0;
	transform: translate(-50%, -50%);
	pointer-events: none;
}

@supports (width: 1cqw) {
	.tct-video-card__preview iframe {
		width: max(100cqw, calc(100cqh * 16 / 9));
		height: max(100cqh, calc(100cqw * 9 / 16));
	}
}

@media (prefers-reduced-motion: reduce) {
	.tct-video-card__preview {
		transition: none;
	}
}
