/* ============================================================
   BOOKATOON — Disco de vinil (música ambiente)
   Canto inferior direito · z-index: var(--z-player) = 75
   (painel de conforto vive à esquerda, em 80)
   Estados: .is-playing | .is-unavailable | popover de volume
   Etapa 3 da migração de @layer (docs/layer-proposal.md).
   ============================================================ */
@layer components {

.vinyl {
  position: fixed;
  right: calc(1rem + env(safe-area-inset-right, 0px));
  bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
  z-index: var(--z-player);
  display: grid;
  justify-items: center;
  gap: 0.4rem;
}

/* ---------------- Botão-disco ---------------- */

.vinyl__btn {
  position: relative;
  width: 76px;
  height: 76px;
  padding: 0;
  background: none;
  border: none;
  cursor: var(--cursor-hand);
  border-radius: 50%;
}

@media (max-width: 39.99rem) {
  .vinyl__btn {
    width: 62px;
    height: 62px;
  }
}

.vinyl__disc-wrap {
  display: block;
  width: 100%;
  height: 100%;
  filter: drop-shadow(0.25rem 0.3rem 0 rgba(36, 21, 51, 0.28));
  transition: translate var(--dur-micro) var(--ease-energy);
}

.vinyl__btn:hover .vinyl__disc-wrap {
  translate: 0 -2px;
}

.vinyl__btn:active .vinyl__disc-wrap {
  translate: 0 1px;
}

.vinyl__disc {
  width: 100%;
  height: 100%;
  /* rotação aplicada via JS (style.rotate) somente enquanto toca */
}

/* Agulha: encostada quando toca, recuada quando pausado */
.vinyl__needle {
  position: absolute;
  top: -8px;
  right: -3px;
  width: 26%;
  transform-origin: 50% 15%;
  rotate: -30deg;
  transition: rotate 0.45s var(--ease-suave);
  pointer-events: none;
}

.vinyl.is-playing .vinyl__needle {
  rotate: 0deg;
}

/* Selo de play/pause sobre o disco */
.vinyl__badge {
  position: absolute;
  right: -4px;
  bottom: -2px;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  color: var(--ink);
  background: var(--branco);
  border: 3px solid var(--ink);
  border-radius: 50%;
  box-shadow: 0.14rem 0.18rem 0 rgba(36, 21, 51, 0.25);
}

.vinyl__badge svg {
  width: 17px;
  height: 17px;
}

.vinyl__icon-pause {
  display: none;
}

.vinyl.is-playing .vinyl__icon-play {
  display: none;
}

.vinyl.is-playing .vinyl__icon-pause {
  display: block;
}

/* Tooltip acessível (mesmo texto do aria-label, para quem enxerga) */
.vinyl__btn::after {
  content: attr(data-tip);
  position: absolute;
  right: calc(100% + 0.6rem);
  top: 50%;
  translate: 0 -50%;
  white-space: nowrap;
  padding: 0.35rem 0.75rem;
  font-family: var(--font-display);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--branco);
  background: var(--ink);
  border-radius: var(--r-pill);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--dur-fast) linear;
  pointer-events: none;
}

.vinyl__btn:hover::after,
.vinyl__btn:focus-visible::after {
  opacity: 1;
  visibility: visible;
}

/* ---------------- Estado indisponível ---------------- */

.vinyl.is-unavailable .vinyl__btn {
  cursor: not-allowed;
}

.vinyl.is-unavailable .vinyl__disc,
.vinyl.is-unavailable .vinyl__needle {
  opacity: 0.55;
}

.vinyl.is-unavailable .vinyl__vol-toggle {
  display: none;
}

/* ---------------- Status (“Tocando” em reduced motion etc.) ---------------- */

.vinyl__status {
  margin: 0;
  min-height: 1.1em;
  max-width: 9rem;
  font-family: var(--font-display);
  font-size: 0.78rem;
  font-weight: 600;
  text-align: center;
  color: var(--ink);
  background: var(--creme);
  border-radius: var(--r-pill);
  padding-inline: 0.5rem;
}

.vinyl__status:empty {
  display: none;
}

/* ---------------- Volume ---------------- */

.vinyl__vol-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 34px;
  padding: 0;
  color: var(--ink);
  background: var(--branco);
  border: 3px solid var(--ink);
  border-radius: var(--r-pill);
  box-shadow: 0.12rem 0.16rem 0 rgba(36, 21, 51, 0.22);
  cursor: var(--cursor-hand);
  transition: translate var(--dur-fast) var(--ease-energy);
}

.vinyl__vol-toggle:hover {
  translate: 0 -1px;
}

.vinyl__vol-toggle svg {
  width: 19px;
  height: 19px;
}

.vinyl__popover[hidden] {
  display: none;
}

.vinyl__popover {
  position: absolute;
  right: 0;
  bottom: calc(100% + 0.6rem);
  display: grid;
  gap: 0.5rem;
  width: 12rem;
  padding: 0.9rem;
  background: var(--branco);
  border: var(--stroke) solid var(--ink);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-sticker);
}

.vinyl__vol-label {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.9rem;
}

.vinyl__range {
  width: 100%;
  accent-color: var(--violeta);
  min-height: 24px;
}

.vinyl__mute {
  justify-self: start;
  padding: 0.25rem 0.8rem;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.85rem;
  background: var(--creme);
  border: 2.5px solid var(--ink);
  border-radius: var(--r-pill);
  cursor: var(--cursor-hand);
}

.vinyl__mute[aria-pressed="true"] {
  background: var(--ink);
  color: var(--branco);
}

/* Em telas muito baixas, o vinil não deve cobrir o conteúdo final */
@media (max-height: 30rem) {
  .vinyl__status {
    display: none;
  }
}

} /* fim de @layer components */
