/**
 * FFA Resource Library — frontend player layout and baseline design system.
 *
 * Structure and neutral defaults live here; personality (colors, fonts,
 * framing) comes from the active CSS scheme via the --ffarl-* variables below,
 * scoped per wrapper through the .ffarl-scheme-{slug} class. Override the
 * variables in a scheme for quick restyling, or target the classes directly
 * for full control — see the Design & Theming Guide in the documentation.
 */

/* Wrappers + theme variables ------------------------------------------------ */
.ffarl-player-wrap,
.ffarl-playlist-wrap,
.ffarl-series-wrap {
	/* Scheme-overridable design tokens (neutral defaults). */
	--ffarl-accent: #2271b1;        /* highlight: active item, hovers, ticks  */
	--ffarl-accent-ink: #ffffff;    /* text color placed ON the accent color  */
	--ffarl-surface: rgba(127, 127, 127, 0.07);  /* card / chip backgrounds   */
	--ffarl-border: rgba(127, 127, 127, 0.22);   /* card / chip borders       */
	--ffarl-radius: 10px;           /* card + pill corner radius              */

	display: flex;
	flex-direction: column;
	gap: 14px;
	width: 100%;
	box-sizing: border-box;
	background: var(--ffarl-bg, transparent);
	color: var(--ffarl-text, inherit);
	font-family: var(--ffarl-font-body, inherit);
	padding: var(--ffarl-pad, 0);
	border-radius: var(--ffarl-wrap-radius, 0);
	box-shadow: var(--ffarl-wrap-shadow, none);
}

.ffarl-player-wrap *,
.ffarl-playlist-wrap *,
.ffarl-series-wrap * {
	box-sizing: border-box;
}

/* Responsive 16:9 player box ------------------------------------------------ */
.ffarl-player-ratio {
	position: relative;
	width: 100%;
	aspect-ratio: 16 / 9;
	background: #000;
	border-radius: var(--ffarl-player-radius, calc(var(--ffarl-radius) - 2px));
	overflow: hidden;
}

/* Fallback for browsers without aspect-ratio support. */
@supports not (aspect-ratio: 16 / 9) {
	.ffarl-player-ratio {
		height: 0;
		padding-top: 56.25%;
	}
}

.ffarl-player-ratio iframe,
.ffarl-iframe {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	border: 0;
}

/* Video.js (self-hosted engine) fills the same responsive ratio box. */
.ffarl-player-ratio .video-js,
.ffarl-player-ratio .ffarl-vjs {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
}

/* Resource pills ------------------------------------------------------------ */
.ffarl-resources {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
}

.ffarl-resources:empty {
	display: none;
}

.ffarl-resource-pill {
	display: inline-block;
	padding: 7px 16px;
	border-radius: 999px;
	font-size: 13.5px;
	font-weight: 600;
	line-height: 1.3;
	letter-spacing: 0.01em;
	text-decoration: none;
	background: var(--ffarl-surface);
	border: 1px solid var(--ffarl-border);
	color: var(--ffarl-text, inherit);
	transition: background-color 0.16s ease, color 0.16s ease,
		border-color 0.16s ease, transform 0.16s ease;
}

.ffarl-resource-pill:hover,
.ffarl-resource-pill:focus-visible {
	background: var(--ffarl-accent);
	border-color: var(--ffarl-accent);
	color: var(--ffarl-accent-ink);
	transform: translateY(-1px);
	text-decoration: none;
}

/* Collection title + description (above the player) ------------------------
   Inner text elements are h2/h3/p tags, so themes style them aggressively;
   every text property is set explicitly at .wrap-class specificity to keep
   the module self-contained. */
.ffarl-player-wrap .ffarl-collection-title,
.ffarl-playlist-wrap .ffarl-collection-title,
.ffarl-series-wrap .ffarl-collection-title {
	display: flex;
	align-items: center;
	gap: 12px;
	margin: 0;
	padding: 0;
	font-family: var(--ffarl-font-display, inherit);
	font-size: clamp(20px, 3.2vw, 27px);
	font-weight: 750;
	line-height: 1.2;
	letter-spacing: var(--ffarl-display-tracking, -0.015em);
	text-transform: none;
	color: var(--ffarl-text, inherit);
}

/* Accent tick before the collection title. Schemes restyle it via
   --ffarl-accent, or remove it with display:none. */
.ffarl-collection-title::before {
	content: "";
	flex: 0 0 auto;
	width: 5px;
	height: 1.05em;
	border-radius: 3px;
	background: var(--ffarl-accent);
}

