/*
  THE STICKY SOUND TOGGLE (js/modules/soundToggle.js) + the Deezer mark in the room. Homepage only.
  One small round button, fixed at the top in the nav bar just left of Contact (--right is
  measured by soundToggle.js); it stays there while the nav hides on scroll, so the music is
  always within reach. A dark, frosted disc with ivory lines: it reads on the dark chapters and
  on the paper ones alike. A word slides out to its left on hover, and once when the music starts.
*/
.sound {
  --right: 160px;
  --size: 38px;
  position: fixed;
  right: var(--right);
  top: calc((var(--nav-h) - var(--size)) / 2);
  z-index: calc(var(--z-nav) + 2);
  opacity: 0;
  visibility: hidden;
  transform: scale(0.8);
  transition: opacity 0.6s var(--ease-out), transform 0.8s cubic-bezier(0.34, 1.4, 0.64, 1), visibility 0s linear 0.6s;
}

.sound.is-on {
  opacity: 1;
  visibility: visible;
  transform: none;
  transition-delay: 0s;
}

.sound__toggle {
  position: relative;
  display: flex;
  align-items: center;
  height: var(--size);
  color: var(--cream);
}

.sound__toggle[hidden] {
  display: none;
}

/* the disc: a small dark record, its edge a fine groove that turns while music plays */
.sound__disc {
  position: relative;
  display: grid;
  place-items: center;
  width: var(--size);
  height: var(--size);
  border-radius: 50%;
  background: rgba(28, 12, 12, 0.72);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  box-shadow: inset 0 0 0 1px rgba(243, 235, 223, 0.16), 0 6px 18px -8px rgba(20, 8, 8, 0.6);
  transition: background var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out);
}

.sound__disc::before {
  content: '';
  position: absolute;
  inset: 3px;
  border-radius: 50%;
  border: 1px dashed rgba(243, 235, 223, 0.32);
  opacity: 0;
  transition: opacity 0.5s var(--ease-out);
}

.sound__toggle[data-state='playing'] .sound__disc::before {
  opacity: 1;
  animation: sound-groove 6s linear infinite;
}

@keyframes sound-groove {
  to { rotate: 360deg; }
}

.sound__toggle:hover .sound__disc,
.sound__toggle:focus-visible .sound__disc {
  background: rgba(90, 24, 34, 0.9);
}

.sound__toggle:focus-visible {
  outline: none;
}

.sound__toggle:focus-visible .sound__disc {
  box-shadow: inset 0 0 0 1px rgba(243, 235, 223, 0.16), 0 0 0 2px var(--cream);
}

/* the word: a small label that slides out to the left of the disc */
.sound__word {
  position: absolute;
  right: calc(100% + 0.6rem);
  top: 50%;
  padding: 0.42rem 0.75rem 0.38rem;
  border-radius: 999px;
  background: rgba(28, 12, 12, 0.72);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  font-size: var(--fs-micro);
  letter-spacing: var(--ls-wide);
  text-transform: uppercase;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transform: translate(8px, -50%);
  transition: opacity 0.45s var(--ease-out), transform 0.6s var(--ease-out);
}

.sound.is-intro .sound__word,
.sound__toggle:hover .sound__word,
.sound__toggle:focus-visible .sound__word {
  opacity: 1;
  transform: translate(0, -50%);
}

.sound__lines {
  display: flex;
  flex-direction: column;
  gap: 3.5px;
  width: 14px;
}

.sound__lines i {
  display: block;
  height: 1.5px;
  border-radius: 2px;
  background: currentColor;
  transform-origin: 0 50%;
  transition: transform 0.5s var(--ease-out), opacity 0.5s var(--ease-out);
}

/* playing: the lines move like a level meter, each at its own pace */
.sound__toggle[data-state='playing'] .sound__lines i {
  animation: sound-level 0.9s var(--ease-in-out) infinite alternate;
}
.sound__toggle[data-state='playing'] .sound__lines i:nth-child(2) {
  animation-duration: 1.2s;
  animation-delay: -0.5s;
}
.sound__toggle[data-state='playing'] .sound__lines i:nth-child(3) {
  animation-duration: 0.75s;
  animation-delay: -0.25s;
}

@keyframes sound-level {
  from { transform: scaleX(1); }
  to { transform: scaleX(0.3); }
}

/* paused: still, stepped and dimmed: clearly at rest */
.sound__toggle[data-state='paused'] .sound__lines i {
  opacity: 0.55;
}
.sound__toggle[data-state='paused'] .sound__lines i:nth-child(1) { transform: scaleX(0.55); }
.sound__toggle[data-state='paused'] .sound__lines i:nth-child(2) { transform: scaleX(1); }
.sound__toggle[data-state='paused'] .sound__lines i:nth-child(3) { transform: scaleX(0.75); }

.sound__toggle:disabled {
  cursor: progress;
}

@media (max-width: 700px) {
  .sound {
    --size: 34px;
  }
  /* phones: the controls are placed one by one (css/room.css); the logo sits where Play was,
     centred between the two arrows */
  .room__deezer {
    position: absolute;
    left: 50%;
    bottom: calc(3.4rem + 1.4vh + 0.55rem);
    width: 60px;
    margin: 0;
    transform: translateX(-50%);
  }
}

/* ---- the Deezer logo, by the records (index.html, .room__browse) ----
   2026-12-06: the complete official logo (heart mark + wordmark) in place of the Play button,
   after the arrows, at the height of the record's name; one colour, cream, like the controls. */
.room__deezer {
  display: block;
  flex: none;
  width: 66px;
  margin-left: 0.9rem;
  color: var(--cream);
  opacity: 0.72;
  transition: opacity var(--dur-fast) var(--ease-out);
}

.room__deezer:hover,
.room__deezer:focus-visible {
  opacity: 0.95;
}

.room__deezer svg {
  display: block;
  width: 100%;
  height: auto;
  fill: currentColor;
}

@media (prefers-reduced-motion: reduce) {
  .sound__toggle[data-state='playing'] .sound__lines i,
  .sound__toggle[data-state='playing'] .sound__disc::before {
    animation: none;
  }
  /* playing without motion: full-strength, full-length lines (paused stays stepped and dim) */
  .sound__toggle[data-state='playing'] .sound__lines i {
    transform: none;
    opacity: 1;
  }
  .sound {
    transition: opacity 0.4s var(--ease-out), visibility 0s linear 0.4s;
    transform: none;
  }
}
