/* Music stand (perform view) auto-scroll + sticky song headers */

.ms-autoscroll-anchor {
  height: 0;
  margin: 0;
  padding: 0;
}

.ms-autoscroll-spacer {
  height: 0;
  margin: 0;
  padding: 0;
  pointer-events: none;
}

.ms-autoscroll {
  position: sticky;
  top: 0;
  z-index: 1030;
  margin: 0 0 1.25rem;
  padding: 0.5rem 0.75rem;
  background: var(--bg-darker, #2d2d2d);
  border: 1px solid var(--border-gray, #495057);
  border-radius: 8px;
  transition: box-shadow 0.2s ease;
}

.ms-autoscroll.is-pinned {
  position: fixed;
  top: 0;
  left: var(--ms-bar-left, 0);
  width: var(--ms-bar-width, 100%);
  margin-bottom: 0;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

.ms-autoscroll-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.5rem;
}

.ms-autoscroll-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-header-muted, #d4d4d4);
  margin-right: 0.15rem;
}

.ms-autoscroll-transport {
  display: inline-flex;
  flex-direction: row;
  flex-wrap: nowrap;
  flex: 0 0 auto;
}

.ms-autoscroll-transport[hidden] {
  display: none !important;
}

/* Standalone button styles — not using Bootstrap btn-group to avoid flex conflicts */
.ms-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.25rem 0.6rem;
  font-size: 0.875rem;
  line-height: 1.5;
  white-space: nowrap;
  cursor: pointer;
  border: 1px solid transparent;
  background: transparent;
  color: inherit;
}

.ms-btn:first-child { border-radius: 4px 0 0 4px; }
.ms-btn:last-child  { border-radius: 0 4px 4px 0; }
.ms-btn:not(:first-child) { margin-left: -1px; }

.ms-btn-secondary {
  color: #adb5bd;
  border-color: #6c757d;
}
.ms-btn-secondary:hover { background: rgba(108,117,125,.15); }
.ms-btn-secondary:disabled { opacity: 0.45; cursor: default; }

.ms-btn-primary {
  color: #0d6efd;
  border-color: #0d6efd;
}
.ms-btn-primary:hover { background: rgba(13,110,253,.12); }
.ms-btn-primary.playing {
  background: #198754;
  border-color: #198754;
  color: #fff;
}

.ms-autoscroll-fwd[hidden] {
  display: none !important;
}

.ms-autoscroll-chevron {
  font-size: 1.1rem;
  line-height: 1;
  font-weight: 700;
}

.ms-autoscroll-play {
  min-width: 2.5rem;
}

.ms-autoscroll-play .bi {
  font-size: 1.1rem;
  line-height: 1;
}

.ms-autoscroll-play-icon[hidden],
.ms-autoscroll-pause-icon[hidden] {
  display: none !important;
}

/* Speed slider always lives on its own second row */
.ms-autoscroll-speed {
  order: 10;
  flex: 0 0 100%;
  width: 100%;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-width: 0;
}

.ms-autoscroll-speed-label {
  font-size: 0.8rem;
  margin: 0;
  color: var(--text-muted, #aaa);
  white-space: nowrap;
}

.ms-autoscroll-range {
  flex: 1 1 4rem;
  min-width: 4rem;
  accent-color: var(--color-primary, #0d6efd);
}

.ms-autoscroll-speed-out {
  display: inline-block;
  min-width: 1.25rem;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-header-muted, #d4d4d4);
  text-align: center;
}

.ms-autoscroll-close {
  margin-left: auto;
  order: 9;
  padding: 0 0.35rem;
  font-size: 1.25rem;
  line-height: 1;
  text-decoration: none;
}

.ms-autoscroll-close:hover {
  color: var(--text-header-muted, #d4d4d4) !important;
}

.ms-autoscroll-hint {
  order: 11;
  font-size: 0.75rem;
  color: var(--text-muted, #aaa);
  margin: 0;
  flex: 0 0 100%;
}

/* Collapsed: hide bar, no sticky headers, minimal restore chip */
html.ms-autoscroll-dismissed .ms-autoscroll {
  display: none;
}

html.ms-autoscroll-dismissed .ms-autoscroll-spacer {
  height: 0 !important;
}

.ms-autoscroll-restore {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin: 0 0 0.75rem;
  padding: 0.2rem 0.55rem;
  font-size: 0.8rem;
  line-height: 1.3;
  color: var(--text-muted, #aaa);
  background: var(--bg-darker, #2d2d2d);
  border: 1px solid var(--border-gray, #495057);
  border-radius: 6px;
  cursor: pointer;
}

.ms-autoscroll-restore:hover {
  color: var(--text-header-muted, #d4d4d4);
  border-color: var(--color-primary, #0d6efd);
}

.ms-autoscroll-restore[hidden] {
  display: none !important;
}

/* Song title scrolls up, then sticks under the pinned auto-scroll bar */
.song-document {
  overflow: visible;
}

html:not(.ms-autoscroll-dismissed) .song-document .song-header.ms-sticky-header,
html:not(.ms-autoscroll-dismissed) .song-header.ms-sticky-header {
  position: sticky;
  top: var(--ms-bar-height, 52px);
  scroll-margin-top: var(--ms-bar-height, 52px);
  z-index: 1020;
  background: var(--bg-darkest, #1a1a1a);
  padding: 0.5rem 0 0.75rem;
  margin-bottom: 1rem;
  border-bottom: 2px solid var(--color-primary, #007bff);
}

html:not(.ms-autoscroll-dismissed) .song-document .song-header.ms-sticky-header h2 {
  margin-bottom: 0.25rem;
}

@media (max-width: 576px) {
  .ms-autoscroll-hint {
    display: none;
  }

  .ms-autoscroll {
    margin-bottom: 0.75rem;
    padding: 0.35rem 0.5rem;
  }

  .ms-autoscroll-range {
    max-width: none;
  }
}

@media print {
  .ms-autoscroll,
  .ms-autoscroll-anchor,
  .ms-autoscroll-spacer,
  .ms-autoscroll-restore {
    display: none !important;
  }

  .song-document .song-header.ms-sticky-header,
  .song-header.ms-sticky-header {
    position: static;
    background: transparent;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ms-autoscroll,
  .ms-autoscroll-restore {
    display: none;
  }
}
