/* Chord finder: the page (chord-finder.html) and the chord builder it shares with chord practice's "Add a chord"
   dialog (js/finder/builder.js). Builds on styles.css and scales.css (the fretboard). Design system: brand/design-guide.md */

/* ---------- the builder: the neck, a button per string, the frets as text ---------- */

.cb { display: grid; gap: 12px; min-width: 0; }
/* Narrower than 46px a fret, the neck scrolls sideways in its own box rather than shrinking the targets. */
.cb-scroll { overflow-x: auto; overscroll-behavior-x: contain; border-radius: 8px; scrollbar-color: var(--border) transparent; }
.cb-scroll.is-scrolling { padding-bottom: 6px; }
.cb .fb-svg { max-width: none; } /* keeps its drawn size: the box scrolls instead */
.cb .fb-note { pointer-events: none; } /* taps go through to the fret under the note */
.cb .fb-hit { fill: transparent; cursor: pointer; }
.cb .fb-hit:hover { fill: rgba(232, 220, 196, 0.1); }
/* A muted string: the chord chart's ×, at the nut, in quiet text. */
.cb .fb-note.is-muted :is(.fb-dot, .fb-halo) { fill: none; stroke: none; }
.cb .fb-note.is-muted text { fill: var(--text-quiet); font-size: 24px; font-weight: 500; }

.cb-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; }
.cb-strings { display: flex; gap: 6px; }
.cb-string {
  display: grid;
  place-items: center;
  align-content: center;
  width: 48px;
  height: 52px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  background: var(--surface);
  color: var(--text);
  line-height: 1.15;
  transition: background-color var(--ease), border-color var(--ease);
}
.cb-string:hover { border-color: #57524a; background: var(--surface-raised); }
.cb-sname { color: var(--text-quiet); font-size: 13px; font-weight: 600; }
.cb-state { font-size: 18px; font-weight: 600; }
.cb-string.is-muted { background: var(--field); }
.cb-string.is-muted .cb-state { color: var(--text-quiet); }
.cb-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-left: auto; }
.cb-shape { display: flex; align-items: center; gap: 8px; color: var(--text-muted); font-size: 14px; }
.cb-shape input[type='text'] { width: 168px; height: 36px; padding: 0 10px; border-radius: var(--radius-small); font-weight: 600; letter-spacing: 0.04em; }
.cb-shape input[aria-invalid='true'] { border-color: var(--danger); }

/* ---------- the chord finder page ---------- */

.finder {
  display: grid;
  gap: 20px;
  max-width: 1120px;
  margin: 0 auto;
  padding: 24px;
  border-radius: 16px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.45);
  text-align: left;
}
.cf-result { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px 24px; min-height: 168px; }
.cf-text { flex: 1 1 auto; min-width: 0; }
.site-page main .cf-name { margin: 0; font: 600 64px/1.05 var(--font-ui); letter-spacing: -0.01em; overflow-wrap: anywhere; }
.site-page main .cf-name.is-plain { font-size: 40px; }
.cf-words { margin: 6px 0 0; color: var(--text-muted); font-size: 16px; }
.cf-tones { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 0; padding: 0; list-style: none; }
.cf-tones:empty { display: none; }
.cf-tones li { display: grid; justify-items: center; min-width: 52px; padding: 5px 10px 6px; border: 1px solid var(--divider); border-radius: var(--radius-small); background: var(--field); line-height: 1.2; }
.cf-tones b { font-size: 18px; font-weight: 600; }
.cf-tones span { color: var(--text-quiet); font-size: 13px; font-weight: 600; }
.cf-alts { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; margin-top: 14px; }
.cf-alts[hidden] { display: none; }
.cf-alts-label { color: var(--text-muted); font-size: 14px; }
.cf-alt-list { display: flex; flex-wrap: wrap; gap: 6px; }
.cf-alt {
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  background: var(--surface);
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  transition: background-color var(--ease), border-color var(--ease);
}
.cf-alt:hover { border-color: var(--denim); background: var(--surface-raised); }
.cf-diagram { flex: none; width: 112px; }
.cf-diagram .chord-svg { width: 112px; }

.cf-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.cf-spacer { flex: 1; }
.cf-actions a.btn { text-decoration: none; }
.cf-actions [hidden] { display: none; }
.cf-status { margin: -6px 0 0; color: var(--text-muted); font-size: 15px; }
.cf-status:empty { display: none; }
.cf-status a { color: var(--text); font-weight: 600; }

.cf-examples { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding-top: 16px; border-top: 1px solid var(--divider); }
.cf-examples-label { color: var(--text-muted); font-size: 14px; }
.cf-example-list { display: flex; flex-wrap: wrap; gap: 6px; }
.cf-example {
  height: 36px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: var(--radius-small);
  background: transparent;
  color: var(--text-muted);
  font-size: 15px;
  font-weight: 600;
  transition: background-color var(--ease), color var(--ease);
}
.cf-example:hover { background: var(--surface-raised); color: var(--text); }

/* "Add to a chart": the charts to choose from, newest first */
.sheet.cf-add { width: min(94vw, 520px); }
.cf-charts { display: grid; gap: 6px; max-height: 52vh; margin: 0 0 16px; padding: 0; overflow: auto; list-style: none; }
.cf-chart {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 56px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  background: var(--surface);
  color: var(--text);
  text-align: left;
  transition: background-color var(--ease), border-color var(--ease);
}
.cf-chart:hover { border-color: var(--denim); background: var(--surface-raised); }
.cf-chart svg { flex: none; width: 18px; height: 18px; color: var(--denim); }
.cf-chart > span { display: grid; min-width: 0; }
.cf-chart b { font-weight: 600; }
.cf-chart small { overflow: hidden; color: var(--text-muted); font-size: 14px; white-space: nowrap; text-overflow: ellipsis; }

@media (max-width: 560px) {
  .finder { gap: 16px; padding: 16px; }
  .cf-result { min-height: 0; }
  .site-page main .cf-name { font-size: 48px; }
  .site-page main .cf-name.is-plain { font-size: 32px; }
  .cf-diagram, .cf-diagram .chord-svg { width: 80px; }
  .cb-strings { flex: 1 1 100%; }
  .cb-string { flex: 1 1 0; width: auto; min-width: 0; }
  .cb-tools { flex: 1 1 100%; margin-left: 0; }
  .cb-shape { flex: 1 1 auto; }
  .cb-shape input[type='text'] { flex: 1 1 auto; width: auto; min-width: 0; }
  .cf-actions .btn { flex: 1 1 auto; }
  .cf-spacer { display: none; }
}
