/* Riff. The player follows YouTube Music's layout and measurements: a
   72px bar on a wide screen and the 2025 Now Playing on a phone. It is
   always dark. Rows in the post use the theme's own colours through
   currentcolor. Animate only transform and opacity. */

/* Roboto, shipped with the plugin (SIL Open Font License, see
   fonts/roboto/OFL.txt) rather than fetched from Google, so a listener's
   address never leaves the site. One variable file, Latin only. */
@font-face {
	font-family: "Riff Roboto";
	font-style: normal;
	font-weight: 100 900;
	font-display: swap;
	src: url(fonts/roboto/roboto.woff2) format("woff2");
}

:root {

	/**
	 * The height of the player bar. The page keeps this much room at its end
	 * so the bar never covers the last line.
	 *
	 * @since 4.0.0
	 */
	--riff-bar-h: 64px;
	/* stylelint-disable-next-line length-zero-no-unit -- calc() needs a length. */
	--riff-safe-b: env(safe-area-inset-bottom, 0px);
	/* stylelint-disable-next-line length-zero-no-unit -- calc() needs a length. */
	--riff-safe-t: env(safe-area-inset-top, 0px);
}

@media (min-width: 900px) {

	:root {
		--riff-bar-h: 72px;
	}
}

/* Room at the end of the page, so the bar never covers a post's last line. */
html.has-riff body::after {
	content: "";
	display: block;
	height: calc(var(--riff-bar-h) + var(--riff-safe-b));
}

/* ---- Rows in the post */

.riff-track > audio[hidden],
.riff-track > video[hidden] {
	display: none !important;
}

/* A playlist block (WordPress 7.1): its own player and its track buttons step
   aside for the rows, and its item hover gives way to the row's. */
.riff-tracks > .wp-block-playlist__waveform-player,
.riff-track > .wp-block-playlist-track__button {
	display: none;
}

.riff-tracks .wp-block-playlist-track.riff-track,
.riff-tracks .wp-block-playlist-track.riff-track:hover {
	background: none;
}

.riff-row {
	all: unset;
	box-sizing: border-box;
	display: grid;
	grid-template-columns: 48px minmax(0, 1fr) auto auto;
	align-items: center;
	gap: 16px;
	width: 100%;
	padding: 8px;
	border-radius: 4px;
	color: inherit;
	font: inherit;
	cursor: pointer;
	-webkit-tap-highlight-color: transparent;
	transition: background-color 0.15s;
}

.riff-row:hover,
.riff-row[data-current] {
	background: color-mix(in srgb, currentcolor 8%, transparent);
}

.riff-row:focus-visible {
	outline: 2px solid currentcolor;
	outline-offset: 2px;
}

.riff-row-art {
	position: relative;
	display: block;
	width: 48px;
	height: 48px;
	border-radius: 4px;
	overflow: hidden;
	background: color-mix(in srgb, currentcolor 12%, transparent);
}

.riff-row-art img {
	display: block;
	width: 100%;
	height: 100%;
	max-width: none;
	margin: 0;
	object-fit: cover;
}

/* Bars over the art of the playing track. */
.riff-row-state {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: flex-end;
	justify-content: center;
	gap: 2px;
	padding-bottom: 30%;
	background: rgb(0 0 0 / 0.5);
	opacity: 0;
	transition: opacity 0.15s;
}

.riff-row-state i {
	width: 3px;
	height: 40%;
	background: #fff;
	border-radius: 1px;
	transform-origin: bottom;
	transform: scaleY(0.35);
}

[data-current] .riff-row-state,
[aria-current] .riff-row-state,
.riff-row:hover .riff-row-state {
	opacity: 1;
}

[data-playing="true"] .riff-row-state i {
	animation: riff-eq 0.9s ease-in-out infinite alternate;
}

[data-playing="true"] .riff-row-state i:nth-child(2) {
	animation-delay: -0.3s;
}

[data-playing="true"] .riff-row-state i:nth-child(3) {
	animation-delay: -0.6s;
}

@keyframes riff-eq {

	to {
		transform: scaleY(1);
	}
}

.riff-row-text {
	display: grid;
	min-width: 0;
}

.riff-row-title,
.riff-row-sub {
	overflow: hidden;
	white-space: nowrap;
	text-overflow: ellipsis;
}

.riff-row-title {
	font-weight: 500;
}

.riff-row-sub,
.riff-row-time {
	opacity: 0.7;
}

.riff-row-time {
	font-variant-numeric: tabular-nums;
}

/* The quality pill: format and bit rate for the playing track, as Tidal
   sets its tier at the right end of the bar. Centred with the controls. */
.riff-quality {
	display: inline-flex;
	align-items: center;
	flex: none;
	height: 28px;
	padding: 0 12px;
	border-radius: 999px;
	background: color-mix(in srgb, currentcolor 10%, transparent);
	color: var(--riff-accent);
	font-size: 12px;
	font-weight: 500;
	letter-spacing: 0.02em;
	white-space: nowrap;
	font-variant-numeric: tabular-nums;
}

.riff-quality:empty {
	display: none;
}

.riff-bar-end .riff-quality {
	margin-inline-end: 8px;
}

#riff .riff-np-quality {
	margin: 8px 0 0;
	color: var(--riff-fg-2);
	line-height: 1;
}

.riff-row .riff-row-dot {
	display: none;
}


/* The video mark: a small film icon after the title, in the row's ink. */
.riff-row-video {
	display: inline-block;
	width: 1em;
	height: 1em;
	margin-inline-start: 0.4em;
	vertical-align: -0.15em;
	opacity: 0.55;
}

.riff-row-video svg {
	display: block;
	width: 100%;
	height: 100%;
}

/* ---- The player. Theme styles stop at #riff. */

