/**
 * Music Player — floating pill, pinned bottom-center.
 *
 * Customization hooks (override in your theme CSS):
 *   #mplay-root { --mplay-accent: #2ee6a8; --mplay-bottom: 18px; --mplay-bg: rgba(17,18,22,.82); }
 */

#mplay-root {
	--mplay-accent: #2ee6a8;
	--mplay-accent-rgb: 46, 230, 168;
	--mplay-bg: rgba(17, 18, 22, 0.82);
	--mplay-border: rgba(255, 255, 255, 0.09);
	--mplay-text: #f5f6f7;
	--mplay-bottom: 18px;
	--mplay-z: 99999;

	position: fixed;
	left: 50%;
	transform: translateX(-50%);
	bottom: calc(var(--mplay-bottom) + env(safe-area-inset-bottom, 0px));
	z-index: var(--mplay-z);
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, "Helvetica Neue", Arial, sans-serif;
	font-size: 13px;
	line-height: 1.25;
	-webkit-font-smoothing: antialiased;
	text-rendering: optimizeLegibility;
	direction: ltr;
}

#mplay-root *,
#mplay-root *::before,
#mplay-root *::after {
	box-sizing: border-box;
	margin: 0;
	padding: 0;
}

#mplay-root .mplay-pill {
	display: flex;
	align-items: center;
	background: var(--mplay-bg);
	-webkit-backdrop-filter: blur(16px) saturate(1.6);
	backdrop-filter: blur(16px) saturate(1.6);
	border: 1px solid var(--mplay-border);
	border-radius: 999px;
	padding: 5px;
	box-shadow: 0 12px 32px rgba(0, 0, 0, 0.38), 0 2px 8px rgba(0, 0, 0, 0.28);
	transition: box-shadow 0.3s ease, transform 0.3s ease;
}

#mplay-root .mplay-pill:hover {
	transform: translateY(-1px);
	box-shadow: 0 16px 40px rgba(0, 0, 0, 0.42), 0 3px 10px rgba(0, 0, 0, 0.3);
}

/* --- progress ring + play/pause button --- */

#mplay-root .mplay-ringwrap {
	flex: 0 0 auto;
	width: 44px;
	height: 44px;
	border-radius: 50%;
	padding: 3px;
	position: relative;
	background: conic-gradient(var(--mplay-accent) calc(var(--p, 0) * 1turn), rgba(255, 255, 255, 0.14) 0);
}

#mplay-root .mplay-btn {
	appearance: none;
	-webkit-appearance: none;
	border: 0;
	outline: 0;
	cursor: pointer;
	width: 38px;
	height: 38px;
	border-radius: 50%;
	background: #fff;
	color: #0d0e11;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: transform 0.15s ease;
	box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
}

#mplay-root .mplay-btn:hover { transform: scale(1.05); background: #fff; }
#mplay-root .mplay-btn:active { transform: scale(0.94); }
#mplay-root .mplay-btn:focus-visible { box-shadow: 0 0 0 3px rgba(var(--mplay-accent-rgb), 0.55); }

#mplay-root .mplay-ic {
	width: 20px;
	height: 20px;
	fill: currentColor;
	display: block;
	pointer-events: none;
}

#mplay-root .mplay-ic-play { margin-left: 2px; }
#mplay-root .mplay-ic-pause { display: none; }

#mplay-root[data-state="playing"] .mplay-ic-play,
#mplay-root[data-state="loading"] .mplay-ic-play { display: none; }
#mplay-root[data-state="playing"] .mplay-ic-pause,
#mplay-root[data-state="loading"] .mplay-ic-pause { display: block; }

/* buffering spinner overlaid on the ring */
#mplay-root .mplay-ringwrap::after {
	content: "";
	position: absolute;
	inset: -2px;
	border-radius: 50%;
	border: 2px solid transparent;
	border-top-color: var(--mplay-accent);
	opacity: 0;
	pointer-events: none;
}

#mplay-root[data-state="loading"] .mplay-ringwrap::after {
	opacity: 1;
	animation: mplay-spin 0.9s linear infinite;
}

@keyframes mplay-spin { to { transform: rotate(1turn); } }

/* --- collapsible meta section (cover / title / clock) --- */

#mplay-root .mplay-meta {
	display: flex;
	align-items: center;
	gap: 10px;
	max-width: 0;
	opacity: 0;
	overflow: hidden;
	transform: translateX(-6px);
	padding: 0;
	white-space: nowrap;
	transition:
		max-width 0.45s cubic-bezier(0.22, 0.61, 0.36, 1),
		padding 0.45s cubic-bezier(0.22, 0.61, 0.36, 1),
		transform 0.45s cubic-bezier(0.22, 0.61, 0.36, 1),
		opacity 0.3s ease 0.08s;
}

#mplay-root:not([data-state="idle"]) .mplay-meta {
	max-width: 300px;
	opacity: 1;
	transform: none;
	padding: 0 16px 0 10px;
}

#mplay-root .mplay-coverwrap {
	flex: 0 0 auto;
	width: 34px;
	height: 34px;
	border-radius: 8px;
	overflow: hidden;
	position: relative;
	background: linear-gradient(135deg, #2b2d33, #3a3d46);
	box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.07);
}

#mplay-root .mplay-cover {
	width: 100%;
	height: 100%;
	max-width: 100%;
	object-fit: cover;
	display: block;
	border: 0;
	border-radius: 0;
}

#mplay-root .mplay-cover-fb {
	position: absolute;
	inset: 0;
	margin: auto;
	width: 16px;
	height: 16px;
	fill: rgba(255, 255, 255, 0.75);
	display: none;
}

#mplay-root.mplay-nocover .mplay-cover { display: none; }
#mplay-root.mplay-nocover .mplay-cover-fb { display: block; }

#mplay-root .mplay-info {
	display: flex;
	flex-direction: column;
	justify-content: center;
	min-width: 0;
	gap: 2px;
}

#mplay-root .mplay-title {
	color: var(--mplay-text);
	font-weight: 600;
	font-size: 12.5px;
	letter-spacing: 0.01em;
	max-width: 200px;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

/* the "digital clock" countdown */
#mplay-root .mplay-time {
	font-family: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
	font-variant-numeric: tabular-nums;
	font-size: 11.5px;
	font-weight: 500;
	letter-spacing: 0.09em;
	color: var(--mplay-accent);
	text-shadow:
		0 0 7px rgba(var(--mplay-accent-rgb), 0.65),
		0 0 18px rgba(var(--mplay-accent-rgb), 0.25);
}

/* --- error state --- */

#mplay-root[data-state="error"] .mplay-time {
	color: #ff6b6b;
	text-shadow: 0 0 7px rgba(255, 107, 107, 0.6);
}

#mplay-root[data-state="error"] .mplay-title { color: #ffb4b4; }

/* --- responsive / a11y / print --- */

@media (max-width: 480px) {
	#mplay-root .mplay-title { max-width: 150px; }
	#mplay-root:not([data-state="idle"]) .mplay-meta { max-width: 240px; }
}

@media (prefers-reduced-motion: reduce) {
	#mplay-root .mplay-pill,
	#mplay-root .mplay-btn,
	#mplay-root .mplay-meta { transition: none; }
	#mplay-root[data-state="loading"] .mplay-ringwrap::after { animation-duration: 2s; }
}

@media print {
	#mplay-root { display: none; }
}
