/* Chord practice — builds on styles.css (tokens, panels, buttons, steppers). Design system: brand/design-guide.md */

/* ---------- stage ---------- */

.cp-stage {
  position: relative;
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  gap: 20px;
  min-height: 420px;
  padding: 20px 24px 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--stage-bg);
  container-type: inline-size;
  transition: border-color var(--ease);
}
body.is-practicing .cp-stage { border-color: var(--amber); }
.cp-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.cp-stage .hud-chip { background: var(--on-stage); }
.cp-meta { color: var(--text-muted); font-size: 14px; font-weight: 500; }

.cp-main { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); gap: 24px; align-items: center; }
.cp-label { display: block; margin-bottom: 8px; color: var(--text-muted); font-size: 14px; font-weight: 600; line-height: 1.2; }
.cp-now .cp-label { color: var(--amber); }
.cp-next-in { color: var(--text); }
.cp-chord { display: flex; align-items: center; gap: clamp(16px, 3cqw, 36px); min-width: 0; }
.cp-name { min-width: 0; color: var(--text); font: 600 clamp(64px, 13cqw, 96px)/1 var(--font-ui); letter-spacing: -0.02em; white-space: nowrap; }
.cp-diagram { flex: none; width: clamp(112px, 19cqw, 160px); }
.cp-next { padding-left: 24px; border-left: 1px solid var(--divider); }
.cp-next .cp-name { font-size: clamp(40px, 7cqw, 60px); }
.cp-next .cp-diagram { width: clamp(72px, 11cqw, 96px); }
.cp-next.is-soon .cp-label, .cp-next.is-soon .cp-next-in { color: var(--amber); }

/* chord diagram: ivory strings and frets; amber dots only for the chord being played */
.chord-svg { display: block; width: 100%; height: auto; overflow: visible; }
.chord-svg .cd-fret, .chord-svg .cd-string { stroke: rgba(232, 220, 196, 0.55); stroke-width: 1.4; }
.chord-svg .cd-nut { stroke: var(--ivory); stroke-width: 4; stroke-linecap: round; }
.chord-svg .cd-dot, .chord-svg .cd-barre { fill: var(--ivory); stroke: none; }
.chord-svg .cd-open { fill: none; stroke: var(--ivory); stroke-width: 1.6; }
.chord-svg .cd-mute { fill: var(--text-quiet); stroke: none; font: 600 14px var(--font-ui); text-anchor: middle; }
.chord-svg .cd-base { fill: var(--text-muted); stroke: none; font: 600 12px var(--font-ui); text-anchor: middle; }
.chord-svg .cd-q { fill: var(--text-quiet); stroke: none; font: 600 40px var(--font-ui); text-anchor: middle; }
.cp-now .cd-dot, .cp-now .cd-barre, .prog-chip.is-current .cd-dot, .prog-chip.is-current .cd-barre { fill: var(--amber); }

/* strum lane: one bar of the pattern, the current step marked by colour and an underline */
.strum-lane { display: grid; grid-template-columns: repeat(var(--steps, 8), minmax(0, 1fr)); gap: 6px; }
.lane-cell {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 6px;
  padding: 12px 0 10px;
  border: 1px solid var(--on-stage-line);
  border-radius: var(--radius-control);
  background: var(--on-stage);
  color: var(--text);
}
.lane-cell.is-beat { border-color: rgba(232, 220, 196, 0.2); }
.lane-cell svg { width: clamp(18px, 3.2cqw, 28px); height: clamp(18px, 3.2cqw, 28px); stroke-width: 2.2; }
.lane-cell[data-code='-'] { color: var(--text-quiet); }
.lane-count { color: var(--text-quiet); font-size: 13px; font-weight: 600; line-height: 1; }
/* Listen mode: each strum's mark sits under its count (the slot is there while listening, so nothing shifts). */
.lane-mark { display: none; }
body.is-listening .lane-mark { display: inline-block; }
body.is-listening .lane-mark:not([data-kind]) { visibility: hidden; }
.lane-cell.is-beat .lane-count { color: var(--text-muted); }
.lane-cell.is-current { border-color: var(--amber); background: var(--amber-tint); color: var(--amber); }
.lane-cell.is-current .lane-count { color: var(--amber); }
.lane-cell.is-current::after { content: ''; position: absolute; right: 10px; bottom: -1px; left: 10px; height: 3px; border-radius: 3px 3px 0 0; background: var(--amber); }
.lane-change {
  position: absolute;
  top: -11px;
  left: 50%;
  padding: 1px 7px;
  border-radius: 6px;
  background: var(--ivory);
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.4;
  white-space: nowrap;
  transform: translateX(-50%);
}

