/* ============================================================================
   IPOT MUSIC — EXPERIENCE LAYER (experience.css)
   Lyric share card · Karaoke fullscreen lyrics · Waveform seek · Sleep dial
   Uses the shared tokens from variables.css only.
   ============================================================================ */

/* ==========================================================================
   1. WAVEFORM PROGRESS BAR
   ========================================================================== */
/* Height is capped so the fixed 84px player bar never clips the bars. */
.waveform-wrap {
  position: relative;
  flex: 1;
  min-width: 0;
  height: 26px;
  display: block;
  touch-action: none;
}

.waveform-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
}

/* The native range stays on top (invisible) so seeking, keyboard access and
   the existing JS handlers keep working exactly as before. */
.waveform-wrap .progress-bar,
.waveform-wrap .mfp-progress-bar {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  opacity: 0;
  background: none;
  cursor: pointer;
}

.waveform-wrap .progress-bar::-webkit-slider-thumb,
.waveform-wrap .mfp-progress-bar::-webkit-slider-thumb {
  width: 18px;
  height: 100%;
  box-shadow: none;
}

.mfp-progress-container .waveform-wrap {
  height: 42px;
}

/* ==========================================================================
   2. LYRICS MODAL HEADER ACTIONS (share + karaoke)
   A single share button lives in the header — per-line buttons were removed
   since they cluttered the reading view.
   ========================================================================== */
.lyrics-head-actions {
  position: absolute;
  top: 12px;
  left: 56px;
  display: inline-flex;
  gap: 8px;
  z-index: 20;
}

.lyrics-head-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(20, 20, 24, 0.92);
  color: var(--text-main);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition-fast);
}

.lyrics-head-btn:hover {
  background: rgba(255, 255, 255, 0.16);
}

/* ==========================================================================
   3. KARAOKE / FULLSCREEN LYRICS (Apple Music style)
   ========================================================================== */
.karaoke-view {
  position: fixed;
  inset: 0;
  z-index: 14500;
  display: flex;
  flex-direction: column;
  background: #050506;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  --kara-rgb: 228, 228, 231;
  --kara-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --kara-smooth: cubic-bezier(0.4, 0, 0.2, 1);
  --kara-origin: right center;
}

.karaoke-view.active {
  opacity: 1;
  pointer-events: auto;
}

.karaoke-view.hidden {
  display: none;
}

.karaoke-view.is-ltr {
  --kara-origin: left center;
}

.karaoke-view.is-ltr .karaoke-line {
  text-align: left;
}

.karaoke-ambient {
  position: absolute;
  inset: -12%;
  z-index: 0;
  pointer-events: none;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  filter: blur(70px) saturate(150%) brightness(0.42);
  transform: scale(1.15);
  opacity: 0.7;
  transition: background-image 0.5s var(--kara-smooth), opacity 0.45s var(--kara-smooth);
  will-change: background-image, opacity;
}

.karaoke-glow {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 50% 18%, rgba(var(--kara-rgb), 0.34) 0%, rgba(5, 5, 6, 0) 62%),
    radial-gradient(circle at 50% 100%, rgba(var(--kara-rgb), 0.16) 0%, rgba(5, 5, 6, 0) 55%);
  transition: background 0.6s var(--kara-smooth);
}

.karaoke-scrim {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: linear-gradient(
    180deg,
    rgba(5, 5, 6, 0.82) 0%,
    rgba(5, 5, 6, 0.34) 26%,
    rgba(5, 5, 6, 0.4) 72%,
    rgba(5, 5, 6, 0.92) 100%
  );
}

.karaoke-topbar {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: calc(14px + var(--safe-top, 0px)) 18px 12px;
  background: linear-gradient(180deg, rgba(5, 5, 6, 0.55) 0%, rgba(5, 5, 6, 0) 100%);
}