.ffarl-player-wrap .ffarl-collection-description,
.ffarl-playlist-wrap .ffarl-collection-description,
.ffarl-series-wrap .ffarl-collection-description,
.ffarl-player-wrap .ffarl-collection-description p,
.ffarl-playlist-wrap .ffarl-collection-description p,
.ffarl-series-wrap .ffarl-collection-description p {
	margin: 0;
	max-width: 72ch;
	font-family: var(--ffarl-font-body, inherit);
	font-size: 15px;
	line-height: 1.65;
	color: var(--ffarl-muted, inherit);
}

.ffarl-player-wrap .ffarl-collection-description,
.ffarl-playlist-wrap .ffarl-collection-description,
.ffarl-series-wrap .ffarl-collection-description {
	margin-top: -4px;
}

.ffarl-collection-description p {
	margin-bottom: 0.6em;
}

.ffarl-collection-description p:last-child {
	margin-bottom: 0;
}

/* Playlist body holds the player + filmstrip flex row; the wrap stacks the
   collection title above this body. */
.ffarl-playlist-body {
	display: flex;
	flex-direction: column;
	gap: 14px;
	width: 100%;
}

/* Playlist: player + filmstrip side-by-side when positioned left/right.
   The left/right filmstrip is rendered before/after the player-col in the DOM,
   so a plain flex row places it correctly (no row-reverse). */
.ffarl-playlist-body[data-filmstrip="left"],
.ffarl-playlist-body[data-filmstrip="right"] {
	flex-direction: row;
	align-items: flex-start;
}

.ffarl-playlist-body[data-filmstrip="left"] .ffarl-filmstrip,
.ffarl-playlist-body[data-filmstrip="right"] .ffarl-filmstrip {
	flex: 0 0 200px;
	flex-direction: column;
	max-height: 60vh;
	overflow-y: auto;
	overflow-x: hidden;
}

.ffarl-playlist-body[data-filmstrip="left"] .ffarl-filmstrip-item,
.ffarl-playlist-body[data-filmstrip="right"] .ffarl-filmstrip-item {
	width: auto;
}

.ffarl-player-col {
	flex: 1 1 auto;
	min-width: 0;
	display: flex;
	flex-direction: column;
	gap: 12px;
}

/* Current-video title + description ----------------------------------------- */
.ffarl-video-meta {
	display: flex;
	flex-direction: column;
	gap: 7px;
	padding-top: 2px;
}

.ffarl-video-meta:not(:has(> :not(:empty))) {
	display: none;
}

.ffarl-player-wrap .ffarl-video-title,
.ffarl-playlist-wrap .ffarl-video-title,
.ffarl-series-wrap .ffarl-video-title {
	margin: 0;
	padding: 0;
	font-family: var(--ffarl-font-display, inherit);
	font-size: clamp(17px, 2.6vw, 22px);
	font-weight: 700;
	line-height: 1.3;
	letter-spacing: var(--ffarl-display-tracking, -0.01em);
	text-transform: none;
	color: var(--ffarl-text, inherit);
}

.ffarl-video-title:empty {
	display: none;
}

.ffarl-player-wrap .ffarl-video-description,
.ffarl-playlist-wrap .ffarl-video-description,
.ffarl-series-wrap .ffarl-video-description,
.ffarl-player-wrap .ffarl-video-description p,
.ffarl-playlist-wrap .ffarl-video-description p,
.ffarl-series-wrap .ffarl-video-description p {
	margin: 0;
	max-width: 68ch;
	font-family: var(--ffarl-font-body, inherit);
	font-size: 14.5px;
	line-height: 1.65;
	color: var(--ffarl-muted, inherit);
}

.ffarl-video-description p {
	margin-bottom: 0.6em;
}

.ffarl-video-description p:last-child {
	margin-bottom: 0;
}

/* Filmstrip ------------------------------------------------------------------
   Cards: 16:9 thumb with duration chip, two-line clamped title, hover lift,
   accent ring + underline strip on the playing item. */
.ffarl-filmstrip {
	display: flex;
	gap: 12px;
	overflow-x: auto;
	overflow-y: hidden;
	scrollbar-width: none;
	-ms-overflow-style: none;
	padding: 3px;
	scroll-snap-type: x proximity;
	scroll-behavior: smooth;
}

.ffarl-filmstrip::-webkit-scrollbar {
	display: none;
}

.ffarl-filmstrip-item {
	flex: 0 0 auto;
	width: 172px;
	cursor: pointer;
	scroll-snap-align: start;
	border-radius: var(--ffarl-radius);
	overflow: hidden;
	background: var(--ffarl-surface);
	border: 1px solid var(--ffarl-border);
	transition: transform 0.18s ease, border-color 0.18s ease,
		box-shadow 0.18s ease;
}

.ffarl-filmstrip-item:hover {
	transform: translateY(-2px);
	border-color: var(--ffarl-accent);
}

.ffarl-filmstrip-item.is-active {
	border-color: var(--ffarl-accent);
	box-shadow: 0 0 0 1.5px var(--ffarl-accent);
}