#riff {

	/**
	 * The background of the bar and Now Playing.
	 *
	 * @since 4.0.0
	 */
	--riff-bg: #030303;

	/**
	 * Raised surfaces in the player: the Up next sheet, menus, chips.
	 *
	 * @since 4.0.0
	 */
	--riff-surface: #212121;

	/**
	 * The player's text and icons.
	 *
	 * @since 4.0.0
	 */
	--riff-fg: #fff;

	/**
	 * Secondary text, such as the artist under a title.
	 *
	 * @since 4.0.0
	 */
	--riff-fg-2: rgb(255 255 255 / 0.7);

	/**
	 * Quiet text, such as times and counts.
	 *
	 * @since 4.0.0
	 */
	--riff-fg-3: rgb(255 255 255 / 0.5);

	/**
	 * Dividers and the unplayed part of the seek bar.
	 *
	 * @since 4.0.0
	 */
	--riff-line: rgb(255 255 255 / 0.1);

	/**
	 * The wash behind a control under the pointer.
	 *
	 * @since 4.0.0
	 */
	--riff-hover: rgb(255 255 255 / 0.1);

	/**
	 * The played part of the seek bar and the active controls. A theme sets it
	 * in theme.json under `settings.custom.riff.accent`, and the `riff_accent`
	 * filter has the last word.
	 *
	 * @since 4.0.0
	 */
	--riff-accent: #ffb020;
	--riff-tint: #303030;
	--riff-p: 0;
	position: relative;
	z-index: 100000;
	color: var(--riff-fg);
	font: 400 16px/1.2 "Riff Roboto", Roboto, system-ui, -apple-system, "Segoe UI", sans-serif;
	-webkit-font-smoothing: antialiased;
}

#riff[hidden],
#riff [hidden] {
	display: none !important;
}

#riff *,
#riff *::before,
#riff *::after {
	box-sizing: border-box;
}

/* Button classes below are written as #riff .class so they outweigh this reset
   and any theme's. */
#riff button {
	all: unset;
	box-sizing: border-box;
	cursor: pointer;
	-webkit-tap-highlight-color: transparent;
}

#riff button:focus-visible,
#riff input:focus-visible {
	outline: 2px solid var(--riff-fg);
	outline-offset: 2px;
	border-radius: 4px;
}

#riff h2,
#riff h3,
#riff p {
	margin: 0;
	padding: 0;
	color: inherit;
	font: inherit;
	letter-spacing: normal;
	text-transform: none;
}

#riff img {
	max-width: none;
	margin: 0;
	border: 0;
	box-shadow: none;
}

#riff svg {
	display: block;
	width: 24px;
	height: 24px;
}

#riff .riff-btn {
	display: inline-grid;
	place-items: center;
	flex: none;
	width: 40px;
	height: 40px;
	border-radius: 50%;
	color: var(--riff-fg);
	transition: background-color 0.15s;
}

#riff .riff-btn:hover {
	background: var(--riff-hover);
}

#riff .riff-btn[aria-pressed="false"] {
	color: var(--riff-fg-2);
}

/* Repeat shows its "one" glyph only in that mode. */
#riff [data-riff-action="repeat"] svg:last-child,
#riff [data-riff-action="repeat"][data-repeat="one"] svg:first-child {
	display: none;
}

#riff [data-riff-action="repeat"][data-repeat="one"] svg:last-child {
	display: block;
}

/* Play and pause share a button; the state picks the glyph. */
#riff .riff-play svg:last-child,
#riff[data-playing="true"] .riff-play svg:first-child {
	display: none;
}

#riff[data-playing="true"] .riff-play svg:last-child {
	display: block;
}

#riff[data-waiting] .riff-play {
	animation: riff-pulse 1s ease-in-out infinite alternate;
}

@keyframes riff-pulse {

	to {
		opacity: 0.5;
	}
}

/* ---- Seek lines. A native range sits on top of a drawn line. */

.riff-line {
	position: absolute;
	left: 0;
	right: 0;
	top: 50%;
	height: 2px;
	margin-top: -1px;
	background: var(--riff-line);
	pointer-events: none;
	transition: transform 0.1s;
}

.riff-line i {
	position: absolute;
	inset: 0;
	background: var(--riff-accent);
	transform-origin: left;
	transform: scaleX(var(--riff-p));
}

/* How far the file has loaded, a lighter band under the played part. */
.riff-line::before {
	content: "";
	position: absolute;
	inset: 0;
	background: color-mix(in srgb, currentcolor 22%, transparent);
	transform-origin: left;
	transform: scaleX(var(--riff-buffered, 0));
}

.riff-seek {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	margin: 0;
	opacity: 0;
	cursor: pointer;
}

.riff-knob,
.riff-tip {
	display: none;
}

/* The seek input is invisible, so its focus ring is drawn on the bar
   around it. */
#riff .riff-seek:focus-visible {
	outline: none;
}

.riff-bar-seek:has(> .riff-seek:focus-visible),
.riff-np-seek:has(> .riff-seek:focus-visible) {
	outline: 2px solid var(--riff-fg);
	outline-offset: 2px;
	border-radius: 4px;
}

/* Right to left: the played part grows from the right, and the knob
   sits at its end. */
[dir="rtl"] .riff-line i,
[dir="rtl"] .riff-line::before,
[dir="rtl"] .riff-wire,
[dir="rtl"] .riff-hot {
	transform-origin: right;
}

[dir="rtl"] .riff-knob {
	left: auto;
	right: calc(var(--riff-p) * 100%);
	margin: -7px -7px 0 0;
}

