:root {
	--bg-h: 0;
	--bg-s: 20%;
	--bg-l: 8%;
	--accent: rgba(255, 255, 255, 0.95);
	--dim: rgba(255, 255, 255, 0.55);
	--dimmer: rgba(255, 255, 255, 0.25);
	--hairline: rgba(255, 255, 255, 0.08);
}

* {
	box-sizing: border-box;
	margin: 0;
	padding: 0;
}

[hidden] {
	display: none !important;
}

html,
body {
	height: 100vh;
	height: 100dvh;
	overflow: hidden;
	font: 16px/1.5 ui-sans-serif, system-ui, -apple-system, sans-serif;
	color: var(--accent);
	background: hsl(var(--bg-h) var(--bg-s) var(--bg-l));
	transition: background 1s ease-in-out;
}

body::before {
	content: "";
	position: fixed;
	inset: -30%;
	background:
		radial-gradient(ellipse at 20% 20%, hsla(var(--bg-h), 80%, 40%, 0.5), transparent 60%),
		radial-gradient(ellipse at 80% 80%, hsla(calc(var(--bg-h) + 60), 70%, 35%, 0.4), transparent 60%);
	pointer-events: none;
	opacity: 0;
	transition: opacity 1s;
	animation: drift 20s ease-in-out infinite alternate;
}

body.ready::before {
	opacity: 1;
}

#cover-bg {
	position: fixed;
	inset: -40%;
	background-size: cover;
	background-position: center;
	filter: blur(80px) brightness(0.35) saturate(1.4);
	pointer-events: none;
	opacity: 0;
	transition: opacity 1s;
	animation: drift 20s ease-in-out infinite alternate;
}

body.has-cover #cover-bg {
	opacity: 1;
}

@keyframes drift {
	from {
		transform: translate(-18%, -10%) scale(1);
	}

	to {
		transform: translate(18%, 10%) scale(1.12);
	}
}

a {
	color: inherit;
}

button {
	background: none;
	border: none;
	color: inherit;
	cursor: pointer;
	font: inherit;
}

/* app */

.app {
	position: relative;
	z-index: 1;
	height: 100%;
	display: grid;
	grid-template-rows: auto auto 1fr auto;
	padding: 1.5rem 2rem;
	gap: 1.5rem;
}

.app header {
	display: flex;
	align-items: center;
	justify-content: space-between;
}

.app main {
	display: flex;
	flex-direction: column;
	justify-content: space-between;
	gap: 2.5rem;
	min-height: 0;
	padding: 1rem 0;
	overflow-y: auto;
}

.app footer {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 0.6rem;
	padding-top: 1rem;
	border-top: 2px solid var(--hairline);
}

/* brand */

.brand {
	display: flex;
	align-items: center;
	gap: 0.5em;
	font-size: 1.5rem;
	font-weight: 800;
}

.brand img {
	width: 1.5em;
	height: 1.5em;
	border-radius: 50%;
	object-fit: cover;
}

/* station tuner */

.tuner {
	display: flex;
	align-items: center;
	gap: 0.5em;
	flex-wrap: wrap;
	opacity: 0;
	transform: translateY(8px);
	transition: opacity 0.6s, transform 0.6s;
}

body.ready .tuner {
	opacity: 1;
	transform: none;
}

.station {
	padding: 0.55em 1.1em;
	border-radius: 999px;
	font-size: 0.95rem;
	font-weight: 500;
	color: var(--dim);
	border: 2px solid var(--hairline);
	transition: color 0.2s, background 0.2s, border-color 0.2s;
}

.station::after {
	content: attr(data-cat);
	font-weight: 700;
	display: block;
	height: 0;
	overflow: hidden;
}

.station:hover {
	color: var(--accent);
	border-color: rgba(255, 255, 255, 0.2);
}

.station.empty:not(:hover):not(.tuned) {
	color: var(--dimmer);
	border-color: rgba(255, 255, 255, 0.04);
}

