/* LAYOUT */
body {
	height: 100vh;
	display: grid;
	grid-template-columns: 20rem 1fr;
	grid-template-rows: 1fr auto auto;
	grid-template-areas:
		"sidebar main"
		"header header"
		"footer footer";
}

/* HEADER */
header {
	grid-area: header;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 0.5rem;
	padding: 0.5rem;
	border-top: 1px solid var(--border);
	background: var(--bg-tertiary);
}

#progress {
	flex: 1;
}

#playback #loop-btn {
	opacity: 0.5;
}

#playback #loop-btn.active {
	opacity: 1;
}

/* BASE STYLES */
button {
	background: none;
	border: none;
	display: inline-flex;
	align-items: center;
	gap: 0.5rem;
	color: inherit;
	font: inherit;
}

@keyframes pulse {
	0%,
	100% {
		background-color: var(--playing);
	}
	50% {
		background-color: var(--playing-pulse);
	}
}

/* SIDEBAR */
#sidebar {
	grid-area: sidebar;
	border-right: 1px solid var(--border);
	background: var(--bg-secondary);
	display: flex;
	flex-direction: column;
	min-height: 0;
}

#sidebar h2 {
	font-size: 1rem;
	margin-block-start: 0.5rem;
}

#sidebar h2 a {
	color: inherit;
	text-decoration: none;
}

#sidebar ul {
	list-style: none;
}

#sidebar li {
	margin-block-start: 0.5rem;
}

/* sidebar - library */
#sidebar #library {
	flex: 1;
	overflow-y: auto;
	min-height: 0;
	padding-inline: 1rem;
}

/* sidebar - library - tree items */
#sidebar #library .tree-item {
	display: flex;
	align-items: center;
	gap: 0.5rem;
}

#sidebar #library .tree-toggle,
#sidebar #library .tree-name {
	color: inherit;
	text-decoration: none;
	flex: 1;
	display: flex;
	gap: 0.5rem;
	align-items: center;
	min-width: 0;
}

#sidebar #library .tree-toggle span,
#sidebar #library .tree-name span {
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

#sidebar #library .tree-action.disabled {
	opacity: 0.5;
}

#sidebar #library .tree-cover {
	width: var(--art-artist);
	height: var(--art-artist);
	flex-shrink: 0;
}

#sidebar #library .tree-cover img {
	width: 100%;
	height: 100%;
	aspect-ratio: 1 / 1;
	object-fit: cover;
}

#sidebar #library ul.nested > li .tree-toggle img,
#sidebar #library ul.nested > li .tree-name img {
	width: var(--art-album);
	height: var(--art-album);
}

#sidebar #library ul.nested > li .tree-cover {
	width: var(--art-album);
	height: var(--art-album);
}

#sidebar #library .nested {
	list-style: none;
	margin-inline-start: 1rem;
}

#sidebar #library .nested li {
	margin-block-start: 0.25rem;
}

/* sidebar - now playing */
#sidebar #now-playing {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 0.75rem;
	padding: 1rem;
	border-top: 1px solid var(--border-subtle);
	flex-shrink: 0;
}

#sidebar #now-playing #cover-art {
	width: var(--art-now-playing);
	height: var(--art-now-playing);
	object-fit: cover;
}

#sidebar #now-playing #track-info {
	text-align: center;
	width: 100%;
}

#sidebar #now-playing #track-title {
	font-weight: bold;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

#sidebar #now-playing #track-artist {
	font-size: 0.8rem;
	opacity: 0.75;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

#sidebar #now-playing #track-lyric {
	font-size: 0.8rem;
	opacity: 0.75;
}

/* QUEUE */
#queue {
	grid-area: main;
	overflow-y: auto;
	padding-inline: 1rem;
}

#queue #queue-table {
	width: 100%;
	border-collapse: collapse;
	table-layout: fixed;
	margin-block-start: 0.5rem;
}

#queue #queue-table th,
#queue #queue-table td {
	text-align: left;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

/* queue - cover art column */
#queue #queue-table th:nth-child(1),
#queue #queue-table td:nth-child(1) {
	width: calc(var(--art-song) * 2);
}

