/**
 * MediaPlyr — structural CSS
 * Layout and wrapper classes only; the looks (skins) are in skins/.
 * All classes are namespaced with .mp- to avoid conflicts.
 */

/* ============================================================
   Wrapper — all player modes share this
   ============================================================ */

/* Sized from the root, not the surrounding text: a player is interface, and inside a
   theme's reading column (17–20px prose) em-based rows grow heavy. A site that wants
   it bigger sets font-size on .mp-wrapper. */
.mp-wrapper {
	box-sizing: border-box;
	width: 100%;
	font-size: 1rem;
	line-height: 1.5;
	text-align: left;
}

.mp-wrapper .plyr {
	width: 100%;
}

/* The site's default color (MediaPlyr setting) arrives inline as
   --mp-default-color and becomes Plyr's main color here, at zero specificity, so
   any skin that sets its own --plyr-color-main wins over it. A color passed to one
   player arrives as --plyr-color-main inline and wins over the skin. */
:where(.mp-wrapper[style*="--mp-default-color"], .mp-btn-play[style*="--mp-default-color"]) {
	--plyr-color-main: var(--mp-default-color);
}

/* ============================================================
   Host-page reset

   Players are dropped into body text, where themes style lists for reading:
   indents, bullets, space between items (e.g. `.prose ol { padding-left }`,
   `.prose li { margin-bottom }`, UIkit's `* + ol { margin-top }`). Those rules
   carry a class AND an element, so a single .mp- class loses to them. These carry
   two classes and an element, which beats ordinary prose rules, and set only what
   a host page adds; padding on the rows is left to the skins.
   ============================================================ */

.mp-wrapper ol.mp-tracklist {
	margin: 0;
	padding: 0;
	list-style: none;
}

.mp-wrapper li.mp-track {
	margin: 0;
	list-style: none;
	text-indent: 0;
}

.mp-wrapper li.mp-track::marker { content: none; }
.mp-wrapper li.mp-track::before,
.mp-wrapper li.mp-track::after { content: none; }

/* ============================================================
   Track description (single + playlist header)
   ============================================================ */

.mp-track-desc {
	margin-bottom: 0.4em;
	font-size: 0.9em;
	line-height: 1.4;
}

.mp-track-title  { font-weight: 600; }
.mp-track-artist { opacity: 0.75; }
.mp-track-duration { opacity: 0.6; font-variant-numeric: tabular-nums; }

/* ============================================================
   Playlist
   ============================================================ */

/* The current track's title, kept up to date by media-player.js. Hidden unless a
   skin places it (SM2 Bar UI shows it inside the bar). */
.mp-now-playing { display: none; }

.mp-playlist { display: flex; flex-direction: column; gap: 0.75em; }
.mp-playlist--right { flex-direction: row; align-items: flex-start; }
.mp-playlist--right .mp-player-area { flex: 0 0 380px; }
.mp-playlist--right .mp-tracklist   { flex: 1; }

.mp-tracklist {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	flex-direction: column;
	gap: 2px;
}

.mp-track {
	display: flex;
	align-items: baseline;
	gap: 0.5em;
	padding: 0.45em 0.6em;
	border-radius: 4px;
	cursor: pointer;
	transition: background-color 0.15s;
	line-height: 1.4;
	font-size: 0.9em;
	user-select: none;
}

.mp-track:hover  { background-color: rgba(0, 0, 0, 0.05); }
.mp-track.mp-active { font-weight: 600; }

.mp-track-num {
	flex: 0 0 1.8em;
	text-align: right;
	opacity: 0.5;
	font-variant-numeric: tabular-nums;
	font-size: 0.85em;
}

/* ============================================================
   Button player
   ============================================================ */

.mp-btn-play {
	display: inline-flex;
	align-items: center;
	gap: 0.35em;
	padding: 0.25em 0.5em;
	border: 1px solid currentColor;
	border-radius: 3px;
	background: transparent;
	cursor: pointer;
	font-size: 0.85em;
	line-height: 1;
	opacity: 0.75;
	transition: opacity 0.15s;
}

.mp-btn-play:hover  { opacity: 1; }
.mp-btn-play.mp-playing { opacity: 1; font-weight: 600; }

