/**
 * Video Hub.
 *
 * Cards, the grouped rows on the hub, the lightbox, and the player on a single
 * video post. Built on the same tokens as the rest of the theme so a video row
 * sits beside an article row without a second visual language.
 *
 * Two shapes throughout: `is-landscape` for YouTube and documentary clips,
 * `is-portrait` for Reels and Shorts. Only the aspect ratio and the column
 * count differ — everything else is shared.
 */

/* Group header ------------------------------------------------------------- */

.mida-video-group + .mida-video-group {
	margin-top: 3.25rem;
}

.mida-video-group-head {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 1rem;
	margin-bottom: 1.25rem;
	padding-bottom: 10px;
	border-bottom: 1px solid var(--mida-line);
}

.mida-video-group-head h2 {
	margin: 0;
	font-family: var(--font-display);
	font-size: 1.3rem;
	font-weight: 600;
	color: #fff;
}

.mida-video-group-head a {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	flex: 0 0 auto;
	font-size: 14px;
	color: var(--brand-sand);
	white-space: nowrap;
}

.mida-video-group-head a:hover {
	color: #fff;
}

.mida-video-group-head svg {
	width: 14px;
	height: 14px;
}

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

.mida-video-grid {
	display: grid;
	gap: 20px 16px;
}

.mida-video-grid.is-landscape {
	grid-template-columns: repeat(3, minmax(0, 1fr));
}

/* A vertical card is about half as wide, so a row holds twice as many before
   the thumbnails start to look like postage stamps. */
.mida-video-grid.is-portrait {
	grid-template-columns: repeat(6, minmax(0, 1fr));
}

@media (max-width: 1199px) {
	.mida-video-grid.is-portrait {
		grid-template-columns: repeat(4, minmax(0, 1fr));
	}
}

@media (max-width: 991px) {
	.mida-video-grid.is-landscape {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}
}

@media (max-width: 767px) {
	.mida-video-grid.is-portrait {
		grid-template-columns: repeat(3, minmax(0, 1fr));
	}
}

@media (max-width: 575px) {
	.mida-video-grid.is-landscape {
		grid-template-columns: minmax(0, 1fr);
	}

	.mida-video-grid.is-portrait {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}
}

/* Card --------------------------------------------------------------------- */

.mida-video-card {
	display: block;
	color: #fff;
}

.mida-video-card:hover,
.mida-video-card:focus {
	color: #fff;
	text-decoration: none;
}

.mida-video-frame {
	position: relative;
	display: block;
	overflow: hidden;
	background: var(--mida-panel-deep);
	border-radius: var(--border_radius);
}

.mida-video-card.is-landscape .mida-video-frame {
	aspect-ratio: 16 / 9;
}

.mida-video-card.is-portrait .mida-video-frame {
	aspect-ratio: 9 / 16;
}

.mida-video-frame img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	transition: transform .45s ease;
}

.mida-video-card:hover .mida-video-frame img {
	transform: scale(1.05);
}

.mida-video-play {
	position: absolute;
	top: 50%;
	left: 50%;
	display: grid;
	place-items: center;
	width: 52px;
	height: 52px;
	color: #fff;
	background: rgba(0, 0, 0, .55);
	border: 1px solid rgba(255, 255, 255, .55);
	border-radius: 50%;
	transform: translate(-50%, -50%);
	transition: background .3s ease, color .3s ease, border-color .3s ease;
}

/* Nudged right by an eighth of its width: a triangle looks centred when its
   visual mass is, not when its bounding box is. */
.mida-video-play svg {
	margin-left: 2px;
}

.mida-video-card:hover .mida-video-play {
	color: var(--brand-black);
	background: var(--brand-sand);
	border-color: var(--brand-sand);
}

.mida-video-time {
	position: absolute;
	right: 8px;
	bottom: 8px;
	padding: 2px 7px;
	font-size: 12px;
	line-height: 1.5;
	color: #fff;
	background: rgba(0, 0, 0, .75);
	border-radius: 3px;
}

.mida-video-body {
	display: block;
	margin-top: 10px;
}

.mida-video-title {
	display: -webkit-box;
	overflow: hidden;
	font-size: 15px;
	font-weight: 500;
	line-height: 1.45;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
}

.mida-video-card:hover .mida-video-title {
	color: var(--brand-sand);
}

.mida-video-desc {
	display: -webkit-box;
	overflow: hidden;
	margin-top: 5px;
	font-size: 13px;
	font-weight: 300;
	line-height: 1.6;
	color: var(--mida-muted);
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
}

/* Smaller type under a narrow portrait card, or the two lines of title alone
   take more room than the thumbnail above them. */
.mida-video-grid.is-portrait .mida-video-title {
	font-size: 14px;
}

.mida-video-grid.is-portrait .mida-video-desc {
	display: none;
}

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

.mida-vlb {
	position: fixed;
	inset: 0;
	z-index: 10000;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 14px;
	padding: 24px;
	background: rgba(0, 0, 0, .92);
}

