/*
 * Radio player. Loaded only on the radio page.
 *
 * Every icon and indicator here is drawn in CSS. The bundled font subsets
 * cover latin + latin-ext only, so media glyphs and geometric shapes would
 * fall back to a system font — see the note at the top of style.css.
 */

.anduro-radio {
	margin-block: var(--wp--preset--spacing--30);
}

.anduro-radio__grid {
	display: grid;
	grid-template-columns: auto minmax(0, 1fr) auto;
	align-items: center;
	gap: var(--wp--preset--spacing--30);
}

/* -------------------------------------------------------- play button --- */

.anduro-radio__play {
	display: grid;
	place-items: center;
	width: 3.25rem;
	height: 3.25rem;
	padding: 0;
	border: 1px solid var(--wp--preset--color--teal);
	border-radius: 50%;
	background: transparent;
	color: var(--wp--preset--color--cyan);
	cursor: pointer;
	transition: background var(--wp--custom--transition),
		color var(--wp--custom--transition),
		border-color var(--wp--custom--transition),
		box-shadow var(--wp--custom--transition);
}

.anduro-radio__play:hover:not(:disabled),
.anduro-radio__play:focus-visible:not(:disabled) {
	border-color: var(--wp--preset--color--cyan);
	background: var(--wp--preset--color--cyan);
	color: var(--wp--preset--color--base);
	box-shadow: var(--wp--preset--shadow--glow-cyan);
}

.anduro-radio__play:disabled {
	opacity: 0.4;
	cursor: not-allowed;
}

.anduro-radio__icon {
	position: relative;
	display: block;
	width: 1rem;
	height: 1.15rem;
	margin-left: 0.12rem; /* optically centre the triangle */
}

/* Play triangle. */
.anduro-radio__icon::before {
	content: "";
	position: absolute;
	inset: 0;
	background: currentColor;
	clip-path: polygon(15% 4%, 15% 96%, 96% 50%);
	transition: opacity var(--wp--custom--transition);
}

/* Pause bars, revealed while playing. */
.anduro-radio__icon::after {
	content: "";
	position: absolute;
	inset: 0;
	opacity: 0;
	background: linear-gradient(
		to right,
		currentColor 0 32%,
		transparent 32% 68%,
		currentColor 68% 100%
	);
	transition: opacity var(--wp--custom--transition);
}

.anduro-radio.is-playing .anduro-radio__icon::before {
	opacity: 0;
}

.anduro-radio.is-playing .anduro-radio__icon::after {
	opacity: 1;
	margin-left: -0.12rem;
}

/* ---------------------------------------------------------- readout --- */

.anduro-radio__readout {
	min-width: 0; /* lets the ellipsis actually work inside grid */
}

.anduro-radio__state {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	margin: 0;
	font-size: var(--wp--preset--font-size--xs);
	text-transform: uppercase;
	letter-spacing: 0.16em;
	color: var(--wp--preset--color--text-dim);
}