.cp-progress { height: 4px; margin: 0 -24px; background: rgba(0, 0, 0, 0.35); }
.cp-progress span { display: block; height: 100%; background: var(--amber); transform: scaleX(0); transform-origin: left; }

/* count-in / done: instant, no motion */
.cp-overlay {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: rgba(16, 16, 16, 0.92);
  text-align: center;
}
.cp-ov-num { color: var(--text); font: 700 clamp(104px, 22cqw, 200px)/1 var(--font-ui); }
.cp-overlay .ov-kicker, .cp-overlay .ov-sub { padding: 0; background: none; }
.cp-overlay .ov-kicker { color: var(--amber); font-size: 18px; }
.cp-overlay .ov-sub { color: var(--text-muted); font-size: 16px; }

.cp-tempo-up {
  margin-left: auto;
  padding: 4px 12px;
  border-radius: 99px;
  background: var(--amber);
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
  animation: tempo-up 2.2s linear forwards;
}
/* A notice, not decoration: 150 ms in, hold, 150 ms out. */
@keyframes tempo-up { 0% { opacity: 0; } 7% { opacity: 1; } 93% { opacity: 1; } 100% { opacity: 0; } }

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

/* styles.css hides the transport until a video is loaded; here it's always needed. */
body.chords-page .transport { display: flex; flex-wrap: wrap; row-gap: 10px; }
.tempo { display: flex; align-items: center; gap: 4px; }
.tempo .step { width: 40px; height: 40px; font-size: 14px; font-weight: 600; }
.tempo-val { display: flex; align-items: baseline; gap: 6px; padding: 0 8px; cursor: text; }
.tempo-val input {
  width: 3.2ch;
  padding: 0;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--text);
  font: 700 28px/1 var(--font-ui);
  text-align: right;
  appearance: textfield;
  -moz-appearance: textfield;
}
.tempo-val:focus-within { outline: 2px solid var(--amber); outline-offset: 3px; border-radius: 6px; }
.tempo-val input::-webkit-inner-spin-button, .tempo-val input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.tempo-val span { color: var(--text-quiet); font-size: 13px; font-weight: 600; }
#tap-btn.is-tapping { border-color: var(--denim); color: var(--text); }

/* ---------- progression ---------- */

