/**
 * MKTV Videos — structural styles only.
 *
 * Deliberately unopinionated: layout, aspect ratios and the lightbox, no brand
 * colours or typography. Per-site styling belongs in the theme, or drop the
 * stylesheet entirely with:
 *
 *   add_filter( 'mktv_videos_module_enabled', fn( $on, $m ) => 'styles' === $m ? false : $on, 10, 2 );
 */

.mktv-videos {
	--mktv-columns: 3;
	--mktv-gap: 1.5rem;
	--mktv-radius: 3px;
}

.mktv-videos *,
.mktv-videos-lightbox * {
	box-sizing: border-box;
}

/* ------------------------------------------------------------------- Layouts */

.mktv-videos__grid {
	display: grid;
	grid-template-columns: repeat(var(--mktv-columns), minmax(0, 1fr));
	gap: var(--mktv-gap);
}

.mktv-videos__featured {
	display: grid;
	grid-template-columns: 4fr 1fr;
	gap: var(--mktv-gap);
	align-items: start;
}

.mktv-videos__side {
	display: grid;
	gap: var(--mktv-gap);
}

.mktv-videos__more {
	display: block;
	padding: 0.6rem 1rem;
	border: 1px solid currentColor;
	border-radius: var(--mktv-radius);
	color: inherit;
	text-align: center;
	text-decoration: none;
}

.mktv-videos__more:hover,
.mktv-videos__more:focus-visible {
	background: rgba(127, 127, 127, 0.15);
}

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

	.mktv-videos__featured {
		grid-template-columns: 1fr;
	}
}

@media (max-width: 560px) {
	.mktv-videos__grid {
		grid-template-columns: 1fr;
	}
}

/* --------------------------------------------------------------------- Cards */

.mktv-videos__card {
	min-width: 0;
}

.mktv-videos__trigger {
	display: block;
	width: 100%;
	padding: 0;
	border: 0;
	background: none;
	cursor: pointer;
	color: inherit;
	font: inherit;
	text-align: inherit;
}

.mktv-videos__thumb {
	position: relative;
	display: block;
	overflow: hidden;
	border-radius: var(--mktv-radius);
	aspect-ratio: 16 / 9;
}

/*
 * Absolutely positioned and !important: themes routinely ship a global
 * `img { max-width: 100%; height: auto }` reset, and WordPress prints width/height
 * attributes on the <img> that browsers use to infer an intrinsic aspect ratio when
 * height is auto. Either one is enough to override a plain width/height:100% rule and
 * leave letterboxing. Taking the image out of flow sizes it strictly from the
 * (already fixed-ratio) .mktv-videos__thumb parent instead.
 */
.mktv-videos__image {
	position: absolute !important;
	inset: 0;
	display: block;
	width: 100% !important;
	height: 100% !important;
	max-width: none !important;
	object-fit: cover;
}

.mktv-videos__image--placeholder {
	position: absolute;
	inset: 0;
	display: block;
	background: #1a1a1a;
}

/* Play badge: a plain CSS triangle, no icon asset to ship. */
.mktv-videos__play {
	position: absolute;
	inset: 0;
	margin: auto;
	width: 3.5rem;
	height: 3.5rem;
	border-radius: 50%;
	background: rgba(0, 0, 0, 0.65);
	transition: transform 0.15s ease, background-color 0.15s ease;
}

.mktv-videos__play::after {
	content: "";
	position: absolute;
	inset: 0;
	margin: auto;
	width: 0;
	height: 0;
	border-style: solid;
	border-width: 0.6rem 0 0.6rem 1rem;
	border-color: transparent transparent transparent #fff;
	transform: translateX(0.15rem);
}

.mktv-videos__trigger:hover .mktv-videos__play,
.mktv-videos__trigger:focus-visible .mktv-videos__play {
	background: rgba(0, 0, 0, 0.85);
	transform: scale(1.08);
}

.mktv-videos__trigger:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 3px;
}

.mktv-videos__card-title {
	margin: 0.75rem 0 0;
	font-size: 1rem;
	line-height: 1.35;
}

.mktv-videos__card--hero .mktv-videos__card-title {
	font-size: 1.35rem;
}

.mktv-videos__card--side .mktv-videos__card-title {
	font-size: 0.9rem;
}

.mktv-videos__card-text {
	margin: 0.4rem 0 0;
	font-size: 0.9rem;
	opacity: 0.8;
}

/* -------------------------------------------------------- Playlists / paging */

.mktv-videos__playlists,
.mktv-videos__pagination {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
	margin-bottom: var(--mktv-gap);
}

.mktv-videos__pagination {
	margin: var(--mktv-gap) 0 0;
	justify-content: center;
}

.mktv-videos__playlist,
.mktv-videos__page {
	padding: 0.45rem 0.9rem;
	border: 1px solid currentColor;
	border-radius: var(--mktv-radius);
	background: none;
	color: inherit;
	font: inherit;
	cursor: pointer;
}

.mktv-videos__playlist.is-current {
	font-weight: 700;
	text-decoration: underline;
	text-underline-offset: 0.25em;
}

.mktv-videos__body[aria-busy="true"] {
	opacity: 0.5;
	pointer-events: none;
}

.mktv-videos__error {
	padding: 0.75rem 1rem;
	border-left: 3px solid #b32d2e;
	background: rgba(179, 45, 46, 0.08);
}

.mktv-videos__page:hover{
	color: #fff
}

/* ------------------------------------------------------------------ Lightbox */

.mktv-videos-locked,
.mktv-videos-locked body {
	overflow: hidden;
}

.mktv-videos-lightbox {
	position: fixed;
	inset: 0;
	z-index: 99999;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 1.5rem;
	background: rgba(0, 0, 0, 0.9);
}

.mktv-videos-lightbox__inner {
	width: min(100%, 1100px);
	aspect-ratio: 16 / 9;
}

.mktv-videos-lightbox iframe {
	width: 100%;
	height: 100%;
	border: 0;
	border-radius: var(--mktv-radius, 4px);
}

/*
 * !important throughout: the host theme's own `button` reset (e.g. a brand-coloured,
 * fully rounded default) otherwise wins over an unqualified rule here, the same
 * conflict the thumbnail image ran into.
 */
.mktv-videos-lightbox__close {
	all: unset;
	position: absolute !important;
	top: 1rem;
	right: 1rem;
	box-sizing: border-box !important;
	display: flex !important;
	align-items: center !important;
	justify-content: center !important;
	width: 2.75rem !important;
	height: 2.75rem !important;
	padding: 0 !important;
	border: 0 !important;
	border-radius: var(--mktv-radius) !important;
	background: rgba(0, 0, 0, 0.6) !important;
	color: #fff !important;
	font-size: 1.75rem;
	line-height: 1;
	cursor: pointer;
}

.mktv-videos-lightbox__close:hover,
.mktv-videos-lightbox__close:focus-visible {
	background: rgba(0, 0, 0, 0.8) !important;
}

@media (prefers-reduced-motion: reduce) {
	.mktv-videos__play {
		transition: none;
	}
}
