/* Chord diagram enhancer (practice / performance doc views) */

/* Inline chord tokens (hover targets) */
.tbp-chord-token {
  cursor: default;
  border-bottom: 1px dotted rgba(100, 180, 255, 0.55);
}

.gig-document-content strong .tbp-chord-token,
.gig-document-content b .tbp-chord-token,
.song-content strong .tbp-chord-token,
.song-content b .tbp-chord-token {
  font-weight: inherit;
}

.tbp-chord-hover-popover {
  position: fixed;
  z-index: 10050;
  pointer-events: auto;
  padding: 8px 10px 10px;
  background: var(--bg-darker);
  color: var(--text-muted);
  border: 1px solid var(--border-gray);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  color-scheme: dark;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.12s ease, transform 0.12s ease;
  text-align: center;
  min-width: 100px;
}

.tbp-chord-hover-popover.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.tbp-chord-hover-popover--below.is-visible {
  transform: translateY(0);
}

.tbp-chord-hover-popover-diagram {
  display: flex;
  justify-content: center;
  align-items: center;
  line-height: 0;
  min-height: 104px;
  padding: 6px 4px;
  background: var(--bg-dark);
  border: 1px solid var(--border-gray);
  border-radius: 6px;
}

.tbp-chord-hover-popover-diagram .tbp-chord-svg {
  display: block;
  color: var(--text-muted);
}

.tbp-chord-hover-popover-nav {
  margin-top: 6px;
}

.tbp-chord-hover-popover-note {
  font-size: 10px;
  text-align: center;
  color: var(--text-muted, #6c757d);
  margin-top: 4px;
}

.tbp-chord-toolbar {
  margin-bottom: 0.5rem;
}

.tbp-chord-open-btn {
  font-size: 12px;
}

.tbp-chord-subhead-link {
  display: inline;
  padding: 0;
  margin: 0;
  border: none;
  background: none;
  color: var(--color-primary, #0d6efd);
  font: inherit;
  font-weight: inherit;
  text-decoration: underline;
  cursor: pointer;
  vertical-align: baseline;
}

.tbp-chord-subhead-link:hover {
  color: var(--color-primary-dark, #0a58ca);
}

.tbp-chord-svg {
  display: block;
  color: inherit;
  overflow: visible;
}

.tbp-chord-svg-label,
.tbp-chord-svg-fret-num {
  fill: currentColor;
}

.tbp-chord-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1060;
}

.tbp-chord-modal.is-open {
  display: block;
}

.tbp-chord-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
}

.tbp-chord-modal-panel {
  position: relative;
  margin: 2vh auto;
  max-width: 720px;
  max-height: 92vh;
  background: var(--bg-darker);
  color: var(--text-muted);
  border: 1px solid var(--border-gray);
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  color-scheme: dark;
}

.tbp-chord-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-gray, #dee2e6);
}

.tbp-chord-modal-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-header-muted);
}

.tbp-chord-modal-close {
  border: none;
  background: none;
  color: inherit;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
  opacity: 0.7;
}

.tbp-chord-modal-close:hover {
  opacity: 1;
}

.tbp-chord-modal-body {
  padding: 16px;
  overflow-y: auto;
}

.tbp-chord-modal-empty {
  margin: 0;
  color: var(--text-muted, #6c757d);
}

.tbp-chord-modal-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 12px;
}

.tbp-chord-card {
  text-align: center;
  border: 1px solid var(--border-gray);
  border-radius: 6px;
  padding: 8px 4px;
  background: var(--bg-dark);
}

.tbp-chord-card-diagram {
  display: flex;
  justify-content: center;
  min-height: 104px;
  align-items: center;
}

.tbp-chord-card-miss {
  font-size: 11px;
  color: var(--text-muted, #6c757d);
  padding: 2rem 0;
}

.tbp-chord-card-label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  margin-top: 4px;
}

.tbp-chord-card-bass {
  display: block;
  font-size: 10px;
  color: var(--text-muted, #6c757d);
  margin-top: 2px;
}

.tbp-chord-card-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  margin-top: 4px;
}