/* ---- The filament. riff.js writes one number a frame, --riff-heat, 0 cold
   to 1 white-hot; everything below derives from it. Registered, so it is a
   real number the browser can interpolate: the short transition on #riff
   turns the frame-by-frame writes into a flow. The colour is a filament's:
   near-black red barely lit, through the accent at working temperature, to a
   pale yellow-white at the peaks. Three layers over the played part of the
   line, static gradients that never repaint: the wire with a tight bloom and
   a white heart that shows only at the peaks. Where the waveform is drawn
   the glow moves into its played bars instead. */

@property --riff-heat {
	syntax: "<number>";
	inherits: true;
	initial-value: 0;
}

/* On the lines and the glow, where riff.js writes the heat, so nothing
   above them restyles each frame. */
.riff-line,
.riff-np-glow {
	--riff-heat: 0;
	--riff-heat-red: calc(min(1, var(--riff-heat) / 0.35));
	--riff-heat-amber: calc(clamp(0, (var(--riff-heat) - 0.35) / 0.35, 1));
	--riff-heat-white: calc(clamp(0, (var(--riff-heat) - 0.7) / 0.3, 1));
	--riff-glow: color-mix(in oklab, color-mix(in oklab, color-mix(in oklab, rgb(74 16 0), rgb(190 58 12) calc(var(--riff-heat-red) * 100%)), var(--riff-accent) calc(var(--riff-heat-amber) * 100%)), rgb(255 232 190) calc(var(--riff-heat-white) * 100%));
	transition: --riff-heat 160ms linear;
}

.riff-wire,
.riff-hot {
	position: absolute;
	inset: 0;
	transform-origin: left;
	transform: scaleX(var(--riff-p));
	will-change: opacity;
	pointer-events: none;
}

.riff-wire {
	color: var(--riff-glow);
	background: currentcolor;
	box-shadow: 0 0 6px 1px currentcolor;
	opacity: calc(0.25 + 0.75 * var(--riff-heat));
}

.riff-hot {
	/* stylelint-disable-next-line @stylistic/max-line-length */
	background: linear-gradient(90deg, transparent, #ffd2a8 30%, #fff1dc 50%, #ffd2a8 70%, transparent);
	box-shadow: 0 0 10px 2px rgb(255 232 200 / 0.6);
	opacity: calc(0.6 * var(--riff-heat) * var(--riff-heat) * var(--riff-heat));
}

/* The wire's heat washes the top of Now Playing on a phone, as a room
   brightening rather than a lamp switching. */
.riff-np-glow {
	position: absolute;
	left: 0;
	right: 0;
	top: 0;
	height: 220px;
	color: var(--riff-glow);
	/* stylelint-disable-next-line @stylistic/max-line-length */
	background: linear-gradient(180deg, color-mix(in srgb, currentcolor 40%, transparent), color-mix(in srgb, currentcolor 12%, transparent) 45%, transparent);
	opacity: calc(0.5 * var(--riff-heat) * var(--riff-heat));
	will-change: opacity;
	pointer-events: none;
}

/* With a live reading the bars follow it; the keyframes are for when there
   is none. */
html:has(#riff[data-live]) [data-playing="true"] .riff-row-state i {
	animation: none;
}

@media (prefers-reduced-transparency: reduce) {

	.riff-np-glow {
		display: none;
	}

	.riff-wire,
	.riff-hot {
		box-shadow: none;
	}
}

/* ---- The bar. On a phone: art, title and artist, Cast, play. Swipe it to
   skip. */

.riff-bar {
	position: fixed;
	left: 0;
	right: 0;
	bottom: 0;
	display: flex;
	align-items: center;
	gap: 4px;
	height: calc(var(--riff-bar-h) + var(--riff-safe-b));
	padding: 0 8px var(--riff-safe-b) 8px;
	background: var(--riff-surface);
}

/* On a phone the line runs along the top edge and is a readout, not a
   control. */
.riff-bar-seek {
	position: absolute;
	left: 0;
	right: 0;
	top: 0;
	height: 2px;
}

.riff-bar-seek .riff-line {
	top: 0;
	margin: 0;
}

.riff-bar-seek .riff-seek {
	pointer-events: none;
}

.riff-bar-start,
.riff-bar-end {
	display: flex;
	align-items: center;
}

.riff-bar-start {
	order: 3;
}

.riff-bar-end {
	order: 2;
}

#riff .riff-bar-info {
	order: 1;
	display: flex;
	flex: 1;
	align-items: center;
	gap: 12px;
	min-width: 0;
	height: 100%;
	touch-action: pan-y;
	transition: transform 0.2s;
}

#riff .riff-bar-info.is-dragging {
	transition: none;
}

.riff-thumb {
	flex: none;
	width: 40px;
	height: 40px;
	border-radius: 2px;
	overflow: hidden;
	background: var(--riff-hover);
}

