:root {
	color-scheme: light dark;
	--bg: #fff;
	--fg: #000;
	--accent: #3498db;
	--on-accent: #fff;
	--line: rgba(0, 0, 0, 0.1);
	--hover: #fafafa;
	--rail: #f0f0f0;
	--link: #00f;
}

/* Dark follows the browser unless the visitor picked a theme with the toggle */
@media (prefers-color-scheme: dark) {
	:root:not([data-theme="light"]) {
		--bg: #121212;
		--fg: #e4e4e4;
		--line: rgba(255, 255, 255, 0.12);
		--hover: #1c1c1c;
		--rail: #2a2a2a;
		--link: #6cb6ff;
	}
}

:root[data-theme="dark"] {
	color-scheme: dark;
	--bg: #121212;
	--fg: #e4e4e4;
	--line: rgba(255, 255, 255, 0.12);
	--hover: #1c1c1c;
	--rail: #2a2a2a;
	--link: #6cb6ff;
}

:root[data-theme="light"] { color-scheme: light; }

html, body { height: 100%; }

body {
	margin: 0;
	background: var(--bg);
	color: var(--fg);
	font-family: "Andale Mono", AndaleMono, ui-monospace, Menlo, Consolas, "DejaVu Sans Mono", monospace;
}

button { font: inherit; color: inherit; }

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

/* Player column */

.player {
	box-sizing: border-box;
	display: flex;
	flex-direction: column;
	width: 100%;
	max-width: 532px;
	height: 100vh;
	height: 100dvh;
	margin: 0 auto;
	padding: 16px 16px 24px;
}

.player > * { flex: none; }

#visualizer { display: block; width: 100%; height: 60px; }

.seek {
	position: relative;
	height: 2px;
	margin-bottom: 5px;
	background: var(--rail);
	cursor: pointer;
	touch-action: none;
}

/* Taller invisible hit area so the 2px bar is easy to grab */
.seek::before { content: ""; position: absolute; inset: -8px 0; }

.seek-fill { width: 0; height: 100%; background: var(--accent); }

.controls { display: flex; align-items: center; gap: 4px; min-height: 34px; }

.btn {
	display: grid;
	place-items: center;
	width: 34px;
	height: 34px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: none;
	cursor: pointer;
}

.btn:active { transform: translateY(2px); }
.btn svg { width: 24px; height: 24px; fill: currentColor; }
.btn-lg svg { width: 30px; height: 30px; }

.ring { fill: none; stroke: currentColor; stroke-width: 1.5; }
.btn-lg .ring { stroke-width: 2; }
.stroke { fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }

#play .icon-pause, #play.playing .icon-play { display: none; }
#play.playing .icon-pause { display: inline; }

#shuffle[aria-pressed="true"] .ring { fill: currentColor; }
#shuffle[aria-pressed="true"] .stroke { stroke: var(--bg); }

#mute .icon-x, #mute[aria-pressed="true"] .icon-wave { display: none; }
#mute[aria-pressed="true"] .icon-x { display: inline; }

.volume {
	-webkit-appearance: none;
	appearance: none;
	flex: 0 1 75px;
	min-width: 40px;
	height: 20px;
	margin: 0 0 0 6px;
	background: transparent;
	cursor: pointer;
}

.volume::-webkit-slider-runnable-track { height: 2px; background: var(--fg); }
.volume::-moz-range-track { height: 2px; background: var(--fg); }

.volume::-webkit-slider-thumb {
	-webkit-appearance: none;
	box-sizing: border-box;
	width: 14px;
	height: 14px;
	margin-top: -6px;
	border: 2px solid var(--fg);
	border-radius: 50%;
	background: var(--bg);
}

.volume::-moz-range-thumb {
	box-sizing: border-box;
	width: 14px;
	height: 14px;
	border: 2px solid var(--fg);
	border-radius: 50%;
	background: var(--bg);
}

.time { margin-left: auto; padding-left: 8px; white-space: nowrap; }

.now { display: flex; gap: 1ch; margin: 14px 0 0; }
.now span { flex: none; }