.anduro-radio__now {
	margin: 0.25rem 0 0;
	font-size: var(--wp--preset--font-size--md);
	color: var(--wp--preset--color--text);
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

/* ----------------------------------------------- live indicator (dot) --- */

/*
 * Concentric rings expanding out of the dot — the same motif as the arcs
 * above the wave in the logo.
 */
.anduro-radio__dot {
	position: relative;
	flex: 0 0 auto;
	width: 0.5rem;
	height: 0.5rem;
	border-radius: 50%;
	background: currentColor;
}

.anduro-radio[data-state="live"] .anduro-radio__state {
	color: var(--wp--preset--color--green);
}

.anduro-radio[data-state="connecting"] .anduro-radio__state,
.anduro-radio[data-state="buffering"] .anduro-radio__state,
.anduro-radio[data-state="blocked"] .anduro-radio__state {
	color: var(--wp--preset--color--yellow);
}

.anduro-radio[data-state="error"] .anduro-radio__state {
	color: var(--wp--preset--color--magenta);
}

@media (prefers-reduced-motion: no-preference) {
	.anduro-radio[data-state="live"] .anduro-radio__dot::before,
	.anduro-radio[data-state="live"] .anduro-radio__dot::after {
		content: "";
		position: absolute;
		inset: 0;
		border: 1px solid currentColor;
		border-radius: 50%;
		animation: anduro-ping 2.4s cubic-bezier(0, 0, 0.2, 1) infinite;
	}

	.anduro-radio[data-state="live"] .anduro-radio__dot::after {
		animation-delay: 1.2s;
	}

	@keyframes anduro-ping {
		from {
			transform: scale(1);
			opacity: 0.9;
		}
		to {
			transform: scale(3.4);
			opacity: 0;
		}
	}

	/* Connecting/buffering: pulse in place rather than ping outwards. */
	.anduro-radio[data-state="connecting"] .anduro-radio__dot,
	.anduro-radio[data-state="buffering"] .anduro-radio__dot {
		animation: anduro-pulse 1s ease-in-out infinite alternate;
	}

	@keyframes anduro-pulse {
		from {
			opacity: 0.25;
		}
		to {
			opacity: 1;
		}
	}
}

/* ------------------------------------------------------------ volume --- */

.anduro-radio__volume {
	display: flex;
	align-items: center;
	gap: 0.6rem;
}

.anduro-radio__mute {
	display: grid;
	place-items: center;
	width: 2rem;
	height: 2rem;
	padding: 0;
	border: none;
	background: transparent;
	color: var(--wp--preset--color--text-dim);
	cursor: pointer;
	transition: color var(--wp--custom--transition);
}

.anduro-radio__mute:hover:not(:disabled),
.anduro-radio__mute:focus-visible:not(:disabled) {
	color: var(--wp--preset--color--cyan);
}

.anduro-radio__mute:disabled {
	opacity: 0.4;
	cursor: not-allowed;
}

.anduro-radio__speaker {
	position: relative;
	display: block;
	width: 0.95rem;
	height: 0.95rem;
	background: currentColor;
	clip-path: polygon(0 32%, 28% 32%, 58% 4%, 58% 96%, 28% 68%, 0 68%);
}

/* Strike-through when muted. */
.anduro-radio.is-muted .anduro-radio__mute {
	color: var(--wp--preset--color--magenta);
}

.anduro-radio.is-muted .anduro-radio__speaker::after {
	content: "";
	position: absolute;
	top: 50%;
	left: -15%;
	width: 130%;
	height: 1px;
	background: currentColor;
	transform: rotate(-45deg);
}

.anduro-radio__slider {
	width: 6.5rem;
	height: 1.25rem;
	background: transparent;
	cursor: pointer;
	-webkit-appearance: none;
	appearance: none;
}

.anduro-radio__slider:disabled {
	opacity: 0.4;
	cursor: not-allowed;
}

/* Track + thumb have to be declared per-engine; they cannot be combined. */
.anduro-radio__slider::-webkit-slider-runnable-track {
	height: 2px;
	background: color-mix(in srgb, var(--wp--preset--color--cyan) 28%, transparent);
}

.anduro-radio__slider::-moz-range-track {
	height: 2px;
	background: color-mix(in srgb, var(--wp--preset--color--cyan) 28%, transparent);
}

.anduro-radio__slider::-webkit-slider-thumb {
	-webkit-appearance: none;
	appearance: none;
	width: 0.7rem;
	height: 0.7rem;
	margin-top: -0.3rem;
	border: none;
	border-radius: 0;
	background: var(--wp--preset--color--cyan);
	transform: rotate(45deg);
}

.anduro-radio__slider::-moz-range-thumb {
	width: 0.7rem;
	height: 0.7rem;
	border: none;
	border-radius: 0;
	background: var(--wp--preset--color--cyan);
	transform: rotate(45deg);
}

.anduro-radio__slider:focus-visible::-webkit-slider-thumb {
	box-shadow: 0 0 0 3px color-mix(in srgb, var(--wp--preset--color--yellow) 55%, transparent);
}

.anduro-radio__slider:focus-visible::-moz-range-thumb {
	box-shadow: 0 0 0 3px color-mix(in srgb, var(--wp--preset--color--yellow) 55%, transparent);
}

/* -------------------------------------------------------------- misc --- */

.anduro-radio__hint {
	margin: var(--wp--preset--spacing--20) 0 0;
	font-size: var(--wp--preset--font-size--sm);
	color: var(--wp--preset--color--text-dim);
}

.anduro-radio.is-offline {
	opacity: 0.75;
}

/* Narrow screens: transport on top, volume below, full width. */
@media (max-width: 34rem) {
	.anduro-radio__grid {
		grid-template-columns: auto minmax(0, 1fr);
		gap: var(--wp--preset--spacing--20);
	}

	.anduro-radio__volume {
		grid-column: 1 / -1;
		justify-content: space-between;
	}

	.anduro-radio__slider {
		width: 100%;
		margin-left: 0.5rem;
	}
}
