/* YouTube Playlist Gallery */

.ytpg-gallery {
	--ytpg-columns: 4;
	--ytpg-gap: 16px;

	display: grid;
	grid-template-columns: repeat(var(--ytpg-columns), 1fr);
	gap: var(--ytpg-gap);
	margin: 1.5em 0;
}

/* Cap columns on smaller screens so thumbnails never get too cramped,
   regardless of what the shortcode requested. */
@media (max-width: 480px) {
	.ytpg-gallery {
		grid-template-columns: repeat(1, 1fr);
	}
}

@media (min-width: 481px) and (max-width: 700px) {
	.ytpg-gallery {
		grid-template-columns: repeat(min(var(--ytpg-columns), 2), 1fr);
	}
}

@media (min-width: 701px) and (max-width: 1000px) {
	.ytpg-gallery {
		grid-template-columns: repeat(min(var(--ytpg-columns), 3), 1fr);
	}
}

.ytpg-item {
	cursor: pointer;
	outline-offset: 4px;
}

.ytpg-item:focus-visible {
	outline: 2px solid #3b82f6;
}

.ytpg-thumb-wrap {
	position: relative;
	width: 100%;
	aspect-ratio: 16 / 9;
	overflow: hidden;
	border-radius: 8px;
	background: #000;
}

.ytpg-thumb {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
	transition: transform 0.2s ease;
}

.ytpg-item:hover .ytpg-thumb {
	transform: scale(1.04);
}

.ytpg-play-icon {
	position: absolute;
	top: 50%;
	left: 50%;
	width: 56px;
	height: 40px;
	margin-top: -20px;
	margin-left: -28px;
	background: rgba(0, 0, 0, 0.7);
	border-radius: 12px;
	transition: background 0.2s ease;
	pointer-events: none;
}

.ytpg-play-icon::before {
	content: "";
	position: absolute;
	top: 50%;
	left: 54%;
	transform: translate(-50%, -50%);
	border-style: solid;
	border-width: 10px 0 10px 16px;
	border-color: transparent transparent transparent #fff;
}

.ytpg-item:hover .ytpg-play-icon {
	background: #ff0000;
}

.ytpg-title {
	margin: 0.5em 0 0;
	font-size: 0.95em;
	line-height: 1.3;
	color: inherit;
}

/* Lightbox */

.ytpg-lightbox {
	position: fixed;
	inset: 0;
	z-index: 100000;
	display: none;
	align-items: center;
	justify-content: center;
	background: rgba(0, 0, 0, 0.92);
}

.ytpg-lightbox.ytpg-active {
	display: flex;
}

.ytpg-lightbox-inner {
	width: 100%;
	height: 100%;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 40px 20px;
	box-sizing: border-box;
}

.ytpg-lightbox-video {
	width: 100%;
	max-width: 1400px;
	aspect-ratio: 16 / 9;
}

.ytpg-lightbox-video iframe {
	width: 100%;
	height: 100%;
	border: 0;
	display: block;
}

.ytpg-lightbox-close {
	position: absolute;
	top: 16px;
	right: 24px;
	background: transparent;
	border: 0;
	color: #fff;
	font-size: 2.5rem;
	line-height: 1;
	cursor: pointer;
	z-index: 100001;
	padding: 8px 12px;
}

.ytpg-lightbox-close:hover,
.ytpg-lightbox-close:focus-visible {
	color: #ff0000;
}

body.ytpg-lightbox-open {
	overflow: hidden;
}
