/* Beat Board.

   The same warm book palette as the rest of the sandpit, but the layout
   answers a different age. Four huge pads, one big button, and a row of
   lights that shows the beat moving. Nothing to configure, nothing to read,
   no wrong answer: pressing a pad always makes a sound, and the beat keeps
   going whether or not anyone plays along. */

:root {
  --sand-50: #f7f0e2;
  --sand-100: #efe4cd;
  --ink-900: #3a2e20;
  --ink-500: #6f5a3f;
  --pad-1: #c0563a;
  --pad-2: #d8a72c;
  --pad-3: #4a8ba0;
  --pad-4: #6f7f4a;
  --radius: 18px;
  --shadow-pad: 0 4px 0 rgba(90, 70, 50, 0.26), 0 10px 20px rgba(90, 70, 50, 0.16);
  --shadow-pad-down: 0 1px 0 rgba(90, 70, 50, 0.3);
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
}

body {
  display: flex;
  flex-direction: column;
  background: var(--sand-100);
  color: var(--ink-900);
  font-family: ui-rounded, "SF Pro Rounded", ui-sans-serif, -apple-system,
    "Segoe UI", Roboto, sans-serif;
  touch-action: none;
  overflow: hidden;
}

/* ---- lid ------------------------------------------------------------- */

.lid {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: calc(14px + env(safe-area-inset-top)) clamp(16px, 4vw, 32px) 8px;
}

.lid__name {
  margin: 0;
  font-size: clamp(19px, 3.2vw, 26px);
  font-weight: 700;
  letter-spacing: -0.015em;
}

/* ---- tempo ----------------------------------------------------------- */

.tempo {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  background: var(--sand-50);
  border: 1px solid rgba(90, 70, 50, 0.2);
  border-radius: 999px;
}
.tempo__btn {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--ink-900);
  font: 700 20px/1 inherit;
  cursor: pointer;
}
.tempo__btn:active { background: var(--sand-200); }
.tempo__btn:disabled { opacity: 0.3; }
.tempo__btn:focus-visible { outline: 3px solid var(--pad-3); outline-offset: 1px; }
.tempo__label {
  min-width: 78px;
  text-align: center;
  font: 600 14px/1 inherit;
  color: var(--ink-900);
}

/* ---- pads ------------------------------------------------------------ */

.pads {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: clamp(10px, 2vw, 18px);
  padding: clamp(10px, 2vw, 20px) clamp(12px, 3vw, 28px);
  min-height: 0;
}

.pad {
  position: relative;
  border: 0;
  border-radius: var(--radius);
  color: #fff8ea;
  font: 700 clamp(17px, 3vw, 24px)/1.1 inherit;
  text-shadow: 0 1px 2px rgba(40, 26, 10, 0.3);
  cursor: pointer;
  box-shadow: var(--shadow-pad);
  transition: transform 0.07s ease, box-shadow 0.07s ease, filter 0.07s ease;
  display: flex;
  align-items: flex-end;
  justify-content: flex-start;
  padding: 16px;
  min-height: 0;
}
.pad[data-down="true"] {
  transform: translateY(3px) scale(0.985);
  box-shadow: var(--shadow-pad-down);
  filter: brightness(1.12);
}
.pad:focus-visible { outline: 3px solid var(--ink-900); outline-offset: 3px; }

.pad--1 { background: var(--pad-1); }
.pad--2 { background: var(--pad-2); color: var(--ink-900); text-shadow: none; }
.pad--3 { background: var(--pad-3); }
.pad--4 { background: var(--pad-4); }

/* The note name is small and quiet. A two-year-old does not read it, but an
   older sibling or a parent does, and it costs nothing. */
.pad__note {
  position: absolute;
  top: 14px;
  right: 16px;
  font: 600 12px/1 inherit;
  opacity: 0.75;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* A ring that flares when the pad is struck, so the tap is visible as well
   as audible. */
.pad::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: var(--radius);
  border: 0 solid rgba(255, 255, 255, 0.6);
  pointer-events: none;
}
.pad[data-down="true"]::after {
  border-width: 4px;
}

/* ---- transport ------------------------------------------------------- */

.transport {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 4px clamp(12px, 3vw, 28px) calc(18px + env(safe-area-inset-bottom));
}

.play {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-height: 68px;
  padding: 0 34px;
  border: 0;
  border-radius: 999px;
  background: var(--ink-900);
  color: #fdf3e0;
  font: 700 21px/1 inherit;
  cursor: pointer;
  box-shadow: 0 4px 0 rgba(90, 70, 50, 0.4), 0 10px 22px rgba(90, 70, 50, 0.22);
  transition: transform 0.08s ease, box-shadow 0.08s ease, background 0.15s ease;
}
.play:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(90, 70, 50, 0.4); }
.play:focus-visible { outline: 3px solid var(--pad-3); outline-offset: 3px; }
.play[aria-pressed="true"] { background: var(--pad-1); }

.play__icon {
  width: 0;
  height: 0;
  border-left: 15px solid currentColor;
  border-top: 10px solid transparent;
  border-bottom: 10px solid transparent;
}
.play[aria-pressed="true"] .play__icon {
  width: 15px;
  height: 18px;
  border: 0;
  background: currentColor;
  border-radius: 3px;
}

/* ---- step lights ----------------------------------------------------- */

/* One light per beat of the bar. They march, so the beat is something you
   can see before you understand what a beat is. */
.steps {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: center;
}
.step {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--sand-200);
  border: 1px solid rgba(90, 70, 50, 0.16);
  transition: background 0.08s ease, transform 0.08s ease;
}
.step[data-on="true"] {
  background: var(--pad-1);
  transform: scale(1.28);
  border-color: transparent;
}
.step[data-on="downbeat"] {
  background: var(--pad-3);
  transform: scale(1.34);
}

@media (min-width: 760px) {
  .pads { grid-template-columns: repeat(4, 1fr); }
  .pads { max-width: 1200px; margin-inline: auto; width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .pad, .play, .step, .tempo__btn { transition: none; }
}
