/* Pulsante Back to Top stile WhatsApp */
#back-to-top {
  position: fixed;
  bottom: 20px;
  right: 88px; /* a sinistra del pulsante musica (20px + 60px + 8px di spazio) */

  background-color: #ffffff; /* colore richiesto */
  color: #4A3826;

  width: auto;
  padding: 10px 16px; /* come WhatsApp */
  border-radius: 50px; /* forma a pillola */

  border: 2px solid #4A3826;
  cursor: pointer;
  display: none;

  display: flex;
  align-items: center;
  justify-content: center;

  font-size: 0; /* nascondiamo eventuale testo */

  box-shadow: 0 4px 6px rgba(0,0,0,0.3);
  transition: transform 0.2s, opacity 0.3s;
  z-index: 9999;
}

#back-to-top.show {
  display: flex;
  opacity: 1;
  transform: translateY(0);
}

#back-to-top.hide {
  opacity: 0;
  transform: translateY(20px);
}

#back-to-top:hover {
  transform: scale(1.1); /* effetto WhatsApp */
}

/* Icona interna */
#back-to-top svg {
  width: 24px;
  height: 24px;
  fill: #4A3826;
}


/* =====================================================
   PULSANTE MUSICA – stesso stile del "torna su",
   fisso nell'angolo in basso a destra
   ===================================================== */
#music-toggle {
  position: fixed;
  bottom: 20px;
  right: 20px;

  background-color: #ffffff;
  color: #4A3826;

  padding: 10px 16px;
  border-radius: 50px;
  border: 2px solid #4A3826;
  cursor: pointer;

  display: flex;
  align-items: center;
  justify-content: center;

  box-shadow: 0 4px 6px rgba(0,0,0,0.3);
  transition: transform 0.2s, opacity 0.3s;
  z-index: 9999;
}

#music-toggle:hover {
  transform: scale(1.1);
}

#music-toggle svg {
  width: 24px;
  height: 24px;
  fill: #4A3826;
  stroke: #4A3826;
}

/* mostra l'icona giusta in base allo stato */
#music-toggle .icon-off { display: none; }
#music-toggle.is-off .icon-on { display: none; }
#music-toggle.is-off .icon-off { display: block; }

/* onde sonore animate solo mentre la musica suona */
#music-toggle .wave { opacity: 0.35; }
#music-toggle.is-playing .wave {
  opacity: 1;
  animation: music-wave 1.4s ease-in-out infinite;
}
#music-toggle.is-playing .wave + .wave { animation-delay: 0.35s; }

@keyframes music-wave {
  0%, 100% { opacity: 0.35; }
  50%      { opacity: 1; }
}

/* musica in attesa di un tocco per ripartire (es. iPhone al cambio pagina):
   il pulsante pulsa con un alone */
#music-toggle.is-waiting {
  animation: music-pulse 1.6s ease-out infinite;
}
@keyframes music-pulse {
  0%   { box-shadow: 0 4px 6px rgba(0,0,0,0.3), 0 0 0 0 rgba(74,56,38,0.55); transform: scale(1); }
  50%  { transform: scale(1.08); }
  70%  { box-shadow: 0 4px 6px rgba(0,0,0,0.3), 0 0 0 14px rgba(74,56,38,0); }
  100% { box-shadow: 0 4px 6px rgba(0,0,0,0.3), 0 0 0 0 rgba(74,56,38,0); transform: scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  #music-toggle.is-playing .wave { animation: none; }
  #music-toggle.is-waiting { animation: none; outline: 3px solid rgba(74,56,38,0.5); outline-offset: 3px; }
}