.karaoke-cover {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  object-fit: cover;
  border: 1px solid rgba(255, 255, 255, 0.12);
  flex: none;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.karaoke-meta {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.karaoke-title {
  font-size: 0.98rem;
  font-weight: 800;
  color: #ffffff;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.karaoke-artist {
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.6);
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.karaoke-icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(18, 18, 22, 0.7);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: #ffffff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  transition: background 0.2s var(--kara-smooth), transform 0.2s var(--kara-spring);
}

.karaoke-icon-btn:hover {
  background: rgba(255, 255, 255, 0.14);
}

.karaoke-icon-btn:active {
  transform: scale(0.94);
}

.karaoke-lines {
  position: relative;
  z-index: 2;
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 18vh 44px 24vh;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.karaoke-lines::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}

.karaoke-line {
  position: relative;
  display: block;
  width: 100%;
  text-align: right;
  border: none;
  background: none;
  font-family: inherit;
  padding: 10px 8px;
  margin: 0 0 6px;
  cursor: pointer;
  color: rgba(255, 255, 255, 0.24);
  font-size: clamp(1.35rem, 5.4vw, 2.9rem);
  font-weight: 800;
  line-height: 1.5;
  letter-spacing: -0.01em;
  filter: blur(0.4px);
  transform: scale(1);
  transform-origin: var(--kara-origin);
  transition:
    color 0.28s ease,
    opacity 0.28s ease,
    transform 0.28s var(--kara-spring),
    filter 0.28s ease,
    text-shadow 0.28s ease;
  will-change: transform, color, filter;
}

.karaoke-line:hover {
  color: rgba(255, 255, 255, 0.5);
}

.karaoke-line.active {
  color: #ffffff;
  filter: none;
  transform: scale(1.04);
  transform-origin: var(--kara-origin);
  text-shadow: 0 0 34px rgba(var(--kara-rgb), 0.45);
}

.karaoke-line.passed {
  color: rgba(255, 255, 255, 0.16);
  filter: blur(0.2px);
  transform: scale(0.98);
  transform-origin: var(--kara-origin);
}

.karaoke-empty {
  color: rgba(255, 255, 255, 0.45);
  font-size: 1rem;
  text-align: center;
  padding-top: 12vh;
}

.karaoke-dock {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 12px 18px calc(18px + var(--safe-bottom, 0px));
}

.karaoke-dock .karaoke-icon-btn.karaoke-play {
  width: 58px;
  height: 58px;
  background: #e4e4e7;
  color: #09090b;
  border-color: transparent;
  font-size: 1.15rem;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.35);
}

.karaoke-dock .karaoke-icon-btn.karaoke-play:hover {
  background: #ffffff;
}

.karaoke-badge {
  position: absolute;
  z-index: 2;
  bottom: calc(84px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.72rem;
  color: var(--text-muted);
  background: rgba(12, 12, 16, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-pill);
  padding: 5px 12px;
  backdrop-filter: blur(10px);
  white-space: nowrap;
}

/* ==========================================================================
   4. LYRIC SHARE CARD MODAL
   ========================================================================== */
.lyric-card-modal .glass-modal-card {
  width: min(430px, 100%);
  max-height: 92vh;
  overflow-y: auto;
  padding: 20px;
}

.lyric-card-preview {
  position: relative;
  width: 100%;
  border-radius: 18px;
  overflow: hidden;
  background: #0a0a0c;
  border: 1px solid rgba(255, 255, 255, 0.1);
  margin: 6px 0 14px;
  min-height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lyric-card-preview canvas {
  width: 100%;
  height: auto;
  display: block;
}

.lyric-card-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--text-muted);
  font-size: 0.85rem;
  background: rgba(8, 8, 10, 0.8);
}

.lyric-card-loading.hidden {
  display: none;
}

.lyric-card-optrow {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.lyric-card-chip {
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-muted);
  border-radius: var(--radius-pill);
  padding: 7px 14px;
  font-size: 0.78rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background var(--transition-fast), color var(--transition-fast),
    border-color var(--transition-fast);
}

.lyric-card-chip:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-main);
}