.riff-thumb img {
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.riff-bar-text {
	display: grid;
	min-width: 0;
}

.riff-title,
.riff-sub {
	overflow: hidden;
	white-space: nowrap;
	text-overflow: ellipsis;
}

.riff-title {
	font-size: 15px;
	font-weight: 500;
}

.riff-sub {
	color: var(--riff-fg-2);
	font-size: 14px;
}

.riff-desk {
	display: none !important;
}

@media (min-width: 900px) {

	.riff-desk {
		display: inline-grid !important;
	}

	.riff-mobile {
		display: none !important;
	}

	/* Three columns: transport and time, the track, then volume, repeat,
	   shuffle and the caret. */
	.riff-bar {
		display: grid;

		/* The end column grows for the quality pill; the middle gives way and
		   its text trims, instead of running under the controls. */
		grid-template-columns: 328px minmax(0, 1fr) minmax(328px, auto);
		gap: 0;
		padding: 0 4px var(--riff-safe-b) 0;
	}

	.riff-bar-start,
	.riff-bar-end,
	#riff .riff-bar-info {
		order: 0;
	}

	.riff-bar-end {
		justify-content: flex-end;
		gap: 8px;
		padding-right: 8px;
	}

	#riff .riff-bar-info {
		justify-content: center;
		gap: 16px;
		cursor: pointer;
	}

	.riff-bar-text {
		max-width: 520px;
	}

	.riff-title,
	.riff-sub {
		font-size: 16px;
		line-height: 19.2px;
	}

	#riff .riff-skip-sm {
		width: 36px;
		height: 36px;
		margin: 4px 4px 4px 8px;
	}

	#riff .riff-bar .riff-play {
		width: 52px;
		height: 52px;
		margin: 4px 4px 4px 8px;
	}

	#riff .riff-bar .riff-play svg {
		width: 40px;
		height: 40px;
	}

	.riff-time {
		display: inline-block !important;
		margin: 0 16px 0 8px;
		color: #aaa;
		font-size: 12px;
		line-height: 14.4px;
		font-variant-numeric: tabular-nums;
		white-space: nowrap;
	}

	/* The seek line straddles the top edge: 2px, 4px with a knob and the time
	   while pointed at. */
	.riff-bar-seek {
		top: -15px;
		height: 32px;
	}

	.riff-bar-seek .riff-line {
		top: 15px;
	}

	.riff-bar-seek .riff-seek {
		pointer-events: auto;
	}

	.riff-bar-seek:hover .riff-line,
	#riff[data-seeking] .riff-bar-seek .riff-line {
		transform: scaleY(2);
	}

	.riff-knob {
		position: absolute;
		top: 16px;
		left: calc(var(--riff-p) * 100%);
		display: block;
		width: 14px;
		height: 14px;
		margin: -7px 0 0 -7px;
		pointer-events: none;
		border-radius: 50%;
		background: var(--riff-accent);
		opacity: 0;
		transition: opacity 0.1s;
	}

	.riff-bar-seek:hover .riff-knob {
		opacity: 1;
	}

	.riff-tip {
		position: absolute;
		bottom: 28px;
		display: block;
		padding: 4px 8px;
		border-radius: 2px;
		background: var(--riff-surface);
		color: var(--riff-fg);
		font-size: 12px;
		transform: translateX(-50%);
		pointer-events: none;
		white-space: nowrap;
	}

	/* Volume: the slider appears beside the icon while the pointer is over it. */
	.riff-volume {
		display: flex !important;
		align-items: center;
		gap: 8px;
		color: var(--riff-fg-2);
	}

	.riff-volume input {
		width: 100px;
		margin: 0;
		accent-color: var(--riff-fg);
		opacity: 0;
		transition: opacity 0.2s;
	}

	.riff-volume:hover input,
	.riff-volume input:focus-visible {
		opacity: 1;
	}

	/* Volume, repeat and shuffle sit back in #909090; the caret is white. */
	#riff .riff-bar-end .riff-btn,
	.riff-volume {
		color: #909090;
	}

	#riff .riff-bar-end .riff-btn[aria-pressed="true"],
	#riff .riff-bar-end .riff-chevron {
		color: var(--riff-fg);
	}

	#riff .riff-chevron svg {
		transition: transform 0.2s;
	}

	#riff .riff-chevron[aria-expanded="true"] svg {
		transform: rotate(180deg);
	}
}

/* ---- Now Playing on a phone */

.riff-np {
	position: fixed;
	inset: 0;
	display: flex;
	flex-direction: column;
	padding: var(--riff-safe-t) 0 var(--riff-safe-b);
	background: var(--riff-bg);
	overflow: hidden;
	transform: translateY(100%);
	transition: transform 0.32s cubic-bezier(0.2, 0, 0, 1);
}

.riff-np.is-in {
	transform: none;
}

/* The whole screen takes the artwork's colour, a little darker towards the
   bottom. */
.riff-np-bg {
	position: absolute;
	inset: 0;
	background: linear-gradient(var(--riff-tint), color-mix(in srgb, var(--riff-tint) 70%, #000));
	pointer-events: none;
}

.riff-np-head,
.riff-np-body,
.riff-np-mini {
	position: relative;
}

.riff-np-head {
	display: grid;
	flex: none;
	grid-template-columns: 1fr auto 1fr;
	align-items: center;
	height: 56px;
	padding: 0 12px;
	touch-action: none;
}

#riff .riff-np-head [data-riff-action="cast"] {
	grid-column: 3;
	justify-self: end;
}

/* Song and Video: two icons on a phone, two words on a wide screen. */
.riff-modes {
	grid-column: 2;
	display: flex;
	padding: 2px;
	border-radius: 999px;
	background: rgb(0 0 0 / 0.3);
}

#riff .riff-modes button {
	display: grid;
	place-items: center;
	width: 48px;
	height: 32px;
	border-radius: 999px;
	color: var(--riff-fg-3);
}

#riff .riff-modes button[aria-checked="true"] {
	background: var(--riff-hover);
	color: var(--riff-fg);
}

#riff .riff-modes svg {
	width: 20px;
	height: 20px;
}

.riff-modes span {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip-path: inset(50%);
	white-space: nowrap;
}

.riff-np-mini {
	display: none;
}

.riff-np-body {
	display: flex;
	flex: 1;
	flex-direction: column;
	min-height: 0;
}

.riff-stage {
	display: grid;
	flex: 1;
	place-items: center;
	min-height: 0;
	padding: 34px 32px 24px;
	container-type: size;
	touch-action: none;
}

.riff-cover,
.riff-video {
	grid-area: 1 / 1;
	border-radius: 8px;
}

.riff-cover {
	width: min(100cqw, 100cqh);
	height: min(100cqw, 100cqh);
	object-fit: cover;
	user-select: none;
}