.station.tuned {
	background: var(--accent);
	border-color: var(--accent);
	color: #111;
	font-weight: 700;
}

/* now playing */

.now-playing {
	display: flex;
	align-items: flex-start;
	gap: 1.5rem;
	opacity: 0;
	transform: translateY(8px);
	transition: opacity 0.6s, transform 0.6s;
}

body.ready .now-playing {
	opacity: 1;
	transform: none;
}

.cover {
	flex-shrink: 0;
	width: clamp(150px, 30vw, 300px);
	height: clamp(150px, 30vw, 300px);
	object-fit: cover;
	border-radius: 8px;
	transition: opacity 0.4s;
}

.now-playing h1 {
	font-size: clamp(2.25rem, 6.5vw, 5rem);
	font-weight: 800;
	line-height: 1;
	margin-bottom: 0.4rem;
}

.subtitle {
	font-size: clamp(1.1rem, 2vw, 1.5rem);
	font-weight: 500;
	color: var(--dim);
}

.track-by {
	margin-top: 1.25rem;
	font-size: 0.95rem;
	color: var(--dim);
}

.track-by a {
	color: var(--accent);
	text-decoration: none;
	font-weight: 600;
}

.user-avatar {
	width: 1.2em;
	height: 1.2em;
	border-radius: 50%;
	object-fit: cover;
	vertical-align: -0.2em;
	margin-right: 0.3em;
}

/* play button */

.play {
	width: 52px;
	height: 52px;
	border-radius: 50%;
	background: var(--accent);
	color: hsl(var(--bg-h) var(--bg-s) calc(var(--bg-l) - 2%));
	display: grid;
	place-items: center;
	font-size: 15px;
	position: relative;
	transition: transform 0.2s, opacity 0.2s;
}

.play:hover {
	transform: scale(1.1);
}

.play:active {
	transform: scale(0.9);
}

.play:disabled {
	opacity: 0.3;
	cursor: not-allowed;
	transform: none;
}

.play.loading {
	color: transparent;
}

.play.loading::after {
	content: "";
	position: absolute;
	inset: 10px;
	border-radius: 50%;
	border: 2px solid hsl(var(--bg-h) var(--bg-s) calc(var(--bg-l) - 2%));
	border-top-color: transparent;
	animation: spin 0.6s linear infinite;
}

/* progress bar */

.progress {
	display: flex;
	align-items: center;
	gap: 0.7em;
	width: min(420px, 80vw);
	height: 1.5em;
	font-size: 0.9rem;
	color: var(--dim);
	font-variant-numeric: tabular-nums;
}

.progress .bar {
	flex: 1;
	height: 4px;
	background: var(--hairline);
	border-radius: 2px;
	position: relative;
	overflow: hidden;
}

.progress .fill {
	position: absolute;
	inset: 0 auto 0 0;
	width: 0%;
	background: var(--accent);
	border-radius: 2px;
	transition: width 0.4s linear;
}

.progress output {
	transition: opacity 0.4s;
}

.progress.idle .bar {
	opacity: 0.4;
}

.progress.idle output {
	opacity: 0;
}

/* details panel */

details {
	max-width: 50ch;
	margin: 0 auto;
	color: var(--dim);
	background: rgba(0, 0, 0, 0.2);
	border-radius: 8px;
	padding: 0.5rem 0.75rem;
}

details a {
	color: var(--accent);
}

details h3 {
	margin: 1.25rem 0 0.4rem;
	color: var(--accent);
	font-size: 0.9rem;
	font-weight: 600;
}

details ul {
	padding-left: 1.2em;
}

details code,
details pre {
	font-family: ui-monospace, "SF Mono", Menlo, monospace;
	font-size: 0.85rem;
}

details pre {
	margin: 0.5em 0;
	padding: 0.6em 0.8em;
	background: rgba(0, 0, 0, 0.25);
	border-radius: 6px;
	overflow-x: auto;
}

details summary {
	cursor: pointer;
}

@keyframes spin {
	to {
		transform: rotate(360deg);
	}
}
