/* ============================================================
   Кнопка музыки и громкость — общая для лендинга и демо
   ============================================================ */

.snd{
  position:relative;
  display:inline-flex;
  flex:0 0 auto;
  z-index:70;
}

.snd__btn{
  width:42px; height:42px;
  padding:0;
  display:grid; place-items:center;
  border-radius:14px;
  border:1px solid rgba(255,255,255,.18);
  background:rgba(255,255,255,.07);
  color:#ffd9a3;
  cursor:pointer;
  transition:background .2s, border-color .2s, color .2s, transform .15s;
}
.snd__btn:hover{
  background:rgba(255,255,255,.13);
  border-color:rgba(255,205,150,.45);
}
.snd__btn:active{ transform:scale(.96) }
.snd__btn:focus-visible{
  outline:2px solid rgba(255,205,150,.75);
  outline-offset:2px;
}

/* «эквалайзер»: живёт, пока музыка играет */
.snd__bars{
  display:flex;
  align-items:flex-end;
  justify-content:center;
  gap:2.5px;
  height:16px;
}
.snd__bars i{
  display:block;
  width:3px;
  height:14px;
  border-radius:2px;
  background:currentColor;
  transform-origin:50% 100%;
  transform:scaleY(.32);
  opacity:.45;
  transition:transform .3s, opacity .3s;
}
.snd.is-on .snd__bars i{
  opacity:.85;
}
/* столбики «пляшут» только когда музыка реально звучит,
   иначе кнопка врёт: выглядит играющей, а звука нет */
.snd.is-playing .snd__bars i{
  opacity:1;
  animation:eqBar 1.15s ease-in-out infinite;
}
.snd.is-playing .snd__bars i:nth-child(2){ animation-delay:.16s; animation-duration:1.32s }
.snd.is-playing .snd__bars i:nth-child(3){ animation-delay:.31s; animation-duration:.96s }
.snd.is-playing .snd__bars i:nth-child(4){ animation-delay:.09s; animation-duration:1.24s }
@keyframes eqBar{
  0%,100%{ transform:scaleY(.30) }
  35%    { transform:scaleY(1) }
  70%    { transform:scaleY(.55) }
}

/* музыка включена, но браузер ждёт клика — мягко подсказываем */
.snd.is-wait .snd__btn{
  animation:sndNudge 2.4s ease-in-out infinite;
}
.snd.is-wait::after{
  content:"Включить музыку";
  position:absolute;
  top:calc(100% + 9px);
  right:0;
  white-space:nowrap;
  padding:7px 11px;
  border-radius:10px;
  font-size:11.5px;
  font-weight:600;
  letter-spacing:.01em;
  color:#3a1f06;
  background:linear-gradient(180deg,#ffd79a,#ffbe6b);
  box-shadow:0 10px 24px rgba(0,0,0,.45);
  pointer-events:none;
  opacity:0;
  transform:translateY(-4px);
  animation:sndHintIn .45s .2s ease-out forwards;
}
@keyframes sndNudge{
  0%,100%{ box-shadow:0 0 0 0 rgba(255,196,107,0) }
  45%    { box-shadow:0 0 0 7px rgba(255,196,107,.14) }
}
@keyframes sndHintIn{
  to{ opacity:1; transform:translateY(0) }
}
@media (prefers-reduced-motion: reduce){
  .snd.is-wait .snd__btn{ animation:none }
  .snd.is-wait::after{ animation:none; opacity:1 }
}

/* поповер с громкостью */
.snd__pop{
  position:absolute;
  top:calc(100% + 12px);
  right:0;
  width:238px;
  padding:14px 14px 12px;
  border-radius:16px;
  background:rgba(11,16,44,.97);
  border:1px solid rgba(255,255,255,.15);
  box-shadow:0 26px 52px -24px #000, 0 2px 10px rgba(0,0,0,.35);
  color:#fff;
  display:none;
  z-index:80;
  text-align:left;
}
/* невидимый «мостик» через зазор: курсор, идущий от кнопки к ползунку,
   не проваливается в пустоту и поповер не захлопывается */
.snd__pop::after{
  content:"";
  position:absolute;
  left:0; right:0;
  bottom:100%;
  height:16px;
}
.snd__pop::before{
  content:"";
  position:absolute;
  top:-5px; right:16px;
  width:10px; height:10px;
  background:rgba(11,16,44,.97);
  border-left:1px solid rgba(255,255,255,.15);
  border-top:1px solid rgba(255,255,255,.15);
  transform:rotate(45deg);
}
.snd__lbl{
  display:block;
  font-size:10.5px;
  font-weight:800;
  letter-spacing:.16em;
  text-transform:uppercase;
  color:rgba(255,255,255,.55);
  margin-bottom:9px;
}

.snd__range{
  -webkit-appearance:none;
  appearance:none;
  width:100%;
  height:22px;
  padding:0;
  background:transparent;
  cursor:pointer;
}
.snd__range::-webkit-slider-runnable-track{
  height:5px;
  border-radius:4px;
  background:rgba(255,255,255,.20);
}
.snd__range::-webkit-slider-thumb{
  -webkit-appearance:none;
  width:16px; height:16px;
  margin-top:-5.5px;
  border:0;
  border-radius:50%;
  background:linear-gradient(160deg,#ffdda6,#eda24c);
  box-shadow:0 2px 8px rgba(0,0,0,.45);
}
.snd__range::-moz-range-track{
  height:5px;
  border-radius:4px;
  background:rgba(255,255,255,.20);
}
.snd__range::-moz-range-thumb{
  width:16px; height:16px;
  border:0;
  border-radius:50%;
  background:linear-gradient(160deg,#ffdda6,#eda24c);
}
.snd__range:focus-visible{ outline:2px solid rgba(255,205,150,.7); outline-offset:4px; border-radius:8px }

.snd__mute{
  margin-top:10px;
  width:100%;
  padding:8px 10px;
  border-radius:11px;
  border:1px solid rgba(255,255,255,.16);
  background:rgba(255,255,255,.06);
  color:#fff;
  font:inherit;
  font-size:12.5px;
  font-weight:700;
  cursor:pointer;
  transition:background .2s, border-color .2s;
}
.snd__mute:hover{ background:rgba(255,255,255,.13); border-color:rgba(255,205,150,.4) }

/* показываем поповер: на мыши открытие/закрытие ведёт music.js
   (с задержкой на закрытие), на тач — по тапу, с клавиатуры — по фокусу */
.snd:focus-within .snd__pop{ display:block }
.snd.is-open .snd__pop{ display:block }

@media (max-width:620px){
  .snd__btn{ width:38px; height:38px; border-radius:12px }
  .snd__bars{ height:14px; gap:2px }
  .snd__bars i{ width:2.5px; height:12px }
  .snd__pop{ width:min(232px,74vw); right:-6px }
  /* на телефоне подсказка-облачко неизбежно накрывает меню —
     оставляем только пульсацию кнопки */
  .snd.is-wait::after{ display:none }
}

@media (prefers-reduced-motion:reduce){
  .snd.is-on .snd__bars i{ animation:none; transform:scaleY(.8) }
}