.progression { margin-top: 20px; }
.prog-list { display: flex; flex-wrap: wrap; gap: 12px; margin: 0; padding: 16px 20px 20px; list-style: none; }
.prog-chip {
  position: relative;
  display: grid;
  grid-template-rows: auto auto;
  width: 124px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--field);
  transition: border-color var(--ease), background-color var(--ease);
}
.prog-chip:hover { border-color: #5a554c; }
.prog-chip.is-current { border-color: var(--amber); background: var(--amber-tint); }
.prog-main { display: grid; justify-items: center; gap: 6px; padding: 12px 8px 8px; border: 0; border-radius: var(--radius) var(--radius) 0 0; background: none; }
.prog-main .chord-svg { width: 60px; }
.prog-name { font-size: 20px; font-weight: 600; line-height: 1.1; }
.prog-foot { display: flex; align-items: center; gap: 2px; padding: 0 6px 8px; }
.prog-foot select {
  flex: 1;
  min-width: 0;
  height: 32px;
  padding: 0 4px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
}
.prog-foot .icon-btn { width: 26px; height: 32px; }
.prog-foot .icon-btn svg { width: 14px; height: 14px; }
.prog-chip:not(:hover):not(:focus-within) .prog-move { opacity: 0; }
.prog-bar { position: absolute; right: 0; bottom: 0; left: 0; height: 3px; background: var(--amber); transform: scaleX(0); transform-origin: left; }
.prog-add {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 6px;
  width: 124px;
  min-height: 152px;
  border: 1.5px dashed var(--border);
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 600;
  transition: border-color var(--ease), color var(--ease);
}
.prog-add:hover { border-color: var(--denim); color: var(--text); }

/* ---------- groove inspector ---------- */

.seg-4 { grid-template-columns: repeat(4, 1fr); }
.seg-3 { grid-template-columns: repeat(3, 1fr); }
.seg-5 { grid-template-columns: repeat(5, 1fr); }
.field-label select {
  max-width: 62%;
  height: 32px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  background: var(--field);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
}
.pattern-grid { display: grid; grid-template-columns: repeat(var(--steps, 8), minmax(0, 1fr)); gap: 4px; }
.pattern-grid.is-16 { grid-template-columns: repeat(8, minmax(0, 1fr)); }
.pattern-cell {
  display: grid;
  justify-items: center;
  gap: 3px;
  padding: 8px 0 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  background: var(--field);
  color: var(--text);
  transition: background-color var(--ease), border-color var(--ease);
}
.pattern-cell:hover { background: var(--surface-raised); }
.pattern-cell svg { width: 16px; height: 16px; stroke-width: 2.2; }
.pattern-cell[data-code='-'], .pattern-cell[data-code='x'] { color: var(--text-quiet); }
.pattern-cell span { color: var(--text-quiet); font-size: 11px; font-weight: 600; line-height: 1; }
.pattern-cell.is-current { border-color: var(--amber); background: var(--amber-tint); color: var(--amber); }
.pattern-legend { margin: 2px 0 0; color: var(--text-quiet); font-size: 13px; }
.pattern-legend b { color: var(--text-muted); }

/* guitar tone */
.tone-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.tone {
  display: grid;
  gap: 2px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  background: var(--field);
  text-align: left;
  transition: border-color var(--ease), background-color var(--ease);
}
.tone:hover { background: var(--surface-raised); }
.tone b { font-size: 14px; font-weight: 600; line-height: 1.3; }
.tone span { color: var(--text-quiet); font-size: 13px; line-height: 1.3; }
.tone[aria-checked='true'] { border-color: var(--denim); background: var(--surface-raised); }
.tone[aria-checked='true'] span { color: var(--text-muted); }

/* ---------- charts library ---------- */

.lib-list:empty { display: none; }
.starters { padding: 16px 16px 20px; border-top: 1px solid var(--divider); }
.lib-list:empty + .starters { border-top: 0; }
.starters-label { margin: 0 0 10px 4px; color: var(--text-muted); font-size: 14px; font-weight: 600; }
.starters-list { display: grid; gap: 8px; }
.starter {
  display: grid;
  gap: 2px;
  padding: 10px 12px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-control);
  background: transparent;
  text-align: left;
  transition: border-color var(--ease), background-color var(--ease);
}
.starter:hover { border-color: var(--denim); background: var(--surface-raised); }
.starter b { font-size: 15px; font-weight: 600; line-height: 1.3; }
.starter span { color: var(--text-quiet); font-size: 13px; line-height: 1.35; }
/* hear it again (Find the note by ear, Melody practice) */
.hear-btn {
  display: grid;
  place-items: center;
  align-self: center;
  width: 52px;
  height: 52px;
  padding: 0;
  border: 1px solid var(--amber);
  border-radius: 50%;
  background: var(--amber-tint);
  color: var(--amber);
  transition: background-color var(--ease);
}
.hear-btn:hover { background: rgba(230, 164, 71, 0.24); }
.hear-btn svg { width: 22px; height: 22px; }
/* the microphone, when answering by playing (Find the note, Melody practice) */
.mic-chip { gap: 8px; border-color: var(--denim); background: rgba(83, 127, 155, 0.16); }
.mic-chip svg { width: 15px; height: 15px; }
.mic-chip .mic-meter { display: block; }
.mic-chip #heard { min-width: 7ch; }
.seg-sub button { padding: 6px 4px; line-height: 1.25; }
.seg-tight button { padding: 0 4px; font-size: 13px; }
.panel-tip { margin: 0; color: var(--text-quiet); font-size: 13px; line-height: 1.45; }

