/* kvworkers.com: readykeys ground (navy, 28px grid, IBM Plex), one column of sections, the keypad first */
:root {
  --ground: #003a70; --ground-2: #00305c; --ground-3: #00284d; --visible: #eaf2ff; --dim: #c6dbf7; --thin: #9dbee8;
  --line: #5b87c4; --accent: #ffd166; --ok: #90c986; --fail: #ffa39e;
  --font-display: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --font-body: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { background: var(--ground); -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background-color: var(--ground); color: var(--visible); font: 16px/1.6 var(--font-body);
  background-image: linear-gradient(rgba(157, 190, 232, .07) 1px, transparent 1px), linear-gradient(90deg, rgba(157, 190, 232, .07) 1px, transparent 1px);
  background-size: 28px 28px;
}
a { color: var(--accent); text-underline-offset: 3px; }
a:hover { color: var(--visible); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 16px; }
.eyebrow { font: 600 11px/1 var(--font-display); letter-spacing: .16em; text-transform: uppercase; color: var(--accent); margin: 0 0 14px; }
h1, h2, h3 { font-family: var(--font-display); font-weight: 600; letter-spacing: -.01em; margin: 0; }
h1 { font-size: clamp(34px, 6vw, 64px); line-height: 1.04; }
h2 { font-size: clamp(26px, 3.6vw, 38px); line-height: 1.12; margin-bottom: 14px; }
h3 { font-size: 15px; margin-bottom: 6px; }
p { margin: 0 0 12px; color: var(--dim); max-width: 68ch; }
.lead { font-size: 18px; color: var(--visible); margin-top: 18px; }
section { padding: 72px 0; border-top: 1px solid rgba(91, 135, 196, .35); }
header.top { padding: 22px 0 0; }
header.top .bar { display: flex; justify-content: space-between; align-items: center; font: 600 13px/1 var(--font-display); }
header.top .bar a { color: var(--dim); text-decoration: none; margin-left: 18px; }
header.top .bar a:hover { color: var(--accent); }
.hero { padding: 44px 0 64px; border-top: 0; }
.hero-grid { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr); gap: 28px; margin-top: 34px; align-items: start; }
@media (max-width: 900px) { .hero-grid { grid-template-columns: 1fr; } }

/* the keypad: canvas when WebGPU runs, SVG otherwise */
.stage { position: relative; border: 1px solid var(--line); background: radial-gradient(120% 90% at 50% 30%, rgba(0, 58, 112, .2), rgba(0, 25, 50, .65)); min-height: 360px; }
#pad-canvas { display: block; width: 100%; height: clamp(360px, 58vw, 560px); touch-action: none; cursor: grab; }
#pad-svg { display: none; width: 100%; height: auto; padding: 22px; }
body[data-gpu="off"] #pad-svg, body:not([data-gpu]) #pad-svg { display: block; }
body[data-gpu="off"] #pad-canvas, body:not([data-gpu]) #pad-canvas { display: none; }
body[data-gpu="off"] .gpu-only, body:not([data-gpu]) .gpu-only { display: none; }
.stage-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 12px; border-top: 1px solid var(--line); background: rgba(0, 40, 77, .7); }
.stage-bar label { font: 600 12px/1 var(--font-display); color: var(--thin); display: flex; align-items: center; gap: 8px; }
.stage-bar input[type=range] { accent-color: var(--accent); width: 140px; }
.note { font-size: 13px; color: var(--thin); margin: 10px 0 0; }

