/*
 * EP YouTube — frontend styles
 *
 * The .youtube box is a fixed-aspect placeholder that holds either a thumbnail
 * (initial state) or an iframe (after click). Default aspect is 16:9 via the
 * padding-top hack; the shortcode overrides padding-top inline for other ratios.
 *
 * Why the padding-top hack and not aspect-ratio: the hack works in every
 * browser back to 2010 and is what Chris's original ships. aspect-ratio is
 * fine in modern browsers but PM sites support old Safari that doesn't grok it.
 */

.youtube {
	position: relative;
	background-color: #000;
	padding-top: 56.25%; /* 16:9 — overridden inline for other ratios */
	margin-bottom: 1.6em;
	overflow: hidden;
	cursor: pointer;
}

.youtube img,
.youtube iframe,
.youtube .play,
.youtube .play::before {
	position: absolute;
}

.youtube img {
	width: 100%;
	height: auto;
	top: 0;
	left: 0;
	opacity: 0.7;
	transition: opacity 0.2s ease;
}

.youtube:hover img {
	opacity: 0.85;
}

/* Custom-thumb mode: image fills cleanly with no vertical offset */
.youtube.custom-thumb img {
	top: 0;
	height: 100%;
	object-fit: cover;
}

/* sddefault.jpg from YouTube is 4:3 letterboxed inside a 16:9 player.
   When the box is 16:9 and we're using YouTube's sd thumbnail, the image
   needs to be pulled up so the visible 4:3 area centres correctly.
   Chris's original computed this in PHP (the $diff value); we do it here
   with object-fit instead, which gets us the same result without per-video
   CSS generation. */
.youtube:not(.custom-thumb) img {
	height: 100%;
	object-fit: cover;
}

.youtube iframe {
	width: 100%;
	height: 100%;
	top: 0;
	left: 0;
	border: 0;
}

.youtube .play,
.youtube .play::before {
	top: 50%;
	left: 50%;
	transform: translate3d(-50%, -50%, 0);
}

.youtube .play {
	width: 90px;
	height: 60px;
	background-color: #ff1616;
	box-shadow: 0 0 30px rgba(0, 0, 0, 0.6);
	z-index: 1;
	opacity: 0.85;
	border-radius: 12px;
	transition: opacity 0.2s ease, background-color 0.2s ease;
	pointer-events: none; /* clicks pass through to the .youtube box */
}

.youtube:hover .play {
	opacity: 1;
}

.youtube .play::before {
	content: "";
	border-style: solid;
	border-width: 14px 0 14px 24px;
	border-color: transparent transparent transparent #fff;
	width: 0;
	height: 0;
}

/* Title overlay: matches YouTube's native idle-state heading.
   Only rendered when the shortcode (or hand-written markup) supplies one.
   Removed on click when the JS replaces the box contents with the iframe. */
.youtube .youtube-title {
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	z-index: 2;
	padding: 14px 16px 28px;
	color: #fff;
	font-weight: 500;
	font-size: 16px;
	line-height: 1.3;
	background: linear-gradient(to bottom, rgba(0, 0, 0, 0.7) 0%, rgba(0, 0, 0, 0) 100%);
	pointer-events: none;
	text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
	overflow: hidden;
	text-overflow: ellipsis;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
}