.riff-video {
	display: none;
	width: 100cqw;
	max-height: 100cqh;
	aspect-ratio: 16 / 9;
	background: #000;
}

#riff[data-mode="video"] .riff-video {
	display: block;
}

#riff[data-mode="video"] .riff-cover {
	display: none;
}

.riff-np-panel {
	flex: none;
	padding: 0 32px;
}

#riff .riff-np-title {
	overflow: hidden;
	font-size: 24px;
	font-weight: 700;
	line-height: 1.25;
	white-space: nowrap;
	text-overflow: ellipsis;
}

#riff .riff-np-sub {
	overflow: hidden;
	margin-top: 2px;
	color: var(--riff-fg-2);
	font-size: 16px;
	line-height: 1.3;
	white-space: nowrap;
	text-overflow: ellipsis;
}

/* Boxy and thumbless; it doubles in height while held. */
.riff-np-seek {
	position: relative;
	height: 48px;
	margin-top: 20px;
}

.riff-np-seek .riff-line {
	top: 10px;
	height: 4px;
	margin: 0;
	border-radius: 2px;
	overflow: hidden;
	background: rgb(255 255 255 / 0.2);
	transform-origin: center;
}

.riff-np-seek .riff-line i {
	background: var(--riff-fg);
}

.riff-np-seek .riff-seek {
	height: 24px;
}

#riff[data-seeking] .riff-np-seek .riff-line {
	transform: scaleY(2);
}

.riff-np-times {
	position: absolute;
	left: 0;
	right: 0;
	bottom: 6px;
	display: flex;
	justify-content: space-between;
	color: var(--riff-fg-2);
	font-size: 14px;
	font-variant-numeric: tabular-nums;
	pointer-events: none;
}

.riff-np-controls {
	display: flex;
	align-items: center;
	justify-content: space-between;
	margin: 8px -8px 0;
}

#riff .riff-np-controls .riff-btn {
	width: 48px;
	height: 48px;
}

#riff .riff-skip svg {
	width: 36px;
	height: 36px;
}

#riff .riff-np-controls .riff-play-big {
	width: 72px;
	height: 72px;
	background: var(--riff-fg);
	color: #000;
}

#riff .riff-play-big:hover {
	background: var(--riff-fg);
	opacity: 0.9;
}

#riff .riff-play-big svg {
	width: 36px;
	height: 36px;
}

/* Actions as pills, in a row that scrolls sideways. */
.riff-chips {
	display: flex;
	gap: 8px;
	margin: 24px -32px 0;
	padding: 0 32px;
	overflow-x: auto;
	scrollbar-width: none;
}

#riff .riff-chip {
	display: inline-flex;
	flex: none;
	align-items: center;
	gap: 8px;
	height: 36px;
	padding: 0 16px;
	border-radius: 999px;
	background: var(--riff-hover);
	font-size: 14px;
	font-weight: 500;
}

#riff .riff-chip svg {
	width: 20px;
	height: 20px;
}

/* Up next: a handle and the source at the bottom, until it is opened. */
.riff-queue {
	position: relative;
	flex: none;
	display: flex;
	flex-direction: column;
	min-height: 0;
}

#riff .riff-peek {
	display: grid;
	justify-items: center;
	gap: 12px;
	padding: 16px 32px 24px;
	color: var(--riff-fg-2);
	font-size: 16px;
	font-weight: 500;
	touch-action: none;
}

.riff-handle {
	display: block;
	width: 36px;
	height: 4px;
	border-radius: 2px;
	background: rgb(255 255 255 / 0.4);
}

.riff-tabs,
.riff-queue-head,
.riff-queue-list {
	display: none;
}

.riff-queue-head {
	padding: 4px 24px 16px;
	border-bottom: 1px solid var(--riff-line);
}

#riff .riff-queue-head p {
	color: var(--riff-fg-2);
	font-size: 14px;
}

#riff .riff-queue-head h3 {
	margin-top: 4px;
	font-size: 16px;
	font-weight: 700;
}

.riff-queue-list {
	flex: 1;
	min-height: 0;
	margin: 0;
	padding: 8px 0 16px;
	overflow-y: auto;
	overscroll-behavior: contain;
	list-style: none;
}

.riff-queue-list li {
	margin: 0;
	padding: 0;
}

#riff .riff-queue-list button {
	display: grid;
	grid-template-columns: 48px minmax(0, 1fr);
	align-items: center;
	gap: 16px;
	width: 100%;
	height: 64px;
	padding: 0 24px;
}

#riff .riff-queue-list button:hover {
	background: var(--riff-hover);
}

#riff .riff-queue-list .riff-row-art {
	background: var(--riff-hover);
}

#riff .riff-queue-list .riff-row-sub {
	color: var(--riff-fg-2);
	font-size: 14px;
	opacity: 1;
}

#riff .riff-queue-list .riff-row-time {
	display: none;
}

#riff .riff-queue-list .riff-row-title {
	font-size: 16px;
}

#riff .riff-queue-list button:not([aria-current]) .riff-row-state {
	opacity: 0;
}

/* Split view: the art shrinks, the controls stay, the list takes the bottom of
   the screen. */
.riff-np[data-sheet="half"] .riff-stage {
	flex: none;
	height: 34vh;
	padding: 16px 32px 8px;
}

.riff-np[data-sheet="half"] .riff-chips {
	display: none;
}

.riff-np[data-sheet="half"] .riff-np-seek {
	margin-top: 12px;
}

.riff-np[data-sheet="half"] .riff-queue,
.riff-np[data-sheet="full"] .riff-queue {
	flex: 1;
	margin-top: 8px;
	border-radius: 16px 16px 0 0;
	background: var(--riff-surface);
}

