.ytgs-gallery {
	--ytgs-gap: 20px;
	--ytgs-radius: 10px;
	--ytgs-accent: #ff0033;
	margin: 0 0 2em;
}

.ytgs-grid {
	display: grid;
	grid-template-columns: repeat(var(--ytgs-cols, 3), minmax(0, 1fr));
	gap: var(--ytgs-gap);
	list-style: none;
	margin: 0;
	padding: 0;
}

@media (max-width: 900px) {
	.ytgs-gallery:not(.ytgs-cols-1) .ytgs-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 560px) {
	.ytgs-gallery:not(.ytgs-cols-2) .ytgs-grid { grid-template-columns: 1fr; }
	.ytgs-cols-2 { --ytgs-gap: 12px; }
}

/* A 2×2 grid stays two-up on phones; only very narrow screens stack. */
@media (max-width: 380px) {
	.ytgs-cols-2 .ytgs-grid { grid-template-columns: 1fr; }
}

.ytgs-item { margin: 0; padding: 0; }

.ytgs-link {
	display: flex;
	flex-direction: column;
	gap: 8px;
	color: inherit;
	text-decoration: none;
}

.ytgs-thumb,
.ytgs-frame {
	position: relative;
	display: block;
	aspect-ratio: 16 / 9;
	overflow: hidden;
	border-radius: var(--ytgs-radius);
	background: #000;
}

.ytgs-thumb img {
	width: 100%;
	height: 100%;
	object-fit: cover; /* Crops the letterbox bars of 4:3 thumbnails. */
	display: block;
	transition: transform .3s ease;
}

.ytgs-link:hover .ytgs-thumb img,
.ytgs-link:focus-visible .ytgs-thumb img { transform: scale(1.05); }

.ytgs-link:focus-visible { outline: 3px solid var(--ytgs-accent); outline-offset: 3px; border-radius: var(--ytgs-radius); }

.ytgs-play {
	position: absolute;
	top: 50%;
	left: 50%;
	width: 64px;
	height: 44px;
	transform: translate(-50%, -50%);
	border-radius: 12px;
	background: rgba(0, 0, 0, .7);
	transition: background .2s ease;
}

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

.ytgs-link:hover .ytgs-play,
.ytgs-link:focus-visible .ytgs-play { background: var(--ytgs-accent); }

.ytgs-duration {
	position: absolute;
	right: 8px;
	bottom: 8px;
	padding: 2px 6px;
	border-radius: 4px;
	background: rgba(0, 0, 0, .8);
	color: #fff;
	font-size: 12px;
	font-weight: 600;
	line-height: 1.4;
}

.ytgs-title {
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
	font-weight: 600;
	line-height: 1.35;
}

.ytgs-meta { font-size: .85em; opacity: .7; }

.ytgs-frame iframe {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	border: 0;
}

.ytgs-featured { margin-bottom: calc(var(--ytgs-gap) * 1.5); }
.ytgs-featured .ytgs-title { margin: .6em 0 0; font-size: 1.25em; }

/* Lightbox */
.ytgs-modal {
	position: fixed;
	inset: 0;
	z-index: 100000;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 16px;
	background: rgba(0, 0, 0, .88);
	animation: ytgs-fade .2s ease;
}

.ytgs-modal .ytgs-frame { width: min(1100px, 100%, calc((100vh - 120px) * 16 / 9)); }

.ytgs-close {
	position: absolute;
	top: 12px;
	right: 12px;
	width: 44px;
	height: 44px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: rgba(255, 255, 255, .15);
	color: #fff;
	font-size: 28px;
	line-height: 44px;
	cursor: pointer;
}

.ytgs-close:hover,
.ytgs-close:focus-visible { background: var(--ytgs-accent); }

body.ytgs-modal-open { overflow: hidden; }

@keyframes ytgs-fade { from { opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
	.ytgs-thumb img, .ytgs-modal { transition: none; animation: none; }
}
