// 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;

// Background color for thumbnail placeholders
$placeholder-background-color: #303030;

// Rules common to mouse and touch devices
.vjs-playlist {
  padding: 0;
  background-color: $background-color;
  color: $main-color;
  list-style-type: none;

  img {
    display: block;
  }

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

  .vjs-playlist-item {
    position: relative;
    cursor: pointer;
    overflow: hidden;
  }

  .vjs-playlist-thumbnail-placeholder {
    background: $placeholder-background-color;
  }

  .vjs-playlist-now-playing-text {
    display: none;
    position: absolute;
    top: 0;
    left: 0;

    // This keeps this element aligned vertically with vjs-playlist-name.
    padding-left: 2px;
    margin: .8rem;
  }

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

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

  .vjs-playlist-name {
    display: block;
    max-height: 2.5em;

    // So drop shadow doesn't get cut off as overflow
    padding: 0 0 4px 2px;
    font-style: normal;
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
    
    // 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;
  }

  .vjs-playlist-description{
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
    display: block;
    font-size: 14px;
    padding: 0 0 0 2px;
  }

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

  .vjs-up-next {

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

  // Selected item rules
  .vjs-selected {
    background-color: $highlight-color;

    img {
      opacity: .2;
    }

    .vjs-playlist-duration {
      display: none;
    }

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

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

// Vertical/default playlist orientation
.vjs-playlist-vertical {
  overflow-x: hidden;
  overflow-y: auto;

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

  .vjs-playlist-item {
    margin-bottom: 5px;
  }

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

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

// Horizontal playlist orientation
.vjs-playlist-horizontal {
  overflow-x: auto;
  overflow-y: hidden;

  img {
    min-width: 100px;
    height: 100%;
  }

  .vjs-playlist-item-list {
    height: 100%;
    white-space: nowrap;
  }

  .vjs-playlist-item {
    display: inline-block;
    height: 100%;
    margin-right: 5px;
  }

  .vjs-playlist-thumbnail {
    display: block;
    height: 100%;
  }

  .vjs-playlist-thumbnail-placeholder {
    height: 100%;
    width: 180px;
  }
}

// prevent clicks and scrolling from affecting the playlist during ads
.vjs-playlist.vjs-ad-playing.vjs-csspointerevents {
  pointer-events: none;
  overflow: auto;
}

// darken the playlist menu display to indicate it's not interactive during ads
.vjs-playlist.vjs-ad-playing .vjs-playlist-ad-overlay {
  display: block;
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  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) {
  font-size: $base-font-size;

  .vjs-playlist-description {
    height: $base-font-size * 2;
    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-now-playing-text,
  .vjs-playlist .vjs-up-next .vjs-up-next-text {
    display: none;
  }

  .vjs-mouse.vjs-playlist .vjs-selected .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;
  }
}
