/* /tap/ only: layout C of design/tap-options.html (big readout, one tap box that becomes the
   strip chart, stats in a row, metronome below). Shared pieces (.intro, .rules-line, .sheet,
   .sheet-h, .btn, kbd, code, .sr, focus ring) come from site.css. Narrow first; the wide layout
   starts at 821px, like the rest of the site. */
:root { --rush: var(--blue); --drag: var(--soon); --stray: #a3adb7; }

.tool { --ro: clamp(84px, 12cqi, 150px); display: grid; gap: 20px; min-width: 0; }
.tapinst, .metro { min-width: 0; }
.t-body { display: grid; gap: 12px; grid-template-columns: minmax(0, 1fr); grid-template-areas: "read" "pad" "stats" "bar"; }
.readout { grid-area: read; } .stats { grid-area: stats; } .pad { grid-area: pad; } .tapbar { grid-area: bar; }

/* Readout */
.readout { min-width: 0; background: var(--sheet); border: 1px solid var(--ink); padding: 14px 16px 16px; display: flex; flex-direction: column; justify-content: space-between; gap: 10px; }
.ro-lab { margin: 0; font: 500 13px var(--mono); color: var(--mute); }
.ro-val { margin: 0; display: flex; align-items: baseline; flex-wrap: wrap; font-family: var(--mono); font-weight: 500; font-size: var(--ro); line-height: .95; letter-spacing: -.045em; color: var(--ink); font-variant-numeric: tabular-nums; }
.ro-dec { font-size: .5em; letter-spacing: -.02em; }
.ro-unit { font-size: max(14px, .16em); letter-spacing: .04em; color: var(--mute); margin-left: 12px; }
.ro-state { margin: 0; font-size: 14.5px; line-height: 1.45; color: var(--body); }

/* Tap box: a finer grid; once bars exist the label moves to the top line and the chart fills the rest */
.pad { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; width: 100%; min-height: 280px; padding: 16px; margin: 0;
  background-color: var(--sheet); border: 1px solid var(--ink); color: var(--ink); cursor: pointer;
  background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px); background-size: 12px 12px; background-position: -1px -1px;
  touch-action: manipulation; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; transition: background-color .2s ease-out; }
.pad:hover { background-color: var(--tint); }
.pad.hit { background-color: var(--press); transition: none; }
.pad-main { font: 600 26px var(--sans); }
.pad-sub { font: 500 13px var(--mono); color: var(--mute); }
.pad.has-bars { flex-direction: row; flex-wrap: wrap; align-items: baseline; align-content: flex-start; justify-content: flex-start; gap: 2px 10px; padding: 9px 14px; }
.pad.has-bars .pad-main { font-size: 17px; }
.pad.has-bars .pad-sub { font-size: 12px; }

/* Statistics row */
.stats { min-width: 0; border: 1px solid var(--ink); }
.stats dl { margin: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; background: var(--rule); }
.stats dl > div { background: var(--sheet); padding: 10px 12px 12px; min-width: 0; }
.stats dt { font: 500 12px var(--mono); color: var(--mute); }
.stats dd { margin: 0; padding: 4px 0 0; font: 500 19px var(--mono); color: var(--ink); font-variant-numeric: tabular-nums; min-width: 0; }
.stats .u { color: var(--mute); font-size: .85em; }
.stats .v2 { display: block; margin: 2px 0 0; color: var(--mute); font-size: 12.5px; }
.stats .na { color: var(--mute); font: 400 14px var(--sans); }
.stats .st-sd { order: 1; grid-column: span 2; }

/* Tempo chart, laid over the tap box: one bar per tap from the 4th, frozen once drawn */
.chart { grid-area: pad; z-index: 1; pointer-events: none; margin: 40px 1px 1px; min-width: 0; display: grid; grid-template-rows: minmax(0, 1fr); visibility: hidden; }
.chart.has-bars { visibility: visible; }
.plot { position: relative; min-height: 0; }
.plot svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.chart text { font: 500 11.5px var(--mono); fill: var(--mute); }
.chart .tlab { fill: var(--ink); font-weight: 600; }
.chart .empty { font: 400 13.5px var(--sans); fill: var(--mute); }
.chart .gl, .chart .base { stroke: var(--rule); stroke-width: 1; }
.chart .tl { stroke: var(--ink); stroke-width: 1.5; }
.chart .rush { fill: var(--rush); } .chart .drag { fill: var(--drag); } .chart .even { fill: var(--ink); }
.chart .stray { fill: var(--stray); } .chart .mk { fill: var(--mute); }

.tapbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; }
.tapbar p { margin: 0; flex: 1 1 16em; min-width: 0; font-size: 13.5px; line-height: 1.6; color: var(--mute); }

