/* Video thumbnails and lightbox (see includes/videos.php).
   The "body" and doubled-class selectors outrank the older rules in the Site Editor's CSS. */

body .tdg-video {
	margin-left: auto;
	margin-right: auto;
	width: 100%;
}
.tdg-video__link {
	position: relative;
	display: block;
	aspect-ratio: 16 / 9;
	overflow: hidden;
	background: #000;
}
/* The theme fades links on hover; thumbnails use their own effect. */
.tdg-video__link:hover {
	opacity: 1;
}
.tdg-video .tdg-video__img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover; /* trims the black bars on 4:3 thumbnails */
	transition: transform 0.4s ease, opacity 0.3s ease;
}
.tdg-video__link:hover .tdg-video__img,
.tdg-video__link:focus-visible .tdg-video__img {
	transform: scale(1.03);
	opacity: 0.8;
}
.tdg-video__link:focus-visible {
	outline: 3px solid #fff;
	outline-offset: 3px;
}

/* Play button */
.tdg-video__play {
	position: absolute;
	top: 50%;
	left: 50%;
	width: 4.5rem;
	height: 4.5rem;
	border-radius: 50%;
	background: #b93729;
	box-shadow: 0 4px 18px rgba(0, 0, 0, 0.5);
	transform: translate(-50%, -50%);
	transition: background 0.25s ease, transform 0.25s ease;
}
.tdg-video__play::after {
	content: "";
	position: absolute;
	top: 50%;
	left: 54%;
	border-style: solid;
	border-width: 0.8rem 0 0.8rem 1.3rem;
	border-color: transparent transparent transparent #fff;
	transform: translate(-50%, -50%);
}
.tdg-video__link:hover .tdg-video__play,
.tdg-video__link:focus-visible .tdg-video__play {
	background: #e6483c;
	transform: translate(-50%, -50%) scale(1.08);
}

body .tdg-video figcaption {
	margin-top: 0.6rem;
	text-align: left;
	font-family: var(--wp--preset--font-family--fjalla-one, sans-serif);
	font-size: 1.6rem;
	text-transform: uppercase;
}

/* The single home page video has its title centred. */
body.home .tdg-video figcaption {
	text-align: center;
}

/* Featured video: any video that is not in the grid. */
body .wp-block-embed.tdg-video.tdg-video {
	max-width: 1100px;
}

/* Grid: 3 across, then 2, then 1. */
body .wp-block-group.video-gallery {
	grid-template-columns: repeat(3, minmax(0, 1fr));
	gap: 4rem 2.5rem;
	margin-top: 5rem; /* breathing room after the featured video */
}
body .video-gallery .wp-block-embed.tdg-video.tdg-video {
	max-width: none;
	margin: 0;
}
body .video-gallery .tdg-video figcaption {
	font-size: 1.05rem;
}
body .video-gallery .tdg-video__play {
	width: 3.25rem;
	height: 3.25rem;
}
body .video-gallery .tdg-video__play::after {
	border-width: 0.55rem 0 0.55rem 0.9rem;
}
@media (max-width: 960px) {
	body .wp-block-group.video-gallery {
		grid-template-columns: repeat(2, minmax(0, 1fr));
		gap: 3rem 1.5rem;
		margin-top: 3.5rem;
	}
}
@media (max-width: 600px) {
	body .wp-block-group.video-gallery {
		grid-template-columns: minmax(0, 1fr);
		gap: 2.5rem;
		margin-top: 2.5rem;
	}
	body .tdg-video figcaption {
		font-size: 1.15rem;
	}
}

/* Lightbox: the dialog covers the screen and is its own dark backdrop. */
.tdg-lightbox {
	position: fixed;
	inset: 0;
	width: 100%;
	height: 100%;
	max-width: 100%;
	max-height: 100%;
	margin: 0;
	padding: 0;
	border: 0;
	background: rgba(0, 0, 0, 0.93);
	color: #fff;
}
.tdg-lightbox[open] {
	display: flex;
	align-items: center;
	justify-content: center;
}
.tdg-lightbox__frame {
	/* as wide as fits, leaving room for the close button above and below */
	width: min(94vw, calc((100vh - 8rem) * 16 / 9), 1600px);
	aspect-ratio: 16 / 9;
	background: #000;
}
.tdg-lightbox__frame iframe {
	display: block;
	width: 100%;
	height: 100%;
	border: 0;
}
.tdg-lightbox__close {
	position: absolute;
	top: 0.75rem;
	right: 0.75rem;
	width: 2.75rem;
	height: 2.75rem;
	padding: 0;
	font-size: 2rem;
	line-height: 1;
	color: #fff;
	background: transparent;
	border: 1px solid #fff;
	cursor: pointer;
}
.tdg-lightbox__close:hover {
	background: #b93729;
	border-color: #b93729;
}
.tdg-lightbox__close:focus-visible {
	outline: 2px solid #fff;
	outline-offset: 3px;
}
html.tdg-lightbox-open {
	overflow: hidden;
}
@media (prefers-reduced-motion: reduce) {
	.tdg-video .tdg-video__img,
	.tdg-video__play {
		transition: none;
	}
}
