/**
 * KMOnlineSolutions - Video Playlist Carousel frontend.
 *
 * Large featured <video> player on top, horizontal thumbnail strip below.
 * Only poster images load on page load: the player uses preload="none" and
 * each card stores its file URL in data-src. The file is fetched only when
 * the user selects that thumbnail (or autoplay-next fires after "ended").
 *
 * Behaviour:
 *   - Click / Enter on a card loads it into the player and plays it.
 *   - Prev/next arrows scroll the strip by exactly one card (smooth).
 *   - Arrows auto-hide at the start / end of the list (and on mobile,
 *     where swipe takes over and arrows are CSS-hidden).
 *   - ArrowLeft / ArrowRight moves the selection when focus is inside
 *     the playlist (strip, cards, or player).
 *   - On "ended", the next video starts automatically (unless data-next=0
 *     or data-loop handling applies).
 *   - Per-video watch progress persists in localStorage and renders as a
 *     progress bar on each card.
 */

.wppm-video-playlist {
  width: 100%;
  max-width: 100%;
}

/* ------------------------------------------------------------------ */
/* Featured player                                                     */
/* ------------------------------------------------------------------ */

.wppm-vp-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: 10px;
  overflow: hidden;
}

.wppm-vp-player {
  display: block;
  width: 100%;
  height: 100%;
  background: #000;
  /* Swap animation target: JS toggles .is-swapping on the stage. */
  opacity: 1;
  transform: scale(1);
  transition: opacity 0.28s ease, transform 0.28s ease;
}

.wppm-vp-stage.is-swapping .wppm-vp-player {
  opacity: 0;
  transform: scale(0.985);
}

/* Big centered play button: overlay on the stage, visible whenever the
   video is paused (JS toggles .is-hidden on play/pause/ended). */
.wppm-vp-bigplay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 84px;
  height: 84px;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3;
  opacity: 1;
  visibility: visible;
  transition: opacity 0.25s ease, visibility 0.25s, background 0.2s ease, transform 0.2s ease;
}

.wppm-vp-bigplay:hover {
  background: var(--wppm-vp-accent, #e50914);
  transform: translate(-50%, -50%) scale(1.07);
}

.wppm-vp-bigplay:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 3px;
}

.wppm-vp-bigplay.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.wppm-vp-bigplay svg {
  width: 34px;
  height: 34px;
  margin-left: 4px;
  fill: currentColor;
}

.wppm-vp-current-title {
  margin: 10px 2px 0;
  font-size: 17px;
  line-height: 1.45;
  font-weight: 600;
  overflow-wrap: break-word;
}

/* ------------------------------------------------------------------ */
/* Carousel strip                                                      */
/* ------------------------------------------------------------------ */

.wppm-vp-nav-wrap {
  position: relative;
  margin-top: 12px;
}

.wppm-vp-strip {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 8px 2px 10px;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  /* App-style carousel: no visible scrollbar. */
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.wppm-vp-strip::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}

