/* ------------------------------------------------------------------
   Four Bars: layout for the sequencer page only. Tokens, chamfer, buttons,
   the logo mark and the scanlines come from ../core.css.
   Colour roles follow STYLE-GUIDE.md: volt is what the player put down and
   what is playing (drum steps, Play, the bar on screen); cyan is the
   sample rows, the recorded material the grid is built round; hot is the
   recorder and nothing else (Rec, the count, the level, mute as a warning
   that a row is silent). A dial's pointer is volt once it has been moved
   off its resting place, so a changed voice shows at a glance.
   This is a tool page, not a full-screen game: it scrolls.
   ------------------------------------------------------------------ */

body.fb {
  min-height: 100vh;
  padding-top: var(--hud-h);
  /* A drag along a row paints steps; it must not select the page. */
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.fb-top {
  position: fixed; top: 0; left: 0; right: 0; z-index: 70;
  height: var(--hud-h);
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 0 var(--gutter);
  background: rgba(6, 7, 11, .92);
  border-bottom: 1px solid var(--line);
  font: 500 12px/1 var(--font-mono);
  letter-spacing: .08em; text-transform: uppercase;
}
.fb-top-id { color: var(--muted); letter-spacing: .16em; }

.fb-wrap {
  max-width: var(--wrap);
  margin: 0 auto;
  padding: 24px var(--gutter) 72px;
}

.fb-label {
  font: 500 11px/1 var(--font-mono);
  letter-spacing: .16em; text-transform: uppercase;
  color: var(--muted);
}

/* ---------- Keys: every control that is not the one solid button ---------- */
.fb-key {
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid var(--line-2);
  background: var(--bg-2);
  color: var(--muted);
  font: 700 12px/1 var(--font-mono);
  letter-spacing: .12em; text-transform: uppercase;
  cursor: pointer;
  transition: color .12s, border-color .12s, background .12s;
}
.fb-key:hover { color: var(--volt); border-color: var(--volt); }
.fb-key[aria-pressed="true"], .fb-key[aria-checked="true"] { color: var(--volt); border-color: var(--volt); }
.fb-key:disabled { color: var(--dim); border-color: var(--line); cursor: default; }
.fb-key--sq { width: 44px; padding: 0; font-size: 16px; }

.fb-key--rec { display: inline-flex; align-items: center; gap: 10px; color: var(--hot); border-color: var(--hot); }
.fb-key--rec i { width: 9px; height: 9px; background: var(--hot); }
.fb-key--rec:hover { color: var(--hot); border-color: var(--hot); background: #1d0810; }
.fb-key--rec[aria-pressed="true"] { background: var(--hot); color: #000; border-color: var(--hot); }
.fb-key--rec[aria-pressed="true"] i { background: #000; }

/* ---------- Range: a square thumb on a 1px line ---------- */
.fb-range {
  -webkit-appearance: none; appearance: none;
  height: 44px; min-width: 110px;
  margin: 0;
  background: transparent;
  cursor: pointer;
}
.fb-range::-webkit-slider-runnable-track { height: 1px; background: var(--line-2); }
.fb-range::-moz-range-track { height: 1px; background: var(--line-2); }
.fb-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px; height: 22px; margin-top: -11px;
  background: var(--volt); border: 0;
}
.fb-range::-moz-range-thumb { width: 12px; height: 22px; background: var(--volt); border: 0; border-radius: 0; }
.fb-range:disabled { cursor: default; }
.fb-range:disabled::-webkit-slider-thumb { background: var(--dim); }
.fb-range:disabled::-moz-range-thumb { background: var(--dim); }

/* ---------- Transport ---------- */
.fb-deck { --c: 22px; padding: 22px 22px 16px; transition: background .15s; }
body.is-rec .fb-deck { --bd: var(--hot); }
.fb-deck-main, .fb-deck-sub { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.fb-deck-sub { margin-top: 14px; }
.fb-deck .btn { padding: 15px 20px; min-width: 124px; justify-content: space-between; }

.fb-bpm { display: flex; align-items: center; gap: 8px; margin-left: auto; flex: 1 1 300px; justify-content: flex-end; }
.fb-bpm-val { display: flex; align-items: baseline; gap: 6px; min-width: 92px; justify-content: center; }
.fb-bpm-val b {
  font: 700 30px/1 var(--font-display);
  color: var(--volt);
  font-variant-numeric: tabular-nums;
}
.fb-bpm-val span { font: 500 11px/1 var(--font-mono); letter-spacing: .16em; color: var(--muted); }
.fb-bpm .fb-range { flex: 1 1 110px; max-width: 220px; }

.fb-bars { display: flex; gap: 4px; }
.fb-bar {
  width: 44px; height: 44px;
  border: 1px solid var(--line-2);
  background: var(--bg-2);
  color: var(--muted);
  font: 700 14px/1 var(--font-mono);
  cursor: pointer;
  transition: color .12s, border-color .12s, background .12s;
}
.fb-bar:hover { color: var(--volt); border-color: var(--volt); }
.fb-bar[aria-checked="true"] { background: var(--volt); border-color: var(--volt); color: #000; }

.fb-status {
  display: flex; align-items: center; gap: 14px;
  min-height: 20px; margin-top: 16px; padding-top: 14px;
  border-top: 1px dashed var(--line-2);
  font: 500 12px/1.3 var(--font-mono);
  letter-spacing: .12em; text-transform: uppercase;
  color: var(--muted);
}
.fb-status.is-hot { color: var(--hot); }
.fb-status.is-ok { color: var(--volt); }
.fb-meter { flex: 0 0 120px; height: 8px; margin-left: auto; background: var(--line); }
.fb-meter i { display: block; height: 100%; width: 0; background: var(--hot); }

/* ---------- Grid ---------- */
.fb-grid { margin-top: 22px; display: grid; gap: 6px; }
.fb-row {
  display: grid;
  grid-template-columns: 216px minmax(0, 1fr) auto;
  gap: 6px 10px;
  align-items: center;
}
.fb-row--sample:nth-child(6) { margin-top: 12px; }   /* a breath between the drums and the takes */

.fb-head { display: flex; align-items: stretch; gap: 4px; min-width: 0; }
.fb-name {
  flex: 1 1 auto; min-width: 0; min-height: 44px;
  display: flex; flex-direction: column; justify-content: center; gap: 5px;
  padding: 0 10px;
  border: 0; border-left: 2px solid var(--volt);
  background: var(--panel);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: background .12s;
}
.fb-name:hover, .fb-row.is-open .fb-name { background: #151a27; }
.fb-row--sample .fb-name { border-left-color: var(--cyan); }
.fb-name-text {
  font: 600 15px/1 var(--font-display);
  text-transform: uppercase;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.fb-name small { font: 500 10px/1 var(--font-mono); letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.fb-name small:empty { display: none; }
.fb-row.is-empty .fb-name { border-left-color: var(--line-2); }
.fb-row.is-empty .fb-name-text { color: var(--muted); }

.fb-mute { flex: 0 0 40px; padding: 0; }
/* Cyan, the colour for information: the eye changes what you see, not what you hear. */
.fb-eye { flex: 0 0 40px; padding: 0; display: grid; place-items: center; color: var(--dim); }
.fb-eye:hover, .fb-eye[aria-pressed="true"] { color: var(--cyan); border-color: var(--cyan); }
.fb-eye[aria-pressed="true"] { background: #071a1d; }
.fb-mute:hover { color: var(--hot); border-color: var(--hot); }
.fb-mute[aria-pressed="true"] { color: var(--hot); border-color: var(--hot); }

.fb-cells {
  display: grid; grid-template-columns: repeat(16, minmax(0, 1fr)); gap: 3px;
  /* Up and down still scrolls the page; side to side paints. */
  touch-action: pan-y;
}
.fb-cell {
  height: 44px; padding: 0;
  border: 1px solid var(--line);
  background: var(--bg-2);
  cursor: pointer;
  transition: background .12s, border-color .12s;
}
/* Beats one and three a shade lighter, so the eye can count in fours. */
.fb-cell:nth-child(8n+1), .fb-cell:nth-child(8n+2), .fb-cell:nth-child(8n+3), .fb-cell:nth-child(8n+4) { background: #141927; border-color: var(--line-2); }
.fb-cell:hover { border-color: var(--volt); }
.fb-cell.on { background: var(--volt); border-color: var(--volt); }
.fb-row--sample .fb-cell:hover { border-color: var(--cyan); }
.fb-row--sample .fb-cell.on { background: var(--cyan); border-color: var(--cyan); }
/* Where a take is still sounding after its start. */
.fb-row--sample .fb-cell.tail { background: rgba(34, 227, 238, .12); border-color: rgba(34, 227, 238, .35); }
.fb-cell.now { box-shadow: inset 0 0 0 2px var(--text); }
.fb-row.is-muted .fb-cells { opacity: .35; }
.fb-cell:focus-visible { outline-offset: 1px; }

/* ---------- Bar sequencer ----------
   Its rows reuse .fb-row and .fb-cells so its sixteen columns sit exactly
   under the grid's sixteen steps. */
.fb-chain { margin-top: 14px; padding: 12px 0 2px; border-top: 1px dashed var(--line-2); }
.fb-chain-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin-bottom: 10px; }
.fb-chain-bar .fb-key { min-height: 34px; margin-left: auto; }
.fb-chain-text { font: 500 11px/1.4 var(--font-mono); letter-spacing: .12em; text-transform: uppercase; color: var(--volt); }
.fb-chain-rows { display: grid; gap: 3px; }
.fb-chain-name {
  display: flex; align-items: center; height: 30px; padding: 0 10px;
  border-left: 2px solid var(--volt); background: var(--panel);
  font: 500 11px/1 var(--font-mono); letter-spacing: .14em; text-transform: uppercase; color: var(--text);
}
.fb-row--chain .fb-cell { height: 30px; }
/* A place left empty before the end of the order: a bar of silence. */
.fb-row--chain .fb-cell.rest { border-style: dashed; border-color: var(--dim); }
.fb-key.is-set { color: var(--volt); }

/* ---------- Dials ----------
   An octagon, not a circle (no curves), with a pointer that app.js turns
   in 30 degree clicks. The same clip-path trick as the chamfer: the knob's
   background is its border, ::before is the fill. */
.fb-dials { display: flex; gap: 2px; width: 232px; }
.fb-dial {
  flex: 0 0 44px;
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  padding: 3px 0 2px;
  cursor: ns-resize;
  touch-action: none;
}
.fb-dial-knob {
  --oct: polygon(30% 0, 70% 0, 100% 30%, 100% 70%, 70% 100%, 30% 100%, 0 70%, 0 30%);
  position: relative;
  width: 26px; height: 26px;
  background: var(--line-2);
  clip-path: var(--oct);
}
.fb-dial-knob::before { content: ''; position: absolute; inset: 1px; background: var(--panel); clip-path: var(--oct); }
.fb-dial-knob i { position: absolute; left: 12px; top: 2px; width: 2px; height: 10px; background: var(--muted); }
.fb-dial-cap {
  font: 500 9px/1 var(--font-mono);
  letter-spacing: .1em; text-transform: uppercase;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.fb-dial:hover .fb-dial-knob, .fb-dial.is-held .fb-dial-knob { background: var(--volt); }
.fb-dial.is-moved .fb-dial-knob i, .fb-dial.is-held .fb-dial-knob i { background: var(--volt); }
.fb-dial.is-held .fb-dial-cap { color: var(--volt); }
.fb-row--sample .fb-dial:hover .fb-dial-knob, .fb-row--sample .fb-dial.is-held .fb-dial-knob { background: var(--cyan); }
.fb-row--sample .fb-dial.is-moved .fb-dial-knob i, .fb-row--sample .fb-dial.is-held .fb-dial-knob i { background: var(--cyan); }
.fb-row--sample .fb-dial.is-held .fb-dial-cap { color: var(--cyan); }
.fb-row.is-muted .fb-dials { opacity: .35; }

.fb-panel {
  grid-column: 1 / -1;
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px;
  padding: 10px 12px;
  border: 1px dashed var(--line-2);
  background: var(--bg-2);
}
.fb-field { display: flex; align-items: center; gap: 10px; flex: 1 1 240px; min-width: 0; }
.fb-field .fb-range { flex: 1 1 auto; }
.fb-field-val {
  flex: 0 0 auto; min-width: 68px; text-align: right;
  font: 500 12px/1 var(--font-mono); letter-spacing: .08em; text-transform: uppercase;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

/* ---------- The screen (viz.js) ---------- */
.fb-vis { --c: 22px; margin-bottom: 22px; }
/* The bar sits under the screen; its left padding clears the bottom-left cut. */
.fb-vis-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; padding: 10px 16px 10px 30px; }
.fb-vis-keys { display: flex; flex-wrap: wrap; gap: 4px; }
.fb-vis-keys .fb-key { min-height: 36px; padding: 0 11px; font-size: 11px; }
.fb-vis-src { font: 500 11px/1.3 var(--font-mono); letter-spacing: .12em; text-transform: uppercase; color: var(--cyan); }
.fb-vis-screen {
  position: relative; display: block;
  width: calc(100% - 2px); height: 230px;
  margin: 1px 1px 0; padding: 0;
  border: 0; border-bottom: 1px solid var(--line-2);
  background: var(--screen);
  cursor: pointer;
  overflow: hidden;
}
.fb-vis-screen canvas { position: absolute; inset: 0; display: block; width: 100%; height: 100%; }
/* The canvas scanlines from the style guide, heavier than the page's own. */
.fb-vis-screen::after {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: repeating-linear-gradient(to bottom, transparent 0 3px, rgba(0, 0, 0, .28) 3px 4px);
}
.fb-vis-screen:focus-visible { outline-offset: -4px; }

/* ---------- Keys and pads (keys.js) ---------- */
.fb-inst { --c: 22px; margin-top: 22px; padding: 14px 16px 16px; }
/* The strip of lights: the bar's sixteen steps, lit one at a time. Volt
   while playing, hot while the recorder is counting in or recording. Glow
   is allowed here: it is a small indicator (STYLE-GUIDE.md, Glow). */
.fb-light { display: grid; grid-template-columns: repeat(16, minmax(0, 1fr)); gap: 3px; height: 8px; margin: 0 22px 12px 0; }
.fb-light i { background: var(--line); }
.fb-light i:nth-child(4n+1) { background: var(--line-2); }
.fb-light i.now { background: var(--volt); box-shadow: 0 0 10px var(--volt); }
.fb-light.is-rec i.now { background: var(--hot); box-shadow: 0 0 10px var(--hot); }
.fb-inst-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding-right: 20px; margin-bottom: 12px; }
.fb-inst-bar .fb-label { margin-right: 6px; }
.fb-inst-bar .fb-key { min-height: 38px; }
.fb-inst-bar .fb-key--sq { width: 38px; }
.fb-inst-bar .fb-key--rec { margin-left: auto; }
.fb-inst-val--wide { min-width: 108px; }
.fb-inst-gap { margin-left: 10px; }
.fb-demos { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.fb-inst-val { min-width: 34px; text-align: center; font: 700 13px/1 var(--font-mono); letter-spacing: .08em; color: var(--volt); }

.fb-inst-body { display: flex; gap: 16px; align-items: stretch; }
/* The keyboard. Keys are placed by keys.js in percentages of the board,
   so the same code lays out one octave or two. White keys are the lit
   panel shade and black keys the screen's black: DG//OS has no white. */
.fb-board {
  position: relative; flex: 1 1 auto; min-width: 0; height: 168px;
  touch-action: none;           /* a finger sliding along the keys plays them; it must not scroll */
  cursor: pointer;
}
.fb-wk, .fb-bk { position: absolute; top: 0; box-sizing: border-box; }
.fb-wk {
  height: 100%;
  border: 1px solid var(--line-2); border-left-width: 0;
  background: #1a2032;
  display: flex; align-items: flex-end; justify-content: center; padding-bottom: 8px;
  flex-direction: column; align-items: center; justify-content: flex-end; gap: 7px;   /* the label, then the note name, at the foot of the key */
  font: 500 9px/1 var(--font-mono); letter-spacing: .1em; color: var(--muted);
}
/* The computer key that plays each note or pad. pointer-events off: a
   press on the label must land on the key under it (keys.js reads the
   key from the element at the pointer). */
.fb-board kbd, .fb-pad kbd {
  pointer-events: none;
  min-width: 18px; padding: 3px 4px;
  border: 1px solid var(--line-2); background: var(--bg);
  font: 700 11px/1 var(--font-mono); letter-spacing: 0; text-align: center; text-transform: uppercase;
  color: var(--text);
}
.fb-board small { pointer-events: none; min-height: 9px; }
.fb-bk { display: flex; align-items: flex-end; justify-content: center; padding-bottom: 7px; }
.fb-wk.on kbd, .fb-bk.on kbd, .fb-pad.hit kbd { border-color: #000; background: transparent; color: #000; }
.fb-pad small { display: flex; align-items: center; gap: 8px; width: 100%; justify-content: space-between; }
/* No keyboard on a phone or tablet: the labels would only be clutter. */
@media (pointer: coarse) { .fb-board kbd, .fb-pad kbd { display: none; } }
.fb-wk:first-child { border-left-width: 1px; }
.fb-bk { height: 60%; z-index: 2; border: 1px solid var(--line-2); border-top: 0; background: var(--screen); }
.fb-wk.on, .fb-bk.on { background: var(--volt); border-color: var(--volt); color: #000; }

/* The synth's dials: two rows of five beside the keys. Not .fb-dials,
   which hides itself into a row's drawer on a narrow screen. */
.fb-knobs { flex: 0 0 268px; display: flex; flex-wrap: wrap; align-content: center; gap: 10px 2px; }
.fb-knobs .fb-dial { flex: 0 0 52px; }

.fb-pads { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.fb-pad {
  height: 84px; padding: 10px 12px;
  display: flex; flex-direction: column; justify-content: space-between; align-items: flex-start;
  border: 1px solid var(--line-2); border-left: 2px solid var(--volt);
  background: var(--bg-2);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  touch-action: manipulation;   /* no double-tap zoom between two quick hits */
}
.fb-pad small { font: 500 10px/1 var(--font-mono); letter-spacing: .14em; color: var(--muted); }
.fb-pad span { max-width: 100%; font: 600 15px/1.1 var(--font-display); text-transform: uppercase; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fb-pad.is-sample { border-left-color: var(--cyan); }
.fb-pad.is-empty { border-left-color: var(--line-2); }
.fb-pad.is-empty span { color: var(--dim); }
.fb-pad:hover { border-color: var(--volt); }
.fb-pad.hit { background: var(--volt); border-color: var(--volt); color: #000; }
.fb-pad.hit small { color: #000; }
.fb-pad.is-sample:hover { border-color: var(--cyan); }
.fb-pad.is-sample.hit { background: var(--cyan); border-color: var(--cyan); }
.fb-pads.is-picking .fb-pad { border-style: dashed; }

/* ---------- Song actions and notes ---------- */
.fb-foot { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 26px; padding-top: 20px; border-top: 1px solid var(--line); }
.fb-notes { margin-top: 26px; max-width: 660px; font-size: 15px; line-height: 1.55; color: var(--muted); }
.fb-notes b { color: var(--text); font-weight: 600; }
.fb-fault { margin-top: 26px; color: var(--hot); }

/* Narrower than a row of cells plus five dials can share: the dials move
   into the row's drawer and show when its name is tapped. */
@media (max-width: 1000px) {
  .fb-row { grid-template-columns: 216px minmax(0, 1fr); }
  .fb-dials { display: none; grid-column: 1 / -1; width: auto; gap: 6px; padding: 8px 12px 4px; border: 1px dashed var(--line-2); border-bottom: 0; background: var(--bg-2); }
  .fb-row.is-open .fb-dials { display: flex; }
  .fb-row.is-open .fb-panel { margin-top: -6px; border-top: 0; }
  .fb-dial { flex: 0 0 52px; }
}

@media (max-width: 760px) {
  .fb-top-id { display: none; }
  .fb-row { grid-template-columns: minmax(0, 1fr); gap: 3px; }
  .fb-row.is-open .fb-panel { margin-top: -3px; }
  .fb-grid { gap: 12px; }
  .fb-name { min-height: 34px; flex-direction: row; align-items: center; justify-content: space-between; gap: 10px; }
  .fb-mute, .fb-eye { min-height: 34px; }
  .fb-cell { height: 40px; }
  .fb-row--chain .fb-cell { height: 34px; }
  .fb-chain-name { height: 22px; border-left-width: 2px; background: none; padding: 0 0 0 8px; }
  .fb-bpm { margin-left: 0; justify-content: flex-start; }
  .fb-deck { padding: 18px 16px 14px; }
  .fb-vis-screen { height: 170px; }
  .fb-inst { padding: 12px 12px 14px; }
  .fb-inst-body { flex-direction: column; }
  .fb-board { height: 150px; flex: none; }
  .fb-knobs { flex: none; justify-content: space-between; }
  .fb-knobs .fb-dial { flex: 0 0 19%; }
  .fb-inst-gap { margin-left: 0; }
  .fb-pad { height: 72px; padding: 8px; }
  .fb-pad span { font-size: 13px; }
}