.tbp-chord-card-nav button {
  border: 1px solid var(--border-gray, #dee2e6);
  background: transparent;
  color: inherit;
  border-radius: 4px;
  width: 24px;
  height: 22px;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 0;
}

.tbp-chord-card-nav button:hover {
  background: var(--tab-bg-hover, #495057);
}

.tbp-chord-card-voicing {
  font-size: 10px;
  color: var(--text-muted, #6c757d);
  min-width: 2.5em;
}

/* ── Transpose controls ─────────────────────────────────────── */

.tbp-transpose {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  flex: 0 0 auto;
}

.tbp-tp-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 24px;
  padding: 0;
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  border: 1px solid var(--border-gray, #6c757d);
  border-radius: 4px;
  background: transparent;
  color: var(--text-muted, #999);
  transition: background 0.12s, color 0.12s;
}

/* Accidental toggle: shows ♯ (default, muted) or ♭/♯ when chosen. */
.tbp-tp-acc {
  width: auto;
  min-width: 28px;
  padding: 0 6px;
  opacity: 0.55;
}

.tbp-tp-acc--active {
  opacity: 1;
  background: rgba(255, 140, 0, 0.18);
  color: #f90;
  border-color: #f90;
}

.tbp-tp-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: var(--text-main, #fff);
}

.tbp-tp-display {
  min-width: 1.8em;
  text-align: center;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted, #999);
  padding: 0 2px;
  font-variant-numeric: tabular-nums;
}

.tbp-transpose--active .tbp-tp-display {
  color: var(--color-primary, #4da6ff);
}

/* Toolbar layout (performance-doc page) */
.tbp-chord-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

/* Song-header layout when transpose controls are injected (music-stand) */
.song-header.tbp-has-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 0.5rem;
}

.song-header.tbp-has-controls > h2,
.song-header.tbp-has-controls > .h2,
.song-header.tbp-has-controls > .h4 {
  flex: 1 1 auto;
  margin-bottom: 0;
}

.song-header.tbp-has-controls > p {
  flex: 0 0 100%;
  margin-bottom: 0;
}

.song-header.tbp-has-controls > .tbp-transpose--header {
  flex: 0 0 auto;
}

/* B♭ / E♭ instrument toggles (performance-doc toolbar) */
.tbp-instrument-btns {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  flex: 0 0 auto;
}

.tbp-inst-btn--active {
  opacity: 1;
  background: rgba(100, 180, 255, 0.2);
  color: var(--color-primary, #4da6ff);
  border-color: var(--color-primary, #4da6ff);
}

.tbp-instrument-btns .tbp-inst-btn:not(.tbp-inst-btn--active) {
  opacity: 0.7;
}

/* Push transpose + instrument groups to the right of the PD toolbar */
.tbp-chord-toolbar .tbp-transpose {
  margin-left: auto;
}

.tbp-chord-toolbar .tbp-instrument-btns::before {
  content: "";
  display: inline-block;
  width: 1px;
  height: 20px;
  background: var(--border-gray, #6c757d);
  margin-right: 0.15rem;
  opacity: 0.5;
}

/* Divider between Chords btn and Transpose in the toolbar */
.tbp-chord-toolbar .tbp-transpose::before {
  content: "";
  display: inline-block;
  width: 1px;
  height: 20px;
  background: var(--border-gray, #6c757d);
  margin-right: 0.15rem;
  opacity: 0.5;
}

/* Performance-doc print appendix (?print=true&chords=1) */
.tbp-chord-print-appendix {
  margin-bottom: 1.25rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid #ccc;
  page-break-after: avoid;
}

.tbp-chord-print-appendix-title {
  font-size: 14pt;
  font-weight: 700;
  margin: 0 0 0.75rem;
}

.tbp-chord-print-appendix-empty {
  font-size: 11pt;
  color: #555;
  margin: 0;
}

.tbp-chord-print-appendix-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(5.5rem, 1fr));
  gap: 0.65rem 0.85rem;
  max-width: 100%;
}

.tbp-chord-print-card {
  text-align: center;
  break-inside: avoid;
  page-break-inside: avoid;
}

.tbp-chord-print-card-diagram {
  display: flex;
  justify-content: center;
}

.tbp-chord-print-card-diagram svg {
  max-width: 100%;
  height: auto;
}

.tbp-chord-print-card-label {
  font-size: 9pt;
  font-weight: 600;
  margin-top: 0.15rem;
  line-height: 1.2;
}

/* PD print preview (?print=true): no hover popovers on chord tokens */
.tbp-chord-print-view .tbp-chord-token {
  cursor: default;
  pointer-events: none;
}

@media print {
  .tbp-chord-toolbar,
  .tbp-chord-modal,
  .tbp-chord-hover-popover,
  .tbp-transpose {
    display: none !important;
  }

  .tbp-chord-print-appendix {
    border-bottom-color: #999;
  }

  .tbp-chord-token {
    background: transparent !important;
  }
}
