/* Boo Band: the shared sub-page base is /boo-remix/boo-remix.css. */

.stage-floor { margin-top: 28px; }

/* The waterfall sits on the keys; its bottom edge is where song notes land and played notes start. */
.waterfall {
	position: relative;
	height: clamp(200px, 42vw, 320px);
	border: 2px solid var(--ink);
	border-bottom: 0;
	overflow: hidden;
	background: var(--paper);
}

.waterfall-canvas {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	image-rendering: pixelated;
}

.waterfall-hint {
	position: absolute;
	inset: 0;
	display: grid;
	place-items: center;
	margin: 0;
	padding: 0 16px;
	text-align: center;
	color: var(--muted);
	font-size: 0.9rem;
	letter-spacing: 0.06em;
	pointer-events: none;
}

.waterfall.has-notes .waterfall-hint { display: none; }

/* The ghost rides the bottom of the waterfall, gliding along the keys (moved from boo-band.js). */
.performer {
	position: absolute;
	left: 0;
	bottom: 0;
	width: clamp(48px, 11vw, 84px);
	will-change: translate;
}

.performer-sync { will-change: transform; }

/* A joyful spin, turned like an old game sprite: squashed flat, flipped, and back in hard steps,
   with a small hop. Only the image moves, so the music's hops and glides on its parents carry on. */
.performer-ghost.is-spinning { animation: ghost-spin 640ms steps(1, end); }

@keyframes ghost-spin {
	0% { transform: scaleX(1); }
	12% { transform: translateY(-6%) scaleX(0.5); }
	24% { transform: translateY(-12%) scaleX(0.12); }
	36% { transform: translateY(-16%) scaleX(-0.5); }
	50% { transform: translateY(-18%) scaleX(-1); }
	62% { transform: translateY(-16%) scaleX(-0.5); }
	74% { transform: translateY(-12%) scaleX(0.12); }
	86% { transform: translateY(-6%) scaleX(0.5); }
	100% { transform: scaleX(1); }
}

/* Pixel music notes puff out of the spin and fade. */
.spin-note {
	position: absolute;
	left: 50%;
	top: 0;
	width: 15px;
	height: 21px;
	margin-left: -7px;
	fill: var(--ink);
	shape-rendering: crispEdges;
	pointer-events: none;
	opacity: 0;
	animation: note-puff 900ms steps(9, end) forwards;
}

@keyframes note-puff {
	0% { opacity: 1; transform: translate(0, 0); }
	70% { opacity: 1; }
	100% { opacity: 0; transform: translate(var(--drift), -48px); }
}

.performer-ghost {
	display: block;
	width: 100%;
	height: auto;
	image-rendering: pixelated;
}

:root[data-theme='dark'] .performer-ghost { filter: invert(1); }

.stage-bar {
	display: flex;
	flex-wrap: wrap;
	gap: 12px;
	align-items: center;
	justify-content: space-between;
	margin: 20px 0 12px;
}

.play-button,
.octave-button {
	min-width: 44px;
	min-height: 44px;
	border: 1px solid var(--ink);
	display: inline-flex;
	gap: 10px;
	align-items: center;
	justify-content: center;
	color: var(--ink);
	background: var(--paper);
	cursor: pointer;
	touch-action: manipulation;
	transition: color 140ms ease, background-color 140ms ease;
}

.play-button { padding: 0 16px 0 12px; }

.play-button:hover,
.play-button[aria-pressed='true'],
.octave-button:hover:not(:disabled) { color: var(--paper); background: var(--ink); }

.octave-button:disabled { color: var(--muted); border-color: var(--line); cursor: default; }

.play-button svg { width: 18px; height: 18px; fill: currentColor; }

.icon-pause,
.play-button[aria-pressed='true'] .icon-play { display: none; }

.play-button[aria-pressed='true'] .icon-pause { display: block; }

.octave-buttons, .stage-actions { display: flex; gap: 8px; align-items: center; }

/* Whether the song plays the visitor's own Boo Remix mix. */
.mix-chip { display: inline-block; margin: 12px 0 0; padding: 4px 10px; border: 1px solid var(--line); font-size: 0.85rem; color: var(--muted); }

.mix-chip strong { color: var(--ink); font-weight: 600; }

.octave-label { min-width: 5.5em; text-align: center; font-variant-numeric: tabular-nums; font-size: 0.9rem; color: var(--muted); }

/* A song note past the keyboard's edge blinks the octave button that would reach it. */
.octave-button.is-hinting { animation: hint 360ms steps(2, jump-none); }

@keyframes hint {
	from { color: var(--paper); background: var(--ink); }
	to { color: var(--ink); background: var(--paper); }
}

.play-button:focus-visible,
.octave-button:focus-visible,
.keyboard:focus-visible {
	outline: 2px solid var(--ink);
	outline-offset: 4px;
}