.riff-np[data-sheet="half"] .riff-peek span,
.riff-np[data-sheet="full"] .riff-peek span {
	display: none;
}

#riff .riff-np[data-sheet="half"] .riff-peek,
#riff .riff-np[data-sheet="full"] .riff-peek {
	padding: 12px 0 8px;
}

.riff-np[data-sheet="half"] .riff-queue-head,
.riff-np[data-sheet="full"] .riff-queue-head {
	display: block;
}

.riff-np[data-sheet="half"] .riff-queue-list,
.riff-np[data-sheet="full"] .riff-queue-list {
	display: block;
}

/* Full: the player is one row above the sheet. */
.riff-np[data-sheet="full"] .riff-np-head,
.riff-np[data-sheet="full"] .riff-stage,
.riff-np[data-sheet="full"] .riff-np-panel {
	display: none;
}

.riff-np[data-sheet="full"] .riff-np-mini {
	display: flex;
	align-items: center;
	gap: 16px;
	flex: none;
	height: 88px;
	padding: 0 12px 0 16px;
}

.riff-np-mini .riff-bar-text {
	flex: 1;
}

.riff-thumb-lg {
	width: 48px;
	height: 48px;
}

.riff-toast {
	position: fixed;
	left: 50%;
	bottom: calc(var(--riff-bar-h) + var(--riff-safe-b) + 16px);
	z-index: 1;
	padding: 12px 16px;
	border-radius: 4px;
	background: #e6e6e6;
	color: #030303;
	font-size: 14px;
	transform: translateX(-50%);
}

@media (min-width: 900px) {

	/* On a wide screen Now Playing fills the space above the bar, and the bar
	   keeps the controls. */
	.riff-np {
		bottom: calc(var(--riff-bar-h) + var(--riff-safe-b));
		padding: 0;
	}

	.riff-np-bg,
	.riff-np-glow {
		display: none;
	}

	.riff-np-head {
		height: 64px;
		padding: 0 24px;
		touch-action: auto;
	}

	#riff .riff-modes {
		gap: 0;
		padding: 0;
		background: var(--riff-surface);
	}

	#riff .riff-modes button {
		width: auto;
		height: 32px;
		padding: 0 16px;
		color: var(--riff-fg-3);
		font-size: 16px;
		font-weight: 500;
	}

	#riff .riff-modes button[aria-checked="true"] {
		background: rgb(255 255 255 / 0.15);
		color: var(--riff-fg);
	}

	#riff .riff-modes svg {
		display: none;
	}

	.riff-modes span {
		position: static;
		width: auto;
		height: auto;
		overflow: visible;
		clip-path: none;
	}

	.riff-np-body {
		display: grid;
		grid-template-columns: minmax(0, 1fr) 392px;
		gap: 56px;
		padding: 0 56px;
	}

	.riff-stage {
		padding: 0 0 40px;
		touch-action: auto;
	}

	/* #riff img clears every theme's max-width; this rule outranks it so the
	   cap holds and the art stays square. */
	#riff .riff-cover {
		max-width: 640px;
		max-height: 640px;
	}

	.riff-video {
		max-width: 640px;
	}

	/* The caret in the bar and Escape close it; the page itself has no close
	   control. */
	#riff .riff-np-head [data-riff-action="close"] {
		display: none;
	}

	.riff-cover {
		border-radius: 4px;
	}

	.riff-video {
		border-radius: 0;
	}

	.riff-np-panel {
		display: none;
	}

	.riff-queue {
		height: 100%;
		min-height: 0;
	}

	#riff .riff-peek {
		display: none;
	}

	.riff-tabs {
		display: flex;
		flex: none;
		border-bottom: 1px solid var(--riff-line);
	}

	.riff-tab {
		display: flex;
		align-items: center;
		height: 48px;
		padding: 0 12px;
		box-shadow: inset 0 -2px 0 var(--riff-fg);
		font-size: 14px;
		font-weight: 500;
		text-transform: uppercase;
	}

	.riff-queue-head {
		display: block;
		margin: 16px 0;
		padding: 0;
		border: 0;
	}

	#riff .riff-queue-head p {
		font-size: 12px;
		line-height: 16.8px;
	}

	#riff .riff-queue-head h3 {
		margin: 0;
		font-size: 16px;
		font-weight: 500;
		line-height: 19.2px;
	}

	.riff-queue-list {
		display: block;
		padding: 0 0 24px;
	}

	.riff-queue-list li + li {
		border-top: 1px solid var(--riff-line);
	}

	#riff .riff-queue-list button {
		grid-template-columns: 32px minmax(0, 1fr) auto;
		gap: 16px;
		height: 56px;
		padding: 0 8px;
	}

	#riff .riff-queue-list button:hover {
		background: rgb(255 255 255 / 0.05);
	}

	#riff .riff-queue-list button[aria-current] {
		background: var(--riff-hover);
	}

	#riff .riff-queue-list .riff-row-art {
		width: 32px;
		height: 32px;
		border-radius: 2px;
	}

	#riff .riff-queue-list .riff-row-title {
		margin-bottom: 4px;
		font-size: 16px;
		line-height: 19.2px;
	}

	#riff .riff-queue-list .riff-row-sub {
		color: #aaa;
		font-size: 16px;
		line-height: 19.2px;
	}

	#riff .riff-queue-list .riff-row-dot {
		display: none;
	}

	#riff .riff-queue-list .riff-row-time {
		display: block;
		padding-left: 8px;
		color: #aaa;
		font-size: 16px;
		opacity: 1;
	}

	.riff-toast {
		left: 24px;
		transform: none;
	}
}

@media (max-height: 700px) and (max-width: 899px) {

	.riff-stage {
		padding-top: 8px;
	}

	.riff-chips {
		margin-top: 12px;
	}

	#riff .riff-peek {
		padding-bottom: 12px;
	}
}

