/* play.javagrant.ac.nz — pocket piano */

:root {
	--bg: #0b0e17;
	--panel: #12172a;
	--ink: #e8ecf8;
	--muted: #8a93ad;
	--accent: #6c9bff;
	--white-key: #f4f2ea;
	--white-key-edge: #d8d4c4;
	--black-key: #16181d;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
	height: 100%;
	margin: 0;
	background:
		radial-gradient(1200px 600px at 50% -10%, #1a2140 0%, var(--bg) 60%);
	color: var(--ink);
	font-family: ui-rounded, "SF Pro Rounded", system-ui, sans-serif;
	overscroll-behavior: none;
}

body {
	display: flex;
	flex-direction: column;
	touch-action: manipulation;
	user-select: none;
	-webkit-user-select: none;
}

main { flex: 1; display: flex; flex-direction: column; max-width: 1100px; width: 100%; margin: 0 auto; padding: env(safe-area-inset-top) 16px calc(10px + env(safe-area-inset-bottom)); }

header { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; padding: 14px 2px; }

h1 { font-size: 22px; margin: 0; letter-spacing: .5px; }
h1 .sub { margin-left: 8px; font-size: 12px; font-weight: 500; color: var(--muted); text-transform: uppercase; letter-spacing: 2px; vertical-align: middle; }

.controls { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.controls button {
	appearance: none;
	border: 1px solid #2a3352;
	background: var(--panel);
	color: var(--ink);
	font: inherit;
	font-size: 14px;
	padding: 7px 13px;
	border-radius: 10px;
	cursor: pointer;
	transition: background .15s, border-color .15s, transform .05s;
}
.controls button:active { transform: scale(.96); }
.controls button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #0b1226; font-weight: 600; }
.oct-readout { min-width: 58px; text-align: center; font-variant-numeric: tabular-nums; color: var(--muted); font-size: 14px; }

#hint { color: var(--muted); font-size: 12.5px; margin: 2px 2px 10px; }
kbd {
	background: #1c2338; border: 1px solid #303b5e; border-bottom-width: 2px;
	border-radius: 5px; padding: 1px 6px; font: 11px ui-monospace, monospace; color: var(--ink);
}
@media (pointer: coarse) { #hint { display: none; } }

#kb-scroll { flex: 1; overflow-x: auto; overflow-y: hidden; padding-bottom: 8px; scrollbar-width: thin; scrollbar-color: #2a3352 transparent; }
#keyboard {
	height: 100%;
	min-height: 240px;
	width: max-content;
	min-width: 100%;
	display: grid;
	grid-template-columns: repeat(var(--n), 1fr);
	gap: 0;
	position: relative;
	touch-action: none;
}

.key { position: relative; border-radius: 0 0 7px 7px; }
.key.white {
	background: linear-gradient(var(--white-key), #fff 30%, var(--white-key-edge));
	box-shadow: inset 0 -7px 10px rgba(0,0,0,.08), inset 0 2px 0 rgba(255,255,255,.7), 0 3px 4px rgba(0,0,0,.45);
	z-index: 1;
}
.key.black {
	position: absolute;
	top: 0;
	height: 58%;
	/* 62% of one white key, centred on the boundary between its neighbours */
	width: calc(100% / var(--n) * 0.62);
	margin-left: calc(100% / var(--n) * -0.31);
	background: linear-gradient(#3a3f4b, var(--black-key) 20%, #000);
	box-shadow: 0 5px 8px rgba(0,0,0,.55), inset 0 -4px 6px rgba(255,255,255,.06);
	z-index: 2;
}

.key .label {
	position: absolute;
	left: 0; right: 0; bottom: 8px;
	text-align: center;
	font-size: 11.5px;
	pointer-events: none;
}
.key.white .label { color: #6b6753; }
.key.black .label { color: #9aa3bd; bottom: 6px; font-size: 10.5px; }
body.no-labels .key .label { visibility: hidden; }

.key.active { filter: brightness(.82) saturate(1.15); transform: translateY(1px); }
.key.white.active { background: linear-gradient(#ffd98a, #ffe9b8 40%, var(--white-key-edge)); box-shadow: inset 0 -4px 8px rgba(150,90,0,.25); }
.key.black.active { background: linear-gradient(#5a6cff33, #262b3f 30%, #10121a); box-shadow: 0 2px 5px rgba(0,0,0,.6); }
