/* BB Custom Modules — Video Playlist (frontend) */

.bbcm-vp-wrapper {
	/* CSS variable defaults — overridden inline by the template from saved config. */
	--bbcm-vp-item-bg: #22272e;
	--bbcm-vp-item-text: #ffffff;
	--bbcm-vp-item-active-bg: #3a3f47;
	--bbcm-vp-accent: #b2fe33;
	--bbcm-vp-sidebar-width: 383px;
	--bbcm-vp-visible-count: 4;
	--bbcm-vp-hero-aspect: 16 / 9;
	--bbcm-vp-item-height: 113px; /* matches thumbnail height */
	--bbcm-vp-item-gap: 16px;     /* matches .bbcm-vp-list gap */

	display: flex;
	flex-direction: column;
	gap: 24px;
	width: 100%;
}

.bbcm-vp-wrapper *,
.bbcm-vp-wrapper *::before,
.bbcm-vp-wrapper *::after {
	box-sizing: border-box;
}

/* ============================================
   LAYOUT (≥1024px) — direction depends on `layout` config:
   right (default): video | sidebar
   left           : sidebar | video
   below          : video on top, full-width grid below
   On narrower viewports we always stack regardless of config.
   ============================================ */

@media (min-width: 1024px) {
	.bbcm-vp-layout-right.bbcm-vp-wrapper {
		flex-direction: row;
	}
	.bbcm-vp-layout-left.bbcm-vp-wrapper {
		flex-direction: row-reverse;
	}
	.bbcm-vp-layout-below.bbcm-vp-wrapper {
		flex-direction: column;
	}
}

/* ============================================
   HERO PLAYER
   ============================================ */

.bbcm-vp-hero {
	flex: 1 1 0;
	min-width: 0;
}

.bbcm-vp-iframe-container {
	position: relative;
	width: 100%;
	aspect-ratio: var(--bbcm-vp-hero-aspect);
	background-color: #000000;
	border-radius: 4px;
	overflow: hidden;
}

/* On desktop in the left/right layouts the wrapper is a flex row whose
   tallest child is the sidebar (its max-height comes from visible_count).
   Drop the aspect-ratio on the iframe container so the hero stretches to
   match the sidebar — no empty space below the video. The configured
   `hero_aspect` still applies in the Below layout and on mobile, where
   the hero is on its own row and has no sibling to match. */
@media (min-width: 1024px) {
	.bbcm-vp-layout-right .bbcm-vp-hero,
	.bbcm-vp-layout-left .bbcm-vp-hero {
		display: flex;
		align-items: stretch;
	}
	.bbcm-vp-layout-right .bbcm-vp-iframe-container,
	.bbcm-vp-layout-left .bbcm-vp-iframe-container {
		aspect-ratio: auto;
		height: 100%;
		min-height: 100%;
	}
}

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

/* ============================================
   SIDEBAR PLAYLIST
   ============================================ */

.bbcm-vp-sidebar {
	width: 100%;
}

/* Desktop: right & left layouts get a fixed-width scroll-bounded sidebar.
   The "below" layout keeps the sidebar full width and uses a flexible grid. */
@media (min-width: 1024px) {
	.bbcm-vp-layout-right .bbcm-vp-sidebar,
	.bbcm-vp-layout-left .bbcm-vp-sidebar {
		width: var(--bbcm-vp-sidebar-width);
		flex-shrink: 0;
		/* visible_count items × (thumb height + gap) − one gap (no gap after last) */
		max-height: calc(
			(var(--bbcm-vp-item-height) * var(--bbcm-vp-visible-count))
			+ (var(--bbcm-vp-item-gap) * (var(--bbcm-vp-visible-count) - 1))
		);
		overflow-y: auto;
	}
}

.bbcm-vp-list {
	list-style: none;
	margin: 0;
	padding: 0;
	display: grid;
	grid-template-columns: 1fr;
	gap: var(--bbcm-vp-item-gap);
}

/* On tablet (non-desktop, non-tiny), show 2 columns to use horizontal space. */
@media (min-width: 640px) and (max-width: 1023px) {
	.bbcm-vp-list {
		grid-template-columns: 1fr 1fr;
	}
}

/* "Below" layout (desktop) — fluid grid using the full width. */
@media (min-width: 1024px) {
	.bbcm-vp-layout-below .bbcm-vp-list {
		grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
	}
}

/* Hide the title column entirely when configured off. The whole button row
   collapses to just the thumbnail. */
.bbcm-vp-no-titles .bbcm-vp-item-btn {
	display: inline-flex;
}
.bbcm-vp-no-titles .bbcm-vp-thumb img {
	border-radius: 4px;
}

/* ============================================
   PLAYLIST ITEM
   ============================================ */

.bbcm-vp-item {
	background-color: var(--bbcm-vp-item-bg);
	border-radius: 4px;
	transition: background-color 0.2s ease;
	margin: 0;
}

.bbcm-vp-item.is-active {
	background-color: var(--bbcm-vp-item-active-bg);
}

.bbcm-vp-item:hover:not(.is-active) {
	filter: brightness(1.15);
}

.bbcm-vp-item-btn {
	display: flex;
	align-items: stretch;
	flex-wrap: nowrap;
	width: 100%;
	background-color: transparent;
	border: 0;
	padding: 0;
	margin: 0;
	cursor: pointer;
	color: var(--bbcm-vp-item-text);
	text-align: left;
	font: inherit;
	border-radius: inherit;
}

.bbcm-vp-item-btn:focus {
	outline: 0;
}

.bbcm-vp-item:focus-within {
	outline: 2px solid var(--bbcm-vp-accent);
	outline-offset: 2px;
}

/* ============================================
   THUMBNAIL
   ============================================ */

.bbcm-vp-thumb {
	position: relative;
	width: 168px;
	height: 113px;
	flex-shrink: 0;
	display: block;
}

@media (min-width: 780px) {
	.bbcm-vp-thumb {
		width: 180px;
	}
}

.bbcm-vp-thumb img {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	object-fit: cover;
	border-radius: 4px 0 0 4px;
	display: block;
}

.bbcm-vp-play-icon {
	position: absolute;
	top: 50%;
	left: 50%;
	width: 40px;
	height: 40px;
	transform: translate(-50%, -50%);
	pointer-events: none;
	display: block;
}

.bbcm-vp-play-icon svg {
	width: 100%;
	height: 100%;
	fill: #ffffff;
	opacity: 0.92;
	filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.4));
}

/* ============================================
   TITLE
   ============================================ */

.bbcm-vp-title {
	flex: 1;
	display: flex;
	align-items: center;
	padding: 12px 16px;
	font-size: 14px;
	line-height: 1.45;
	color: var(--bbcm-vp-item-text);
}

/* ============================================
   ACCESSIBILITY / MOTION
   ============================================ */

@media (prefers-reduced-motion: reduce) {
	.bbcm-vp-item {
		transition: none;
	}
}
