/* ==========================================================================
   Starwood Radio — the broadcast player.

   A deliberately different shape from the catalogue player: no progress track to
   drag, no skip buttons, and a waveform where a seek bar would be. It reads as a
   live tuner rather than a transport, so nobody looks for controls that a
   broadcast cannot offer.

   Colours come from the existing --ms-* glass tokens; a station may override
   --ms-rp-accent from its own configuration.
   ========================================================================== */

.ms-rp {
	--ms-rp-accent: var(--ms-accent, #43b2cd);
	--ms-rp-bg:     rgba(16, 18, 24, .82);
	--ms-rp-text:   var(--ms-text, #f3f4f8);
	--ms-rp-dim:    var(--ms-text-dim, rgba(243, 244, 248, .62));

	position: fixed;
	z-index: 9998;             /* below modals, above page furniture */
	left: 50%;
	bottom: 18px;
	transform: translate(-50%, 140%);
	width: min(680px, calc(100vw - 24px));

	display: flex;
	align-items: center;
	gap: 12px;
	padding: 10px 14px;

	background: var(--ms-rp-bg);
	backdrop-filter: blur(18px) saturate(150%);
	-webkit-backdrop-filter: blur(18px) saturate(150%);
	border: 1px solid rgba(255, 255, 255, .12);
	border-radius: 18px;
	box-shadow: 0 18px 50px rgba(0, 0, 0, .45);
	color: var(--ms-rp-text);

	opacity: 0;
	pointer-events: none;
	transition: transform .32s cubic-bezier(.2, .8, .3, 1), opacity .32s ease;
}

.ms-rp.is-open {
	transform: translate(-50%, 0);
	opacity: 1;
	pointer-events: auto;
}

/* A thin live-accent hairline along the top edge. */
.ms-rp::before {
	content: "";
	position: absolute;
	inset: 0 0 auto 0;
	height: 2px;
	border-radius: 18px 18px 0 0;
	background: linear-gradient(90deg, transparent, var(--ms-rp-accent), transparent);
	opacity: 0;
	transition: opacity .3s ease;
}

.ms-rp.is-live::before { opacity: .9; }

/* ── Play / stop ─────────────────────────────────────────────────────────── */

.ms-rp__btn {
	flex: 0 0 auto;
	width: 44px;
	height: 44px;
	display: grid;
	place-items: center;
	border: 0;
	border-radius: 50%;
	cursor: pointer;
	color: #fff;
	background: var(--ms-rp-accent);
	box-shadow: 0 6px 18px -6px var(--ms-rp-accent);
	transition: transform .18s ease, filter .18s ease;
}

.ms-rp__btn:hover  { transform: scale(1.06); filter: brightness(1.08); }
.ms-rp__btn:active { transform: scale(.96); }

.ms-rp.is-loading .ms-rp__btn {
	animation: ms-rp-breathe 1.1s ease-in-out infinite;
}

@keyframes ms-rp-breathe {
	0%, 100% { opacity: 1; }
	50%      { opacity: .55; }
}

/* ── Station identity ────────────────────────────────────────────────────── */

.ms-rp__id {
	flex: 1 1 auto;
	min-width: 0;
	display: flex;
	align-items: center;
	gap: 10px;
	text-decoration: none;
	color: inherit;
}

.ms-rp__art {
	flex: 0 0 auto;
	width: 40px;
	height: 40px;
	border-radius: 10px;
	object-fit: cover;
	background: rgba(255, 255, 255, .08);
}

.ms-rp__art--empty {
	display: grid;
	place-items: center;
	font-size: 20px;
}

.ms-rp__text {
	min-width: 0;
	display: flex;
	flex-direction: column;
	gap: 1px;
	line-height: 1.25;
}

.ms-rp__station {
	display: flex;
	align-items: center;
	gap: 6px;
	font-size: .68rem;
	font-weight: 800;
	letter-spacing: .1em;
	text-transform: uppercase;
	color: var(--ms-rp-accent);
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.ms-rp__dot {
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: #ff4d4d;
	flex: 0 0 auto;
}

.ms-rp.is-live .ms-rp__dot {
	animation: ms-rp-pulse 1.8s ease-out infinite;
}

@keyframes ms-rp-pulse {
	0%   { box-shadow: 0 0 0 0 rgba(255, 77, 77, .7); }
	70%  { box-shadow: 0 0 0 7px rgba(255, 77, 77, 0); }
	100% { box-shadow: 0 0 0 0 rgba(255, 77, 77, 0); }
}

.ms-rp__track {
	font-weight: 700;
	font-size: .92rem;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

/* Ad-break marker — a broadcast must never pass an advert off as a song. */
.ms-rp__tag {
	display: inline-block;
	margin-right: 6px;
	padding: 1px 5px;
	border-radius: 4px;
	font-size: .6rem;
	font-weight: 800;
	letter-spacing: .08em;
	vertical-align: 1px;
	background: rgba(255, 255, 255, .16);
	color: var(--ms-rp-text);
}

.ms-rp__artist,
.ms-rp__msg {
	font-size: .78rem;
	color: var(--ms-rp-dim);
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

/* ── Waveform ────────────────────────────────────────────────────────────────
   Stands in for the progress bar. It is honest decoration: a listener cannot move
   through a broadcast, so showing a draggable position would promise a control
   that does not exist. Pure CSS, so it costs nothing when the station is idle.  */

.ms-rp__wave {
	flex: 0 0 auto;
	display: flex;
	align-items: flex-end;
	gap: 2px;
	height: 26px;
	padding: 0 2px;
}

.ms-rp__wave span {
	width: 3px;
	height: 20%;
	border-radius: 2px;
	background: linear-gradient(180deg, var(--ms-rp-accent), rgba(255, 255, 255, .35));
	opacity: .35;
	transform-origin: bottom;
}

.ms-rp.is-live .ms-rp__wave span {
	opacity: 1;
	animation: ms-rp-bar 1s ease-in-out infinite alternate;
	/* Each bar is offset from its neighbour, which is what reads as a waveform
	   rather than 28 bars blinking in unison. */
	animation-delay: calc(var(--i) * -73ms);
	animation-duration: calc(760ms + (var(--i) * 21ms));
}

@keyframes ms-rp-bar {
	from { height: 15%; }
	to   { height: 100%; }
}

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

	.ms-rp.is-live .ms-rp__wave span,
	.ms-rp.is-live .ms-rp__dot,
	.ms-rp.is-loading .ms-rp__btn {
		animation: none;
	}

	.ms-rp.is-live .ms-rp__wave span { height: 55%; }
}

/* ── Time remaining ──────────────────────────────────────────────────────── */

.ms-rp__ends {
	flex: 0 0 auto;
	font-size: .74rem;
	font-variant-numeric: tabular-nums;
	color: var(--ms-rp-dim);
	min-width: 42px;
	text-align: right;
}

/* ── Volume — the only real control ──────────────────────────────────────── */

.ms-rp__vol {
	flex: 0 0 auto;
	display: flex;
	align-items: center;
	gap: 6px;
}

.ms-rp__mute {
	border: 0;
	background: none;
	color: var(--ms-rp-dim);
	cursor: pointer;
	padding: 4px;
	display: grid;
	place-items: center;
	border-radius: 6px;
	transition: color .15s ease;
}

.ms-rp__mute:hover { color: var(--ms-rp-text); }

.ms-rp__vol input[type="range"] {
	width: 84px;
	height: 4px;
	appearance: none;
	-webkit-appearance: none;
	border-radius: 4px;
	background: rgba(255, 255, 255, .18);
	cursor: pointer;
	outline-offset: 4px;
}

.ms-rp__vol input[type="range"]::-webkit-slider-thumb {
	-webkit-appearance: none;
	width: 13px;
	height: 13px;
	border-radius: 50%;
	background: var(--ms-rp-text);
	border: 2px solid var(--ms-rp-accent);
	cursor: pointer;
}

.ms-rp__vol input[type="range"]::-moz-range-thumb {
	width: 13px;
	height: 13px;
	border: 2px solid var(--ms-rp-accent);
	border-radius: 50%;
	background: var(--ms-rp-text);
	cursor: pointer;
}

/* ── Close ───────────────────────────────────────────────────────────────── */

.ms-rp__close {
	flex: 0 0 auto;
	border: 0;
	background: none;
	color: var(--ms-rp-dim);
	font-size: 1.3rem;
	line-height: 1;
	cursor: pointer;
	padding: 2px 4px;
	border-radius: 6px;
	transition: color .15s ease;
}

.ms-rp__close:hover { color: var(--ms-rp-text); }

/* ── Narrow screens ──────────────────────────────────────────────────────────
   The waveform and the countdown are the first things to go: identity and the two
   working controls matter more than decoration on a phone.                     */

@media (max-width: 720px) {

	.ms-rp {
		left: 8px;
		right: 8px;
		bottom: 8px;
		width: auto;
		transform: translateY(140%);
		gap: 9px;
		padding: 9px 10px;
	}

	.ms-rp.is-open { transform: translateY(0); }

	.ms-rp__wave,
	.ms-rp__ends { display: none; }

	.ms-rp__vol input[type="range"] { width: 60px; }
}

@media (max-width: 480px) {
	.ms-rp__vol input[type="range"] { display: none; }
}

/* Keep the bar clear of a theme footer player, when one is present. */
body.has-ms-player .ms-rp { bottom: calc(18px + var(--ms-player-height, 72px)); }

/* ==========================================================================
   On-page station panel (the station's own page)
   ========================================================================== */

.ms-rp-panel {
	display: flex;
	align-items: center;
	gap: 16px;
	flex-wrap: wrap;
	padding: 16px 20px;
	margin: 0 0 24px;
	border-radius: 18px;
	border: 1px solid rgba(255, 255, 255, .1);
	background: var(--ms-radio-glass, rgba(255, 255, 255, .06));
}

.ms-rp-panel__label {
	font-size: .7rem;
	font-weight: 800;
	letter-spacing: .12em;
	text-transform: uppercase;
	color: var(--ms-radio-accent, #43b2cd);
}

.ms-rp-panel__next {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	flex-direction: column;
	gap: 8px;
	width: 100%;
}

.ms-rp-panel__next li {
	display: flex;
	align-items: center;
	gap: 10px;
	font-size: .86rem;
	color: var(--ms-text-dim, rgba(243, 244, 248, .62));
}

.ms-rp-panel__next img {
	width: 32px;
	height: 32px;
	border-radius: 7px;
	object-fit: cover;
	flex: 0 0 auto;
}

.ms-rp-panel__next b {
	color: var(--ms-text, #f3f4f8);
	font-weight: 650;
}

.ms-rp-panel__in {
	margin-left: auto;
	font-variant-numeric: tabular-nums;
	font-size: .78rem;
	opacity: .75;
}
