/* ==========================================================================
   Background music button — sits beside the menu trigger in the header.

   Four bars in the same 1.35px-ish stroke language as the icon sprite.
   Off: the bars rest low under a slash. On: the slash draws away and the
   bars breathe. Colour is always currentColor, so it follows the header
   through its inverted / stuck states like every other header action.
   ========================================================================== */

.md-music { position: relative; }
.at-header__bar--music .at-header__start { position: relative; }

.md-music__bars {
  position: relative;
  display: inline-flex;
  align-items: flex-end;
  justify-content: center;
  gap: 3px;
  width: 21px;
  height: 16px;
}

.md-music__bars i {
  display: block;
  width: 2px;
  height: 100%;
  border-radius: 2px;
  background: currentColor;
  transform-origin: 50% 100%;
  transform: scaleY(var(--md-h, .4));
  transition: transform .5s cubic-bezier(.2, .8, .2, 1), opacity .3s ease;
}
.md-music__bars i:nth-child(1) { --md-h: .38; }
.md-music__bars i:nth-child(2) { --md-h: .72; }
.md-music__bars i:nth-child(3) { --md-h: .5; }
.md-music__bars i:nth-child(4) { --md-h: .28; }

.md-music[data-state="off"] .md-music__bars i { opacity: .72; }

/* The slash: drawn across the bars while the music is off. */
.md-music__bars::after {
  content: "";
  position: absolute;
  left: -3px;
  right: -3px;
  top: 50%;
  height: 1.5px;
  margin-top: -.75px;
  border-radius: 2px;
  background: currentColor;
  transform: rotate(-40deg) scaleX(1);
  transition: transform .4s cubic-bezier(.2, .8, .2, 1);
}
.md-music[data-state="on"] .md-music__bars::after { transform: rotate(-40deg) scaleX(0); }

.md-music[data-state="on"] .md-music__bars i {
  animation: md-eq 1.1s ease-in-out infinite;
}
.md-music[data-state="on"] .md-music__bars i:nth-child(1) { animation-duration: .95s; animation-delay: -.3s; }
.md-music[data-state="on"] .md-music__bars i:nth-child(2) { animation-duration: 1.2s; animation-delay: -.8s; }
.md-music[data-state="on"] .md-music__bars i:nth-child(3) { animation-duration: 1.05s; animation-delay: -.1s; }
.md-music[data-state="on"] .md-music__bars i:nth-child(4) { animation-duration: 1.3s; animation-delay: -.55s; }

@keyframes md-eq {
  0%, 100% { transform: scaleY(.22); }
  50% { transform: scaleY(1); }
}

/* Loading: a slow shimmer while the first bytes arrive. */
.md-music[data-state="loading"] .md-music__bars::after { transform: rotate(-40deg) scaleX(0); }
.md-music[data-state="loading"] .md-music__bars i { animation: md-wait 1.2s ease-in-out infinite; }
.md-music[data-state="loading"] .md-music__bars i:nth-child(2) { animation-delay: .15s; }
.md-music[data-state="loading"] .md-music__bars i:nth-child(3) { animation-delay: .3s; }
.md-music[data-state="loading"] .md-music__bars i:nth-child(4) { animation-delay: .45s; }
@keyframes md-wait {
  0%, 100% { transform: scaleY(.25); opacity: .45; }
  50% { transform: scaleY(.25); opacity: 1; }
}

/* Now-playing note, shown briefly when a visitor turns the music on. */
.md-music__tip {
  position: absolute;
  z-index: 30;
  top: calc(100% + 8px);
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: min(260px, 70vw);
  padding: 9px 13px;
  border-radius: var(--cc-shape-icon, 10px);
  background: var(--cc-paper, #f7f5ef);
  color: var(--cc-ink, #111);
  box-shadow: 0 1px 2px rgba(8, 8, 8, .08), 0 14px 34px -12px rgba(8, 8, 8, .35);
  font: 500 12px/1.25 var(--cc-ui, system-ui, sans-serif);
  letter-spacing: .01em;
  text-transform: none;
  white-space: nowrap;
  opacity: 0;
  transform: translateY(-4px);
  pointer-events: none;
  transition: opacity .28s ease, transform .28s cubic-bezier(.2, .8, .2, 1);
}
.md-music__tip[data-show="true"] { opacity: 1; transform: none; }
.md-music__tip::before {
  content: "\266A";
  flex: 0 0 auto;
  font-size: 13px;
  color: var(--cc-burgundy, currentColor);
}
.md-music__tip span { min-width: 0; overflow: hidden; text-overflow: ellipsis; }

/* Mobile: the start column only fit the menu trigger. Match the end
   column so the brand stays optically centred. */
@media (max-width: 719px) {
  .at-header__bar.at-header__bar--music { grid-template-columns: 96px minmax(0, 1fr) 96px; }
}

@media (prefers-reduced-motion: reduce) {
  .md-music[data-state="on"] .md-music__bars i,
  .md-music[data-state="loading"] .md-music__bars i { animation: none; }
  .md-music[data-state="on"] .md-music__bars i { opacity: 1; }
}
