/**
 * Mortise Stream — 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 --mstream-* variables below,
 * scoped per wrapper through the .mstream-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 ------------------------------------------------ */
.mstream-player-wrap,
.mstream-playlist-wrap,
.mstream-series-wrap {
	/* Scheme-overridable design tokens (neutral defaults). */
	--mstream-accent: #2271b1;        /* highlight: active item, hovers, ticks  */
	--mstream-accent-ink: #ffffff;    /* text color placed ON the accent color  */
	--mstream-surface: rgba(127, 127, 127, 0.07);  /* card / chip backgrounds   */
	--mstream-border: rgba(127, 127, 127, 0.22);   /* card / chip borders       */
	--mstream-radius: 10px;           /* card + pill corner radius              */

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

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

/* Player-only: strip the scheme's card framing so nothing surrounds the video.
   Targets the properties directly (the scheme only sets the --mstream-* vars),
   so it wins regardless of the active scheme. */
.mstream-player-wrap.mstream-player-only {
	gap: 0;
	padding: 0;
	background: transparent;
	border-radius: 0;
	box-shadow: none;
}

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

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

/* Members-only gate shown in place of a private video the viewer cannot watch. */
.mstream-gated {
	aspect-ratio: 16 / 9;
	display: flex;
	align-items: center;
	justify-content: center;
	text-align: center;
	padding: 1.5rem;
	background: #14110f;
	color: #f0ebe2;
	border-radius: var(--mstream-player-radius, calc(var(--mstream-radius) - 2px));
}
.mstream-gated-message {
	margin: 0 0 1rem;
	font-size: 1.05rem;
}
.mstream-gated-login {
	display: inline-block;
	padding: 0.55rem 1.2rem;
	background: var(--mstream-accent, #c17d3c);
	color: #14110f;
	text-decoration: none;
	font-weight: 600;
	border-radius: var(--mstream-radius, 6px);
}

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

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

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

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

.mstream-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(--mstream-surface);
	border: 1px solid var(--mstream-border);
	color: var(--mstream-text, inherit);
	transition: background-color 0.16s ease, color 0.16s ease,
		border-color 0.16s ease, transform 0.16s ease;
}

.mstream-resource-pill:hover,
.mstream-resource-pill:focus-visible {
	background: var(--mstream-accent);
	border-color: var(--mstream-accent);
	color: var(--mstream-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. */
.mstream-player-wrap .mstream-collection-title,
.mstream-playlist-wrap .mstream-collection-title,
.mstream-series-wrap .mstream-collection-title {
	display: flex;
	align-items: center;
	gap: 12px;
	margin: 0;
	padding: 0;
	font-family: var(--mstream-font-display, inherit);
	font-size: clamp(20px, 3.2vw, 27px);
	font-weight: 750;
	line-height: 1.2;
	letter-spacing: var(--mstream-display-tracking, -0.015em);
	text-transform: none;
	color: var(--mstream-text, inherit);
}

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

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

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

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

.mstream-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. */
.mstream-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). */
.mstream-playlist-body[data-filmstrip="left"],
.mstream-playlist-body[data-filmstrip="right"] {
	flex-direction: row;
	align-items: flex-start;
}

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

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

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

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

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

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

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

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

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

.mstream-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. */
.mstream-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;
}

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

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

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

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

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

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

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

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

.mstream-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. */
.mstream-filmstrip .mstream-filmstrip-item .mstream-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(--mstream-text, inherit);
}

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

/* Filmstrip search ----------------------------------------------------------
   A scheme-styled search field that filters the filmstrip(s) by title. Matches
   are kept in DOM order; non-matches get .mstream-filmstrip-item--hidden and a
   fully-filtered season gets .mstream-series-season--empty. */
.mstream-filmstrip-search {
	position: relative;
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	width: 100%;
}

.mstream-filmstrip-search-icon {
	position: absolute;
	left: 13px;
	top: 50%;
	width: 17px;
	height: 17px;
	margin-top: -8.5px;
	color: var(--mstream-muted, inherit);
	pointer-events: none;
}

/* When the no-results line shows, it wraps below the field, so pin the icon to
   the input's own height rather than the flex container's. */
.mstream-filmstrip-search:has(.mstream-filmstrip-search-empty:not([hidden])) .mstream-filmstrip-search-icon {
	top: 21px;
}

.mstream-filmstrip-search-input {
	flex: 1 1 100%;
	min-width: 0;
	box-sizing: border-box;
	margin: 0;
	padding: 10px 14px 10px 38px;
	font-family: var(--mstream-font-body, inherit);
	font-size: 14.5px;
	line-height: 1.4;
	color: var(--mstream-text, inherit);
	background: var(--mstream-surface);
	border: 1px solid var(--mstream-border);
	border-radius: var(--mstream-radius);
	transition: border-color 0.18s ease, box-shadow 0.18s ease;
	-webkit-appearance: none;
	appearance: none;
}

.mstream-filmstrip-search-input::placeholder {
	color: var(--mstream-muted, inherit);
	opacity: 0.85;
}

.mstream-filmstrip-search-input:focus {
	outline: none;
	border-color: var(--mstream-accent);
	box-shadow: 0 0 0 1.5px var(--mstream-accent);
}

.mstream-filmstrip-search-empty {
	flex: 1 1 100%;
	margin: 8px 0 0;
	padding: 0 2px;
	font-family: var(--mstream-font-body, inherit);
	font-size: 13.5px;
	color: var(--mstream-muted, inherit);
}

/* Filtered-out items and empty seasons are hidden but kept in the DOM so the
   player controllers' positional index mapping stays intact. */
.mstream-filmstrip-item--hidden,
.mstream-series-season--empty {
	display: none !important;
}

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

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

/* Auto-advance countdown overlay --------------------------------------------- */
.mstream-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;
}

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

.mstream-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;
}

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

/* Seek-bar scrub preview (self-hosted engine) -------------------------------- */
.mstream-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);
}

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

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

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

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