.now button {
	min-width: 0;
	padding: 0;
	border: 0;
	background: none;
	overflow: hidden;
	text-align: left;
	text-overflow: ellipsis;
	white-space: nowrap;
	cursor: pointer;
}

.now button:disabled { cursor: default; }

/* Search */

.search { display: flex; gap: 8px; margin: 24px 0 0; }

.search input {
	flex: 1;
	min-width: 0;
	box-sizing: border-box;
	height: 34px;
	padding: 0 8px;
	border: 1px solid var(--line);
	border-radius: 0;
	background: var(--bg);
	color: inherit;
	font: inherit; /* 16px keeps iOS from zooming in on focus */
	/* Drop Safari's own rounded search-field look and magnifier */
	-webkit-appearance: none;
	appearance: none;
}

.search input:focus { border-color: var(--fg); outline: none; }
.search input::placeholder { color: inherit; opacity: 0.5; }
/* Hide the browser's own clear (x) so there's only one clear control */
.search input::-webkit-search-cancel-button,
.search input::-webkit-search-decoration { -webkit-appearance: none; display: none; }

.clear {
	padding: 0 4px;
	border: 0;
	background: none;
	color: var(--link);
	text-decoration: underline;
	cursor: pointer;
}

.clear:disabled { color: inherit; opacity: 0.35; text-decoration: none; cursor: default; }

/* Track list */

.tracks {
	flex: 1 1 0;
	min-height: 0;
	margin: 12px 0 0;
	padding: 0;
	overflow-y: auto;
	list-style: none;
}

.tracks li { border-top: 1px solid var(--line); }

.tracks a {
	display: block;
	padding: 10px 5px;
	color: inherit;
	text-decoration: none;
	overflow-wrap: anywhere;
}

.tracks a:hover { background: var(--hover); }
.tracks a:focus-visible { outline-offset: -2px; }
.tracks .playing a { background: var(--accent); color: var(--on-accent); }

.note { padding: 10px 5px; }

/* Title and corner notice */

.brand {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 10px;
	margin-bottom: 20px;
	font-weight: bold;
}

.mascot { width: 31px; height: 20px; fill: currentColor; shape-rendering: crispEdges; }

.about {
	position: fixed;
	right: 20px;
	bottom: 30px;
	box-sizing: border-box;
	width: 200px;
	background: var(--bg);
	font-size: 75%;
	text-align: justify;
	transition: opacity 0.2s;
}

.about.dismissed { opacity: 0; }
.about h2 { margin: 0; font: inherit; }
.about p { margin: 0 0 1.5em; }
.about a { color: inherit; text-decoration: none; }

.dismiss {
	display: block;
	margin: 0 auto 1em;
	padding: 0;
	border: 0;
	background: none;
	color: var(--link);
	text-decoration: underline;
	cursor: pointer;
}

/* Theme toggle */

.theme-toggle {
	position: fixed;
	top: 10px;
	right: 10px;
	display: flex;
	gap: 6px;
	width: auto;
	padding: 0 6px;
	border-radius: 0;
	font-size: 75%;
}
.theme-toggle .stroke { stroke-width: 1.6; }
.icon-sun { display: none; }

@media (prefers-color-scheme: dark) {
	:root:not([data-theme="light"]) .icon-sun { display: inline; }
	:root:not([data-theme="light"]) .icon-moon { display: none; }
}

:root[data-theme="dark"] .icon-sun { display: inline; }
:root[data-theme="dark"] .icon-moon { display: none; }

/* Narrow screens: no room in the corner, so give the toggle its own row above the title */
@media (max-width: 640px) {
	.theme-toggle {
		position: static;
		align-self: flex-end;
		height: 28px;
		margin: -8px -6px 4px 0;
	}
}

/* Not enough side margin for the corner notice: show it as a card instead */
@media (max-width: 960px) {
	.about {
		left: 16px;
		right: 16px;
		bottom: 16px;
		width: auto;
		max-width: 500px;
		margin: 0 auto;
		padding: 12px 12px 0;
		border: 1px solid var(--line);
		text-align: left;
	}
}
