/* =====================================================================================
   Isomorph, base: fontes, tokens, pagina, capa e lentes. O deck (deck.css) e o que fica por
   cima da obra (layers.css) so usam os tokens daqui. Uma escala so: tudo por clamp/rem, e os
   componentes respondem ao proprio espaco (container queries), nao ao device.
   ===================================================================================== */

/* Inclusive Sans (OFL, Olivia King), variavel 300-700, servida local: o CSP so libera
   font-src 'self'. Dois recortes do Google Fonts: latin (toda a UI) e latin-ext. */
@font-face {
	font-family: 'Inclusive Sans';
	src: url('assets/InclusiveSans-latin.woff2') format('woff2');
	font-weight: 300 700; font-style: normal; font-display: swap;
	unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
	font-family: 'Inclusive Sans';
	src: url('assets/InclusiveSans-latin-ext.woff2') format('woff2');
	font-weight: 300 700; font-style: normal; font-display: swap;
	unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* ---------------------------------------------------------------- tokens
   Uma escala so. Componentes nao carregam numero solto: toda geometria da tecla, do fader,
   do switch e do drive deriva de --key (fluido); espacos de --space-*; texto de --text-*. */
:root {
	--font-ui: 'Inclusive Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;

	/* tinta: segue a tinta da simulacao (Main.hx inkColor). O deck.js troca p/ ambar. */
	--ink: #40b3ff;
	--ink-glow: color-mix(in srgb, var(--ink) 55%, transparent);
	--rec: #ff3b30;
	--drive-led: #8cff5a;

	/* plastico e teclas */
	--chassis: #1a1a1c;
	--chassis-top: #212124;
	--chassis-edge: #0b0b0c;
	--well: #0a0c0d;
	--cap: #2a2a2e;
	--cap-top: #36363b;
	--cap-edge: #141416;
	--legend: #e8e3d7;
	--legend-dim: #9a968c;
	--engrave: #7c7970;
	--led-off: #2b2724;

	--space-1: clamp(0.25rem, 0.22rem + 0.15vw, 0.35rem);
	--space-2: clamp(0.5rem, 0.44rem + 0.3vw, 0.7rem);
	--space-3: clamp(0.75rem, 0.66rem + 0.45vw, 1.05rem);
	--text-xs: clamp(0.68rem, 0.65rem + 0.12vw, 0.75rem);
	--text-s: clamp(0.78rem, 0.75rem + 0.15vw, 0.86rem);
	--text-m: clamp(0.9rem, 0.86rem + 0.2vw, 1rem);

	/* a tecla e a unidade do aparelho */
	--key: clamp(2.1rem, 1.95rem + 0.5vw, 2.45rem);
	--key-sm: calc(var(--key) * 0.78);
	--key-tall: calc(var(--key) * 1.5);
	--icon: calc(var(--key) * 0.4);
	--led: calc(var(--key) * 0.17);
	--led-pitch: calc(var(--key) * 0.3);
	--cap-depth: calc(var(--key) * 0.095);
	--cap-press: calc(var(--cap-depth) * 0.6);
	--r-cap: calc(var(--key) * 0.17);
	--r-well: calc(var(--key) * 0.22);
	--r-chassis: calc(var(--key) * 0.38);
	--hairline: max(1px, 0.0625rem);
	--shade: calc(var(--key) * 0.2);
	--jog: calc(var(--key) * 1.25);

	/* LCD: o passo do ponto e o token; colunas e linhas saem do espaco (deck.js) */
	--lcd-dot: clamp(0.15rem, 0.135rem + 0.08vw, 0.19rem);
	--panel-w: clamp(18.5rem, 15rem + 9vw, 22.5rem);
	--strip-max: 96rem;

	--edge-pad: clamp(0.75rem, 0.55rem + 1vw, 1.5rem);
	--motion-fast: 110ms;
	--motion: 220ms;
	--motion-slow: 420ms;
	--ease-out: cubic-bezier(0.22, 1, 0.36, 1);
	--ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}
/* toque: alvo maior (adaptacao de input, nao de device) */
@media (pointer: coarse) { :root { --key: clamp(2.5rem, 2.3rem + 0.5vw, 2.8rem); } }
body.ink-amber { --ink: #ff8c2e; }

html { width: 100%; height: 100%; margin: 0; }
body {
	width: 100%; height: 100%; margin: 0; overflow: hidden; background-color: black;
	font-family: var(--font-ui); color: var(--legend);
	-webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
}
#wrapper { width: 100%; height: 100%; }
#canvas { width: 100%; height: 100%; display: block; }
.sr-only {
	position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
	overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* #cover: o Haxe remove ao terminar o decode. Com o deck, o loading visivel e o drive + LCD;
   a linha abaixo so aparece se o deck.js nao carregar (progressive enhancement). */
#cover { position: absolute; inset: 0; display: grid; place-items: center; user-select: none; -webkit-user-select: none; }
.cover-line { display: flex; align-items: center; gap: var(--space-2); font-size: var(--text-s); color: var(--legend-dim); }
body.has-deck .cover-line { position: absolute; inline-size: 1px; block-size: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); }

/* ---------------------------------------------------------------- lentes (filtros no canvas)
   CADEIA CANONICA: as seis funcoes, sempre na mesma ordem; transition:filter so interpola
   entre listas estruturalmente iguais. */
#wrapper { transition: filter 0.45s ease; }
body.view-blackbody #wrapper { filter: invert(0) hue-rotate(155deg) grayscale(0) saturate(1.6) contrast(1.12) brightness(1.05); }
body.view-plate #wrapper { filter: invert(1) hue-rotate(180deg) grayscale(0) saturate(1) contrast(1.08) brightness(1.02); }
body.view-phosphor #wrapper { filter: invert(0) hue-rotate(0deg) grayscale(1) saturate(1) contrast(1.25) brightness(1.35); }

/* calmo (calm.js): troca de lente vira um crossfade longo, nunca um corte */
body.calm #wrapper { transition-duration: 1.6s; }

@media (prefers-reduced-motion: reduce) {
	#wrapper { transition: none !important; }
}
