/**
 * Acaville radio player (P8.3).
 *
 * Front-end CSS, so it lands in someone else's theme rather than wp-admin. Every
 * rule is scoped under .acaradio-player and uses custom properties for colour, so a
 * theme can retheme it without fighting specificity:
 *
 *   .acaradio-player { --acaradio-accent: #b8143c; }
 *
 * Sized in rem/em off the inherited font so it sits naturally in whatever it is
 * dropped into.
 */

.acaradio-player {
	--acaradio-bg: #ffffff;
	--acaradio-fg: #1a1a1a;
	--acaradio-dim: #6b7280;
	--acaradio-line: #e2e3e5;
	--acaradio-accent: #2271b1;
	--acaradio-locked: #9ca3af;
	--acaradio-live: #c62828;

	background: var(--acaradio-bg);
	color: var(--acaradio-fg);
	border: 1px solid var(--acaradio-line);
	border-radius: 10px;
	padding: 0.875rem 1rem;
	max-width: 40rem;
	font-size: 0.95rem;
	line-height: 1.4;

	/* Adapt to the COLUMN we are dropped into, not the viewport. On the home page
	   this sits in a one-third column beside Previously and Up Next, which is far
	   narrower than the screen — a viewport media query would never fire. */
	container-type: inline-size;
	text-align: left;
}

.acaradio-player-title {
	font-weight: 600;
	margin-bottom: 0.5rem;
}

.acaradio-player-bar {
	display: flex;
	align-items: center;
	gap: 0.75rem;
}

/* ── play / pause ─────────────────────────────────────────────────────────── */

.acaradio-play {
	flex: 0 0 auto;
	width: 2.75rem;
	height: 2.75rem;
	border-radius: 50%;
	border: none;
	background: var(--acaradio-accent);
	color: #fff;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 0;
}

.acaradio-play:focus-visible {
	outline: 2px solid var(--acaradio-accent);
	outline-offset: 2px;
}

/* Triangle by default, two bars while playing — drawn in CSS so there is no icon
   font or SVG request. */
.acaradio-play-icon {
	display: block;
	width: 0;
	height: 0;
	margin-left: 3px;
	border-left: 0.85rem solid currentColor;
	border-top: 0.55rem solid transparent;
	border-bottom: 0.55rem solid transparent;
}

.acaradio-player.is-playing .acaradio-play-icon {
	margin-left: 0;
	width: 0.85rem;
	height: 1.05rem;
	border: none;
	background: linear-gradient( to right,
		currentColor 0 0.28rem, transparent 0.28rem 0.57rem, currentColor 0.57rem 0.85rem );
}

.acaradio-player.is-loading .acaradio-play {
	opacity: 0.7;
}

/* ── now playing ──────────────────────────────────────────────────────────── */

.acaradio-now {
	flex: 1 1 auto;
	min-width: 0;   /* lets the ellipsis actually work inside a flex child */
}

.acaradio-channel-name {
	font-size: 0.75rem;
	text-transform: uppercase;
	letter-spacing: 0.05em;
	color: var(--acaradio-dim);
}

/* Channel name and the live badge share a row. The badge must stay a SIBLING of
   .acaradio-channel-name — the refresh rewrites that element's textContent, which
   would delete a nested badge on the first update. */
.acaradio-chan-line {
	display: flex;
	align-items: center;
	gap: 0.4rem;
	min-width: 0;
}

/* Set off from the channel name by a middot rather than another colour — the eye
   already has the LIVE badge to land on, and two accents in one line compete. */
.acaradio-program {
	font-size: 0.75rem;
	text-transform: uppercase;
	letter-spacing: 0.05em;
	color: var(--acaradio-fg);
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	min-width: 0;
}

.acaradio-program::before {
	content: '·';
	margin-right: 0.4rem;
	color: var(--acaradio-dim);
}

.acaradio-program[hidden] {
	display: none;
}

/* Deliberately the one saturated red in the component. It is the only state where
   something is happening that the listener cannot replay later, so it gets to shout;
   everything else stays in the muted palette. */
.acaradio-live-badge {
	flex: 0 0 auto;
	font-size: 0.62rem;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.08em;
	line-height: 1.6;
	color: #fff;
	background: var(--acaradio-live);
	border-radius: 3px;
	padding: 0 0.32rem;
}

/* The UA stylesheet already honours [hidden], but this component sets display on
   siblings freely and a future flex/grid rule here would silently override it. */