.ffarl-thumb-wrap {
	display: block;
	position: relative;
	aspect-ratio: 16 / 9;
	overflow: hidden;
	background: #000;
}

.ffarl-thumb-wrap img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
	transition: transform 0.35s ease;
}

.ffarl-filmstrip-item:hover .ffarl-thumb-wrap img {
	transform: scale(1.05);
}

/* Accent strip along the bottom of the playing item's thumbnail. */
.ffarl-filmstrip-item.is-active .ffarl-thumb-wrap::after {
	content: "";
	position: absolute;
	left: 0;
	right: 0;
	bottom: 0;
	height: 3px;
	background: var(--ffarl-accent);
}

.ffarl-item-duration {
	position: absolute;
	right: 6px;
	bottom: 6px;
	padding: 2px 8px;
	border-radius: 999px;
	font-size: 11px;
	font-weight: 650;
	line-height: 1.5;
	letter-spacing: 0.03em;
	font-variant-numeric: tabular-nums;
	background: rgba(0, 0, 0, 0.72);
	color: #fff;
}

/* Two-line title clamp, host-theme-proof: the box is exactly two lines tall
   (top padding only; the gap below comes from margin, which text can never
   paint into), so a third line is clipped even when a theme overrides the
   -webkit-box clamp with its own !important display rules. */
.ffarl-filmstrip .ffarl-filmstrip-item .ffarl-title {
	display: -webkit-box !important;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden !important;
	box-sizing: border-box !important;
	height: calc(2 * 1.4 * 12.5px + 9px) !important;
	padding: 9px 11px 0 !important;
	margin: 0 0 11px !important;
	font-size: 12.5px !important;
	font-weight: 600;
	line-height: 1.4 !important;
	text-transform: none;
	letter-spacing: 0;
	color: var(--ffarl-text, inherit);
}

.ffarl-filmstrip-item.is-active .ffarl-title {
	color: var(--ffarl-accent);
}

/* Series --------------------------------------------------------------------- */
.ffarl-series-seasons {
	display: flex;
	flex-direction: column;
	gap: 22px;
}

/* Season titles read as uppercase eyebrows above each filmstrip. */
.ffarl-player-wrap .ffarl-series-season-title,
.ffarl-series-wrap .ffarl-series-season-title {
	margin: 0 0 10px;
	padding: 0;
	font-family: var(--ffarl-font-display, inherit);
	font-size: 12.5px;
	font-weight: 700;
	line-height: 1.4;
	letter-spacing: 0.09em;
	text-transform: uppercase;
	color: var(--ffarl-muted, inherit);
}

/* Auto-advance countdown overlay --------------------------------------------- */
.ffarl-countdown {
	position: absolute;
	inset: 0;
	z-index: 5;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 16px;
	background: rgba(0, 0, 0, 0.65);
	-webkit-backdrop-filter: blur(3px);
	backdrop-filter: blur(3px);
	color: #fff;
}

.ffarl-countdown-num {
	font-family: var(--ffarl-font-display, inherit);
	font-size: 52px;
	font-weight: 750;
	line-height: 1;
	font-variant-numeric: tabular-nums;
}

.ffarl-countdown-skip {
	padding: 8px 22px;
	border: 1.5px solid #fff;
	border-radius: 999px;
	background: transparent;
	color: #fff;
	font-size: 13.5px;
	font-weight: 600;
	letter-spacing: 0.02em;
	cursor: pointer;
	transition: background-color 0.16s ease, color 0.16s ease;
}

.ffarl-countdown-skip:hover {
	background: #fff;
	color: #000;
}

/* Seek-bar scrub preview (self-hosted engine) -------------------------------- */
.ffarl-scrub-preview {
	position: absolute;
	bottom: 36px;
	transform: translateX(-50%);
	pointer-events: none;
	z-index: 2;
	border: 2px solid #fff;
	border-radius: 3px;
	overflow: hidden;
	background: #000;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}

.ffarl-scrub-preview img {
	display: block;
	height: 90px;
	width: auto;
}

/* Mobile: stack side-positioned layouts -------------------------------------- */
@media (max-width: 640px) {
	.ffarl-playlist-body[data-filmstrip="left"],
	.ffarl-playlist-body[data-filmstrip="right"] {
		flex-direction: column;
	}

	.ffarl-playlist-body[data-filmstrip="left"] .ffarl-filmstrip,
	.ffarl-playlist-body[data-filmstrip="right"] .ffarl-filmstrip {
		flex-direction: row;
		flex-basis: auto;
		max-height: none;
		overflow-x: auto;
	}

	.ffarl-playlist-body[data-filmstrip="left"] .ffarl-filmstrip-item,
	.ffarl-playlist-body[data-filmstrip="right"] .ffarl-filmstrip-item {
		width: 172px;
	}
}
