/**
 * AASM YouTube Playlist — front end.
 *
 * Colours are inherited from Astra's global settings (--ast-global-color-*),
 * so the Customizer still governs the palette. Fallbacks exist only for a
 * non-Astra context.
 *
 * The play badge is drawn in CSS. No image, icon font, or SVG file is
 * requested, which keeps the component free of any external dependency.
 */

.aasm-yt {
	--aasm-yt-columns: 3;
	--aasm-yt-text:    var( --ast-global-color-3, #3a3a3a );
	--aasm-yt-strong:  var( --ast-global-color-2, #1b1b1b );
	--aasm-yt-accent:  var( --ast-global-color-0, #0a6ebd );
	--aasm-yt-muted:   var( --ast-global-color-4, #f3f4f5 );
	--aasm-yt-rule:    rgba( 0, 0, 0, 0.12 );

	color: var( --aasm-yt-text );
}

.aasm-yt__heading {
	margin: 0 0 0.75rem;
}

/* ---- Controls ---------------------------------------------------------- */

.aasm-yt__controls {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem 1rem;
	align-items: baseline;
	justify-content: space-between;
	margin-bottom: 1rem;
}

.aasm-yt__filter {
	flex: 1 1 16rem;
	max-width: 22rem;
}

.aasm-yt__search {
	width: 100%;
	padding: 0.5rem 0.75rem;
	border: 1px solid var( --aasm-yt-rule );
	border-radius: 3px;
	font: inherit;
	font-size: 0.9375rem;
	background: #fff;
	color: inherit;
}

.aasm-yt__search:focus-visible {
	outline: 2px solid var( --aasm-yt-accent );
	outline-offset: 1px;
}

.aasm-yt__count {
	margin: 0;
	font-size: 0.8125rem;
	opacity: 0.75;
}

/* ---- Grid -------------------------------------------------------------- */

.aasm-yt__grid {
	display: grid;
	grid-template-columns: repeat( var( --aasm-yt-columns ), minmax( 0, 1fr ) );
	gap: 1.5rem 1.25rem;
	margin: 0;
	padding: 0;
	list-style: none;
}

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

@media ( max-width: 540px ) {
	.aasm-yt__grid {
		grid-template-columns: minmax( 0, 1fr );
	}
}

.aasm-yt__item {
	margin: 0;
}

/* Astra applies `.ast-single-post .entry-content a { text-decoration: underline }`
   at specificity 0,2,1. These selectors carry three classes plus the element
   so they win on specificity rather than !important. */
.aasm-yt .aasm-yt__item a.aasm-yt__card,
.aasm-yt .aasm-yt__item a.aasm-yt__card:hover,
.aasm-yt .aasm-yt__item a.aasm-yt__card:focus,
.aasm-yt .aasm-yt__item a.aasm-yt__card:visited {
	display: block;
	color: var( --aasm-yt-strong );
	text-decoration: none;
}

.aasm-yt__card:focus-visible {
	outline: 2px solid var( --aasm-yt-accent );
	outline-offset: 3px;
}

/* ---- Thumbnail --------------------------------------------------------- */

.aasm-yt__media {
	position: relative;
	display: block;
	aspect-ratio: 16 / 9;
	overflow: hidden;
	background: var( --aasm-yt-muted );
	border-radius: 2px;
}

@supports not ( aspect-ratio: 16 / 9 ) {
	.aasm-yt__media {
		height: 0;
		padding-bottom: 56.25%;
	}
}

.aasm-yt__thumb {
	position: absolute;
	inset: 0;
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
}

/* Play badge, drawn rather than fetched. */
.aasm-yt__play {
	position: absolute;
	left: 50%;
	top: 50%;
	width: 3.25rem;
	height: 2.25rem;
	transform: translate( -50%, -50% );
	border-radius: 0.5rem;
	background: rgba( 18, 18, 18, 0.78 );
}

.aasm-yt__play::after {
	content: "";
	position: absolute;
	left: 50%;
	top: 50%;
	transform: translate( -42%, -50% );
	border-style: solid;
	border-width: 0.4rem 0 0.4rem 0.68rem;
	border-color: transparent transparent transparent #fff;
}

.aasm-yt__card:hover .aasm-yt__play,
.aasm-yt__card:focus-visible .aasm-yt__play {
	background: rgba( 18, 18, 18, 0.92 );
}

/* ---- Label ------------------------------------------------------------- */

.aasm-yt__label {
	display: block;
	margin-top: 0.625rem;
	font-size: 0.9375rem;
	line-height: 1.4;
	color: var( --aasm-yt-strong );
}

.aasm-yt .aasm-yt__item a.aasm-yt__card:hover .aasm-yt__label,
.aasm-yt .aasm-yt__item a.aasm-yt__card:focus-visible .aasm-yt__label {
	text-decoration: underline;
	text-underline-offset: 2px;
}

.aasm-yt__date {
	display: block;
	margin-top: 0.25rem;
	font-size: 0.8125rem;
	color: var( --aasm-yt-text );
	opacity: 0.7;
}

/* ---- States ------------------------------------------------------------ */

.aasm-yt__empty {
	margin: 1.25rem 0;
	font-size: 0.9375rem;
	opacity: 0.8;
}

.aasm-yt__admin {
	margin: 1.25rem 0 0;
	font-size: 0.75rem;
	opacity: 0.7;
}

.aasm-yt__admin span {
	display: block;
}

.aasm-yt__notice {
	padding: 0.75rem 1rem;
	border-left: 3px solid #b32d2e;
	background: var( --ast-global-color-4, #f3f4f5 );
	font-size: 0.875rem;
}

/* Only needed if the theme does not already define it. */
.aasm-yt .screen-reader-text {
	position: absolute !important;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect( 0, 0, 0, 0 );
	white-space: nowrap;
	border: 0;
}
