/* ============================================================
   SHELLSHOCK — MÚSICA + EFEITOS NEON
   Player de música e efeitos visuais sincronizados com o áudio
   ============================================================ */

/* Canvas overlay para as veias neon */
#neonCanvas {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 300;
  opacity: 0;
  transition: opacity 1.2s ease;
  mix-blend-mode: screen;
}

body.music-active #neonCanvas { opacity: 1; }

/* Flash no beat */
#beatFlash {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 299;
  opacity: 0;
  background: radial-gradient(ellipse at 50% 40%, rgba(60,179,113,0.14) 0%, transparent 70%);
  transition: opacity 0.05s linear;
  mix-blend-mode: screen;
}

/* ============================
   MUSIC PLAYER — Posicionamento
   ============================ */
.music-player {
  position: fixed;
  bottom: 1.5rem;
  left: 1.5rem;
  z-index: 900;
  user-select: none;
}

/* ============================
   BOTÃO MINI
   ============================ */
.music-mini {
  width: 52px;
  height: 52px;
  background: var(--card, #0d0d16);
  border: 2px solid var(--green, #3cb371);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  color: var(--green, #3cb371);
  box-shadow:
    0 0 16px rgba(60,179,113,0.3),
    0 4px 20px rgba(0,0,0,0.6);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  outline: none;
}

.music-mini:hover,
.music-mini:focus-visible {
  transform: scale(1.08);
  box-shadow: 0 0 28px rgba(60,179,113,0.5), 0 4px 20px rgba(0,0,0,0.6);
}

.music-mini-pulse {
  position: absolute;
  inset: -5px;
  border-radius: 50%;
  border: 2px solid var(--green, #3cb371);
  opacity: 0;
  pointer-events: none;
}

body.music-active .music-mini-pulse {
  animation: pulse-ring 1.8s ease-out infinite;
}

@keyframes pulse-ring {
  0%   { transform: scale(0.88); opacity: 0.9; }
  100% { transform: scale(1.6);  opacity: 0; }
}

/* Ícone muda com o estado */
.music-mini svg { transition: transform 0.2s ease; }
body.music-active .music-mini { border-color: var(--green, #3cb371); }
body.music-active .music-mini svg { animation: icon-bounce 0.6s ease infinite alternate; }

@keyframes icon-bounce {
  from { transform: scale(0.9); }
  to   { transform: scale(1.1); }
}

/* ============================
   PAINEL COMPLETO (comic style)
   ============================ */
.music-full {
  position: absolute;
  bottom: 60px;
  left: 0;
  width: 268px;
  background: var(--card, #0d0d16);
  border: 2px solid var(--green, #3cb371);
  border-radius: 12px 12px 4px 4px;
  overflow: hidden;
  opacity: 0;
  transform: translateY(12px) scale(0.95);
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.22s ease;
  box-shadow:
    0 0 30px rgba(60,179,113,0.25),
    0 -4px 30px rgba(0,0,0,0.8),
    0 10px 40px rgba(0,0,0,0.6);
}

.music-player.expanded .music-full {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: all;
}

/* Cantos estilo comic panel */
.music-full::before,
.music-full::after {
  content: '';
  position: absolute;
  bottom: -6px;
  width: 12px;
  height: 12px;
  background: var(--card, #0d0d16);
  border: 2px solid var(--green, #3cb371);
  transform: rotate(45deg);
  z-index: -1;
}
.music-full::before { left: 20px; }
.music-full::after  { right: 20px; display: none; }

/* Header estilo faixa de HQ */
.music-header {
  background: var(--green, #3cb371);
  padding: 0.5rem 0.9rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 2px solid rgba(0,0,0,0.4);
  position: relative;
}

.music-header::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 100%;
  background: repeating-linear-gradient(
    -45deg,
    rgba(255,255,255,0.06),
    rgba(255,255,255,0.06) 3px,
    transparent 3px,
    transparent 10px
  );
  pointer-events: none;
}

.music-header-title {
  font-family: var(--font-title, 'Bangers', cursive);
  font-size: 1rem;
  letter-spacing: 2px;
  color: #000;
  text-shadow: 1px 1px 0 rgba(0,0,0,0.3);
}

.music-header-close {
  background: rgba(0,0,0,0.15);
  border: 1px solid rgba(0,0,0,0.2);
  color: #000;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 0.1rem 0.35rem;
  border-radius: 3px;
  transition: background 0.15s;
  font-weight: 700;
}

.music-header-close:hover { background: rgba(0,0,0,0.3); }

/* ============================
   VISUALIZADOR
   ============================ */
.music-visualizer {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 52px;
  padding: 0.5rem 0.75rem 0.4rem;
  background: var(--bg3, #0f0f18);
  border-bottom: 1px solid rgba(60,179,113,0.15);
}

.viz-bar {
  flex: 1;
  background: linear-gradient(to top, var(--green, #3cb371), rgba(0,201,167,0.7));
  height: 3px;
  min-height: 3px;
  max-height: 40px;
  border-radius: 2px 2px 0 0;
  box-shadow: 0 0 5px rgba(60,179,113,0.5);
  transition: height 0.04s linear;
}

/* Barras idle pulsam suavemente */
body:not(.music-active) .viz-bar {
  animation: idle-bars 2.5s ease-in-out infinite;
  animation-delay: calc(var(--bar-i, 0) * 0.15s);
}

@keyframes idle-bars {
  0%, 100% { height: 3px; }
  50%       { height: 8px; opacity: 0.5; }
}

/* ============================
   CONTROLES
   ============================ */
.music-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 0.9rem;
}

.music-play-btn {
  width: 42px;
  height: 42px;
  background: var(--green, #3cb371);
  border: none;
  border-radius: 50%;
  color: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  box-shadow: 0 0 14px rgba(60,179,113,0.5);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.music-play-btn:hover {
  transform: scale(1.12);
  box-shadow: 0 0 24px rgba(60,179,113,0.7);
}

.music-track-info { flex: 1; overflow: hidden; }

.music-track-name {
  display: block;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text, #ede8e0);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: 0.3px;
}

.music-track-label {
  display: block;
  font-size: 0.68rem;
  color: var(--green, #3cb371);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin-top: 0.15rem;
  font-family: var(--font-title, 'Bangers', cursive);
}

/* ============================
   NEON PULSE — efeitos musicais
   ============================ */

/* Glow contínuo no logo quando música ativa */
body.music-active .nav-logo-text {
  text-shadow:
    0 0 calc(18px + var(--audio-glow, 0px)) var(--green-glow, rgba(60,179,113,0.35)),
    0 0 calc(4px + var(--audio-glow, 0px)) rgba(60,179,113,0.9),
    2px 2px 0 #000;
}

/* Hero title respira com a música */
body.music-active .hero-title-accent {
  text-shadow:
    4px 4px 0 #000,
    0 0 calc(35px + var(--audio-glow, 0px) * 2) var(--green-glow, rgba(60,179,113,0.35)),
    0 0 calc(8px + var(--audio-glow, 0px)) rgba(60,179,113,0.8);
}

/* Brillo na imagem capa */
body.music-active .hero-cover-frame {
  box-shadow:
    0 0 0 1px rgba(60,179,113,0.2),
    0 0 calc(60px + var(--audio-glow, 0px) * 3) rgba(60,179,113,0.25),
    0 30px 80px rgba(0,0,0,0.7);
}

/* Nav border pulse */
body.music-active .nav {
  border-bottom-color: rgba(60, 179, 113, calc(0.14 + var(--audio-level, 0) * 0.5));
}

/* Footer logo glow */
body.music-active .footer-logo {
  text-shadow:
    0 0 calc(30px + var(--audio-glow, 0px) * 3) var(--green-glow, rgba(60,179,113,0.35)),
    3px 3px 0 #000;
}

/* Chapter cards border pulse */
body.music-active .chapter-card {
  border-color: rgba(60, 179, 113, calc(0.14 + var(--audio-level, 0) * 0.4));
}

/* ============================
   BEAT FLASH — efeito por beat
   ============================ */
body.beat-pulse .section-title {
  animation: title-beat 0.18s ease;
}

body.beat-pulse .nav-logo-text {
  animation: logo-beat 0.18s ease;
}

body.beat-pulse .music-mini {
  animation: mini-beat 0.18s ease;
}

@keyframes title-beat {
  0%   { text-shadow: 2px 2px 0 #000; }
  40%  { text-shadow: 0 0 25px rgba(60,179,113,0.9), 2px 2px 0 #000; }
  100% { text-shadow: 2px 2px 0 #000; }
}

@keyframes logo-beat {
  0%   { }
  40%  { text-shadow: 0 0 40px rgba(60,179,113,1), 0 0 8px rgba(60,179,113,0.9), 2px 2px 0 #000; }
  100% { }
}

@keyframes mini-beat {
  0%   { box-shadow: 0 0 16px rgba(60,179,113,0.3), 0 4px 20px rgba(0,0,0,0.6); }
  40%  { box-shadow: 0 0 40px rgba(60,179,113,0.8), 0 4px 20px rgba(0,0,0,0.6); transform: scale(1.1); }
  100% { box-shadow: 0 0 16px rgba(60,179,113,0.3), 0 4px 20px rgba(0,0,0,0.6); }
}

/* Reader page — progress bar pulses */
body.music-active .reader-progress-bar {
  box-shadow: 0 0 calc(8px + var(--audio-glow, 0px)) var(--green-glow, rgba(60,179,113,0.35));
}

/* ============================
   RESPONSIVE
   ============================ */
@media (max-width: 480px) {
  .music-player { bottom: 1rem; left: 1rem; }
  .music-full { width: calc(100vw - 2rem); max-width: 280px; }
}