/* svg keys */
.k rect.cap { fill: var(--line); stroke: rgba(0, 0, 0, .35); stroke-width: 2; }
.k.light rect.cap { fill: var(--visible); }
.k.ctl rect.cap { fill: var(--dim); }
.k text { font-family: var(--font-display); font-weight: 600; fill: var(--visible); text-anchor: middle; dominant-baseline: middle; pointer-events: none; }
.k.light text, .k.ctl text { fill: var(--ground); }
.k text.sub { font-size: 11px; opacity: .8; }
.k { cursor: pointer; }
.k:hover rect.cap, .k:focus-visible rect.cap { stroke: var(--accent); stroke-width: 3; }
.k.selected rect.cap { stroke: var(--accent); stroke-width: 4; }
.k:focus { outline: none; }
.led { fill: #20314a; }

/* lights: the same states and pulses as the keymap */
[data-light="i"] .led, .dot[data-light="i"] { fill: #9dbee8; background: #9dbee8; }
[data-light="w"] .led, .dot[data-light="w"] { fill: #eaf2ff; background: #eaf2ff; animation: working 2.4s ease-in-out infinite; }
[data-light="n"] .led, .dot[data-light="n"] { fill: #ffd166; background: #ffd166; animation: needs 1.2s ease-in-out infinite; }
[data-light="d"] .led, .dot[data-light="d"] { fill: #90c986; background: #90c986; }
[data-light="-"] .led, .dot[data-light="-"] { fill: #20314a; background: transparent; }
@keyframes working { 50% { opacity: .45; } }
@keyframes needs { 50% { opacity: .25; } }
@media (prefers-reduced-motion: reduce) { [data-light] .led, .dot { animation: none !important; } }

/* the selected key */
.panel { border: 1px solid var(--line); background: rgba(0, 40, 77, .72); padding: 20px; }
.panel .big { font: 600 54px/1 var(--font-display); color: var(--accent); margin: 2px 0 10px; }
.panel[data-empty="true"] .when-selected { display: none; }
.panel[data-empty="false"] .when-empty { display: none; }
.kv { font: 13px/1.75 var(--font-display); color: var(--dim); margin: 0 0 14px; padding: 0; list-style: none; overflow-wrap: anywhere; }
.kv .k { color: var(--accent); }
.kv .v { color: var(--visible); }
.buttons { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 4px; }
button, .btn {
  font: 600 13px/1 var(--font-display); color: var(--visible); background: transparent; border: 1px solid var(--line);
  padding: 10px 12px; cursor: pointer; text-decoration: none; display: inline-block;
}
button:hover:not(:disabled), .btn:hover { border-color: var(--accent); color: var(--accent); }
button[aria-pressed="true"] { border-color: var(--accent); color: var(--ground); background: var(--accent); }
button:disabled { opacity: .45; cursor: not-allowed; }
button.primary { background: var(--accent); color: var(--ground); border-color: var(--accent); }
button.primary:hover { background: transparent; color: var(--accent); }
.status { font-size: 13px; color: var(--thin); margin: 10px 0 0; min-height: 1.6em; }
body[data-hid="on"] .status { color: var(--ok); }

/* the S-team list */
.team { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; margin-top: 28px; }
.member { display: grid; grid-template-columns: 44px 1fr; grid-auto-rows: auto; gap: 2px 12px; align-items: center; border: 1px solid var(--line); background: rgba(0, 40, 77, .55); padding: 14px; text-align: left; width: 100%; font: inherit; color: inherit; cursor: pointer; }
.member:hover, .member.selected { border-color: var(--accent); }
.member .key { grid-row: span 3; font: 600 26px/44px var(--font-display); text-align: center; border: 1px solid var(--line); height: 44px; color: var(--visible); }
.member .name { font: 600 14px/1.3 var(--font-display); color: var(--visible); }
.member .meta { font-size: 13px; color: var(--thin); display: flex; align-items: center; gap: 8px; }
.member .who { font-size: 12px; color: var(--thin); font-family: var(--font-display); }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; border: 1px solid var(--line); }
.gap { opacity: .7; cursor: default; }

/* parts, firmware, how it works */
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 20px; margin-top: 26px; }
.card { border: 1px solid var(--line); background: rgba(0, 40, 77, .55); padding: 20px; }
.card p { font-size: 15px; }
ol.steps { margin: 18px 0 0; padding-left: 22px; color: var(--dim); max-width: 74ch; }
ol.steps li { margin-bottom: 10px; }
code { font-family: var(--font-display); font-size: .92em; color: var(--visible); background: rgba(0, 25, 50, .7); padding: 1px 5px; }
.flow { width: 100%; height: auto; margin-top: 26px; border: 1px solid var(--line); background: rgba(0, 25, 50, .45); }
.flow .box { fill: rgba(0, 58, 112, .9); stroke: var(--line); stroke-width: 1.5; }
.flow .hot { stroke: var(--accent); }
.flow text { font: 600 13px var(--font-display); fill: var(--visible); text-anchor: middle; dominant-baseline: middle; }
.flow text.small { font: 12px var(--font-body); fill: var(--thin); }
.flow path { stroke: var(--thin); stroke-width: 1.5; fill: none; marker-end: url(#arrow); }
footer { padding: 46px 0 64px; border-top: 1px solid rgba(91, 135, 196, .35); }
footer p { font-size: 14px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
@media (max-width: 600px) {
  header.top .bar { flex-direction: column; align-items: flex-start; gap: 10px; }
  header.top .bar a { margin: 0 16px 0 0; }
  section { padding: 52px 0; }
  .lead { font-size: 16px; }
  .panel .big { font-size: 40px; }
}
