/** @license
 * Shaka Player
 * Copyright 2016 Google LLC
 * SPDX-License-Identifier: Apache-2.0
 */

.shaka-sub-menu {
  /* Where the menu appears. */
  position: relative;

  /* When displayed as a flex container, elements inside will flow in a
   * vertical column. */
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

/* The overflow menu and all settings submenus.  These appear on top of all
 * other controls (Z axis) when the overflow button is clicked. */
.shaka-overflow-menu,
.shaka-context-menu,
.shaka-settings-menu {
  /* It's okay to add a vertical scroll if there are too many items, but
   * horizontal scrolling is not allowed. */
  overflow-x: hidden;
  overflow-y: auto;

  scrollbar-color: @general-font-color @general-background-color;
  scrollbar-width: thin;

  /* Don't wrap text to the next line. */
  white-space: nowrap;

  /* Styles for the menu itself. */
  background: rgba(28, 28, 28, 90%);
  border-radius: 12px;
  max-height: 250px;
  min-width: 190px;
  padding: 5px;

  /* The menus fade out with the other controls. */
  .show-when-controls-shown();

  /* When displayed as a flex container, elements inside will flow in a
   * vertical column. */
  display: flex;
  flex-direction: column;
  align-items: stretch;

  /* Where the menu appears. */
  position: absolute;
  z-index: 2;
  bottom: @material-icons-width + 14px;

  /* The buttons inside the menu. */
  button {
    font-size: @general-font-size;
    background: transparent;
    color: @general-font-color;
    border: none;
    border-radius: 12px;
    min-height: 30px;
    padding: 10px;

    /* The button itself is a flex container, with children center-aligned. */
    display: flex;
    align-items: center;

    /* When hovered, the button's background is highlighted. */
    &:hover {
      background: rgba(255, 255, 255, 10%);
    }

    /* The button is clickable, showing cursor pointer */
    cursor: pointer;

    /* The label inside button is also showing cursor pointer  */
    label {
      cursor: pointer;
    }

    .shaka-keyboard-navigation &:focus {
      background: rgba(255, 255, 255, 10%);
    }
  }

  /* These are the elements which contain the material design icons.
   * TODO: Pull MD icon details out of JS. */
  .shaka-ui-icon {
    /* TODO(b/116651454): eliminate hard-coded offsets */
    padding-left: 0;
    padding-right: 10px;

    &.shaka-chosen-item {
      order: -1;
      line-height: 17px;
      font-size: 18px;
    }
  }

  // If the seekbar is missing, this is positioned lower.
  &.shaka-low-position {
    bottom: @material-icons-width;
  }
}

/* The span elements inside the top-level overflow menu contain single lines
 * of text, which are the button name and the current selection.  For example,
 * a captions button might have "Captions" in one span (the button name), and
 * "Farsi" in another (the current selection).
 * These are displayed inside a .shaka-overflow-button-label grouping, to the
 * right of MD icons. */
.shaka-overflow-menu span {
  text-align: left;
}

.shaka-overflow-button {
  position: relative;
}

/* This contains span elements with single lines of text, and appears to the
 * right of MD icons. */
.shaka-overflow-button-label {
  position: relative;

  /* This is a flex container, whose children flow vertically. */
  display: flex;
  align-items: center;
  flex-direction: column;
}

.shaka-overflow-button-label-inline {
  box-sizing: border-box;
  flex-direction: row;
  justify-content: space-between;
  width: calc(100% - 24px);
  padding-right: 28px;
  background-image: url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGhlaWdodD0iMjRweCIgdmlld0JveD0iMCAwIDI0IDI0IiB3aWR0aD0iMjRweCIgZmlsbD0iI2VlZWVlZSI+PHBhdGggZD0iTTAgMGgyNHYyNEgwVjB6IiBmaWxsPSJub25lIi8+PHBhdGggZD0iTTguNTkgMTYuNTlMMTMuMTcgMTIgOC41OSA3LjQxIDEwIDZsNiA2LTYgNi0xLjQxLTEuNDF6Ii8+PC9zdmc+");
  background-repeat: no-repeat;
  background-position: right 5px center;
  background-size: 24px 24px;
}

.shaka-simple-overflow-button-label-inline {
  box-sizing: border-box;
  flex-direction: row;
  justify-content: space-between;
  width: calc(100% - 50px);
}

/* This is the specific span element which shows the current selection from some
 * submenu.  For example, it would contain the currently-selected subtitle
 * language, the currently-selected resolution, etc. */
.shaka-current-selection-span {
  /* This is dimmer than the other span, which is the name of the submenu. */
  font-size: 12px;
  padding-left: 10px;
}

.shaka-current-auto-quality {
  margin-left: 5px;
  font-size: 11px;
  color: @general-font-color-secondary;
}

.shaka-quality-mark,
.shaka-current-quality-mark {
  color: @quality-mark-hightlight-color;
  margin-left: 2px !important;
  font-size: 10px;
  height: 17px;
}

.shaka-quality-mark {
  line-height: 6px;
}

.shaka-overflow-quality-mark,
.shaka-overflow-playback-rate-mark {
  background: @quality-mark-hightlight-color;
  color: @quality-mark-color;
  border-radius: 2px;
  font-family: @general-font-family;
  font-size: 10px;
  font-weight: bold;
  line-height: 10px;
  text-shadow: none;
  padding: 1px;
  position: absolute;
  right: 4px;
  top: 10px;
}

/* The submenus have somewhat different margins inside them. */
.shaka-settings-menu,
.shaka-sub-menu {
  span {
    /* TODO(b/116651454): eliminate hard-coded offsets */
    margin-left: 28px;

    &.shaka-chosen-item {
      margin-left: 0;
    }
  }

  .shaka-chapter-item {
    display: flex;
    align-items: center;
    flex-direction: row;
  }

  .shaka-chapter-thumbnail {
    width: 60px;
    height: 34px;
    overflow: hidden;
    border-radius: 4px;
    flex-shrink: 0;
    position: relative;
  }

  .shaka-chapter {
    /* TODO(b/116651454): eliminate hard-coded offsets */
    margin-left: 10px;
  }
}

/* This is a button within each submenu that takes you back to the main overflow
 * menu. */
.shaka-back-to-overflow-button {
  border-bottom: 1px solid rgba(255, 255, 255, 20%) !important;
  border-radius: 0 !important;

  margin-bottom: 5px;

  /* The label inside the button, which says something like "back". */
  span {
    /* TODO(b/116651454): eliminate hard-coded offsets */
    margin-left: 0;
  }

  /* The MD icon for the "back" arrow. */
  .shaka-ui-icon {
    /* TODO(b/116651454): eliminate hard-coded offsets */
    padding-right: 10px;
    font-size: 18px !important;
  }

  &:hover {
    background: transparent !important;
  }
}