.mida-vlb[hidden] {
	display: none;
}

.mida-vlb-box {
	position: relative;
	width: min(1040px, 100%);
	max-height: 78vh;
	aspect-ratio: 16 / 9;
	background: #000;
}

/*
 * A tall frame is bounded by the window, not by the page: sizing it from the
 * height and letting the width follow keeps 9:16 exact on a short screen,
 * where capping the height of a width-sized box would squash it instead.
 */
.mida-vlb.is-portrait .mida-vlb-box {
	width: auto;
	height: min(78vh, 760px);
	max-width: 100%;
	aspect-ratio: 9 / 16;
}

.mida-vlb-box iframe {
	width: 100%;
	height: 100%;
	border: 0;
}

.mida-vlb-close {
	position: absolute;
	top: -46px;
	right: 0;
	display: grid;
	place-items: center;
	width: 36px;
	height: 36px;
	padding: 0;
	font-size: 22px;
	line-height: 1;
	color: #fff;
	background: transparent;
	border: 1px solid rgba(255, 255, 255, .4);
	border-radius: 50%;
	cursor: pointer;
}

.mida-vlb-close:hover {
	color: var(--brand-black);
	background: var(--brand-sand);
	border-color: var(--brand-sand);
}

.mida-vlb-foot {
	display: flex;
	align-items: center;
	gap: 1rem;
	width: min(1040px, 100%);
	color: #fff;
}

.mida-vlb-title {
	flex: 1 1 auto;
	overflow: hidden;
	font-size: 15px;
	white-space: nowrap;
	text-overflow: ellipsis;
}

.mida-vlb-source {
	flex: 0 0 auto;
	font-size: 14px;
	color: var(--brand-sand);
}

.mida-vlb-source:hover {
	color: #fff;
}

/* Player on a single video post -------------------------------------------- */

.mida-video-player {
	margin-bottom: 1.5rem;
	background: #000;
	border-radius: var(--border_radius);
	overflow: hidden;
}

.mida-video-player.is-landscape {
	aspect-ratio: 16 / 9;
}

.mida-video-player.is-portrait {
	width: min(420px, 100%);
	margin-inline: auto;
	aspect-ratio: 9 / 16;
}

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

.mida-video-offsite {
	position: relative;
	margin-bottom: 1.5rem;
	text-align: center;
}

.mida-video-offsite img {
	width: 100%;
	border-radius: var(--border_radius);
}

.mida-video-offsite-btn {
	display: inline-block;
	margin-top: 1rem;
	padding: 12px 26px;
	font-size: 16px;
	color: var(--brand-black);
	background: var(--brand-sand);
	border-radius: var(--border_radius);
}

.mida-video-offsite-btn:hover {
	color: var(--brand-black);
	background: #fff;
}

/* Home shelf ---------------------------------------------------------------
 *
 * One row holding both shapes. Height is fixed and width derives from it, so
 * the row has a single baseline whatever mix of Reels and wide clips it holds.
 * `--shelf-h` is the only value that changes per screen.
 */

.mida-home-videos {
	--shelf-h: 280px;

	padding: 60px 0;
}

@media (max-width: 991px) {
	.mida-home-videos {
		--shelf-h: 240px;

		padding: 40px 0;
	}
}

@media (max-width: 575px) {
	.mida-home-videos {
		/* Small enough that a wide card still fits a phone, which is also
		   roughly where three vertical cards sit side by side — the size
		   every short-form app shows them at. */
		--shelf-h: 200px;
	}
}

.mida-home-videos .swiper-slide {
	width: auto;
}

.mida-home-videos .mida-video-card {
	width: calc(var(--shelf-h) * 16 / 9);
	max-width: 88vw;
}

.mida-home-videos .mida-video-card.is-portrait {
	width: calc(var(--shelf-h) * 9 / 16);
}

/* Both dimensions are stated here, so the ratio on the card is spent. */
.mida-home-videos .mida-video-frame {
	height: var(--shelf-h);
	aspect-ratio: auto;
}

.mida-home-videos .mida-video-card.is-portrait .mida-video-title {
	font-size: 14px;
}

.mida-home-videos .mida-video-card.is-portrait .mida-video-desc {
	display: none;
}

.mida-home-videos .swiper-pagination {
	position: static;
	margin-top: 1.25rem;
}

.mida-home-videos-foot {
	margin-top: 1.5rem;
	text-align: center;
}

.mida-home-videos-foot a {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 11px 26px;
	font-size: 15px;
	color: var(--brand-sand);
	border: 1px solid var(--mida-line-strong);
	border-radius: var(--border_radius);
}

.mida-home-videos-foot a:hover {
	color: var(--brand-black);
	background: var(--brand-sand);
	border-color: var(--brand-sand);
}

.mida-home-videos-foot svg {
	width: 14px;
	height: 14px;
}
