/* ------------------------------------------------------------------
   Expérience sonore — LEMONY
   Contrôle discret et persistant, affiché en bas de page.
   ------------------------------------------------------------------ */

@font-face {
  font-family: "FonteLoewTech";
  src: url("../css/PerpetuaTitlingMTLight2.ttf") format("truetype");
  font-display: swap;
}

.lemony-sound-toggle {
  position: fixed;
  left: calc(20px + env(safe-area-inset-left, 0px));
  bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  z-index: 1040;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 38px;
  margin: 0;
  padding: 0 16px;
  border: 1px solid rgba(17, 17, 17, 0.35);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.82);
  color: #111;
  font-family: "FonteLoewTech", "Perpetua Titling MT", Georgia, serif;
  font-size: 11px;
  line-height: 1;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  white-space: nowrap;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.12);
  opacity: 0;
  transform: translateY(8px);
  animation: lemony-sound-enter 0.9s 0.8s cubic-bezier(0.22, 1, 0.36, 1) forwards;
  transition: background-color 0.3s ease, color 0.3s ease,
    border-color 0.3s ease, box-shadow 0.3s ease;
  -webkit-appearance: none;
  appearance: none;
}

.lemony-sound-toggle:hover,
.lemony-sound-toggle:focus-visible {
  background: #111;
  border-color: #111;
  color: #fff;
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.22);
  outline: none;
}

.lemony-sound-toggle:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 3px;
}

.lemony-sound-toggle.is-loading {
  cursor: progress;
}

.lemony-sound-toggle.has-error {
  border-color: #b3261e;
  color: #b3261e;
}

.lemony-sound-toggle--light.has-error {
  border-color: rgba(255, 138, 128, 0.9);
  color: #ffb4ab;
}

.lemony-sound-toggle.is-loading .lemony-sound-bars span {
  animation: lemony-sound-bar 1.1s ease-in-out infinite;
}

/* Variante pour fond sombre (page d'entrée vidéo) */
.lemony-sound-toggle--light {
  background: rgba(10, 10, 10, 0.38);
  border-color: rgba(255, 255, 255, 0.55);
  color: #fff;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.28);
}

.lemony-sound-toggle--light:hover,
.lemony-sound-toggle--light:focus-visible {
  background: #fff;
  border-color: #fff;
  color: #111;
}

/* Position en bas à droite */
.lemony-sound-toggle--right {
  right: calc(24px + env(safe-area-inset-right, 0px));
  left: auto;
}

/* Barres animées */
.lemony-sound-bars {
  display: inline-flex;
  align-items: flex-end;
  justify-content: center;
  gap: 2px;
  width: 14px;
  height: 13px;
}

.lemony-sound-bars span {
  display: block;
  width: 2px;
  height: 100%;
  border-radius: 1px;
  background: currentColor;
  transform: scaleY(0.32);
  transform-origin: center bottom;
  transition: transform 0.35s ease;
}

.lemony-sound-bars span:nth-child(1) {
  height: 62%;
}

.lemony-sound-bars span:nth-child(2) {
  height: 100%;
}

.lemony-sound-bars span:nth-child(3) {
  height: 78%;
}

.lemony-sound-toggle.is-playing .lemony-sound-bars span {
  animation: lemony-sound-bar 1.1s ease-in-out infinite;
}

.lemony-sound-toggle.is-playing .lemony-sound-bars span:nth-child(2) {
  animation-delay: -0.35s;
}

.lemony-sound-toggle.is-playing .lemony-sound-bars span:nth-child(3) {
  animation-delay: -0.7s;
}

@keyframes lemony-sound-bar {
  0%,
  100% {
    transform: scaleY(0.32);
  }
  50% {
    transform: scaleY(1);
  }
}

@keyframes lemony-sound-enter {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 575.98px) {
  .lemony-sound-toggle {
    gap: 8px;
    min-height: 36px;
    padding: 0 13px;
    font-size: 10px;
    letter-spacing: 0.12em;
  }
}

@media (prefers-reduced-motion: reduce) {
  .lemony-sound-toggle {
    animation: none;
    opacity: 1;
    transform: none;
    transition: background-color 0.3s ease, color 0.3s ease,
      border-color 0.3s ease;
  }

  .lemony-sound-toggle.is-playing .lemony-sound-bars span {
    animation: none;
    transform: scaleY(1);
  }

  .lemony-sound-toggle.is-loading .lemony-sound-bars span {
    animation: none;
    transform: scaleY(1);
  }
}

@media print {
  .lemony-sound-toggle {
    display: none !important;
  }
}