@media (prefers-reduced-motion: reduce) {

	#riff,
	.riff-np,
	#riff .riff-bar-info,
	.riff-line,
	.riff-knob,
	.riff-np-glow {
		transition: none;
	}

	[data-playing="true"] .riff-row-state i,
	#riff[data-waiting] .riff-play {
		animation: none;
	}
}

/* ---- The app: the library and a post inside it, on the page that holds the
   block. Drawn in WordPress.org's own design system, a natural extension of
   it for a music player: its palette, Inter for text, EB Garamond for the
   headings, 2px corners. The two fonts are bundled (SIL Open Font License,
   see fonts/) and fetched only where the block renders. The bar and Now
   Playing keep their own dark look below. */

@font-face {
	font-family: "Riff Inter";
	font-style: normal;
	font-weight: 400 700;
	font-display: swap;
	src: url(fonts/inter/inter.woff2) format("woff2");
}

@font-face {
	font-family: "Riff Garamond";
	font-style: normal;
	font-weight: 400 700;
	font-display: swap;
	src: url(fonts/eb-garamond/eb-garamond.woff2) format("woff2");
}

.riff-app {
	font-weight: 400;
	letter-spacing: 0;

	/**
	 * The Listen block's background.
	 *
	 * @since 4.0.0
	 */
	--riff-app-bg: #f6f6f6;

	/**
	 * Cards and rows in the Listen block.
	 *
	 * @since 4.0.0
	 */
	--riff-app-surface: #fff;

	/**
	 * The Listen block's text.
	 *
	 * @since 4.0.0
	 */
	--riff-app-ink: #1e1e1e;

	/**
	 * Secondary text in the Listen block.
	 *
	 * @since 4.0.0
	 */
	--riff-app-ink-2: #656a71;

	/**
	 * Dividers and borders in the Listen block.
	 *
	 * @since 4.0.0
	 */
	--riff-app-line: #d9d9d9;

	/**
	 * Links and the selected item in the Listen block.
	 *
	 * @since 4.0.0
	 */
	--riff-app-accent: #3858e9;

	/**
	 * The accent under the pointer.
	 *
	 * @since 4.0.0
	 */
	--riff-app-accent-deep: #213fd4;

	/**
	 * The background of a selected item.
	 *
	 * @since 4.0.0
	 */
	--riff-app-accent-tint: #eff2ff;

	box-sizing: border-box;
	padding: clamp(40px, 5vw, 60px) clamp(20px, 5vw, 80px) clamp(60px, 6vw, 100px);
	background: var(--riff-app-bg);
	color: var(--riff-app-ink);
	font-family: "Riff Inter", Inter, -apple-system, BlinkMacSystemFont, sans-serif;
	font-size: 16px;
	line-height: 1.875;
	-webkit-font-smoothing: antialiased;
}

.riff-app *,
.riff-app *::before,
.riff-app *::after {
	box-sizing: border-box;
}

.riff-app[aria-busy="true"] .riff-app-view {
	opacity: 0.6;
	transition: opacity 0.2s;
}

/* wordpress.org's content width: whatever the block's alignment, what it
   holds sits in a 1160px column, the library grid and the strip above it
   sharing one edge. */
.riff-app > * {
	max-width: 1160px;
	margin-left: auto;
	margin-right: auto;
}

.riff-app-bar {
	display: flex;
	align-items: center;
	height: 40px;
	margin-bottom: 8px;
}

.riff-app .riff-app-home {
	display: inline-flex;
	align-items: center;
	min-height: 44px;
	color: var(--riff-app-accent);
	font-size: 14px;
	font-weight: 400;
	text-decoration: underline;
	text-underline-offset: 3px;
}

/* While the library itself is showing, the link to it says nothing. */
.riff-app:has(.riff-app-title) .riff-app-home {
	visibility: hidden;
}

.riff-app .riff-app-home:hover,
.riff-app .riff-app-home:focus-visible {
	color: var(--riff-app-accent-deep);
}

.riff-app h2 {
	margin: 0;
	color: inherit;
	font-family: "Riff Garamond", "EB Garamond", Garamond, Georgia, serif;
	font-weight: 400;
	letter-spacing: 0;
}

.riff-app h2:focus {
	outline: none;
}

.riff-app .riff-app-title {
	margin-bottom: 32px;
	font-size: clamp(36px, 4vw, 50px);
	line-height: 1.2;
}

.riff-app .riff-app-empty {
	margin: 0;
	color: var(--riff-app-ink-2);
}

/* The library grid: square art, two lines under it. */
.riff-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
	gap: 32px 24px;
}

/* A card is a link and a play button side by side, never one inside the
   other: the link stretches over the whole card through its ::after, and
   the button sits above that. */
.riff-app .riff-card {
	position: relative;
	display: grid;
	gap: 2px;
}

.riff-app .riff-card-link {
	color: inherit;
	text-decoration: none;
}

.riff-app .riff-card-link::after {
	content: "";
	position: absolute;
	inset: 0;
}

.riff-app .riff-card-link:focus-visible {
	outline: none;
}

.riff-app .riff-card:has(> .riff-card-link:focus-visible) {
	outline: 2px solid var(--riff-app-accent);
	outline-offset: 4px;
}

.riff-card-art {
	display: block;
	aspect-ratio: 1;
	margin-bottom: 12px;
	border-radius: 2px;
	overflow: hidden;
	background: var(--riff-app-line);
	box-shadow: 0 1px 2px rgb(0 0 0 / 0.08);
	transition: box-shadow 0.2s;
}

.riff-card-art img {
	display: block;
	width: 100%;
	height: 100%;
	max-width: none;
	margin: 0;
	object-fit: cover;
}

