/* Player component --------------------------------------------------------
   Canonical, mobile-first layout and modal system for the practice player.
   Theme files provide tokens and colours; this file owns player geometry. */

.app-shell {
  box-sizing: border-box;
  width: 100%;
  max-width: 1920px;
  padding-inline: clamp(10px, 2.2vw, 40px);
}
.player {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "topline" "progress" "options";
  align-content: start;
  box-sizing: border-box;
  width: 100%;
  height: auto;
  min-width: 0;
  min-height: 0;
  margin: 0 0 22px;
  padding: 43px 10px 10px;
  gap: 7px;
  overflow: visible;
}
.player.player-modal-open {
  z-index: 100;
}
.player::before {
  content: "LIVE BACKING MACHINE";
  position: absolute;
  inset: 0 0 auto;
  box-sizing: border-box;
  height: 34px;
  padding: 0 13px;
  border: 0;
  border-radius: 15px 15px 0 0;
  background: var(--mem-yellow);
  box-shadow: inset 0 -3px 0 var(--mem-ink);
  color: var(--mem-ink);
  font: 850 11px/34px var(--mem-display);
  letter-spacing: .08em;
}
.player::after {
  display: none;
  content: none;
}
.player > .player-topline {
  grid-area: topline;
  display: grid;
  grid-template-columns: 91px minmax(0, 1fr);
  align-items: center;
  min-width: 0;
  gap: 7px;
}
.player-topline > .player-primary {
  display: grid;
  grid-template-columns: 42px 42px;
  align-items: center;
  min-width: 0;
  gap: 6px;
}
.player .play-button,
.player.playing .play-button,
.player .secondary-button {
  display: grid;
  box-sizing: border-box;
  width: 42px;
  min-width: 42px;
  height: 42px;
  min-height: 42px;
  padding: 0;
  place-items: center;
  box-shadow: none;
  transform: none;
}
.player .play-button {
  border: 2px solid var(--mem-paper);
  border-radius: 10px;
}
.player .play-button span:last-child {
  display: none;
}
.player .play-button .play-icon {
  display: grid;
  width: 18px;
  height: 22px;
  place-items: center;
  font-size: 15px;
  line-height: 1;
}
.player .play-button .play-icon svg {
  display: block;
  width: 100%;
  height: 100%;
}
.player .secondary-button {
  border-width: 2px;
  font-size: 20px;
}
.player-topline > .groove-picker-control {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-rows: auto auto;
  align-content: center;
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 5px 10px;
  gap: 1px 8px;
  border: 0;
  border-radius: 10px;
  box-shadow: none;
  transform: none;
  text-align: left;
}
.player-topline > .groove-picker-control span {
  overflow: hidden;
  color: var(--mem-secondary);
  font-size: 9px;
  font-weight: 850;
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.player-topline > .groove-picker-control strong {
  min-width: 0;
  overflow: hidden;
  color: var(--mem-ink);
  font: 850 15px/1.15 var(--mem-display);
  text-overflow: ellipsis;
  white-space: nowrap;
}
.player-topline > .groove-picker-control i {
  grid-column: 2;
  grid-row: 1 / span 2;
  align-self: center;
  font-size: 16px;
  font-style: normal;
}
.player > .progress-control {
  grid-area: progress;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-rows: auto auto;
  align-content: center;
  box-sizing: border-box;
  min-width: 0;
  min-height: 64px;
  padding: 8px 10px;
  gap: 6px 9px;
  border: 1px solid rgba(255, 253, 245, .38);
  border-radius: 10px;
  background: rgba(255, 253, 245, .055);
}
.player > .progress-control::before {
  content: none;
}
.player .progress-control > .transport {
  display: flex;
  grid-column: 1 / -1;
  align-items: baseline;
  min-width: 0;
  margin: 0;
  padding: 0;
  gap: 7px;
  border: 0;
  background: transparent;
}
.player .progress-control .transport span:first-child {
  flex: 0 1 auto;
  min-width: 0;
  overflow: hidden;
  color: var(--mem-paper);
  font: 850 13px/1.2 var(--mem-display);
  text-overflow: ellipsis;
  white-space: nowrap;
}
.player .progress-control .transport span:last-child {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  color: var(--mem-mint);
  font: 800 10px/1.2 var(--mem-body);
  text-overflow: ellipsis;
  white-space: nowrap;
}
.player .progress-control input {
  grid-column: 1;
  grid-row: 2;
  width: 100%;
  min-width: 0;
  margin: 0;
}
.player .progress-control output {
  grid-column: 2;
  grid-row: 2;
  min-width: 52px;
  padding: 0;
  color: var(--mem-yellow);
  font: 850 12px/1 var(--mem-data);
  text-align: right;
  white-space: nowrap;
}
.player > .player-options {
  grid-area: options;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  grid-auto-rows: 44px;
  align-content: stretch;
  min-width: 0;
  gap: 5px;
}
.player .compact-control,
.player .tempo-control > button,
.player .chord-display-control,
.player .loop-control,
.player .chord-tone-control {
  display: grid;
  grid-template-rows: auto 1fr;
  align-items: center;
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  min-height: 44px;
  height: 44px;
  padding: 5px 6px;
  gap: 1px;
  border: 0;
  border-radius: 9px;
  box-shadow: none;
  transform: none;
}
.player .compact-control span,
.player .tempo-control > button span,
.player .chord-display-control span,
.player .loop-control span,
.player .chord-tone-control span {
  overflow: hidden;
  color: var(--mem-secondary);
  font: 800 9px/1 var(--mem-body);
  text-overflow: ellipsis;
  white-space: nowrap;
}
.player .key-control strong,
.player .tempo-control > button output,
.player .chord-display-control strong,
.player .loop-control strong,
.player .chord-tone-control strong {
  min-width: 0;
  overflow: hidden;
  color: var(--mem-ink);
  font: 850 15px/1.05 var(--mem-display);
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.player .key-control {
  cursor: default;
}
.player .tempo-control,
.player .loop-settings {
  width: 100%;
  min-width: 0;
}
/* One viewport modal system for accompaniment, speed and loop selection. */
.player-modal-backdrop {
  position: fixed;
  z-index: 1000;
  inset: 0;
  background: rgba(24, 49, 83, .22);
  -webkit-backdrop-filter: blur(5px) saturate(.86);
  backdrop-filter: blur(5px) saturate(.86);
}
.player-modal-backdrop[hidden],
.player .tempo-popover[hidden],
.player .human-loop-popover[hidden],
.player > .groove-picker-popover[hidden] {
  display: none !important;
}
body.player-modal-open {
  overflow: hidden;
}
.player .tempo-popover,
.player .human-loop-popover,
.player > .groove-picker-popover {
  position: fixed;
  z-index: 1001;
  top: 50%;
  right: auto;
  bottom: auto;
  left: 50%;
  box-sizing: border-box;
  width: min(440px, calc(100vw - 28px));
  max-height: min(680px, calc(100dvh - 28px));
  margin: 0;
  padding: 15px;
  overflow: auto;
  border: 2px solid var(--mem-ink);
  border-radius: 14px;
  box-shadow: 0 20px 54px rgba(24, 49, 83, .28);
  transform: translate(-50%, -50%);
}
.player .tempo-popover {
  width: min(380px, calc(100vw - 28px));
  background: var(--mem-yellow);
}
.player .human-loop-popover {
  width: min(390px, calc(100vw - 28px));
  background: var(--mem-paper);
}
.player > .groove-picker-popover {
  width: min(500px, calc(100vw - 28px));
  background: var(--mem-cream);
}
.player .human-loop-popover > strong,
.player .human-loop-popover > span {
  display: block;
}
.player .human-loop-popover > strong {
  font: 850 18px/1.15 var(--mem-display);
}
.player .human-loop-popover > span {
  margin-top: 5px;
  color: var(--mem-secondary);
  font-size: 12px;
  line-height: 1.45;
}
.player .loop-stepper {
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
}
.player .loop-stepper button {
  min-height: 44px;
  box-shadow: none;
}
.player .loop-stepper output {
  font: 850 17px/1 var(--mem-display);
}
.player .loop-jump-list {
  margin-top: 13px;
}
.player .human-speed-readout span {
  font-size: 12px;
}
.player .human-speed-readout output {
  font: 850 20px/1 var(--mem-display);
}
.player .speed-scale span {
  font-size: 10px;
}
/* The public picker exposes only playable recordings: groove -> recording. */
.player .groove-picker-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px;
  align-items: start;
  gap: 12px;
  margin-bottom: 13px;
}
.player .groove-picker-toolbar h2 {
  margin: 0;
  color: var(--mem-ink);
  font: 900 clamp(24px, 6vw, 32px)/1 var(--mem-display);
  letter-spacing: -.025em;
}
.player .groove-picker-toolbar p {
  max-width: 34ch;
  margin: 5px 0 0;
  color: var(--mem-secondary);
  font-size: 11px;
  font-weight: 750;
  line-height: 1.45;
}
.player .groove-picker-field {
  position: relative;
  display: grid;
  min-width: 0;
}
.player .groove-picker-field::after {
  content: "";
  position: absolute;
  top: 50%;
  right: 18px;
  width: 9px;
  height: 9px;
  border-right: 3px solid var(--mem-ink);
  border-bottom: 3px solid var(--mem-ink);
  pointer-events: none;
  transform: translateY(-68%) rotate(45deg);
}
.player .groove-picker-field select {
  appearance: none;
  box-sizing: border-box;
  width: 100%;
  min-height: 54px;
  padding: 10px 46px;
  border: 3px solid var(--mem-ink);
  border-radius: 12px;
  background: var(--mem-yellow);
  color: var(--mem-ink);
  font: 900 18px/1.2 var(--mem-display);
  text-align: center;
  text-align-last: center;
}
.player .groove-picker-field select:focus-visible {
  outline: 4px solid #2f6bff;
  outline-offset: 3px;
}
.player .groove-picker-field option {
  text-align: center;
}
.player .groove-picker-toolbar > button {
  display: grid;
  width: 44px;
  min-width: 44px;
  height: 44px;
  min-height: 44px;
  padding: 0;
  place-items: center;
  border: 2px solid var(--mem-ink);
  border-radius: 50%;
  background: var(--mem-coral);
  color: var(--mem-ink);
  box-shadow: none;
  font-size: 22px;
}
.player .groove-backing-picker {
  margin: 16px 0 0;
  padding: 0;
  border: 0;
}
.player .groove-backing-picker > h3 {
  margin: 0 8px 8px;
  color: var(--mem-secondary);
  font: 850 12px/1.3 var(--mem-body);
  text-align: center;
}
.player .groove-backing-list {
  display: block;
  max-height: 300px;
  overflow: auto;
  border-top: 1px solid rgba(24,49,83,.32);
}
.player .groove-backing-choice {
  display: flex;
  width: 100%;
  min-height: 54px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 8px;
  border: 0;
  border-bottom: 1px solid rgba(24,49,83,.22);
  border-radius: 0;
  background: transparent;
  color: var(--mem-ink);
  box-shadow: none;
  text-align: left;
}
.player .groove-backing-choice strong {
  display: block;
  overflow: hidden;
  font: 850 15px/1.25 var(--mem-display);
  text-overflow: ellipsis;
  white-space: nowrap;
}
.player .groove-backing-choice small {
  display: block;
  margin-top: 3px;
  color: var(--mem-secondary);
  font: 700 10px/1.25 var(--mem-data);
}
.player .groove-backing-choice b {
  flex: 0 0 auto;
  color: var(--mem-secondary);
  font-size: 10px;
}
.player .groove-backing-choice:hover {
  background: rgba(255, 221, 59, .28);
}
.player .groove-backing-choice.active {
  background: var(--mem-yellow);
}
.player .groove-backing-empty {
  margin: 0;
  padding: 18px 8px;
  color: var(--mem-secondary);
  font-size: 12px;
  font-weight: 750;
  text-align: center;
}
.arrangement-title {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  min-width: 0;
  gap: 14px;
}
.arrangement-title > div:first-child {
  min-width: 0;
}
.arrangement-title h2 {
  overflow-wrap: anywhere;
}
.chord-tone-hint {
  display: flex;
  position: relative;
  isolation: isolate;
  align-items: center;
  justify-content: center;
  min-width: clamp(190px, 24vw, 360px);
  min-height: 72px;
  padding: 7px clamp(14px, 2vw, 27px);
  gap: clamp(3px, .5vw, 8px);
  white-space: nowrap;
}
.chord-tone-hint[hidden] {
  display: none;
}
.chord-tone-hint .chord-tone {
  display: inline-flex;
  align-items: baseline;
  gap: 0;
  color: var(--mem-coral);
  font: 950 clamp(38px, 4.2vw, 64px)/1 var(--mem-display);
  letter-spacing: -.035em;
  text-shadow: 0 2px 0 rgba(24, 49, 83, .14);
  transform: translateY(0) rotate(calc((var(--tone-index) - 2) * 1deg));
}
.chord-tone-hint .chord-tone-group {
  display: inline-flex;
  align-items: baseline;
  gap: inherit;
  min-width: 0;
}
.chord-tone-hint .chord-tone-divider {
  align-self: stretch;
  width: 3px;
  min-height: 40px;
  margin: 0 clamp(4px, .8vw, 11px);
  border-radius: 99px;
  background: var(--mem-ink, #183153);
  opacity: .72;
}
.chord-tone-hint .tone-accidental {
  flex: 0 0 auto;
  margin-right: -.04em;
  font-size: .48em;
  line-height: 1;
  transform: translateY(-.28em);
}
.chord-tone-hint .tone-degree {
  flex: 0 0 auto;
}
.chord-tone-hint .chord-tone:nth-of-type(4n + 2) { color: #08739f; }
.chord-tone-hint .chord-tone:nth-of-type(4n + 3) { color: #24725f; }
.chord-tone-hint .chord-tone:nth-of-type(4n + 4) { color: #744e99; }
.chord-tone-hint.is-dense .chord-tone {
  font-size: clamp(32px, 3.5vw, 52px);
}
.chord-tone-hint.has-multiple-chords .chord-tone {
  font-size: clamp(28px, 3.4vw, 50px);
}
.chord-tone-hint.is-animated .chord-tone {
  animation: chord-tone-sway 2.25s ease-in-out infinite alternate;
  animation-delay: calc((var(--tone-index) - 1) * -110ms);
  will-change: transform;
}
@keyframes chord-tone-sway {
  0% { transform: translate(calc((var(--tone-index) - 2) * -1.4px), calc((var(--tone-index) - 2) * 1.2px)) rotate(calc((var(--tone-index) - 2) * -1.25deg)); }
  100% { transform: translate(calc((var(--tone-index) - 2) * 1.4px), calc((var(--tone-index) - 2) * -1.2px)) rotate(calc((var(--tone-index) - 2) * 1.25deg)); }
}
@media (min-width: 720px) {
  .player {
    grid-template-columns: minmax(300px, .9fr) minmax(300px, 1.1fr);
    grid-template-areas: "topline progress" "options options";
    gap: 8px 12px;
    padding: 45px 14px 12px;
  }
  .player > .player-options {
    grid-auto-rows: 44px;
    gap: 7px;
  }
  .player .compact-control span,
  .player .tempo-control > button span,
  .player .chord-display-control span,
  .player .loop-control span,
  .player .chord-tone-control span {
    font-size: 10px;
  }
  .player .key-control strong,
  .player .tempo-control > button output,
  .player .chord-display-control strong,
  .player .loop-control strong,
  .player .chord-tone-control strong {
    font-size: 17px;
  }
}
@media (min-width: 1320px) {
  .player {
    grid-template-columns: minmax(350px, .95fr) minmax(340px, .9fr) minmax(420px, 1.15fr);
    grid-template-areas: "topline progress options";
    align-items: center;
    gap: 14px;
    padding: 45px 18px 12px;
  }
}
@media (max-width: 719px) {
  .player .key-control strong,
  .player .tempo-control > button output,
  .player .chord-display-control strong,
  .player .loop-control strong,
  .player .chord-tone-control strong {
    font-size: clamp(11px, 3.4vw, 14px);
  }
  .player .tempo-control > button output {
    font-size: 10px;
    letter-spacing: -.035em;
  }
  .player .tempo-control > button {
    padding-inline: 3px;
  }
  .arrangement-title {
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
  }
  .arrangement-title > div:first-child {
    grid-column: 1;
    grid-row: 1;
  }
  .arrangement-title.has-chord-tone-hint > div:first-child {
    display: none;
  }
  .chord-tone-hint {
    grid-column: 1;
    grid-row: 1;
    justify-self: stretch;
    min-width: 0;
    min-height: 58px;
    padding: 5px 12px;
    gap: clamp(2px, 1.3vw, 6px);
  }
  .chord-tone-hint .chord-tone {
    font-size: clamp(30px, 10vw, 46px);
  }
  .chord-tone-hint.is-dense .chord-tone {
    font-size: clamp(24px, 7.4vw, 34px);
  }
  .chord-tone-hint.has-multiple-chords {
    gap: clamp(1px, .7vw, 4px);
    padding-inline: 5px;
  }
  .chord-tone-hint.has-multiple-chords .chord-tone-group {
    gap: clamp(1px, .8vw, 4px);
  }
  .chord-tone-hint.has-multiple-chords .chord-tone {
    font-size: clamp(22px, 7.8vw, 39px);
  }
  .chord-tone-hint.has-multiple-chords .chord-tone-divider {
    width: 2px;
    min-height: 31px;
    margin-inline: clamp(3px, 1.4vw, 7px);
  }
}
@media (max-width: 370px) {
  .player {
    padding-inline: 8px;
  }
  .player > .player-topline {
    grid-template-columns: 86px minmax(0, 1fr);
  }
  .player-topline > .player-primary {
    grid-template-columns: 40px 40px;
  }
  .player .play-button,
  .player.playing .play-button,
  .player .secondary-button {
    width: 40px;
    min-width: 40px;
    height: 40px;
    min-height: 40px;
  }
  .player .compact-control span,
  .player .tempo-control > button span,
  .player .chord-display-control span,
  .player .loop-control span,
  .player .chord-tone-control span {
    font-size: 8px;
  }
  .player .key-control strong,
  .player .tempo-control > button output,
  .player .chord-display-control strong,
  .player .loop-control strong,
  .player .chord-tone-control strong {
    font-size: 12px;
  }
  .player .tempo-control > button output {
    font-size: 10px;
  }
}
@media (prefers-reduced-motion: reduce) {
  .chord-tone-hint.is-animated .chord-tone {
    animation: none;
    will-change: auto;
  }
}

/* Timeline cards share one coordinate system. One- and two-chord measures
   only change the middle row; measure and section metadata stay anchored. */
.timeline .bar {
  display: grid;
  grid-template-areas: "number" "chord" "function";
  grid-template-rows: auto minmax(0, 1fr) auto;
  align-items: stretch;
  box-sizing: border-box;
  height: 104px;
  min-height: 104px;
  padding: 11px 14px 9px;
  text-align: left;
}
.timeline .bar-number {
  grid-area: number;
  align-self: start;
  justify-self: start;
  margin: 0;
  font-size: 11px;
  line-height: 1;
}
.timeline .bar-chord {
  grid-area: chord;
  align-self: center;
  justify-self: start;
  min-width: 0;
  margin: 0;
  font-size: clamp(30px, 3vw, 46px);
  line-height: 1;
  max-width: 100%;
  overflow: hidden;
  text-overflow: clip;
  white-space: nowrap;
}
.timeline .bar-chord.chord-text-compact {
  font-size: clamp(24px, 2.45vw, 38px);
  letter-spacing: -.035em;
}
.timeline .bar-chord.chord-text-long {
  font-size: clamp(19px, 2vw, 30px);
  letter-spacing: -.055em;
}
.timeline .bar .bar-chord-split {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: center;
  justify-self: stretch;
  width: 100%;
  gap: clamp(8px, 1.5vw, 24px);
  font-size: clamp(26px, 2.4vw, 40px);
}
.timeline .bar-chord-split > span {
  min-width: 0;
  overflow: hidden;
  text-align: center;
  text-overflow: clip;
  white-space: nowrap;
}
.timeline .bar-chord-split > .chord-text-compact {
  font-size: .84em;
  letter-spacing: -.035em;
}
.timeline .bar-chord-split > .chord-text-long {
  font-size: .68em;
  letter-spacing: -.055em;
}
.timeline .bar-function {
  display: block;
  grid-area: function;
  align-self: end;
  justify-self: start;
  max-width: 100%;
  margin: 0;
  overflow: hidden;
  font-size: 11px;
  line-height: 1;
  text-overflow: clip;
  white-space: nowrap;
}
@media (max-width: 719px) {
  .timeline .bar {
    height: 68px;
    min-height: 68px;
    padding: 7px 7px 6px;
  }
  .timeline .bar-number {
    font-size: 8px;
  }
  .timeline .bar-chord {
    font-size: clamp(17px, 5vw, 23px);
  }
  .timeline .bar-chord.chord-text-compact {
    font-size: clamp(14px, 4vw, 19px);
  }
  .timeline .bar-chord.chord-text-long {
    font-size: clamp(11px, 3.2vw, 16px);
  }
  .timeline .bar .bar-chord-split {
    gap: 2px;
    font-size: clamp(11px, 3.5vw, 17px);
  }
  .timeline .bar-function {
    font-size: clamp(6px, 1.8vw, 9px);
  }
}
