/* ============================================================
   Custom Media Players - Audio + Video
   ============================================================ */

/* ── Audio Player ─────────────────────────────────────────── */

.aplayer {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  direction: ltr;
  background: var(--surface-2);
  border-top: 1px solid var(--divider);
}

.aplayer-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  padding: 0;
  transition: background 0.15s, transform 0.12s;
}

.aplayer-btn:hover {
  background: var(--accent-hover);
  transform: scale(1.07);
}

.aplayer-btn:active {
  transform: scale(0.93);
}

.aplayer-track {
  flex: 1;
  height: 3px;
  background: var(--surface-pressed);
  border-radius: 2px;
  cursor: pointer;
  position: relative;
  min-width: 0;
  margin: 0 2px;
  touch-action: none; /* pointer-drag to scrub, not scroll */
}

.aplayer-fill {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  width: 0%;
  pointer-events: none;
}

.aplayer-knob {
  position: absolute;
  top: 50%;
  left: 0%;
  transform: translate(-50%, -50%) scale(0.4);
  width: 13px;
  height: 13px;
  background: var(--accent);
  border: 2px solid white;
  border-radius: 50%;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.18);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.14s, transform 0.14s;
}

.aplayer-track:hover .aplayer-knob {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.aplayer-times {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--text-3);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
  direction: ltr;
  unicode-bidi: isolate;
}

.aplayer-cur,
.aplayer-dur,
.aplayer-sep {
  direction: ltr;
  unicode-bidi: plaintext;
}

.aplayer-sep {
  color: var(--border-strong);
  opacity: 0.6;
}

.aplayer-dur {
  color: var(--text-muted);
}


/* ── Video Player ─────────────────────────────────────────── */

.vplayer-wrap {
  position: relative;
  background: #000;
  border-radius: var(--r-md);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 100%;
  cursor: pointer;
  user-select: none;
}

.vplayer-video {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  object-fit: contain;
}

/* Fitted to native video dimensions (portrait, landscape, square). */
.vplayer-wrap.vplayer-fit {
  width: auto;
  max-width: 100%;
  max-height: var(--vplayer-max-h, calc(85vh - 100px));
  margin-inline: auto;
}

.vplayer-wrap.vplayer-fit .vplayer-video {
  width: 100%;
  height: 100%;
  max-width: none;
  object-fit: contain;
}

/* Fullscreen - fill entire screen, video centered */
.vplayer-wrap:fullscreen,
.vplayer-wrap:-webkit-full-screen {
  width: 100vw !important;
  height: 100vh !important;
  max-width: none !important;
  border-radius: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.vplayer-wrap:fullscreen .vplayer-video,
.vplayer-wrap:-webkit-full-screen .vplayer-video {
  max-width: 100vw;
  max-height: 100vh;
  width: auto;
  height: auto;
}

/* Overlay shown when paused */
.vplayer-overlay {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.26);
  transition: background 0.18s, opacity 0.18s;
}

.vplayer-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.vplayer-overlay:hover {
  background: rgba(0, 0, 0, 0.38);
}

.vplayer-big-btn {
  width: 66px;
  height: 66px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.16);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1.5px solid rgba(255, 255, 255, 0.28);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, transform 0.15s;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.vplayer-overlay:hover .vplayer-big-btn {
  background: rgba(255, 255, 255, 0.24);
  transform: scale(1.08);
}

/* Bottom controls bar */
.vplayer-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 24px 14px 12px;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.7));
  direction: ltr;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.2s, transform 0.2s;
  /* Keep controls clickable even when faded - otherwise seek/play are dead while playing. */
  pointer-events: auto;
}

.vplayer-bar.visible,
.vplayer-wrap.paused .vplayer-bar {
  opacity: 1;
  transform: translateY(0);
}

.vplayer-ctrl-btn {
  width: 30px;
  height: 30px;
  background: transparent;
  border: none;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border-radius: 50%;
  flex-shrink: 0;
  transition: background 0.12s;
}

.vplayer-ctrl-btn:hover {
  background: rgba(255, 255, 255, 0.15);
}

.vplayer-seek {
  flex: 1;
  height: 3px;
  min-width: 0;
  background: rgba(255, 255, 255, 0.25);
  border-radius: 2px;
  cursor: pointer;
  position: relative;
  transition: height 0.14s;
  touch-action: none; /* pointer-drag to scrub, not scroll */
}

/* Wider hit target without changing the visible track height */
.vplayer-seek::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 22px;
  transform: translateY(-50%);
}

.vplayer-seek:hover {
  height: 5px;
}

.vplayer-fill {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  background: white;
  border-radius: 2px;
  width: 0%;
  pointer-events: none;
}

.vplayer-knob {
  position: absolute;
  top: 50%;
  left: 0%;
  transform: translate(-50%, -50%);
  width: 13px;
  height: 13px;
  background: white;
  border-radius: 50%;
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.35);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.12s;
}

.vplayer-seek:hover .vplayer-knob {
  opacity: 1;
}

.vplayer-times {
  display: flex;
  gap: 4px;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.85);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

.vplayer-dur {
  color: rgba(255, 255, 255, 0.5);
}

.vplayer-fs-btn {
  margin-inline-start: auto;
}
