/* ==========================================================================
   Floating Video Player — triBBBal
   z-index: 9000 (above mini-player at 8500, below modals at 99999)
   ========================================================================== */

/* ---------- Custom Properties ---------- */
.floating-video {
  --fv-bg: var(--ml-color-bg-darker);
  --fv-text: var(--ml-color-text-emphasis);
  --fv-accent: var(--ml-color-accent);
  --fv-overlay: var(--ml-color-overlay);
  --fv-control-hover: var(--ml-color-control-hover-strong);
  --fv-radius: var(--ml-radius-md);
  --fv-transition: var(--ml-transition-default);
  --fv-width: var(--ml-floating-width);
  --fv-height: var(--ml-floating-height);
}

/* ---------- Keyframes ---------- */
@keyframes fvSlideUp {
  from { transform: translateY(100%); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}

/* ---------- Box-sizing Reset ---------- */
.floating-video,
.floating-video *,
.floating-video *::before,
.floating-video *::after {
  box-sizing: border-box;
}

/* ---------- Container ---------- */
.floating-video {
  position: fixed;
  z-index: var(--ml-z-floating);
  background: var(--fv-bg);
  box-shadow: var(--ml-shadow-lg);
  font-family: inherit;
  overflow: hidden;
}

/* --- State: visible --- */
.floating-video.is-visible {
  display: block;
  animation: fvSlideUp var(--fv-transition) forwards;
}

/* --- State: dragging --- */
.floating-video.is-dragging {
  transition: none;
  will-change: transform;
}

/* --- State: snapping --- */
.floating-video.is-snapping {
  transition: transform 0.3s cubic-bezier(0.2, 0, 0, 1);
}

/* ---------- Desktop (>= 768px) ---------- */
@media (min-width: 768px) {
  .floating-video {
    width: var(--fv-width);
    height: auto;
    bottom: var(--ml-edge-margin);
    right: var(--ml-edge-margin);
    border-radius: var(--fv-radius);
  }

  /* Shift up when mini-player is active */
  .body-has-mini-player .floating-video {
    bottom: var(--ml-stack-mini-offset); /* 64px mini-player + 20px gap */
  }
}

/* ---------- Mobile (< 768px) ---------- */
@media (max-width: 767px) {
  .floating-video {
    width: 100%;
    bottom: 0;
    left: 0;
    right: 0;
    border-radius: 0;
  }

  /* Body padding to prevent content overlap */
  .body-has-floating-video {
    padding-bottom: 200px;
  }

  .floating-video-info {
    padding-bottom: calc(6px + env(safe-area-inset-bottom, 0px));
  }
}

/* ---------- Drag Handle ---------- */
.floating-video-drag-handle {
  width: 40px;
  height: 4px;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 2px;
  margin: 6px auto;
  cursor: grab;
}

.is-dragging .floating-video-drag-handle {
  cursor: grabbing;
}

@media (max-width: 767px) {
  .floating-video-drag-handle {
    display: none;
  }
}

@media (min-width: 768px) {
  .floating-video-drag-handle {
    display: block;
  }
}

/* ---------- Video Content ---------- */
.floating-video-content {
  position: relative;
  width: 100%;
  padding-top: 56.25%; /* 16:9 aspect ratio */
  overflow: hidden;
  border-radius: var(--fv-radius) var(--fv-radius) 0 0;
}

.floating-video-content video {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.floating-video-content .video-js {
  position: absolute !important;
  top: 0;
  left: 0;
  width: 100% !important;
  height: 100% !important;
}

@media (max-width: 767px) {
  .floating-video-content {
    border-radius: 0;
    max-height: 180px;
  }
}

/* ---------- Controls Overlay ---------- */
.floating-video-controls {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--fv-overlay);
  opacity: 0;
  transition: opacity 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  pointer-events: none;
}

/* Show on hover (desktop) */
.floating-video-content:hover .floating-video-controls {
  opacity: 1;
  pointer-events: auto;
}

/* Show on tap (mobile — JS toggles .is-tapped) */
.floating-video-controls.is-tapped {
  opacity: 1;
  pointer-events: auto;
}

/* ---------- Control Buttons ---------- */
.floating-video-controls button {
  background: rgba(0, 0, 0, 0.6);
  border: none;
  color: #fff;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background 0.15s ease;
}

.floating-video-controls button:hover {
  background: var(--fv-control-hover);
}

/* Play button — slightly larger */
.floating-video-play-btn {
  width: 48px;
  height: 48px;
  font-size: 20px;
}

/* PiP button — hidden unless JS confirms support */
.floating-video-pip {
  display: none;
}

.pip-supported .floating-video-pip {
  display: flex;
}

/* Go-to-source button — hidden by default, shown by JS when there's a source */
.floating-video-goto-source {
  display: none;
}

/* ---------- Info Bar ---------- */
.floating-video-info {
  padding: 6px 12px;
  background: var(--fv-bg);
}

.floating-video-title {
  font-size: 12px;
  color: var(--fv-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}

@media (max-width: 767px) {
  .floating-video-title {
    font-size: 13px;
  }
}

/* ---------- Social Meta Slots ---------- */
.floating-video-social-meta {
  display: flex;
  gap: 8px;
  padding: 0 12px 8px;
}

.floating-video-social-meta > * {
  min-height: 0;
}

@media (min-width: 768px) {
  .floating-video-social-meta {
    border-radius: 0 0 var(--fv-radius) var(--fv-radius);
  }
}

/* Poster avatar in floating video */
.floating-video-poster-link {
  flex-shrink: 0;
  margin-right: 6px;
}
.floating-video-poster-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  border: 1.5px solid var(--fv-accent, #e94560);
}
.floating-video-info {
  display: flex;
  align-items: center;
}