/* ready-made exercises (Find the note, Melody practice): one click sets up and starts */
.side-scroll { flex: 1; min-height: 0; overflow: auto; }
.preset-list { padding: 12px 12px 16px; }
.preset.is-active { border-style: solid; border-color: var(--denim); background: #24292c; box-shadow: inset 0 0 0 1px var(--denim); }
.preset b { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.preset-mic { display: inline-flex; color: var(--text-quiet); }
.preset-mic svg { width: 14px; height: 14px; }
.chart-row { --row-bg: var(--surface); position: relative; display: flex; align-items: center; border-radius: var(--radius-small); }
.chart-row:hover { --row-bg: var(--surface-raised); background: var(--row-bg); }
.chart-row.is-active { --row-bg: #24292c; background: var(--row-bg); box-shadow: inset 0 0 0 1px var(--denim); }
.chart-row .lib-loop-main { padding: 10px 12px; }
.chart-row:hover .row-actions, .chart-row:focus-within .row-actions { opacity: 1; pointer-events: auto; }

/* ---------- chord picker ---------- */

.sheet.picker { width: min(94vw, 780px); max-height: 86vh; padding: 0; overflow: hidden; }
.sheet.picker[open] { display: grid; grid-template-rows: auto minmax(0, 1fr) auto auto; }
.picker-head { display: flex; align-items: center; gap: 16px; padding: 20px 24px 12px; }
.picker-head h2 { margin: 0; white-space: nowrap; }
.picker-head input { flex: 1; min-width: 0; }
.picker-groups { overflow: auto; padding: 4px 24px 16px; }
.picker-group h3 { margin: 16px 0 10px; color: var(--text-muted); font-size: 14px; font-weight: 600; }
.picker-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 8px; }
.pick {
  display: grid;
  justify-items: center;
  gap: 6px;
  padding: 12px 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  background: var(--field);
  transition: border-color var(--ease), background-color var(--ease);
}
.pick:hover { border-color: var(--denim); background: var(--surface-raised); }
.pick .chord-svg { width: 54px; }
.pick b { font-size: 17px; font-weight: 600; line-height: 1.1; }
.picker-custom { display: grid; grid-template-columns: 120px minmax(0, 1fr) auto; gap: 8px; align-items: center; padding: 16px 24px; border-top: 1px solid var(--divider); }
.picker-custom .field-label { grid-column: 1 / -1; }
.picker-custom .field-error { grid-column: 1 / -1; min-height: 0; margin: 0; }
.picker-custom .field-error:empty { display: none; }
.sheet.picker .sheet-actions { padding: 0 24px 20px; }

/* ---------- responsive ---------- */

@media (max-width: 1280px) {
  .chords-page .insp-body { grid-template-columns: 1fr 1fr; }
  .chords-page .insp-body > .field:nth-child(4), .chords-page .insp-body > .wide { grid-column: 1 / -1; }
  .tone-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 860px) {
  .chords-page .insp-body { grid-template-columns: 1fr; }
  .cp-main { grid-template-columns: 1fr; }
  .cp-next { padding: 16px 0 0; border-top: 1px solid var(--divider); border-left: 0; }
}
@media (max-width: 560px) {
  .tempo .step[data-bpm='-5'], .tempo .step[data-bpm='5'] { display: none; }
  .tone-grid { grid-template-columns: 1fr 1fr; }
  .picker-custom { grid-template-columns: 1fr; }
  .cp-stage { padding: 16px 16px 0; }
  .cp-progress { margin: 0 -16px; }
}
