/* Beat Board: a two-deck DJ toy in the sandpit's warm book palette.

   Deck A is coral, deck B is teal, and the platters are dark vinyl. On a phone
   everything stacks: shared transport, the two decks side by side, the mixer
   under them, and the four pads in one row. Wide screens put the transport on
   one line and lay each deck out as a platter with its controls alongside, so
   nothing has to scroll to be played.

   Type is set with longhand properties on purpose: `font: 700 18px/1 inherit`
   is invalid (a CSS-wide keyword cannot be a shorthand component), which
   silently drops the whole declaration. */

:root {
  --sand-50: #f7f0e2;
  --sand-100: #efe4cd;
  --sand-200: #e8d9bd;
  --ink-900: #3a2e20;
  --ink-500: #6f5a3f;
  --cream: #fff8ea;
  --vinyl: #241c16;
  --vinyl-edge: #171210;
  --deck-a: #c0563a;
  --deck-a-deep: #a8472f;
  --deck-b: #4a8ba0;
  --deck-b-deep: #35687a;
  --pad-1: #c0563a;
  --pad-2: #d8a72c;
  --pad-3: #4a8ba0;
  --pad-4: #6f7f4a;
  --radius: 14px;
  --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 {
  min-height: 100%;
  margin: 0;
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  /* A long-press on a pad or chip must act on it, never raise the callout. */
  -webkit-touch-callout: none;
}

body {
  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;
  /* The page scrolls vertically on short screens; only the surfaces that own
     a drag say so themselves. */
  touch-action: pan-y;
  overflow-x: hidden;
}

.board {
  display: flex;
  flex-direction: column;
  gap: clamp(6px, 1.2vh, 14px);
  max-width: 1080px;
  min-height: 100%;
  margin-inline: auto;
  padding: calc(10px + env(safe-area-inset-top)) clamp(10px, 3vw, 28px)
    calc(14px + env(safe-area-inset-bottom));
}

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

.top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
}

.top__name {
  order: 1;
  margin: 0;
  font-size: clamp(20px, 4.4vw, 26px);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.015em;
}

.play {
  order: 2;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  padding: 0 20px;
  border: 0;
  border-radius: 999px;
  background: var(--ink-900);
  color: #fdf3e0;
  font-family: inherit;
  font-size: 18px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  touch-action: manipulation; /* a double tap on Play must not zoom */
  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(--deck-b); outline-offset: 3px; }
.play[aria-pressed="true"] { background: var(--deck-a-deep); }

.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: 14px;
  height: 18px;
  border: 0;
  background: currentColor;
  border-radius: 3px;
}

.tempo {
  order: 3;
  flex-basis: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 4px;
  background: var(--sand-50);
  border-radius: 999px;
  box-shadow: 0 2px 0 rgba(90, 70, 50, 0.14), 0 8px 18px rgba(90, 70, 50, 0.1);
}
.tempo__btn {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--ink-900);
  font-family: inherit;
  font-size: 20px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  touch-action: manipulation;
}
.tempo__btn:active { background: var(--sand-200); }
.tempo__btn:disabled { opacity: 0.35; }
.tempo__btn:focus-visible { outline: 3px solid var(--deck-b); outline-offset: 1px; }
.tempo__label {
  min-width: 86px;
  text-align: center;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
  color: var(--ink-900);
  font-variant-numeric: tabular-nums;
}

/* ---- bar position ---------------------------------------------------- */

.steps {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
}
.step {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--sand-200);
  transition: background 0.08s ease, transform 0.08s ease;
}
.step[data-on="true"] {
  background: var(--deck-a);
  transform: scale(1.35);
}
.step[data-on="downbeat"] {
  background: var(--deck-b-deep);
  transform: scale(1.45);
}

/* ---- decks ----------------------------------------------------------- */

.decks {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(8px, 2vw, 18px);
}

.deck {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 8px 8px 10px;
  border-radius: var(--radius);
  background: var(--sand-50);
  box-shadow: 0 2px 0 rgba(90, 70, 50, 0.16), 0 10px 22px rgba(90, 70, 50, 0.12);
}
.deck--a { --deck-color: var(--deck-a); --deck-color-deep: var(--deck-a-deep); }
.deck--b { --deck-color: var(--deck-b); --deck-color-deep: var(--deck-b-deep); }

.deck__name {
  margin: 0;
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--deck-color-deep);
}

/* The platter is the scratch surface: dark vinyl with microgrooves, a
   coloured centre label, and a marker that only turns while the bar runs. */
.platter {
  position: relative;
  width: min(100%, 152px);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 42%, #35291f 0%, var(--vinyl) 45%, var(--vinyl-edge) 100%);
  /* One declaration: the vinyl's own thickness. The deck panel above already
     carries the elevation, and a second soft shadow read as a nested card. */
  box-shadow: 0 3px 0 rgba(23, 18, 16, 0.45);
  touch-action: none;
  cursor: grab;
  transition: transform 0.08s ease;
}
.platter:active,
.platter[data-dragging="true"] { transform: scale(0.985); }
.platter:focus-visible { outline: 3px solid var(--deck-color-deep); outline-offset: 4px; }

