/* ==========================================================================
   Tempo: a drum machine's step row as a metronome. Charcoal panel, keys in
   the classic red / orange / yellow / off-white run, printed labels, one
   readout legible across a room.
   ========================================================================== */

:root {
  --body: #1b1b19;
  --panel: #242421;
  --panel-2: #2d2d29;
  --line: #3a3a35;
  --print: #d8d3c4;          /* printed panel text */
  --print-2: #a19c8e;        /* 6.6:1 on body */
  --k0: #d9352c;
  --k1: #f08a24;
  --k2: #f2cf2f;
  --k3: #ece8dc;
  --lamp: #ff3b2f;
  --font: "Jost", system-ui, sans-serif;
  --ease-out: cubic-bezier(.16, 1, .3, 1);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; background: var(--body); color: var(--print);
  font: 400 1rem/1.5 var(--font); -webkit-font-smoothing: antialiased;
}
::selection { background: var(--k2); color: var(--body); }
p, fieldset, legend { margin: 0; padding: 0; }
fieldset { border: 0; min-width: 0; }
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 2px solid var(--k2); outline-offset: 3px; border-radius: 6px; }

.machine {
  width: min(100% - 2rem, 70rem); margin: clamp(1rem, 4vw, 2.5rem) auto 0;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border-radius: 14px; padding: clamp(1.25rem, 4vw, 2.5rem);
  box-shadow: 0 1px 0 rgb(255 255 255 / .06) inset, 0 30px 60px -30px rgb(0 0 0 / .8);
}
.plate { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: .5rem 2rem; padding-bottom: 1rem; border-bottom: 2px solid var(--line); }
.brand { font-weight: 800; font-size: 1.5rem; letter-spacing: .02em; text-transform: uppercase; }
.brand span { font-weight: 500; font-size: .8rem; letter-spacing: .14em; color: var(--print-2); margin-left: .6rem; }
.hint { color: var(--print-2); font-size: .9rem; }
.label { font-size: .74rem; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; color: var(--print-2); }

/* ---------- Readout ---------- */
.readout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); gap: 1.5rem 3rem; align-items: center; padding: clamp(1.5rem, 4vw, 2.5rem) 0; }
.bpm-block { display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 1rem; align-items: end; }
.bpm {
  grid-row: 1 / 3; font-weight: 800; font-size: clamp(5rem, 16vw, 10rem); line-height: .8; letter-spacing: -.04em;
  font-variant-numeric: tabular-nums; color: var(--k3);
  text-shadow: 0 0 30px rgb(236 232 220 / .12);
  transition: color .08s;
}
body.downbeat .bpm { color: #fff9e8; }
.bpm-unit { font-weight: 700; letter-spacing: .2em; color: var(--print-2); font-size: .9rem; }
.marking { font-style: italic; font-weight: 500; font-size: 1.35rem; color: var(--k2); }
.tempo-ctl { display: grid; grid-template-columns: auto 1fr auto auto; gap: .8rem; align-items: center; }
.nudge { width: 3rem; height: 3rem; border-radius: 50%; border: 1px solid var(--line); background: var(--body); font-size: 1.4rem; font-weight: 500; transition: background-color .15s; }
.nudge:hover { background: var(--line); }
input[type="range"] { width: 100%; accent-color: var(--k1); height: 2.5rem; }
.tap {
  min-width: 5rem; height: 3rem; border-radius: 6px; border: 0; background: var(--k3); color: var(--body);
  font-weight: 800; letter-spacing: .12em; text-transform: uppercase;
  box-shadow: 0 4px 0 #9e998a; transition: transform .06s, box-shadow .06s;
}
.tap:active, .tap.hit { transform: translateY(3px); box-shadow: 0 1px 0 #9e998a; }
@media (max-width: 50rem) { .readout { grid-template-columns: 1fr; } }

/* ---------- Step row ---------- */
.steps-wrap { padding: 1.25rem 0 1.5rem; border-top: 2px solid var(--line); border-bottom: 2px solid var(--line); }
.steps { list-style: none; margin: .9rem 0 0; padding: 0; display: grid; grid-template-columns: repeat(var(--n), minmax(0, 1fr)); gap: clamp(.4rem, 1.5vw, .9rem); }
.step {
  position: relative; width: 100%; aspect-ratio: 3 / 4; max-height: 11rem;
  display: grid; grid-template-rows: auto 1fr auto; justify-items: center; align-items: center;
  padding: .8rem .3rem; border: 0; border-radius: 6px;
  background: var(--c); color: var(--body);
  box-shadow: 0 6px 0 color-mix(in srgb, var(--c) 55%, #000), 0 10px 18px -8px rgb(0 0 0 / .7);
  transition: transform .06s, box-shadow .06s, filter .2s;
}
.step:active { transform: translateY(4px); box-shadow: 0 2px 0 color-mix(in srgb, var(--c) 55%, #000); }
.step[data-a="0"] { filter: saturate(.25) brightness(.55); }
.lamp { width: .8rem; height: .8rem; border-radius: 50%; background: #4a1411; box-shadow: inset 0 1px 2px rgb(0 0 0 / .6); }
.step.lit .lamp { background: var(--lamp); box-shadow: 0 0 12px 3px rgb(255 59 47 / .75); }
.num { font-weight: 800; font-size: clamp(1.4rem, 4vw, 2.4rem); line-height: 1; }
.state { font-size: .7rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; opacity: .75; }
.step[data-a="2"] .num::after { content: ""; display: block; width: 1.2em; height: 3px; margin: .25em auto 0; background: currentColor; border-radius: 2px; }
@media (max-width: 40rem) { .state { display: none; } }

/* ---------- Bottom row ---------- */
.bottom { display: grid; grid-template-columns: auto 1fr 1fr minmax(8rem, .6fr); gap: 1.5rem 2.5rem; align-items: end; padding-top: 1.5rem; }
.start {
  display: inline-flex; align-items: center; gap: .8rem; height: 4rem; padding: 0 1.8rem;
  border: 0; border-radius: 8px; background: var(--k0); color: #fff4ee;
  font-weight: 800; font-size: 1.25rem; letter-spacing: .12em; text-transform: uppercase;
  box-shadow: 0 6px 0 #7e1c16; transition: transform .06s, box-shadow .06s;
}
.start:active { transform: translateY(4px); box-shadow: 0 2px 0 #7e1c16; }
.start-lamp { width: .8rem; height: .8rem; border-radius: 50%; background: #5e140f; }
.start[aria-pressed="true"] .start-lamp { background: #ffd8d0; box-shadow: 0 0 10px 2px rgb(255 216 208 / .8); }
.opts { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .5rem; }
.opts button { padding: .45rem .7rem; min-height: 2.5rem; border-radius: 4px; border: 1px solid var(--line); background: var(--body); color: var(--print); font-weight: 500; transition: background-color .15s, color .15s; }
.opts button:hover { background: var(--line); }
.opts button[aria-checked="true"] { background: var(--print); color: var(--body); border-color: var(--print); }
.vol { display: grid; gap: .3rem; }
@media (max-width: 60rem) { .bottom { grid-template-columns: 1fr 1fr; } .start { grid-column: 1 / -1; justify-content: center; } }
@media (max-width: 30rem) { .bottom { grid-template-columns: 1fr; } }

.foot { width: min(100% - 2rem, 70rem); margin: 1.5rem auto 3rem; color: var(--print-2); font-size: .88rem; }
.foot p { max-width: 70ch; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; }
}