.acaradio-live-badge[hidden] {
	display: none;
}

.acaradio-track {
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.acaradio-title { font-weight: 600; }
.acaradio-artist { color: var(--acaradio-dim); }

.acaradio-progress {
	margin-top: 0.4rem;
	height: 3px;
	background: var(--acaradio-line);
	border-radius: 2px;
	overflow: hidden;
}

.acaradio-progress-fill {
	display: block;
	height: 100%;
	width: 0;
	background: var(--acaradio-accent);
	/* Matches the 1s tick so the bar glides instead of stepping. */
	transition: width 1s linear;
}

.acaradio-time {
	flex: 0 0 auto;
	font-variant-numeric: tabular-nums;
	font-size: 0.85rem;
	color: var(--acaradio-dim);
	min-width: 3em;
	text-align: right;
}

.acaradio-vol-wrap { flex: 0 0 auto; display: flex; align-items: center; }
.acaradio-vol { width: 5.5rem; }

/* ── channel switcher ─────────────────────────────────────────────────────── */

.acaradio-channels {
	display: grid;
	grid-template-columns: repeat( auto-fit, minmax( 11rem, 1fr ) );
	gap: 0.5rem;
	margin-top: 0.875rem;
	padding-top: 0.875rem;
	border-top: 1px solid var(--acaradio-line);
}

.acaradio-chan {
	text-align: left;
	background: transparent;
	border: 1px solid var(--acaradio-line);
	border-radius: 7px;
	padding: 0.5rem 0.625rem;
	cursor: pointer;
	color: inherit;
	font: inherit;
	display: flex;
	flex-direction: column;
	gap: 0.1rem;
	min-width: 0;
}

.acaradio-chan:focus-visible {
	outline: 2px solid var(--acaradio-accent);
	outline-offset: 1px;
}

.acaradio-chan.is-active {
	border-color: var(--acaradio-accent);
	box-shadow: inset 0 0 0 1px var(--acaradio-accent);
}

.acaradio-chan-name { font-weight: 600; font-size: 0.85rem; }

.acaradio-chan-now {
	font-size: 0.75rem;
	color: var(--acaradio-dim);
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

/* Locked channels stay legible — non-members are meant to see what they're missing,
   so this dims the control without hiding the content. */
.acaradio-chan.is-locked { cursor: not-allowed; }
.acaradio-chan.is-locked .acaradio-chan-name { color: var(--acaradio-locked); }

.acaradio-lock {
	font-size: 0.65rem;
	text-transform: uppercase;
	letter-spacing: 0.05em;
	color: var(--acaradio-locked);
}

/* Shake on a locked click, so the refusal is visible rather than a dead button. */
.acaradio-chan.acaradio-nudge { animation: acaradio-nudge 0.3s ease-in-out 2; }

@keyframes acaradio-nudge {
	0%, 100% { transform: translateX( 0 ); }
	25%      { transform: translateX( -3px ); }
	75%      { transform: translateX( 3px ); }
}

@media ( prefers-reduced-motion: reduce ) {
	.acaradio-chan.acaradio-nudge { animation: none; opacity: 0.6; }
	.acaradio-progress-fill { transition: none; }
}

.acaradio-player-empty { color: var(--acaradio-dim); }

/* ── dark mode ────────────────────────────────────────────────────────────── */

@media ( prefers-color-scheme: dark ) {
	.acaradio-player {
		--acaradio-bg: #16181c;
		--acaradio-fg: #e8e9ea;
		--acaradio-dim: #9aa0a6;
		--acaradio-line: #2e3238;
		--acaradio-accent: #5aa2e0;
		--acaradio-locked: #6b7280;
		/* Lifted off the dark ground: white-on-#c62828 loses contrast against
		   #16181c, where the same red reads muddy rather than urgent. */
		--acaradio-live: #e5484d;
	}
}

/* ── narrow screens ───────────────────────────────────────────────────────── */

@media ( max-width: 30rem ) {
	.acaradio-player-bar { flex-wrap: wrap; }
	.acaradio-now { flex: 1 1 60%; }
	.acaradio-vol-wrap { order: 3; margin-left: auto; }
	.acaradio-channels { grid-template-columns: 1fr 1fr; }
}

/* ---------------------------------------------------------------------------
   Channel line-up tease (P8.4) — what's on every channel, as a join prompt.
   Shares the player's tokens so both read as one component.
   --------------------------------------------------------------------------- */
.acaradio-tease {
	--acaradio-bg: #ffffff;
	--acaradio-fg: #1a1a1a;
	--acaradio-dim: #6b7280;
	--acaradio-line: #e2e3e5;
	--acaradio-accent: #2271b1;
	--acaradio-locked: #9ca3af;
	--acaradio-live: #c62828;
	color: var(--acaradio-fg);
}

/* The name sits on its own line with the badge trailing it, so a long channel name
   wraps without pushing the badge out of the card. */
.acaradio-tease-name {
	display: flex;
	align-items: center;
	gap: 0.35rem;
	flex-wrap: wrap;
}

.acaradio-tease-title { margin: 0 0 0.75rem; font-size: 1.05rem; }

.acaradio-tease-grid {
	display: grid;
	grid-template-columns: repeat( auto-fit, minmax( 12rem, 1fr ) );
	gap: 0.625rem;
}

.acaradio-tease-card {
	border: 1px solid var(--acaradio-line);
	border-radius: 8px;
	padding: 0.7rem 0.8rem;
	background: var(--acaradio-bg);
	display: flex;
	flex-direction: column;
	gap: 0.15rem;
	min-width: 0;
	text-align: left;
}

.acaradio-tease-name {
	font-weight: 600;
	font-size: 0.85rem;
	text-transform: uppercase;
	letter-spacing: 0.04em;
}

/* Track and artist stay fully legible on locked cards — the whole point is to show
   non-members what they are missing, so this dims the chrome, never the content. */
.acaradio-tease-now { min-width: 0; }

.acaradio-tease-track,
.acaradio-tease-artist {
	display: block;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.acaradio-tease-track { font-size: 0.92rem; }
.acaradio-tease-artist { font-size: 0.8rem; color: var(--acaradio-dim); }

.acaradio-tease-card.is-locked { border-style: dashed; }
.acaradio-tease-card.is-locked .acaradio-tease-name { color: var(--acaradio-locked); }

.acaradio-tease-lock {
	margin-top: 0.15rem;
	font-size: 0.65rem;
	text-transform: uppercase;
	letter-spacing: 0.05em;
	color: var(--acaradio-locked);
}

.acaradio-tease-cta { margin: 0.875rem 0 0; }

.acaradio-tease-join {
	display: inline-block;
	padding: 0.5rem 1rem;
	border-radius: 6px;
	background: var(--acaradio-accent);
	color: #fff;
	text-decoration: none;
	font-weight: 600;
}

/* Editor-only placeholder shown before switchover. */
.acaradio-tease-pending {
	border: 1px dashed var(--acaradio-line, #e2e3e5);
	border-radius: 8px;
	padding: 0.75rem 1rem;
	color: #6b7280;
	font-size: 0.85rem;
}

@media ( prefers-color-scheme: dark ) {
	.acaradio-tease {
		--acaradio-bg: #16181c;
		--acaradio-fg: #e8e9ea;
		--acaradio-dim: #9aa0a6;
		--acaradio-line: #2e3238;
		--acaradio-accent: #5aa2e0;
		--acaradio-locked: #6b7280;
		--acaradio-live: #e5484d;
	}
}

/* ---------------------------------------------------------------------------
   Compact mode — driven by the player's own width, not the screen's.
   Used when the player shares a row with other content (home page: Previously |
   player | Up Next). Things are dropped in order of least value: the volume
   slider first (system volume still works), then the countdown.
   --------------------------------------------------------------------------- */

@container ( max-width: 26rem ) {
	.acaradio-player-bar { gap: 0.55rem; }
	.acaradio-play { width: 2.35rem; height: 2.35rem; }
	.acaradio-play-icon {
		border-left-width: 0.7rem;
		border-top-width: 0.45rem;
		border-bottom-width: 0.45rem;
	}
	.acaradio-player.is-playing .acaradio-play-icon { width: 0.7rem; height: 0.9rem; }
	.acaradio-vol-wrap { display: none; }
	.acaradio-channel-name { font-size: 0.68rem; }
	.acaradio-track { font-size: 0.88rem; }
	.acaradio-time { font-size: 0.78rem; min-width: 2.6em; }
	.acaradio-channels { grid-template-columns: 1fr; }
}

@container ( max-width: 17rem ) {
	.acaradio-time { display: none; }
	.acaradio-play { width: 2.1rem; height: 2.1rem; }
}

/* The home page section centres its text; keep the player's own copy left-aligned
   so the track name and channel label line up under each other. */
.acaradio-player .acaradio-now { text-align: left; }