.riff-card:hover .riff-card-art {
	box-shadow: 0 8px 24px -8px rgb(30 30 30 / 0.35);
}

.riff-card-title {
	display: block;
	overflow: hidden;
	font-weight: 600;
	white-space: nowrap;
	text-overflow: ellipsis;
}

.riff-card:hover .riff-card-title {
	color: var(--riff-app-accent);
	text-decoration: underline;
	text-underline-offset: 3px;
}

.riff-card-sub {
	display: block;
	overflow: hidden;
	color: var(--riff-app-ink-2);
	font-size: 14px;
	line-height: 1.714;
	white-space: nowrap;
	text-overflow: ellipsis;
}

/* Play from a cover: a blueberry button that appears when the cover is
   pointed at or focused, as every streaming app has. */
.riff-card-art {
	position: relative;
}

.riff-app .riff-card-play {
	all: unset;
	position: absolute;
	z-index: 1;
	right: 12px;
	bottom: 12px;
	display: grid;
	place-items: center;
	width: 44px;
	height: 44px;
	border-radius: 50%;
	background: var(--riff-app-accent);
	color: #fff;
	box-shadow: 0 4px 12px rgb(0 0 0 / 0.3);
	opacity: 0;
	transform: translateY(6px);
	cursor: pointer;
	transition: opacity 0.15s, transform 0.15s, background-color 0.15s;
}

.riff-app .riff-card-play svg {
	width: 26px;
	height: 26px;
}

.riff-card:hover .riff-card-play,
.riff-app .riff-card-play:focus-visible {
	opacity: 1;
	transform: none;
}

.riff-app .riff-card-play:hover {
	background: var(--riff-app-accent-deep);
}

.riff-app .riff-card-play:focus-visible {
	outline: 2px solid #fff;
	outline-offset: 2px;
}

@media (hover: none) {

	.riff-app .riff-card-play {
		opacity: 1;
		transform: none;
	}
}

/* Now playing, at the top of the library: a way back to what is on. */
.riff-now {
	display: flex;
	align-items: center;
	gap: 16px;
	margin: 0 auto 32px;
	padding: 12px 16px;
	border: 1px solid var(--riff-app-line);
	border-radius: 2px;
	background: var(--riff-app-surface);
}

.riff-now-art {
	display: block;
	flex: none;
	width: 56px;
	height: 56px;
	border-radius: 2px;
	overflow: hidden;
	background: var(--riff-app-line);
}

.riff-now-art img {
	display: block;
	width: 100%;
	height: 100%;
	max-width: none;
	margin: 0;
	object-fit: cover;
}

.riff-now-text {
	display: grid;
	flex: 1;
	min-width: 0;
}

/* A label, as wordpress.org sets one: quiet and tracked, the accent kept
   for links. */
.riff-now-label {
	color: var(--riff-app-ink-2);
	font-size: 12px;
	font-weight: 600;
	letter-spacing: 0.04em;
	text-transform: uppercase;
}

.riff-now-title,
.riff-now-sub {
	overflow: hidden;
	white-space: nowrap;
	text-overflow: ellipsis;
}

.riff-now-title {
	font-weight: 600;
}

.riff-now-sub {
	color: var(--riff-app-ink-2);
	font-size: 14px;
}

.riff-app .riff-app-more {
	margin: 32px 0 0;
	text-align: center;
}

.riff-app .riff-pill:disabled {
	opacity: 0.5;
	cursor: progress;
}

/* The browser's own view transition between the library and a post. */
@media (prefers-reduced-motion: no-preference) {

	::view-transition-old(root),
	::view-transition-new(root) {
		animation-duration: 0.22s;
	}
}

/* A post opened: one line, the title and byline beside Play and Shuffle,
   then the rows the post itself has, on a white card. */
.riff-album {
	display: flex;
	max-width: 960px;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 16px 24px;
	margin-bottom: 24px;
}

.riff-album-text {
	min-width: 0;
}

.riff-app .riff-album-title {
	font-size: clamp(30px, 3.5vw, 50px);
	line-height: 1.2;
	text-wrap: balance;
}

.riff-app .riff-album-meta {
	margin: 4px 0 0;
	color: var(--riff-app-ink-2);
	font-size: 14px;
	line-height: 1.714;
}

.riff-app .riff-album-actions {
	display: flex;
	flex: none;
	gap: 8px;
	margin: 0;
}

.riff-app .riff-pill {
	all: unset;
	display: inline-flex;
	align-items: center;
	height: 44px;
	padding: 0 24px;
	border: 1px solid var(--riff-app-ink);
	border-radius: 2px;
	font: inherit;
	font-size: 16px;
	line-height: 1;
	cursor: pointer;
	transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}

.riff-app .riff-pill:hover {
	background: var(--riff-app-ink);
	color: #fff;
}

.riff-app .riff-pill:focus-visible {
	outline: 2px solid var(--riff-app-accent);
	outline-offset: 2px;
}

.riff-app .riff-pill-solid {
	border-color: var(--riff-app-accent);
	background: var(--riff-app-accent);
	color: #fff;
}

.riff-app .riff-pill-solid:hover {
	border-color: var(--riff-app-accent-deep);
	background: var(--riff-app-accent-deep);
}

.riff-album-tracks {
	max-width: 960px;
	padding: 8px;
	border: 1px solid var(--riff-app-line);
	border-radius: 2px;
	background: var(--riff-app-surface);
}

.riff-app .riff-track {
	margin: 0;
}

.riff-app .riff-row {
	border-radius: 2px;
}

.riff-app .riff-row:hover,
.riff-app .riff-row[data-current] {
	background: var(--riff-app-accent-tint);
}

.riff-app .riff-row-art {
	border-radius: 2px;
}
