/* The bar along the top of every page, shared so nothing moves between pages (shell.js keeps it in
   place): the page menu, with the same links in the same order (the current page is marked and not
   underlined), then the song's play/pause, Record, the mix's Reset, and the light/dark button, with
   a notice under them (bar.js). On narrow screens the links fold into a menu. The empty part of the
   bar lets clicks through, so the home page's ghosts can still be caught under it. */

/* The sub-pages scroll and the home page does not. Where scrollbars take up room, every page keeps
   the scrollbar's space, so the bar's right edge stays put from page to page. */
html { scrollbar-gutter: stable; }

.site-bar {
	position: absolute;
	top: max(12px, env(safe-area-inset-top));
	right: max(16px, env(safe-area-inset-right));
	left: max(16px, env(safe-area-inset-left));
	display: flex;
	flex-wrap: wrap;
	justify-content: flex-end;
	align-items: center;
	gap: 8px;
	z-index: 10;
	pointer-events: none;
}

.site-bar > * { pointer-events: auto; }

.page-nav {
	display: flex;
	gap: 0 14px;
	margin-right: 6px;
}

.page-nav a {
	min-height: 44px;
	display: grid;
	place-items: center;
	padding: 0 4px;
	color: var(--ink);
	font-size: 0.85rem;
	letter-spacing: 0.08em;
	text-decoration-thickness: 1px;
	text-underline-offset: 3px;
}

.page-nav a[aria-current='page'] {
	font-weight: 600;
	text-decoration: none;
}

.page-nav a:focus-visible {
	outline: 2px solid var(--ink);
	outline-offset: 4px;
}

.bar-button {
	width: 44px;
	height: 44px;
	padding: 0;
	border: 1px solid var(--ink);
	display: grid;
	place-items: center;
	color: var(--ink);
	background: var(--paper);
	cursor: pointer;
	touch-action: manipulation;
	transition: color 140ms ease, background-color 140ms ease;
}

.bar-button:not(:disabled):hover,
.bar-button[aria-pressed='true']:not(.theme-button),
.menu-toggle[aria-expanded='true'] {
	color: var(--paper);
	background: var(--ink);
}

/* Reset is dimmed while the normal mix plays, so the buttons beside it never move. */
.bar-button:disabled {
	color: var(--muted);
	border-color: var(--line);
	cursor: default;
}

/* The menu button shows only on narrow screens. */
.menu-toggle { display: none; }

/* Record's dot blinks while it records. */
.record-toggle[aria-pressed='true'] svg { animation: record-blink 1s steps(2, jump-none) infinite; }

@keyframes record-blink {
	from { opacity: 1; }
	to { opacity: 0; }
}

/* A line about each page, shown in the narrow menu. */
.page-note { display: none; }

/* What Record and Reset are doing, under the bar's right end: the recording's time, the download
   link, or a reset's Undo. */
.bar-notice {
	position: absolute;
	top: calc(100% + 8px);
	right: 0;
	max-width: 100%;
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 6px 12px;
	padding: 6px 6px 6px 12px;
	border: 1px solid var(--ink);
	color: var(--ink);
	background: var(--paper);
	font-size: 0.85rem;
}

.bar-notice[hidden],
.bar-notice [hidden] { display: none; }

.notice-time { font-variant-numeric: tabular-nums; font-weight: 600; }

.notice-link { color: var(--ink); text-underline-offset: 3px; }

.notice-action,
.notice-close {
	min-width: 32px;
	min-height: 32px;
	padding: 0 10px;
	border: 1px solid var(--ink);
	color: var(--ink);
	background: var(--paper);
	font: inherit;
	cursor: pointer;
}

.notice-close { padding: 0; font-size: 1.1rem; line-height: 1; }

.notice-action:hover,
.notice-close:hover {
	color: var(--paper);
	background: var(--ink);
}

.notice-link:focus-visible,
.notice-action:focus-visible,
.notice-close:focus-visible {
	outline: 2px solid var(--ink);
	outline-offset: 3px;
}

.bar-button:focus-visible {
	outline: 2px solid var(--ink);
	outline-offset: 4px;
}

.bar-button svg {
	width: 18px;
	height: 18px;
	display: block;
	fill: currentColor;
}

.play-toggle .icon-pause,
.play-toggle.is-playing .icon-play,
.theme-button .icon-sun,
.theme-button[aria-pressed='true'] .icon-moon { display: none; }

.play-toggle.is-playing .icon-pause,
.theme-button[aria-pressed='true'] .icon-sun { display: block; }

/* On narrow screens the page links fold into the menu button, at the bar's left, and open as a
   list under it with a line about each page. */
@media (max-width: 520px) {
	.menu-toggle {
		display: grid;
		margin-right: auto;
	}

	.page-nav {
		position: absolute;
		top: calc(100% + 8px);
		left: 0;
		width: min(300px, 100%);
		margin: 0;
		flex-direction: column;
		border: 1px solid var(--ink);
		background: var(--paper);
	}

	.site-bar:not(.is-menu-open) > .page-nav { display: none; }
	/* The open menu covers the notice's place, so the notice waits behind it until the menu closes. */
	.site-bar.is-menu-open > .bar-notice { display: none; }

	.page-nav a {
		display: flex;
		flex-direction: column;
		align-items: flex-start;
		justify-content: center;
		padding: 8px 14px;
		font-size: 0.9rem;
	}

	.page-nav a + a { border-top: 1px solid var(--line); }

	.page-note {
		display: block;
		color: var(--muted);
		font-size: 0.8rem;
		letter-spacing: 0;
	}

	.page-nav a:focus-visible { outline-offset: -4px; }
}

/* The whole bar fits on one line at 320 px. */
@media (max-width: 400px) {
	.site-bar {
		right: max(12px, env(safe-area-inset-right));
		left: max(12px, env(safe-area-inset-left));
		gap: 6px;
	}

	.bar-button { width: 40px; height: 40px; }
}

@media (prefers-reduced-motion: reduce) {
	.bar-button { transition: none; }
	.record-toggle[aria-pressed='true'] svg { animation: none; }
}

/* After a page change, focus that left with the old page lands on the new <main> (shell.js),
   which needs no ring of its own. */
main[tabindex='-1']:focus { outline: none; }

/* Moving between pages crossfades where the browser supports it (shell.js within the visit, and
   this rule for a full page load), while the song carries on. */
@media (prefers-reduced-motion: no-preference) {
	@view-transition {
		navigation: auto;
	}
}
