/* ============================================================
   KARMAFLEX PLAYLIST — PLAYER CSS
   Uses --kf-* design tokens so it blends perfectly with the
   KarmaFlex theme in both light and dark mode.
   ============================================================ */

/* ==========================================
   CSS VARIABLES — plugin-scoped overrides
   ========================================== */
.kfp-player {
  --kfp-accent:       var(--kf-accent,       #16a34a);
  --kfp-accent-2:     var(--kf-accent-2,     #22c55e);
  --kfp-accent-glow:  var(--kf-accent-glow,  rgba(22,163,74,0.12));
  --kfp-bg:           var(--kf-bg-card,       #ffffff);
  --kfp-bg-2:         var(--kf-bg-2,          #f8fafc);
  --kfp-bg-3:         var(--kf-bg-3,          #f1f5f9);
  --kfp-text:         var(--kf-text,          #0f172a);
  --kfp-text-2:       var(--kf-text-2,        #334155);
  --kfp-text-3:       var(--kf-text-3,        #64748b);
  --kfp-text-muted:   var(--kf-text-muted,    #94a3b8);
  --kfp-border:       var(--kf-border,        #e2e8f0);
  --kfp-border-2:     var(--kf-border-2,      #cbd5e1);
  --kfp-shadow:       var(--kf-shadow-md,     0 4px 16px rgba(0,0,0,.08));
  --kfp-shadow-lg:    var(--kf-shadow-lg,     0 10px 40px rgba(0,0,0,.10));
  --kfp-r-sm:         var(--kf-r-sm,          6px);
  --kfp-r-md:         var(--kf-r-md,          10px);
  --kfp-r-lg:         var(--kf-r-lg,          16px);
  --kfp-r-xl:         var(--kf-r-xl,          24px);
  --kfp-font-head:    var(--kf-font-head,     'Space Grotesk', sans-serif);
  --kfp-font-body:    var(--kf-font-body,     'Inter', sans-serif);
  --kfp-font-mono:    var(--kf-font-mono,     'JetBrains Mono', monospace);
  --kfp-ease:         var(--kf-ease,          0.2s cubic-bezier(.4,0,.2,1));
  --kfp-cover-size:   96px;
}

/* Dark theme overrides */
.kfp-player--dark,
[data-theme="dark"] .kfp-player {
  --kfp-accent:     #22c55e;
  --kfp-accent-2:   #4ade80;
  --kfp-accent-glow:rgba(34,197,94,0.14);
  --kfp-bg:         #141414;
  --kfp-bg-2:       #111113;
  --kfp-bg-3:       #18181b;
  --kfp-text:       #f8fafc;
  --kfp-text-2:     #cbd5e1;
  --kfp-text-3:     #94a3b8;
  --kfp-text-muted: #475569;
  --kfp-border:     rgba(255,255,255,0.08);
  --kfp-border-2:   rgba(255,255,255,0.14);
  --kfp-shadow:     0 4px 16px rgba(0,0,0,.4);
  --kfp-shadow-lg:  0 10px 40px rgba(0,0,0,.5);
}

.kfp-player--light {
  --kfp-accent:     #16a34a;
  --kfp-accent-2:   #22c55e;
  --kfp-bg:         #ffffff;
  --kfp-text:       #0f172a;
  --kfp-border:     #e2e8f0;
}

/* ==========================================
   PLAYER SHELL
   ========================================== */
.kfp-player {
  font-family: var(--kfp-font-body);
  background: var(--kfp-bg);
  border: 1px solid var(--kfp-border);
  border-radius: var(--kfp-r-xl);
  overflow: hidden;
  box-shadow: var(--kfp-shadow);
  margin: 24px 0;
  transition: box-shadow var(--kfp-ease);
  position: relative;
  overflow-anchor: none; /* prevent browser scroll-anchoring from targeting this element */
}
.kfp-player:hover { box-shadow: var(--kfp-shadow-lg); }

/* Accent top strip */
.kfp-player::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, var(--kfp-accent), var(--kfp-accent-2), var(--kfp-accent));
  z-index: 1;
}

/* ==========================================
   STAGE — cover + now playing
   ========================================== */
.kfp-stage {
  display: flex;
  gap: 20px;
  align-items: stretch;
  padding: 24px;
  background: linear-gradient(135deg,
    rgba(var(--kfp-accent, 22, 163, 74), 0.04) 0%,
    transparent 60%);
}

/* ==========================================
   COVER ART
   ========================================== */
.kfp-cover {
  flex-shrink: 0;
}
.kfp-cover__img-wrap {
  position: relative;
  width: var(--kfp-cover-size);
  height: var(--kfp-cover-size);
  border-radius: var(--kfp-r-lg);
  overflow: hidden;
  background: var(--kfp-bg-3);
  border: 1px solid var(--kfp-border);
  box-shadow: 0 4px 20px rgba(0,0,0,.15);
}
.kfp-cover__img {
  width: 100%; height: 100%;
  object-fit: cover; display: block;
  transition: transform .4s ease;
}
.kfp-player.is-playing .kfp-cover__img {
  transform: scale(1.04);
}
.kfp-cover__overlay {
  position: absolute; inset: 0;
  background: rgba(0,0,0,.35);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity var(--kfp-ease);
}
.kfp-player.is-playing .kfp-cover__overlay {
  opacity: 1;
}

/* Equaliser animation on cover */
.kfp-cover__eq {
  display: flex; gap: 3px; align-items: flex-end; height: 24px;
}
.kfp-cover__eq span {
  display: block; width: 3px; background: #fff; border-radius: 2px;
  animation: none;
  height: 4px;
}
.kfp-player.is-playing .kfp-cover__eq span {
  animation: kfp-eq .8s ease-in-out infinite alternate;
}
.kfp-cover__eq span:nth-child(1) { animation-delay: 0s;    animation-duration: .6s; }
.kfp-cover__eq span:nth-child(2) { animation-delay: .15s;  animation-duration: .9s; }
.kfp-cover__eq span:nth-child(3) { animation-delay: .07s;  animation-duration: .7s; }
.kfp-cover__eq span:nth-child(4) { animation-delay: .22s;  animation-duration: .8s; }

@keyframes kfp-eq {
  0%   { height: 4px; }
  100% { height: 20px; }
}

/* ==========================================
   NOW PLAYING INFO
   ========================================== */
.kfp-nowplaying {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; gap: 12px;
}
.kfp-nowplaying__meta {
  display: flex; flex-direction: column; gap: 4px;
}
.kfp-nowplaying__label {
  display: flex; align-items: center; gap: 5px;
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 1.2px; color: var(--kfp-accent);
}
.kfp-nowplaying__label svg { flex-shrink: 0; }
.kfp-nowplaying__title {
  font-family: var(--kfp-font-head);
  font-size: 18px; font-weight: 800;
  color: var(--kfp-text); line-height: 1.2;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  margin: 0;
}
.kfp-nowplaying__artist {
  display: flex; align-items: center; gap: 6px;
  font-size: 13px; color: var(--kfp-text-3); font-weight: 500;
}
.kfp-genre-dot {
  width: 3px; height: 3px; border-radius: 50%; background: var(--kfp-text-muted);
}
.kfp-genre {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .5px; color: var(--kfp-accent);
  background: var(--kfp-accent-glow); padding: 2px 8px;
  border-radius: var(--kfp-r-sm);
}

/* ==========================================
   PROGRESS BAR
   ========================================== */
.kfp-progress {
  display: flex; align-items: center; gap: 10px;
}
.kfp-progress__time {
  font-size: 11px; font-family: var(--kfp-font-mono);
  color: var(--kfp-text-muted); flex-shrink: 0; min-width: 32px;
}
.kfp-progress__time--cur { text-align: right; }

.kfp-progress__track {
  flex: 1; height: 5px;
  background: var(--kfp-bg-3);
  border: 1px solid var(--kfp-border);
  border-radius: var(--kfp-r-full);
  position: relative; cursor: pointer;
  transition: height var(--kfp-ease);
}
.kfp-progress__track:hover { height: 8px; }

.kfp-progress__fill {
  position: absolute; left: 0; top: 0; bottom: 0; width: 0%;
  background: linear-gradient(90deg, var(--kfp-accent), var(--kfp-accent-2));
  border-radius: var(--kfp-r-full);
  transition: width .1s linear;
}

.kfp-progress__thumb {
  position: absolute; top: 50%; right: -6px;
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--kfp-accent); border: 2px solid var(--kfp-bg);
  transform: translateY(-50%) scale(0);
  transition: transform var(--kfp-ease);
  box-shadow: 0 0 0 3px var(--kfp-accent-glow);
  pointer-events: none;
}
.kfp-progress__track:hover .kfp-progress__thumb,
.kfp-progress__track:active .kfp-progress__thumb {
  transform: translateY(-50%) scale(1);
}

/* ==========================================
   CONTROLS
   ========================================== */
.kfp-controls {
  display: flex; align-items: center; gap: 8px;
}

/* Base control button */
.kfp-ctrl {
  display: inline-flex; align-items: center; justify-content: center;
  border: none; background: transparent; cursor: pointer;
  color: var(--kfp-text-2); transition: all var(--kfp-ease);
  font-family: var(--kfp-font-body); line-height: 1; padding: 0;
  border-radius: 50%;
}

/* Icon-only small controls (shuffle, repeat) */
.kfp-ctrl--icon {
  width: 32px; height: 32px;
  color: var(--kfp-text-muted);
}
.kfp-ctrl--icon:hover { color: var(--kfp-text); transform: scale(1.08); }
.kfp-ctrl--icon.is-active { color: var(--kfp-accent); }
.kfp-ctrl--icon.is-active svg path { opacity: 1; }

/* Prev / Next */
.kfp-ctrl--prev,
.kfp-ctrl--next {
  width: 36px; height: 36px;
  color: var(--kfp-text-2);
}
.kfp-ctrl--prev:hover,
.kfp-ctrl--next:hover {
  color: var(--kfp-text); transform: scale(1.1);
}

/* Play/Pause — primary big button */
.kfp-ctrl--play {
  width: 54px; height: 54px;
  background: var(--kfp-accent);
  color: #fff;
  box-shadow: 0 4px 16px var(--kfp-accent-glow);
  transition: all var(--kfp-ease);
}
.kfp-ctrl--play:hover {
  background: var(--kfp-accent-2);
  transform: scale(1.06);
  box-shadow: 0 6px 24px var(--kfp-accent-glow);
}
.kfp-ctrl--play:active { transform: scale(0.97); }

/* Spinning loader inside play btn */
@keyframes kfp-spin {
  to { transform: rotate(360deg); }
}
.kfp-spin { animation: kfp-spin .8s linear infinite; display: inline-block; }

/* Volume */
.kfp-volume {
  display: flex; align-items: center; gap: 6px;
  margin-left: auto;
}
.kfp-vol-btn {
  width: 28px; height: 28px; flex-shrink: 0;
  color: var(--kfp-text-muted);
}
.kfp-vol-btn:hover { color: var(--kfp-text); }

.kfp-volume__slider {
  width: 72px; position: relative; display: flex; align-items: center;
}
.kfp-volume__track {
  width: 100%; height: 4px;
  background: var(--kfp-bg-3); border-radius: var(--kfp-r-full);
  border: 1px solid var(--kfp-border); overflow: hidden; cursor: pointer;
}
.kfp-volume__fill {
  height: 100%; background: var(--kfp-accent); border-radius: var(--kfp-r-full);
  transition: width .1s linear;
}
.kfp-volume__input {
  position: absolute; inset: 0; opacity: 0; cursor: pointer;
  width: 100%; height: 100%; margin: 0; padding: 0;
}

/* ==========================================
   FOOTER ROW (track counter + link)
   ========================================== */
.kfp-nowplaying__footer {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-top: 2px;
}
.kfp-track-counter {
  font-size: 11px; font-family: var(--kfp-font-mono);
  color: var(--kfp-text-muted);
}
.kfp-goto-post {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 700; color: var(--kfp-text-3);
  text-decoration: none; transition: color var(--kfp-ease);
}
.kfp-goto-post:hover { color: var(--kfp-accent); }

/* ==========================================
   QUEUE / TRACK LIST
   ========================================== */
.kfp-queue {
  border-top: 1px solid var(--kfp-border);
}

.kfp-queue__header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 24px;
  background: var(--kfp-bg-2);
  border-bottom: 1px solid var(--kfp-border);
}
.kfp-queue__title {
  display: flex; align-items: center; gap: 7px;
  font-size: 11px; font-weight: 800; text-transform: uppercase;
  letter-spacing: 1px; color: var(--kfp-text-3);
}
.kfp-queue__title svg { color: var(--kfp-accent); }
.kfp-queue__count {
  font-size: 11px; font-family: var(--kfp-font-mono);
  color: var(--kfp-text-muted);
  background: var(--kfp-bg-3); padding: 2px 9px;
  border-radius: var(--kfp-r-full); border: 1px solid var(--kfp-border);
}

.kfp-queue__list {
  max-height: 340px; overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--kfp-border) transparent;
}
.kfp-queue__list::-webkit-scrollbar { width: 4px; }
.kfp-queue__list::-webkit-scrollbar-thumb { background: var(--kfp-border-2); border-radius: 4px; }

.kfp-queue__item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 24px;
  border-bottom: 1px solid var(--kfp-border);
  cursor: pointer; transition: background var(--kfp-ease);
  position: relative;
}
.kfp-queue__item:last-child { border-bottom: none; }
.kfp-queue__item:hover { background: var(--kfp-bg-2); }
.kfp-queue__item.is-active {
  background: var(--kfp-accent-glow);
  border-left: 3px solid var(--kfp-accent);
}
.kfp-queue__item.is-active .kfp-queue__track-title { color: var(--kfp-accent); font-weight: 800; }

/* Track number / EQ badge */
.kfp-queue__num {
  width: 24px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  position: relative;
}
.kfp-queue__idx {
  font-size: 11px; font-family: var(--kfp-font-mono);
  color: var(--kfp-text-muted); font-weight: 700;
}
.kfp-queue__eq {
  display: none; gap: 2px; align-items: flex-end; height: 16px;
}
.kfp-queue__eq span {
  display: block; width: 3px; background: var(--kfp-accent);
  border-radius: 2px; height: 3px;
  animation: kfp-eq .8s ease-in-out infinite alternate;
}
.kfp-queue__eq span:nth-child(1) { animation-duration: .6s; }
.kfp-queue__eq span:nth-child(2) { animation-duration: .9s; animation-delay: .1s; }
.kfp-queue__eq span:nth-child(3) { animation-duration: .7s; animation-delay: .05s; }

.kfp-queue__item.is-active .kfp-queue__idx  { display: none; }
.kfp-queue__item.is-active .kfp-queue__eq   { display: flex; }
.kfp-player.is-playing .kfp-queue__item.is-active .kfp-queue__eq span { animation-play-state: running; }
.kfp-player:not(.is-playing) .kfp-queue__item.is-active .kfp-queue__eq span { animation-play-state: paused; height: 8px; }

/* Track art thumbnail */
.kfp-queue__art {
  width: 40px; height: 40px; border-radius: var(--kfp-r-sm);
  overflow: hidden; flex-shrink: 0; background: var(--kfp-bg-3);
  border: 1px solid var(--kfp-border);
  display: flex; align-items: center; justify-content: center;
  color: var(--kfp-text-muted);
}
.kfp-queue__art img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* Track info */
.kfp-queue__info {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; gap: 2px;
}
.kfp-queue__track-title {
  font-size: 13px; font-weight: 700; color: var(--kfp-text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  transition: color var(--kfp-ease);
}
.kfp-queue__item:hover .kfp-queue__track-title { color: var(--kfp-accent); }
.kfp-queue__track-artist {
  font-size: 11px; color: var(--kfp-text-3);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.kfp-queue__dur {
  font-size: 11px; font-family: var(--kfp-font-mono);
  color: var(--kfp-text-muted); flex-shrink: 0;
}
.kfp-queue__link {
  opacity: 0; color: var(--kfp-text-muted); transition: all var(--kfp-ease);
  flex-shrink: 0; padding: 4px; border-radius: 4px;
}
.kfp-queue__item:hover .kfp-queue__link { opacity: 1; color: var(--kfp-text-3); }
.kfp-queue__link:hover { color: var(--kfp-accent) !important; }

/* ==========================================
   COMPACT MODE — single-row mini player
   ========================================== */
.kfp-player--compact {
  --kfp-cover-size: 56px;
  border-radius: var(--kfp-r-lg);
}
.kfp-player--compact .kfp-stage {
  padding: 14px 18px; gap: 14px; align-items: center;
}
.kfp-player--compact .kfp-nowplaying { gap: 8px; }
.kfp-player--compact .kfp-nowplaying__title { font-size: 14px; }
.kfp-player--compact .kfp-nowplaying__artist { font-size: 12px; }
.kfp-player--compact .kfp-controls { gap: 6px; }
.kfp-player--compact .kfp-ctrl--play { width: 40px; height: 40px; }
.kfp-player--compact .kfp-ctrl--prev,
.kfp-player--compact .kfp-ctrl--next { width: 28px; height: 28px; }
.kfp-player--compact .kfp-ctrl--prev svg,
.kfp-player--compact .kfp-ctrl--next svg { width: 18px; height: 18px; }
.kfp-player--compact .kfp-ctrl--icon { display: none; }
.kfp-player--compact .kfp-volume__slider { width: 56px; }
.kfp-player--compact .kfp-volume { gap: 4px; }

/* ==========================================
   EMPTY NOTICE (admin-only)
   ========================================== */
.kfp-empty-notice {
  padding: 16px 20px;
  background: var(--kfp-bg-2, #f8fafc);
  border: 1px dashed var(--kfp-border, #e2e8f0);
  border-radius: var(--kfp-r-lg, 16px);
  font-size: 13px; color: var(--kfp-text-3, #64748b);
  margin: 16px 0;
}
.kfp-empty-notice a { color: var(--kfp-accent, #16a34a); font-weight: 600; }

/* ==========================================
   RESPONSIVE
   ========================================== */
@media (max-width: 640px) {
  .kfp-stage { padding: 18px 16px; gap: 14px; }
  --kfp-cover-size: 72px;
  .kfp-nowplaying__title { font-size: 15px; }
  .kfp-volume { display: none; }
  .kfp-ctrl--icon { width: 28px; height: 28px; }
  .kfp-ctrl--play { width: 46px; height: 46px; }
  .kfp-queue__item { padding: 10px 16px; }
  .kfp-queue__header { padding: 10px 16px; }
}

@media (max-width: 400px) {
  .kfp-ctrl--icon { display: none; }
  .kfp-volume { display: none; }
}

/* ==========================================
   READY / IDLE STATE
   Play button pulses gently to invite a click.
   Removed as soon as the user starts playing.
   ========================================== */
@keyframes kfp-pulse {
  0%   { box-shadow: 0 4px 16px var(--kfp-accent-glow); }
  50%  { box-shadow: 0 4px 24px var(--kfp-accent-glow), 0 0 0 8px rgba(var(--kfp-accent-rgb, 22,163,74), 0.1); }
  100% { box-shadow: 0 4px 16px var(--kfp-accent-glow); }
}

.kfp-player.kfp-ready .kfp-ctrl--play {
  animation: kfp-pulse 2s ease-in-out infinite;
}
.kfp-player.kfp-ready .kfp-ctrl--play:hover {
  animation: none;
}
