/* The default color for the playlist menu background, almost black */
$background-color: #1a1a1a;
/* The color used to emphasize the currently playing video and for effects */
$highlight-color: #141a21;
/* The primary foreground color */
$main-color: #fff;

/* Rules common to mouse and touch devices */
.vjs-playlist {
  list-style-type: none;

  overflow: scroll;

  .vjs-playlist-item-list {
    position: relative;
    margin: 0;
    padding: 0;
    list-style: none;
  }

  .vjs-playlist-item {
    cursor: pointer;
    overflow: hidden;
    position: relative;
    margin-bottom: 5px;
  }

  .vjs-playlist-thumbnail {
    display: block;
  }

  .vjs-playlist-thumbnail-placeholder {
    height: 100px;
    background: #303030;
  }

  img {
    display: block;
    width: 100%;
    min-height: 54px;

    // Needed because sometimes IE10 adds width / height properties
    height: auto;
  }

  .vjs-playlist-duration {
    background-color: rgba(26, 26, 26, 0.8);
    top: .5rem;
    left: .5rem;
    padding: 2px 5px 3px;
    margin-left: 2px;
    position: absolute;
  }
  .vjs-selected .vjs-playlist-duration {
    display: none;
  }

  .vjs-playlist-name {
    display: block;
    font-style: normal;
    max-height: 2.5em;
    overflow: hidden;

    // line-height:normal was causing overflow cutoff issues on Android, since normal
    // lets different user agents pick a value. Here we set a consistent precise value.
    line-height: 20px;

    // So drop shadow doesn't get cut off as overflow
    padding: 0 0 4px 2px;
  }

  .vjs-playlist-description {
    text-overflow: ellipsis;
    overflow: hidden;
    margin: 0;
  }
}

/* Prevent interaction with the playlist menu while ads are playing */
/* on browsers that don't support pointer-events (IE<11), prevent
scrolling past the ad overlay */
.vjs-playlist.vjs-ad-playing {
  overflow: hidden;
}
/* prevent clicks and scrolling from affecting the playlist during ads */
.vjs-playlist.vjs-ad-playing.vjs-csspointerevents {
  pointer-events: none;
  overflow: auto;

  // Fix for IE11 pointer-events bug that allowed clicking playlist during ads
  .vjs-playlist-ad-overlay {
    pointer-events: auto;
  }
}
/* darken the playlist menu display to indicate it's not interactive
during ads and capture click events on IE<11 */
.vjs-playlist.vjs-ad-playing .vjs-playlist-ad-overlay {
  display: none;
}
.vjs-playlist.vjs-ad-playing .vjs-playlist-ad-overlay {
  display: block;
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;

  /* IE8 fallback */
  background-color: #1a1a1a;
  -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=50)";

  /* modern browsers */
  background-color: rgba(0, 0, 0, 0.5);
}

/* Parametric rules. These are specialized for touch and mouse-based devices */
@mixin playlist-base($base-font-size: 14px) {
  $small-font-size: ceil($base-font-size * 0.75);
  $item-height: $base-font-size * 4;
  $name-height: $base-font-size;
  $description-height: $item-height - $name-height;
  $thumbnail-font-size: 18px;

  font-size: $base-font-size;
  background-color: $background-color;
  color: $main-color;
  padding: 0;

  .vjs-playlist-item {
  }

  .vjs-playlist-thumbnail {
    width: 100%;
  }

  .vjs-selected .vjs-playlist-thumbnail img {
    opacity: .2;
  }

  .vjs-playlist-thumbnail .vjs-playlist-now-playing-text {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    margin: .5rem .8rem;
    padding-left: 2px;
  }

  .vjs-selected .vjs-playlist-thumbnail .vjs-playlist-now-playing-text {
    display: block;
  }

  .vjs-selected {
    background-color: $highlight-color;
  }

  .vjs-up-next-text {
    display: none;
  }

  .vjs-up-next .vjs-up-next-text {
    text-transform: uppercase;
    display: block;
    padding: .1rem 2px;
    font-size: .8em;
  }

  time {
    font-size: 1em;
  }

  .vjs-playlist-title-container {
    position: absolute;
    bottom: 0;
    padding: .5rem .8rem;
    text-shadow:  1px  1px 2px black,
                 -1px  1px 2px black,
                  1px -1px 2px black,
                 -1px -1px 2px black;
  }

  .vjs-selected .vjs-playlist-title-container {
    text-shadow: none;
  }

  .vjs-playlist-description {
    height: $description-height;
    line-height: ceil($base-font-size * 1.5);
  }
}

/* Touch-device playlist dimensions */
.vjs-playlist {
  @include playlist-base();
}

/* Mouse-only playlist dimensions */
.vjs-mouse.vjs-playlist {
  @include playlist-base(15px);
}

// Larger font size for larger player
@media (min-width: 600px) {
  .vjs-mouse.vjs-playlist {
    @include playlist-base(17px);
  }

  .vjs-playlist .vjs-playlist-name {
    line-height: 22px;
  }
}

// Don't show now playing / up next when there isn't room
@media (max-width: 520px) {
  // These styles exist both with and without .vjs-mouse
  .vjs-playlist .vjs-selected .vjs-playlist-thumbnail .vjs-playlist-now-playing-text,
  .vjs-playlist .vjs-up-next .vjs-up-next-text {
    display: none;
  }

  .vjs-mouse.vjs-playlist .vjs-selected .vjs-playlist-thumbnail .vjs-playlist-now-playing-text,
  .vjs-mouse.vjs-playlist .vjs-up-next .vjs-up-next-text {
    display: none;
  }
}

// If now playing / up next are shown, make sure there is room.
// Only affects thumbnails with very wide aspect ratio, which get
// stretched vertically. We could avoid the stretching by making this a
// CSS background image and using background-size: cover; but then it'd
// get clipped, so not sure that's better.
@media (min-width: 521px) {
  .vjs-playlist img {
    min-height: 85px;
  }
}

// Don't show duration when there isn't room
@media (max-width: 750px) {
  .vjs-playlist .vjs-playlist-duration {
    display: none;
  }
}
