@font-face { font-family: 'Kenney Future'; src: url('assets/fonts/KenneyFuture.ttf') format('truetype'); font-display: swap; }
@font-face { font-family: 'Atkinson'; src: url('assets/fonts/AtkinsonHyperlegible-Regular.ttf') format('truetype'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Atkinson'; src: url('assets/fonts/AtkinsonHyperlegible-Bold.ttf') format('truetype'); font-weight: 700; font-display: swap; }

:root {
  --ink: #1d1b24;
  --muted: #5c5868;
  --paper: #f6f4ef;
  --card: #ffffff;
  --line: #e2ded5;
  --accent: #0f7b6c;
  --accent-ink: #ffffff;
  --off: #4a4656;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 16px/1.5 'Atkinson', system-ui, -apple-system, 'Segoe UI', sans-serif;
}
#app { max-width: 720px; margin: 0 auto; padding: 20px 12px 40px; }
h1, h2, .tag, .num { font-family: 'Kenney Future', 'Atkinson', system-ui, sans-serif; font-weight: normal; letter-spacing: .02em; }
h1 { font-size: 30px; line-height: 1.15; margin: 4px 0 10px; }
.intro p { margin: 0 0 10px; }
.intro .hint { color: var(--muted); font-size: 14.5px; }

.demo {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 14px; margin: 18px 0;
}
.demo-head { display: flex; gap: 10px; align-items: baseline; }
.num {
  flex: none; width: 26px; height: 26px; border-radius: 50%; background: var(--ink); color: #fff;
  display: inline-grid; place-items: center; font-size: 13px; transform: translateY(-2px);
}
h2 { font-size: 21px; margin: 0; }
.lede { margin: 4px 0 12px; color: var(--muted); font-size: 15px; }

.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.pair.single { grid-template-columns: 1fr; }
.panel { margin: 0; min-width: 0; }
.stage { position: relative; border-radius: 9px; overflow: hidden; background: #ccc; aspect-ratio: 3 / 2; touch-action: manipulation; }
.stage canvas { display: block; width: 100%; height: 100%; }
.gray .stage canvas { filter: grayscale(1); }
.tag {
  position: absolute; left: 7px; top: 7px; font-size: 11px; padding: 3px 7px 2px; border-radius: 5px;
  background: rgba(20, 18, 26, .78); color: #fff; pointer-events: none;
}
.panel.on .tag { background: var(--accent); }
.meas { font-size: 12.5px; color: var(--muted); min-height: 0; margin-top: 5px; line-height: 1.35; }
.meas:empty { display: none; }
.meas b.ok { color: var(--accent); }
.meas b.bad { color: #8a5a00; }

.overlay {
  position: absolute; inset: 0; display: none; place-items: center; text-align: center; padding: 10px;
  color: #fff; font-weight: 700; font-size: 15px; pointer-events: none;
}
.overlay.show { display: grid; }
.overlay.dim { background: rgba(20, 18, 26, .72); }
.panel.active .stage { outline: 3px solid var(--accent); outline-offset: -3px; cursor: crosshair; }

.caption { margin-top: 10px; }
.event { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 15px; min-height: 24px; }
.bar { flex: none; width: 44px; height: 5px; border-radius: 3px; background: var(--line); overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--ink); }
.takeaway { margin: 6px 0 0; font-size: 15px; }

.controls { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; align-items: center; }
button, .btn {
  font: 700 14px/1 'Atkinson', system-ui, sans-serif; color: var(--ink); background: #fff;
  border: 1.5px solid #cfcabd; border-radius: 999px; padding: 8px 12px; cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center; gap: 5px; min-height: 36px;
}
button:hover, .btn:hover { border-color: var(--ink); }
button:focus-visible, .btn:focus-visible, input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 2px; }
button[aria-pressed="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.controls .solo-link { margin-left: auto; font-weight: 400; color: var(--muted); border-color: transparent; padding-right: 2px; }
.controls .solo-link:hover { text-decoration: underline; border-color: transparent; }

.switches { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 0; }
.switches label { position: relative; }
.switches input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switches span {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 11px; border-radius: 999px; min-height: 34px;
  border: 1.5px solid #cfcabd; font-weight: 700; font-size: 14px; cursor: pointer; user-select: none;
}
.switches span::before { content: ''; width: 10px; height: 10px; border-radius: 50%; border: 2px solid currentColor; }
.switches input:checked + span { background: var(--accent); border-color: var(--accent); color: #fff; }
.switches input:checked + span::before { background: #fff; border-color: #fff; }

.testbar {
  margin: 0 0 10px; scroll-margin-top: 8px; padding: 10px 12px; border-radius: 10px; background: #eef6f4; border: 1px solid #cfe5e0;
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
}
.testbar[hidden] { display: none; }
.testbar canvas { width: 56px; height: 56px; flex: none; background: #fff; border-radius: 8px; border: 1px solid #cfe5e0; }
.testbar canvas[hidden] { display: none; }
.testbar .msg { flex: 1 1 200px; font-size: 15px; }
.testbar .msg small { display: block; color: var(--muted); font-size: 13px; }
.score { display: flex; gap: 14px; font-size: 15px; }
.score b { font-size: 20px; }

.foot { color: var(--muted); font-size: 13px; margin-top: 24px; }
.notfound { background: #fff3d6; padding: 10px; border-radius: 8px; }

.side-l::before { content: 'Left:'; }
.side-r::before { content: 'Right:'; }
.single .side-l::before { content: ''; }

@media (max-width: 520px) {
  .side-l::before { content: 'Top:'; }
  .side-r::before { content: 'Bottom:'; }
  #app { padding: 14px 8px 30px; }
  h1 { font-size: 25px; }
  .demo { padding: 11px; border-radius: 12px; }
  .pair { grid-template-columns: 1fr; gap: 8px; }
  .controls .solo-link { margin-left: 0; }
}

/* ?trick=<id>&solo : just the one demo, for embedding */
body.solo { background: transparent; }
body.solo #app { padding: 0; }
body.solo .intro, body.solo .foot { display: none; }
body.solo .demo { margin: 0; }