.platter__disc {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: repeating-radial-gradient(
    circle at 50% 50%,
    rgba(255, 248, 234, 0.055) 0 1px,
    transparent 1px 5px
  );
  animation: spin 2.6s linear infinite;
  animation-play-state: paused;
}
#board[data-playing="true"] .platter__disc { animation-play-state: running; }

/* The marker is what makes the rotation readable at a glance. */
.platter__disc::after {
  content: "";
  position: absolute;
  top: 9%;
  left: 50%;
  width: 7px;
  height: 7px;
  margin-left: -3.5px;
  border-radius: 50%;
  background: var(--deck-color);
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* While a finger is on the platter the vinyl stops turning and this cue picks
   up the hand's back-and-forth motion instead. */
.platter__cue {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  opacity: 0;
  transform: rotate(var(--cue, 0deg));
  transition: opacity 0.12s ease;
  pointer-events: none;
}
.platter__cue::after {
  content: "";
  position: absolute;
  top: 8%;
  left: 50%;
  width: 8px;
  height: 8px;
  margin-left: -4px;
  border-radius: 50%;
  background: var(--cream);
  box-shadow: 0 0 0 2px var(--deck-color-deep);
}
.platter[data-dragging="true"] .platter__cue { opacity: 1; }
.platter[data-dragging="true"] .platter__disc { animation-play-state: paused; }

.platter__label {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 38%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--deck-color-deep);
  color: var(--cream);
  font-family: inherit;
  font-size: clamp(14px, 3.6vw, 18px);
  font-weight: 700;
  line-height: 1;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.45);
}

.platter__hint {
  position: absolute;
  bottom: 7%;
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  letter-spacing: 0.02em;
  color: rgba(255, 248, 234, 0.82);
}

.grooves {
  display: flex;
  gap: 6px;
  width: 100%;
}
.chip {
  flex: 1;
  min-height: 44px;
  padding: 4px 6px;
  border: 0;
  border-radius: 12px;
  background: var(--sand-200);
  color: var(--ink-900);
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.15;
  cursor: pointer;
  touch-action: manipulation;
  transition: background 0.12s ease, color 0.12s ease, transform 0.08s ease;
}
.chip:active { transform: scale(0.97); }
.chip:focus-visible { outline: 3px solid var(--deck-color-deep); outline-offset: 2px; }
.chip[aria-pressed="true"] {
  background: var(--deck-color-deep);
  color: var(--cream);
}

/* ---- faders ---------------------------------------------------------- */

.fader {
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 100%;
}
.fader__name {
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-500);
}

.range {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 44px; /* the whole strip is the target, thumb or not */
  margin: 0;
  background: transparent;
  cursor: pointer;
  touch-action: pan-y;
}
.range:focus-visible { outline: 3px solid var(--ink-900); outline-offset: 3px; border-radius: 999px; }

.range::-webkit-slider-runnable-track {
  height: 10px;
  border-radius: 999px;
  background: var(--sand-200);
  box-shadow: inset 0 1px 2px rgba(90, 70, 50, 0.25);
}
.range::-moz-range-track {
  height: 10px;
  border-radius: 999px;
  background: var(--sand-200);
  box-shadow: inset 0 1px 2px rgba(90, 70, 50, 0.25);
}

.range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 36px;
  height: 36px;
  margin-top: -13px;
  border-radius: 50%;
  background: var(--cream);
  box-shadow: 0 2px 4px rgba(58, 46, 32, 0.35), 0 6px 12px rgba(58, 46, 32, 0.22);
}
.range::-moz-range-thumb {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: var(--cream);
  box-shadow: 0 2px 4px rgba(58, 46, 32, 0.35), 0 6px 12px rgba(58, 46, 32, 0.22);
}

/* Each deck's filter thumb carries its side's colour. */
.range--filter::-webkit-slider-thumb { background: var(--deck-color-deep, var(--cream)); }
.range--filter::-moz-range-thumb { background: var(--deck-color-deep, var(--cream)); }

/* ---- mixer ----------------------------------------------------------- */