.lyric-card-chip.active {
  background: var(--accent-light);
  border-color: transparent;
  color: #09090b;
}

.lyric-card-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 6px;
}

.lyric-card-btn {
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-main);
  border-radius: var(--radius-md);
  padding: 11px 8px;
  font-size: 0.8rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  transition: background var(--transition-fast), border-color var(--transition-fast);
}

.lyric-card-btn i {
  font-size: 0.95rem;
}

.lyric-card-btn:hover {
  background: rgba(255, 255, 255, 0.11);
  border-color: rgba(255, 255, 255, 0.26);
}

.lyric-card-btn.primary {
  background: var(--accent-light);
  color: #09090b;
  border-color: transparent;
}

.lyric-card-btn.primary:hover {
  background: #ffffff;
}

.lyric-card-hint {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-align: center;
  margin-top: 10px;
}

/* ==========================================================================
   5. SLEEP TIMER DIAL
   ========================================================================== */
.sleep-modal .glass-modal-card {
  width: min(360px, 100%);
  text-align: center;
  padding: 22px 20px 20px;
}

.sleep-dial {
  position: relative;
  width: 168px;
  height: 168px;
  margin: 8px auto 16px;
}

.sleep-dial svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.sleep-dial-track {
  fill: none;
  stroke: rgba(255, 255, 255, 0.08);
  stroke-width: 8;
}

.sleep-dial-progress {
  fill: none;
  stroke: var(--accent-light);
  stroke-width: 8;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.9s linear;
}

.sleep-dial-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
}

.sleep-dial-value {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--text-main);
  font-variant-numeric: tabular-nums;
  direction: ltr;
}

.sleep-dial-label {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.sleep-presets {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 8px;
}

.sleep-preset {
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-main);
  border-radius: var(--radius-md);
  padding: 12px 6px;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 800;
  cursor: pointer;
  transition: background var(--transition-fast), border-color var(--transition-fast);
}

.sleep-preset:hover {
  background: rgba(255, 255, 255, 0.11);
  border-color: rgba(255, 255, 255, 0.26);
}

.sleep-preset.active {
  background: var(--accent-light);
  color: #09090b;
  border-color: transparent;
}

.sleep-preset-wide {
  grid-column: 1 / -1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 0.82rem;
}

.sleep-cancel {
  width: 100%;
  margin-top: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: transparent;
  color: var(--text-muted);
  border-radius: var(--radius-md);
  padding: 11px;
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: color var(--transition-fast), border-color var(--transition-fast);
}

.sleep-cancel:hover {
  color: var(--text-main);
  border-color: rgba(255, 255, 255, 0.26);
}

/* ==========================================================================
   6. RESPONSIVE
   ========================================================================== */
@media (max-width: 768px) {
  .lyrics-head-actions {
    left: 52px;
  }

  .karaoke-lines {
    padding: 16vh 20px 22vh;
  }

  .karaoke-line {
    font-size: clamp(1.25rem, 6.2vw, 2.2rem);
  }

  .lyric-card-actions {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 480px) {
  .waveform-wrap {
    height: 28px;
  }
}

/* Low-power devices: soften ambient blur, keep spring scale subtle */
@media (max-width: 768px) {
  .karaoke-ambient {
    filter: blur(48px) saturate(135%) brightness(0.4);
  }

  .karaoke-line {
    filter: none;
  }

  .karaoke-line.active {
    transform: scale(1.03);
    text-shadow: 0 0 22px rgba(var(--kara-rgb), 0.35);
  }

  .karaoke-line.passed {
    filter: none;
    transform: scale(0.99);
  }
}

@media (prefers-reduced-motion: reduce) {
  .karaoke-view,
  .karaoke-line,
  .karaoke-ambient,
  .karaoke-glow {
    transition: none !important;
  }

  .karaoke-line.active,
  .karaoke-line.passed {
    transform: none !important;
    filter: none !important;
  }

  .sleep-dial-progress {
    transition: none;
  }
}