/* queue - duration column */
#queue #queue-table th:nth-child(5),
#queue #queue-table td:nth-child(5) {
	width: 6rem;
}

/* queue - actions column */
#queue #queue-table th:nth-child(6),
#queue #queue-table td:nth-child(6) {
	max-width: 160px;
	overflow: visible;
	white-space: normal;
}

#queue #queue-table td:nth-child(6) button {
	margin-inline-end: 0.5rem;
}

#queue #queue-table td:nth-child(6) button:last-child {
	margin-inline-end: 0;
}

/* queue - rows */
#queue #queue-table tbody tr.stripe {
	background: var(--bg-secondary);
}

#queue #queue-table tbody tr.currently-playing {
	background: var(--playing);
	animation: pulse 4s linear infinite;
}

#queue #queue-table tbody tr.dragging {
	opacity: 0.5;
}

#queue #queue-table tbody tr.selected {
	background: Highlight;
	color: HighlightText;
}

#queue #queue-table tbody tr.drag-over-above {
	border-block-start: 2px solid currentColor;
}

#queue #queue-table tbody tr.drag-over-below {
	border-block-end: 2px solid currentColor;
}

/* queue - row items */
#queue #queue-table .queue-cover {
	width: var(--art-song);
	height: var(--art-song);
	aspect-ratio: 1 / 1;
	object-fit: cover;
	flex-shrink: 0;
}

#queue #queue-table .queue-favorite {
	opacity: 0.25;
}

#queue #queue-table .queue-favorite:hover {
	opacity: 0.5;
}

#queue #queue-table .queue-favorite.favorited {
	opacity: 1;
}

/* FOOTER */
#footer {
	grid-area: footer;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 1rem;
	padding: 0.5rem 1rem;
	border-top: 1px solid var(--border-subtle);
	background: var(--bg-tertiary);
}

#footer #actions {
	display: flex;
	align-items: center;
	gap: 1rem;
}

/* CONTEXT MENU */
#context-menu {
	position: fixed;
	background: var(--bg-context-menu);
	backdrop-filter: blur(16px);
	border: 1px solid var(--border);
	border-radius: 0.25rem;
	box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
	z-index: 1000;
	min-width: 10rem;
}

#context-menu .context-menu-item {
	display: block;
	width: 100%;
	padding: 0.25rem 1rem;
	background: none;
	border: none;
	text-align: left;
}

#context-menu .context-menu-item:hover {
	background: Highlight;
	color: HighlightText;
}

/* MODAL */
.modal {
	position: fixed;
	inset: 0;
	background: rgba(0, 0, 0, 0.75);
	display: flex;
	align-items: center;
	justify-content: center;
	z-index: 2000;
}

.modal.hidden {
	display: none;
}

.modal-content {
	background: Menu;
	border: 1px solid var(--border);
	padding: 1rem;
	box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
}

.modal-content h2 {
	margin-bottom: 1rem;
}

/* FORMS & SETTINGS */
.form-group,
.settings-group {
	margin-bottom: 1.5rem;
}

.form-group label,
.settings-group label {
	display: block;
	margin-bottom: 0.5rem;
}

/* UTILITIES */
/* error */
.error {
	color: var(--error-color);
}

/* famfamfam-silk icons - force pixelated rendering for retina displays */
img[src*="famfamfam-silk"] {
	image-rendering: pixelated;
}

/* MOBILE */
@media (max-width: 768px) {
	/* layout */
	body {
		grid-template-columns: 1fr;
		grid-template-rows: 1fr 1fr auto auto;
		grid-template-areas:
			"main"
			"sidebar"
			"header"
			"footer";
	}

	/* queue - hide album and duration columns */
	th:nth-child(4),
	th:nth-child(5),
	td:nth-child(4),
	td:nth-child(5) {
		display: none;
	}

	#sidebar {
		border-right: none;
		border-top: 1px solid var(--border);
		overflow: hidden;
	}

	/* sidebar - now playing cover art */
	#now-playing #cover-art {
		display: none;
	}

	/* footer - button labels */
	footer button span {
		display: none;
	}
}