.mixer {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.cross {
  display: flex;
  align-items: center;
  gap: 8px;
}
.cross__end {
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  color: var(--ink-500);
}

/* The track itself says which way the fader moves. */
.range--cross::-webkit-slider-runnable-track {
  background: linear-gradient(90deg, var(--deck-a) 0%, var(--sand-200) 45%, var(--sand-200) 55%, var(--deck-b) 100%);
}
.range--cross::-moz-range-track {
  background: linear-gradient(90deg, var(--deck-a) 0%, var(--sand-200) 45%, var(--sand-200) 55%, var(--deck-b) 100%);
}

.meter {
  height: 8px;
  border-radius: 999px;
  background: var(--sand-200);
  box-shadow: inset 0 1px 2px rgba(90, 70, 50, 0.22);
  overflow: hidden;
}
.meter__fill {
  display: block;
  height: 100%;
  width: 100%;
  background: var(--pad-4);
  transform: scaleX(0);
  transform-origin: left center;
}

/* ---- the lane -------------------------------------------------------- */

/* The lane is the strip that shows the child the phrase they have written:
   one slot per eighth note of the bar, filled in the colour of the pad
   they hit there. The slot being played back right now is lit, so the
   strip reads as a phrase that is moving rather than a row of dots. */
.memory {
  position: relative;
  display: flex;
  justify-content: center;
}

.memory__strip {
  display: flex;
  gap: clamp(3px, 1vw, 7px);
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 560px;
  padding: 7px clamp(8px, 2vw, 14px);
  border-radius: 999px;
  background: var(--sand-50);
  box-shadow: inset 0 1px 3px rgba(90, 70, 50, 0.22);
}

.lane__slot {
  flex: 1;
  min-width: 0;
  height: 22px;
  border-radius: 999px;
  background: var(--sand-200);
  transition: background 0.12s ease, transform 0.12s ease;
}

/* An empty slot is a low, quiet mark: the lane is always there, so the
   child can see where a tap would land before they make it.

   The slot keeps its height and only its colour changes, so filling the
   lane never moves the layout under the child's finger. */
.lane__slot[data-key="none"] {
  background: var(--sand-200);
  opacity: 0.5;
}

/* A filled slot takes the pad's colour, so the phrase is legible at a
   glance: a row of coral and blue reads as a rhythm. */
.lane__slot[data-key="kick"] { background: var(--pad-1); }
.lane__slot[data-key="snare"] { background: var(--pad-2); }
.lane__slot[data-key="hat"] { background: var(--pad-3); }
.lane__slot[data-key="bass"] { background: var(--pad-4); }

/* The slot under the play head lifts, and the slot that is being answered
   right now is the one the board is sounding. */
.lane__slot[data-on="true"] {
  transform: scaleY(1.35);
}

/* The strip is a picture of the phrase, so it is also described in words
   for anyone who cannot see it. The text is taken out of the layout but
   not out of the accessibility tree. */
.memory__status {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

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

/* One row of four, even on a phone: each pad is still a thumb-width target
   and the row costs a quarter of the height two rows would. */
.pads {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: clamp(6px, 1.6vw, 14px);
}

.pad {
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: flex-start;
  min-height: 56px;
  padding: 8px;
  border: 0;
  border-radius: var(--radius);
  color: var(--cream);
  font-family: inherit;
  font-size: clamp(12px, 3vw, 20px);
  font-weight: 700;
  line-height: 1.1;
  text-shadow: 0 1px 2px rgba(40, 26, 10, 0.3);
  cursor: pointer;
  touch-action: manipulation;
  box-shadow: var(--shadow-pad);
  transition: transform 0.07s ease, box-shadow 0.07s ease, filter 0.07s ease;
}
.pad[data-down="true"] {
  transform: translateY(3px) scale(0.985);
  box-shadow: var(--shadow-pad-down);
  filter: brightness(1.12);
}

/* The answering light is different from the pressed one: the pad glows
   without being held down, so the child can see which of their taps the
   board is playing back right now. */
.pad[data-echo="true"] {
  filter: brightness(1.22) saturate(1.1);
  box-shadow: var(--shadow-pad), 0 0 0 3px rgba(255, 248, 234, 0.55);
}
.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 word is a second read for an adult; on a narrow pad it would only
   crowd the label, so it appears once there is room for it. */
.pad__note {
  display: none;
  position: absolute;
  top: 10px;
  right: 12px;
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  opacity: 0.8;
  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; }

@media (min-width: 560px) {
  .pad { min-height: 72px; padding: 12px 14px; }
  .pad__note { display: block; }
}

/* Wide screens: the transport collapses onto one line and each deck becomes a
   platter with its controls beside it, so the whole instrument fits a laptop
   without a scroll. */
@media (min-width: 900px) {
  .board { gap: 12px; }
  .top { flex-wrap: nowrap; }
  .tempo { order: 2; flex-basis: auto; }
  .play { order: 3; }
  .decks { gap: 20px; }
  .deck {
    display: grid;
    /* An explicit platter column: `auto` inside a grid whose child asks for
       100% collapsed to the intrinsic sliver the first browser round found. */
    grid-template-columns: 180px minmax(0, 1fr);
    grid-template-areas:
      "platter name"
      "platter grooves"
      "platter fader";
    align-items: center;
    gap: 8px 16px;
    padding: 14px 16px;
  }
  .deck__name { grid-area: name; align-self: end; }
  .platter { grid-area: platter; width: 180px; max-width: 100%; }
  .grooves { grid-area: grooves; }
  .fader { grid-area: fader; align-self: start; }
  .pad { min-height: 84px; }
}

@media (prefers-reduced-motion: reduce) {
  .platter__disc { animation: none; }
  .platter__cue { transition: none; }
  .pad, .play, .step, .tempo__btn, .chip, .platter, .lane__slot { transition: none; }
}