/* Square pixel keys: white keys share the row, black keys sit on the lines between them. */
.keyboard {
	--white: calc(100% / var(--whites));
	position: relative;
	display: flex;
	height: clamp(120px, 26vw, 190px);
	border: 2px solid var(--ink);
	background: var(--ink);
	user-select: none;
	-webkit-user-select: none;
	touch-action: none;
	-webkit-touch-callout: none;
}

.key { position: relative; }

.key.is-white {
	flex: 1 1 0;
	border-right: 2px solid var(--ink);
	background: var(--paper);
}

.key.is-white:last-child { border-right: 0; }

.key.is-black {
	position: absolute;
	top: 0;
	left: calc(var(--at) * var(--white) - var(--white) * 0.32 - 1px);
	z-index: 1;
	width: calc(var(--white) * 0.64);
	height: 60%;
	border: 2px solid var(--ink);
	border-top: 0;
	background: var(--ink);
}

/* A song note is dithered, like the pixel art; a note you play is solid. */
.key.is-white.is-song { background: repeating-conic-gradient(var(--ink) 0 25%, var(--paper) 0 50%) 0 0 / 4px 4px; }

.key.is-black.is-song { background: repeating-conic-gradient(var(--paper) 0 25%, var(--ink) 0 50%) 0 0 / 4px 4px; }

.key.is-white.is-live { background: var(--ink); box-shadow: inset 0 0 0 3px var(--paper); }

.key.is-black.is-live { background: var(--paper); }

/* With "no wrong notes" on, black keys play the white key below, so they fade back. */
.keyboard.is-snapped .key.is-black:not(.is-live, .is-song) { background: var(--muted); }

.key[data-name]::after,
.key[data-letter]::before {
	position: absolute;
	left: 0;
	right: 0;
	text-align: center;
	font-size: 0.7rem;
	line-height: 1;
	pointer-events: none;
}

.key[data-name]::after { content: attr(data-name); bottom: 8px; color: var(--muted); }

/* Computer keyboard letters, only where there is a keyboard to type on. */
@media (hover: hover) and (pointer: fine) {
	.key[data-letter]::before { content: attr(data-letter); bottom: 24px; color: var(--line); }
	.key.is-black[data-letter]::before { bottom: 8px; color: var(--muted); }
}

.key.is-live::after, .key.is-live::before { color: var(--paper) !important; }

.key.is-black.is-live::before { color: var(--ink) !important; }

/* The pedalboard: one card per pedal, two to a row where there is room. */
.pedals { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; margin-top: 20px; }

.pedal { display: grid; gap: 12px; align-content: start; padding: 16px; border: 2px solid var(--line); }

.pedal:has([data-param='on']:checked) { border-color: var(--ink); }

.pedal .hint, .pedal .controls { margin: 0; }

.pedal-heading { display: flex; gap: 12px; align-items: center; justify-content: space-between; }

/* Six square-cornered pads under the keys: three to a row on a phone, all six on a wider screen. */
.pads {
	display: grid;
	grid-template-columns: repeat(3, 1fr);
	gap: 8px;
	margin-top: 16px;
	user-select: none;
	-webkit-user-select: none;
	-webkit-touch-callout: none;
}

.pad {
	position: relative;
	min-height: 64px;
	border: 2px solid var(--ink);
	border-radius: 0;
	font-size: 0.85rem;
	color: var(--ink);
	background: var(--paper);
	cursor: pointer;
	touch-action: manipulation;
}

/* A hit you play flashes solid; the song's percussion flashes dithered, like its notes on the keys. */
.pad.is-live { animation: pad-live 160ms steps(1, end); }

.pad.is-song { animation: pad-song 160ms steps(1, end); }

@keyframes pad-live {
	from { color: var(--paper); background: var(--ink); }
}

@keyframes pad-song {
	from { background: repeating-conic-gradient(var(--ink) 0 25%, var(--paper) 0 50%) 0 0 / 4px 4px; }
}

.pad:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }

@media (hover: hover) and (pointer: fine) {
	.pad[data-digit]::before { content: attr(data-digit); position: absolute; top: 6px; left: 8px; font-size: 0.7rem; color: var(--muted); }
	.pad.is-live::before { color: var(--paper); }
}

@media (min-width: 640px) {
	.pads { grid-template-columns: repeat(6, 1fr); }
}

@media (max-width: 520px) {
	.keyboard { height: 132px; }
	.key[data-name]::after { font-size: 0.6rem; }
}

@media (prefers-reduced-motion: reduce) {
	.play-button, .octave-button { transition: none; }
	.performer-ghost.is-spinning, .spin-note { animation: none; }
	.octave-button.is-hinting { animation: none; }
}
