/**
 * "Resource row" block (arpl/resources) — front-end + shared styles.
 *
 * A category-driven grid of post cards (bold excerpt + a white "Read more" pill,
 * or featured-image "media" cards). A "Load more" button appends the next page of
 * cards in place (see assets/js/resources-view.js). Author any heading/intro with
 * core blocks above it.
 *
 * The section color is carried by the custom property `--arpl-resource-color`,
 * set inline per instance; the eyebrow, cards, pills and button all read from it.
 *
 * @package arpl-fse
 */

.arpl-resources {
	--arpl-resource-color: var( --wp--preset--color--primary, #3376bd );
}

/* Card grid. Column count is author-set via --arpl-resource-cols; it collapses to
   two, then one, on smaller screens. */
.arpl-resources__grid {
	display: grid;
	grid-template-columns: repeat( var( --arpl-resource-cols, 3 ), minmax( 0, 1fr ) );
	gap: 1.5rem;
}

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

@media ( max-width: 600px ) {
	.arpl-resources__grid {
		grid-template-columns: 1fr;
	}
}

/* Card. Border-box + min-height keeps a tidy, even row; the pill is pinned to the
   bottom via margin-top:auto so ragged excerpt lengths still line up. */
.arpl-resource-card {
	display: flex;
	flex-direction: column;
	box-sizing: border-box;
	min-height: 220px;
	padding: 1.75rem;
	color: #fff;
	background-color: var( --arpl-resource-color );
	border-radius: 16px;
}

.arpl-resource-card__title {
	margin: 0 0 1.25rem;
	font-size: 1.5rem;
	font-weight: 700;
	line-height: 1.35;
	/* Clamp to keep card heights even regardless of title length. */
	display: -webkit-box;
	-webkit-line-clamp: 6;
	line-clamp: 6;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

/* White "Read more" pill; its text takes the card color. */
.arpl-resource-card__link {
	align-self: flex-start;
	margin-top: auto;
	display: inline-block;
	padding: 3px 1.4em;
	color: var( --arpl-resource-color );
	font-size: var( --wp--preset--font-size--small, 1.125rem );
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.03em;
	text-decoration: none;
	background: #fff;
	border-radius: 999px;
	transition: background-color 0.15s ease;
}

.arpl-resource-card__link:hover,
.arpl-resource-card__link:focus-visible {
	background: #eef1f4;
}

/* Media layout (Audio & Video) reuses the same colored panel as the text card —
   title inside + a pill. The pill is "PLAY NOW" and opens the lightbox; see the
   card + pill rules above and the lightbox rules below. */

/* ---------------------------------------------------------------------------
 * Lightbox player (media "PLAY NOW" opens this in place — no landing page).
 * ------------------------------------------------------------------------ */
.arpl-lightbox[hidden] {
	display: none;
}

.arpl-lightbox {
	position: fixed;
	inset: 0;
	z-index: 100000;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 5vmin;
	background: rgba( 0, 0, 0, 0.82 );
}

.arpl-lightbox__dialog {
	position: relative;
	width: min( 1100px, 100% );
}

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

.arpl-lightbox__content.is-audio {
	aspect-ratio: auto;
	background: transparent;
	overflow: visible;
}

.arpl-lightbox__iframe,
.arpl-lightbox__video {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	border: 0;
}

.arpl-lightbox__audio {
	width: 100%;
}

.arpl-lightbox__close {
	position: absolute;
	top: -2.75rem;
	right: 0;
	width: 2.5rem;
	height: 2.5rem;
	padding: 0;
	font-size: 2rem;
	line-height: 1;
	color: #fff;
	background: transparent;
	border: 0;
	cursor: pointer;
}

.arpl-lightbox__close:focus-visible {
	outline: 2px solid #fff;
	outline-offset: 2px;
}

html.arpl-lightbox-open {
	overflow: hidden;
}

/* Load more. */
.arpl-resources__more {
	margin-top: 2rem;
	text-align: center;
}

.arpl-resources__load {
	appearance: none;
	cursor: pointer;
	display: inline-block;
	padding: 0.4em 2.25em;
	color: #fff;
	font-family: inherit;
	font-size: var( --wp--preset--font-size--small, 1.125rem );
	font-weight: 700;
	background-color: var( --arpl-resource-color );
	border: 0;
	border-radius: 999px;
	transition: opacity 0.15s ease, transform 0.15s ease;
}

.arpl-resources__load:hover {
	transform: translateY( -1px );
}

.arpl-resources__load:focus-visible {
	outline: 2px solid var( --arpl-resource-color );
	outline-offset: 3px;
}

.arpl-resources__load[disabled],
.arpl-resources__load.is-loading {
	opacity: 0.6;
	cursor: default;
	transform: none;
}

@media ( prefers-reduced-motion: reduce ) {
	.arpl-resource-card__link,
	.arpl-resources__load {
		transition: none;
	}
}