/* Metronome */
.m-body { display: grid; gap: 16px; padding: 16px 14px 18px; grid-template-columns: minmax(0, 1fr); grid-template-areas: "tempo" "slider" "use" "bar" "lights" "go"; align-items: center; }
.m-tempo { grid-area: tempo; } .m-slider { grid-area: slider; } .m-use { grid-area: use; } .m-bar { grid-area: bar; } .lights { grid-area: lights; } .go { grid-area: go; }
.m-lab { display: block; margin-bottom: 6px; font: 500 13px var(--mono); color: var(--mute); }
.stepper { display: flex; align-items: stretch; }
.stepper button { flex: none; width: 48px; min-height: 48px; padding: 0; border: 1px solid var(--field); background: var(--sheet); color: var(--ink); font: 500 22px var(--mono); cursor: pointer; }
.stepper button:hover { background: var(--tint); }
.stepper input { width: 4.4ch; min-width: 0; padding: 0 4px; text-align: center; border: 1px solid var(--field); border-inline: 0; border-radius: 0; background: var(--sheet); color: var(--ink); font: 500 26px var(--mono); -moz-appearance: textfield; appearance: textfield; }
.stepper input:focus-visible { position: relative; z-index: 1; }
.stepper input::-webkit-inner-spin-button, .stepper input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.stepper .unit { align-self: center; margin-left: 10px; font: 500 14px var(--mono); color: var(--mute); }
.m-slider input { display: block; width: 100%; height: 32px; margin: 0; accent-color: var(--ink); cursor: pointer; }
.m-scale { display: flex; justify-content: space-between; font: 500 12px var(--mono); color: var(--mute); }
.m-use { width: 100%; gap: 0; }
.m-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 22px; }
.fld { display: flex; align-items: center; gap: 10px; color: var(--ink); font-size: 15px; }
.m-bar select { min-height: 44px; padding: 0 8px; border: 1px solid var(--field); border-radius: 0; background: var(--sheet); color: var(--ink); font: 500 16px var(--mono); cursor: pointer; }
.check { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; color: var(--ink); font-size: 15px; cursor: pointer; }
.check input { width: 20px; height: 20px; margin: 0; accent-color: var(--ink); cursor: pointer; }
/* One light per beat: as many equal columns as there are lights, no inline style needed */
.lights { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 6px; }
.lt { height: 48px; display: grid; place-items: center; border: 1px solid var(--rule); background: var(--sheet); font: 500 14px var(--mono); color: var(--mute);
  transition: background-color .3s ease-out, color .3s ease-out, border-color .3s ease-out; }
.lt.acc { box-shadow: inset 0 3px 0 var(--blue); }
.lt.cur { border-color: var(--ink); color: var(--ink); }
.lt.on { background: var(--ink); border-color: var(--ink); color: var(--sheet); transition: none; }
.lt.acc.on { background: var(--blue); border-color: var(--blue); }
.go { display: inline-flex; align-items: center; justify-content: center; gap: 10px; width: 100%; min-height: 56px; padding: 10px 22px; border: 1px solid var(--ink); background: var(--ink); color: var(--sheet); font: 600 17px var(--sans); cursor: pointer; }
.go:hover { background: var(--ink-hover); }
.go svg { width: 14px; height: 14px; fill: currentColor; }
.go[data-on="true"] { background: var(--sheet); color: var(--ink); }
.go[data-on="true"]:hover { background: var(--tint); }
.m-note { grid-column: 1 / -1; margin: 0; font-size: 14px; color: var(--soon); }

/* How this measures */
.how { min-width: 0; }
.how dl { margin: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 1px; background: var(--rule); }
.how dl > div { background: var(--sheet); padding: 12px 14px 14px; min-width: 0; }
.how dt { margin: 0 0 4px; font: 500 13px var(--mono); color: var(--mute); }
.how dd { margin: 0; font-size: 14.5px; line-height: 1.6; color: var(--body); max-width: 70ch; }
.how code { font: 500 13px var(--mono); background: var(--chip); padding: 0 4px; }
.how .rd { font: 500 14px var(--mono); color: var(--ink); }
.how .rd.wait { font: italic 400 14.5px var(--sans); color: var(--mute); }

@media (prefers-reduced-motion: reduce) {
  .pad, .lt { transition: none !important; }
}

@media (min-width: 821px) {
  .readout { display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-areas: "lab lab" "val state"; align-items: end; gap: 10px 40px; padding: 18px 20px 20px; }
  .ro-lab { grid-area: lab; } .ro-val { grid-area: val; }
  .ro-state { grid-area: state; max-width: 30em; padding-bottom: 8px; }
  .pad { min-height: 320px; }
  .stats dl { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .stats .st-sd { order: 0; grid-column: auto; }
  .stats dl > div { padding: 12px 16px 14px; }
  .stats dd { font-size: 22px; }

  .m-body { grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "tempo slider use" "bar lights go"; gap: 18px 28px; padding: 16px 16px 18px; }
  .m-use { width: auto; min-width: 15.5em; }
  .go { width: auto; min-width: 15.5em; min-height: 52px; }
  .lt { height: 44px; }

  .how dl { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 520px) {
  .keys { display: none; }
}
@media (max-width: 420px) {
  .lights { gap: 4px; }
  .lt { font-size: 13px; }
}
