@font-face {
  font-family: KenneyFuture;
  src: url(assets/fonts/KenneyFuture.ttf) format('truetype');
  font-display: swap;
}
@font-face {
  font-family: KenneyFutureNarrow;
  src: url(assets/fonts/KenneyFutureNarrow.ttf) format('truetype');
  font-display: swap;
}

:root {
  color-scheme: light dark;
  --bg: #f7f6f2;
  --card: #ffffff;
  --ink: #1d2129;
  --muted: #59606e;
  --line: #e2e0da;
  --btn: #f1f0ec;
  --btn-hover: #e7e5df;
  --accent: #1f7a45;
  --accent-ink: #ffffff;
  --cap: #f4f7f2;
  --tag-off-bg: #ebeae6;
  --tag-off: #555b66;
  --tag-on-bg: #dbf3e2;
  --tag-on: #17663a;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161b;
    --card: #1c1f26;
    --ink: #e9ebf0;
    --muted: #a3a9b6;
    --line: #2e333d;
    --btn: #262a33;
    --btn-hover: #30353f;
    --accent: #3fbf6e;
    --accent-ink: #0d1a12;
    --cap: #20262a;
    --tag-off-bg: #2b2f38;
    --tag-off: #b5bac5;
    --tag-on-bg: #1f3a29;
    --tag-on: #8fe3ad;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}

main {
  max-width: 720px;
  margin: 0 auto;
  padding: 24px 16px 40px;
}

h1, h2 {
  font-weight: 750;
  letter-spacing: -0.01em;
  line-height: 1.2;
}
h1 { font-size: 28px; margin: 0 0 8px; }

.page-head p { margin: 0 0 12px; color: var(--muted); }

nav {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 20px;
}
nav a {
  font-size: 14px;
  color: var(--ink);
  background: var(--btn);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 12px;
  text-decoration: none;
}
nav a:hover { background: var(--btn-hover); }

.demo {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  margin: 0 0 20px;
  scroll-margin-top: 12px;
}
.demo.highlight { box-shadow: 0 0 0 3px var(--accent); }

.demo h2 { font-size: 20px; margin: 0 0 4px; }
.demo h2 a { color: inherit; text-decoration: none; }
.demo h2 a:hover { text-decoration: underline; }
.blurb { margin: 0; color: var(--muted); font-size: 15px; }

.pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 14px 0 10px;
}
.panel { margin: 0; min-width: 0; }
.panel figcaption { margin-bottom: 6px; }
.panel canvas {
  display: block;
  width: 100%;
  aspect-ratio: 360 / 200;
  border-radius: 8px;
  background: #1b2236;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.playing .panel canvas { cursor: pointer; }

.tag {
  display: inline-block;
  font: 700 11.5px/1 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 5px 8px;
  border-radius: 4px;
}
.tag.off { background: var(--tag-off-bg); color: var(--tag-off); }
.tag.on { background: var(--tag-on-bg); color: var(--tag-on); }

.caption {
  margin: 0 0 12px;
  padding: 8px 12px;
  min-height: calc(2 * 1.45em + 16px);
  font-size: 15px;
  line-height: 1.45;
  font-weight: 500;
  background: var(--cap);
  border-left: 3px solid var(--accent);
  border-radius: 4px;
}
.caption.flash { animation: cap-in 0.35s ease-out; }
@keyframes cap-in {
  from { opacity: 0.25; transform: translateY(3px); }
  to { opacity: 1; transform: none; }
}

.controls, .loop-controls, .play-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.play-controls { display: none; }
.playing .play-controls { display: flex; }
.playing .loop-controls { display: none; }

button {
  font: 600 14px/1.2 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--btn);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 14px;
  min-height: 40px;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
button:hover { background: var(--btn-hover); }
button:active { transform: translateY(1px); }
button:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
button.primary:hover { filter: brightness(1.08); }
.sound, .play-controls .replay { margin-left: auto; }
.play-controls .replay { margin-left: 0; }

.page-foot { font-size: 13px; color: var(--muted); }
.page-foot a { color: inherit; }
.error { padding: 16px; }

/* Phones: stack the two panels, without above with. */
@media (max-width: 480px) {
  main { padding: 16px 10px 28px; }
  h1 { font-size: 24px; }
  .demo { padding: 12px; border-radius: 12px; }
  .pair { grid-template-columns: 1fr; gap: 8px; }
  .caption { min-height: calc(3 * 1.45em + 16px); font-size: 14.5px; }
  .sound { margin-left: 0; }
}

/* ?trick=<id>&solo: just the one card, sized for an iframe. */
body.solo { background: transparent; }
body.solo main { max-width: none; padding: 0; }
body.solo .page-head, body.solo .page-foot { display: none; }
body.solo .demo { margin: 0; }
