/* ============================================================
   ВИЗАРТЪ — переключатель «Музыка залов»

   Правило: кнопка всегда говорит не только о состоянии, но и о том, что
   произойдёт при нажатии. Когда музыка играет — рядом со свечой дышат
   звуковые полоски (это узнаётся мгновенно), а подпись прямо обещает
   «затушить свечу».
   ============================================================ */

.ambience-toggle {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 5px 14px 5px 10px;
  background: none;
  border: 1px solid rgba(201, 162, 39, .22);
  border-radius: 2px;
  cursor: pointer;
  font-family: var(--font-serif, 'Cormorant', serif);
  color: #8A6420;
  transition: color .4s var(--ease-lux, ease), border-color .4s, background .4s,
              box-shadow .4s;
  white-space: nowrap;
  text-align: left;
}

.ambience-toggle:hover {
  color: #C9A227;
  border-color: rgba(201, 162, 39, .5);
  background: rgba(201, 162, 39, .06);
}

.ambience-toggle:focus-visible {
  outline: 1px solid #E8C55F;
  outline-offset: 2px;
}

/* --- две строки: что звучит и что сделает нажатие --- */

.ambience-toggle__text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.ambience-toggle__label {
  font-size: 14px;
  letter-spacing: .09em;
  font-variant: small-caps;
}

.ambience-toggle__action {
  font-size: 10.5px;
  letter-spacing: .13em;
  text-transform: uppercase;
  color: #6b5836;
  transition: color .35s;
}

.ambience-toggle:hover .ambience-toggle__action { color: #C9A227; }

/* --- свеча --- */

.ambience-toggle__flame {
  display: block;
  width: 16px;
  height: 22px;
  flex: none;
}

.ambience-toggle__wax { fill: #6b5836; transition: fill .5s; }

.ambience-toggle__fire {
  fill: transparent;
  transform-origin: 50% 100%;
  transition: fill .5s, opacity .3s, transform .3s;
}

.ambience-toggle__smoke {
  fill: none;
  stroke: #b9a887;
  stroke-width: 1.1;
  stroke-linecap: round;
  opacity: 0;
  transition: opacity .3s;
}

/* --- звуковые полоски: безошибочный знак «звук включён» --- */

.ambience-toggle__bars {
  display: none;
  align-items: flex-end;
  gap: 2px;
  height: 14px;
  flex: none;
}

.ambience-toggle__bars i {
  display: block;
  width: 2px;
  background: #E8C55F;
  border-radius: 1px;
  box-shadow: 0 0 5px rgba(232, 197, 95, .55);
}

.ambience-toggle.is-on .ambience-toggle__bars { display: flex; }

.ambience-toggle.is-on .ambience-toggle__bars i:nth-child(1) { animation: ambience-bar 1.5s ease-in-out infinite; }
.ambience-toggle.is-on .ambience-toggle__bars i:nth-child(2) { animation: ambience-bar 1.5s ease-in-out infinite .35s; }
.ambience-toggle.is-on .ambience-toggle__bars i:nth-child(3) { animation: ambience-bar 1.5s ease-in-out infinite .7s; }

@keyframes ambience-bar {
  0%, 100% { height: 4px; opacity: .55; }
  50%      { height: 13px; opacity: 1; }
}

/* --- включённое состояние --- */

.ambience-toggle.is-on {
  color: #E8C55F;
  border-color: rgba(232, 197, 95, .55);
  background: rgba(232, 197, 95, .07);
  box-shadow: inset 0 0 14px rgba(232, 197, 95, .09);
}

.ambience-toggle.is-on .ambience-toggle__action { color: #C9A227; }
.ambience-toggle.is-on .ambience-toggle__wax { fill: #d8c9a4; }

.ambience-toggle.is-on .ambience-toggle__fire {
  fill: #E8C55F;
  filter: drop-shadow(0 0 5px rgba(232, 197, 95, .85))
          drop-shadow(0 0 12px rgba(201, 162, 39, .45));
  animation: ambience-flicker 2.6s ease-in-out infinite;
}

/* Наведение на горящую свечу показывает, что случится: пламя гаснет,
   вьётся дымок, полоски замирают — «затушить» становится буквальным */
.ambience-toggle.is-on:hover {
  border-color: rgba(232, 197, 95, .8);
  background: rgba(232, 197, 95, .12);
}

.ambience-toggle.is-on:hover .ambience-toggle__fire {
  opacity: 0;
  transform: scaleY(.3);
  animation: none;
}

.ambience-toggle.is-on:hover .ambience-toggle__smoke { opacity: .85; }

.ambience-toggle.is-on:hover .ambience-toggle__bars i {
  animation-play-state: paused;
  opacity: .3;
}

@keyframes ambience-flicker {
  0%, 100% { transform: scaleY(1)    scaleX(1);    opacity: 1; }
  25%      { transform: scaleY(1.14) scaleX(.93);  opacity: .92; }
  50%      { transform: scaleY(.94)  scaleX(1.06); opacity: 1; }
  75%      { transform: scaleY(1.08) scaleX(.97);  opacity: .96; }
}

/* Плавающий вариант — если в разметке страницы не нашлось верхней панели */
.ambience-toggle--floating {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 65;
  background: linear-gradient(160deg, rgba(74, 14, 28, .94), rgba(43, 6, 15, .96));
  box-shadow: 0 8px 24px rgba(0, 0, 0, .55);
}

@media (max-width: 1100px) {
  /* Тесно — оставляем свечу, полоски и одно слово действия */
  .ambience-toggle__label { display: none; }
  .ambience-toggle { padding: 5px 11px; gap: 7px; }
}

@media (max-width: 760px) {
  .ambience-toggle__action { display: none; }
  .ambience-toggle { padding: 6px 9px; }
}

@media (prefers-reduced-motion: reduce) {
  .ambience-toggle.is-on .ambience-toggle__fire,
  .ambience-toggle.is-on .ambience-toggle__bars i { animation: none; }
  .ambience-toggle.is-on .ambience-toggle__bars i { height: 9px; }
}
