/* Chord Generator tables, press-and-hold cells, and envelope note. */

/* Contain wide tables so they scroll locally instead of widening the page. */
.chordtable-scroll {
  max-width: 100%;
  margin: 1.5rem 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.chordtable-scroll > table.chordtable {
  margin: 0;
}

table.chordtable {
  border-collapse: collapse;
  margin: 1.5rem 0;
  width: 100%;
}

table.chordtable th,
table.chordtable td {
  border: 1px solid rgba(0, 0, 0, 0.125);
  padding: 0.5rem;
  vertical-align: top;
}

table.chordtable tbody tr:nth-child(odd) {
  background-color: rgba(0, 0, 0, 0.03);
}

/* mode_nav puts the degree header inside <tbody>; don't stripe that row. */
table.chordtable:has(.mode-nav-col) tbody tr:nth-child(odd) {
  background-color: transparent;
}
table.chordtable:has(.mode-nav-col) tbody tr:nth-child(even) {
  background-color: rgba(0, 0, 0, 0.03);
}

table.chordtable td.chordy,
table.chordtable th.chordy {
  cursor: pointer;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

table.chordtable td.chordy:hover,
table.chordtable th.chordy:hover {
  background-color: rgba(46, 31, 94, 0.08);
}

table.chordtable td.chordy p,
table.chordtable th.chordy p {
  margin: 0;
}

/* Mode-wheel chrome: full-height ◀/▶ columns (not .chordy; no playback). */
table.chordtable th.mode-nav-col {
  position: relative;
  width: 2rem;
  min-width: 2rem;
  max-width: 2.25rem;
  padding: 0;
  vertical-align: middle;
  text-align: center;
}

table.chordtable th.mode-nav-col .mode-nav-btn {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0.25rem;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font-size: 1.25rem;
  line-height: 1;
}

table.chordtable th.mode-nav-col .mode-nav-btn:hover,
table.chordtable th.mode-nav-col .mode-nav-btn:focus-visible {
  background-color: rgba(46, 31, 94, 0.08);
}

table.chordtable caption {
  background-color: var(--light, #f8f9fa);
  border-bottom: 1px solid rgba(0, 0, 0, 0.125);
  caption-side: top;
  color: #212529;
  display: table-caption;
  font-size: 1rem;
  font-weight: 600;
  padding: 0.65rem 0.75rem;
  text-align: center;
  width: 100%;
}

.envelope-note {
  color: var(--secondary, #6c757d);
  font-size: 0.875rem;
  margin: 0 0 0.75rem;
}

/* Last row / nested fieldset already sit inside fieldset padding (p-4);
   drop the extra site .row / fieldset bottom margin that looked like empty space. */
.app-content fieldset > .row:last-child,
.app-content fieldset > fieldset:last-child {
  margin-bottom: 0;
}

/* Scale form uses the same .row / .col-md-6 grid as Audio Controls so
   Octave and ASCII friendly share the right column with MIDI volume,
   Decay, and Release. Row spacing is site .row mb-4 (Attack ↔ Sustain). */
#fontchoice > fieldset > legend {
  float: none;
  width: auto;
}

#fontchoice .row {
  align-items: center;
}

.scale-form-controls,
.scale-form-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
  min-height: 2.25rem;
}

#fontchoice .button,
.app-content #fontchoice input[type="submit"] {
  margin-top: 0;
  margin-bottom: 0;
  margin-left: 0;
  vertical-align: middle;
}

.sonority-priority {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem 0.75rem;
  margin: 0;
  padding: 0;
  border: none;
  min-height: 2.25rem;
  white-space: normal;
}

.sonority-priority-label {
  display: inline-flex;
  align-items: center;
  font-weight: 600;
  line-height: 1.25;
  margin: 0;
}

.sonority-priority label,
.scale-form-check {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-weight: normal;
  line-height: 1.25;
  margin: 0;
}

.sonority-priority input[type="radio"],
.scale-form-check input[type="checkbox"] {
  margin: 0;
  flex-shrink: 0;
  align-self: center;
}

/* Waveform + MIDI out: label above select so the two dropdowns share a baseline;
   status sits under the MIDI select (not inline-wrapped beside it). */
.app-content .row.audio-selects-row {
  align-items: flex-start;
}

.audio-control-stack {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.35rem;
}

.audio-control-stack > select {
  width: 100%;
  max-width: 100%;
  margin-right: 0;
}

.midi-status {
  display: block;
  margin: 0;
}

.midi-status:empty {
  display: none;
}

body.theme-dark table.chordtable {
  border-color: rgba(255, 255, 255, 0.28);
}

body.theme-dark table.chordtable th,
body.theme-dark table.chordtable td {
  border: 1px solid rgba(255, 255, 255, 0.28);
}

body.theme-dark table.chordtable tbody tr:nth-child(odd) {
  background-color: rgba(255, 255, 255, 0.06);
}

body.theme-dark table.chordtable:has(.mode-nav-col) tbody tr:nth-child(odd) {
  background-color: transparent;
}
body.theme-dark table.chordtable:has(.mode-nav-col) tbody tr:nth-child(even) {
  background-color: rgba(255, 255, 255, 0.06);
}

body.theme-dark table.chordtable td.chordy:hover,
body.theme-dark table.chordtable th.chordy:hover {
  background-color: rgba(255, 255, 255, 0.12);
}

body.theme-dark table.chordtable caption {
  background-color: rgba(255, 255, 255, 0.1);
  border-bottom-color: rgba(255, 255, 255, 0.28);
  color: rgba(255, 255, 255, 0.95);
}

body.theme-dark .envelope-note {
  color: rgba(255, 255, 255, 0.7);
}