.wppm-vp-strip:focus-visible {
  outline: 2px solid var(--wppm-vp-accent, #e50914);
  outline-offset: 2px;
  border-radius: 6px;
}

/* ------------------------------------------------------------------ */
/* Thumbnail cards                                                     */
/* ------------------------------------------------------------------ */

.wppm-vp-card {
  flex: 0 0 200px;
  width: 200px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  text-align: left;
  font: inherit;
  color: inherit;
  border-radius: 8px;
  /* Hover/focus lift (Netflix-style). transform is GPU-cheap here. */
  transition: transform 0.22s ease;
}

.wppm-vp-card:hover,
.wppm-vp-card:focus-visible {
  transform: scale(1.05);
  outline: none;
  z-index: 1;
}

.wppm-vp-card:focus-visible .wppm-vp-thumb {
  outline: 2px solid var(--wppm-vp-accent, #e50914);
  outline-offset: 2px;
}

.wppm-vp-thumb {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: 8px;
  background: #111;
  border: 2px solid transparent;
  box-shadow: 0 0 0 rgba(0, 0, 0, 0);
  transition: border-color 0.22s ease, box-shadow 0.22s ease;
}

.wppm-vp-card:hover .wppm-vp-thumb,
.wppm-vp-card:focus-visible .wppm-vp-thumb {
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35);
}

.wppm-vp-card.is-active .wppm-vp-thumb {
  border-color: var(--wppm-vp-accent, #e50914);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35);
}

.wppm-vp-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.wppm-vp-thumb-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  min-height: 100%;
  background: linear-gradient(135deg, #2b2b2b 0%, #101010 100%);
  color: #fff;
  font-size: 28px;
}

.wppm-vp-duration {
  position: absolute;
  right: 6px;
  bottom: 8px;
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.75);
  color: #fff;
  font-size: 11px;
  line-height: 1.6;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.wppm-vp-duration:empty {
  display: none;
}

.wppm-vp-badge {
  position: absolute;
  left: 6px;
  top: 6px;
  display: none;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--wppm-vp-accent, #e50914);
  color: #fff;
  font-size: 10px;
  line-height: 1.6;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.wppm-vp-card.is-active .wppm-vp-badge {
  display: inline-block;
}

.wppm-vp-progress {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  background: rgba(255, 255, 255, 0.25);
}

.wppm-vp-progress-fill {
  display: block;
  width: 0%;
  height: 100%;
  background: var(--wppm-vp-accent, #e50914);
  transition: width 0.3s linear;
}

.wppm-vp-card-title {
  display: block;
  margin: 8px 2px 0;
  font-size: 13px;
  line-height: 1.4;
  font-weight: 500;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.wppm-vp-card.is-active .wppm-vp-card-title {
  font-weight: 700;
}

/* ------------------------------------------------------------------ */
/* Arrows                                                              */
/* ------------------------------------------------------------------ */

.wppm-vp-prev,
.wppm-vp-next {
  position: absolute;
  top: 42%;
  transform: translateY(-50%);
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 1;
  transition: opacity 0.25s ease, background 0.2s ease, transform 0.2s ease;
}

.wppm-vp-prev {
  left: -6px;
}

.wppm-vp-next {
  right: -6px;
}

.wppm-vp-prev:hover,
.wppm-vp-next:hover {
  background: rgba(0, 0, 0, 0.8);
  transform: translateY(-50%) scale(1.06);
}

.wppm-vp-prev.is-hidden,
.wppm-vp-next.is-hidden {
  opacity: 0;
  pointer-events: none;
}

/* Videos-only mode (thumbnail titles off): cards are pure thumbnails, so
   center the arrows on the strip instead of offsetting for title text. */
.wppm-video-playlist.wppm-vp-no-titles .wppm-vp-prev,
.wppm-video-playlist.wppm-vp-no-titles .wppm-vp-next {
  top: 50%;
}

.wppm-vp-empty {
  padding: 24px;
  text-align: center;
  background: #f7f7f7;
  border: 1px dashed #ccc;
  border-radius: 6px;
  color: #666;
}

/* ------------------------------------------------------------------ */
/* Responsive: smaller cards, swipe instead of arrows                  */
/* ------------------------------------------------------------------ */

@media (max-width: 767px) {
  .wppm-vp-bigplay {
    width: 64px;
    height: 64px;
  }

  .wppm-vp-bigplay svg {
    width: 26px;
    height: 26px;
  }

  .wppm-vp-card {
    flex-basis: 132px;
    width: 132px;
  }

  .wppm-vp-prev,
  .wppm-vp-next {
    display: none;
  }

  .wppm-vp-strip {
    scroll-snap-type: x proximity;
  }

  .wppm-vp-card {
    scroll-snap-align: start;
  }

  .wppm-vp-current-title {
    font-size: 15px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .wppm-vp-strip {
    scroll-behavior: auto;
  }

  .wppm-vp-card,
  .wppm-vp-thumb,
  .wppm-vp-player,
  .wppm-vp-bigplay,
  .wppm-vp-prev,
  .wppm-vp-next {
    transition: none;
  }

  .wppm-vp-card:hover,
  .wppm-vp-card:focus-visible {
    transform: none;
  }
}