/* SVG play/pause icon via CSS — no extra files needed */
.mp-btn-icon {
	display: inline-block;
	width: 0.9em;
	height: 0.9em;
	background-color: currentColor;
	mask-size: contain;
	mask-repeat: no-repeat;
	mask-position: center;
	-webkit-mask-size: contain;
	-webkit-mask-repeat: no-repeat;
	-webkit-mask-position: center;
}

.mp-btn-play:not(.mp-playing) .mp-btn-icon {
	mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M8 5v14l11-7z'/%3E%3C/svg%3E");
	-webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M8 5v14l11-7z'/%3E%3C/svg%3E");
}

.mp-btn-play.mp-playing .mp-btn-icon {
	mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M6 19h4V5H6v14zm8-14v14h4V5h-4z'/%3E%3C/svg%3E");
	-webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M6 19h4V5H6v14zm8-14v14h4V5h-4z'/%3E%3C/svg%3E");
}

/* The now-playing line, above the player so it reads as a caption to the progress bar.
   :empty keeps it out of the layout entirely until something names a track, so a site
   that never sends a title sees the bar exactly as it was. Clamped to two lines: a
   track title can run long and the bar must not grow under the page. */
.mp-shared-title {
	/* Inset to the controls' own line. The shared bar has no padding of its own and
	   clips at its rounded corners, so an unpadded line sits against the edge — which
	   is what it did on the Media Catalog dashboard. 10px matches the padding Plyr
	   puts on .plyr__controls, measured rather than assumed: Plyr compiles that
	   spacing in and exposes no custom property to follow. */
	padding: 0.7em 10px 0.5em;
	/* ITS OWN BACKGROUND, and this is not decoration. Until this line existed the bar
	   had exactly one child — Plyr, which paints its own surface — so the wrapper never
	   needed one. A transparent band over a dashboard showed the rows straight through
	   the title. A tint rather than plain white because the band reads better as a
	   header to the controls than as more of the same surface, and because that is what
	   it looked like over a grey page, which is the version Marc liked. */
	background: var(--plyr-audio-controls-background, #fff);
	box-shadow: inset 0 0 0 999px rgba(0, 0, 0, 0.035);
	border-bottom: 1px solid rgba(0, 0, 0, 0.07);
	font-size: 0.85em;
	line-height: 1.35;
	font-weight: 600;
	margin: 0 0 0.4em;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}
.mp-shared-title:empty { display: none; }

/* Dismiss, in the bar's own corner — the wrapper is position: fixed, so it is already
   the containing block. Drawn as a glyph rather than a button so it does not compete
   with the transport controls below it; faint until hovered, because it is the one
   control here that is about the player rather than about the music. */
.mp-shared-close {
	position: absolute;
	top: 0;
	right: 0;
	padding: 0.35em 0.6em;
	border: 0;
	background: none;
	color: inherit;
	opacity: 0.45;
	font-size: 1.1em;
	line-height: 1;
	cursor: pointer;
	transition: opacity 0.15s;
}
.mp-shared-close:hover { opacity: 0.9; }

/* Shared player — hidden by default, shown when active */
.mp-shared-wrap {
	display: none;
}
.mp-shared-wrap.mp-shared-active {
	display: block;
	/* The card's own surface. Plyr paints the controls area, so the wrapper got away
	   without one while the player was its only child; anything added above or below
	   it would float over whatever is behind the bar. */
	background: var(--plyr-audio-controls-background, #fff);
	position: fixed;
	bottom: 1rem;
	left: 50%;
	transform: translateX(-50%);
	width: min(480px, calc(100vw - 2rem));
	z-index: 9000;
	box-shadow: 0 4px 24px rgba(0, 0, 0, 0.2);
	border-radius: 8px;
	overflow: hidden;
}

/* ============================================================
   Mini player
   ============================================================ */

.mp-mini {
	display: flex;
	flex-direction: column;
	gap: 0.25em;
}

.mp-mini-meta {
	font-size: 0.875em;
	line-height: 1.4;
}

.mp-mini-title  { font-weight: 600; }
.mp-mini-artist { opacity: 0.7; }

/* ============================================================
   Responsive
   ============================================================ */

@media (max-width: 600px) {
	.mp-playlist--right {
		flex-direction: column;
	}
	.mp-playlist--right .mp-player-area {
		flex: none;
		width: 100%;
	}
}
