//
// Bootstrap v3.3.7: Dropdown menus
// --------------------------------------------------

@gray-base: #32373c;
@gray-dark: lighten(@gray-base, 20%);   // #333
@gray-light: lighten(@gray-base, 46.7%); // #777
@screen-sm: 783px;
@screen-sm-min: @screen-sm;

@caret-width-base:  4px;
@zindex-dropdown: 1000;
@font-size-base:  13px;
@dropdown-bg: #fff;
@dropdown-fallback-border:  #ccc;
@dropdown-border: rgba(0,0,0,.15);
@dropdown-divider-bg: #e5e5e5;
@line-height-base:  1.428571429; // 20/14
@line-height-computed:  floor((@font-size-base * @line-height-base)); // ~20px
@dropdown-link-color: @gray-dark;
@dropdown-link-hover-color: darken(@gray-dark, 5%);
@dropdown-link-hover-bg: #f5f5f5;
@dropdown-link-active-color: #fff;
@dropdown-link-active-bg: darken(#428bca, 6.5%); // #337ab7
@dropdown-link-disabled-color:   @gray-light;
@cursor-disabled: not-allowed;
@font-size-small: ceil((@font-size-base * 0.85)); // ~12px
@dropdown-header-color: @gray-light;
@grid-float-breakpoint:     @screen-sm-min;

// Drop shadows
//
// Note: Deprecated `.box-shadow()` as of v3.1.0 since all of Bootstrap's
// supported browsers that have box shadow capabilities now support it.

.box-shadow(@shadow) {
  -webkit-box-shadow: @shadow; // iOS <4.3 & Android <4.1
          box-shadow: @shadow;
}

// Horizontal dividers
//
// Dividers (basically an hr) within dropdowns and nav lists

.nav-divider(@color: #e5e5e5) {
  height: 1px;
  margin: ((@line-height-computed / 2) - 1) 0;
  overflow: hidden;
  background-color: @color;
}

// Reset filters for IE
//
// When you need to remove a gradient background, do not forget to use this to reset
// the IE filter for IE9 and below.

.reset-filter() {
  filter: e(%("progid:DXImageTransform.Microsoft.gradient(enabled = false)"));
}


// Dropdown arrow/caret
.caret {
  display: inline-block;
  width: 0;
  height: 0;
  margin-top: -1px;
  margin-left: 2px;
  vertical-align: middle;
  border-top:   @caret-width-base dashed;
  border-top:   @caret-width-base solid ~"\9"; // IE8
  border-right: @caret-width-base solid transparent;
  border-left:  @caret-width-base solid transparent;
}

// The dropdown wrapper (div)
.wphr-dropup,
.wphr-dropdown {
  position: relative;
}

// Prevent the focus on the dropdown toggle when closing dropdowns
.wphr-dropdown-toggle:focus {
  outline: 0;
}

// The dropdown menu (ul)
.wphr-dropdown-menu {
  position: absolute;
  top: 100%;
  left: 0;
  z-index: @zindex-dropdown;
  display: none; // none by default, but block on "open" of the menu
  float: left;
  min-width: 160px;
  padding: 5px 0;
  margin: 0; // override default ul
  list-style: none;
  font-size: @font-size-base;
  text-align: left; // Ensures proper alignment if parent has it changed (e.g., modal footer)
  background-color: @dropdown-bg;
  border: 1px solid @dropdown-fallback-border; // IE8 fallback
  border: 1px solid @dropdown-border;
  border-radius: 0;
  .box-shadow(0 6px 12px rgba(0,0,0,.175));
  background-clip: padding-box;

  // Aligns the dropdown menu to right
  //
  // Deprecated as of 3.1.0 in favor of `.wphr-dropdown-menu-[dir]`
  &.pull-right {
    right: 0;
    left: auto;
  }

  // Dividers (basically an hr) within the dropdown
  .divider {
    .nav-divider(@dropdown-divider-bg);
  }

  // Links within the dropdown menu
  > li > a {
    display: block;
    padding: 3px 20px;
    clear: both;
    font-weight: normal;
    line-height: @line-height-base;
    color: @dropdown-link-color;
    white-space: nowrap; // prevent links from randomly breaking onto new lines
    text-decoration: none;
  }
}

// Hover/Focus state
.wphr-dropdown-menu > li > a {
  &:hover,
  &:focus {
    text-decoration: none;
    color: @dropdown-link-hover-color;
    background-color: @dropdown-link-hover-bg;
  }
}

// Active state
.wphr-dropdown-menu > .active > a {
  &,
  &:hover,
  &:focus {
    color: @dropdown-link-active-color;
    text-decoration: none;
    outline: 0;
    background-color: @dropdown-link-active-bg;
  }
}

// Disabled state
//
// Gray out text and ensure the hover/focus state remains gray

.wphr-dropdown-menu > .disabled > a {
  &,
  &:hover,
  &:focus {
    color: @dropdown-link-disabled-color;
  }

  // Nuke hover/focus effects
  &:hover,
  &:focus {
    text-decoration: none;
    background-color: transparent;
    background-image: none; // Remove CSS gradient
    .reset-filter();
    cursor: @cursor-disabled;
  }
}

// Open state for the dropdown
.open {
  // Show the menu
  > .wphr-dropdown-menu {
    display: block;
  }

  // Remove the outline when :focus is triggered
  > a {
    outline: 0;
  }
}

// Menu positioning
//
// Add extra class to `.wphr-dropdown-menu` to flip the alignment of the dropdown
// menu with the parent.
.wphr-dropdown-menu-right {
  left: auto; // Reset the default from `.wphr-dropdown-menu`
  right: 0;
}
// With v3, we enabled auto-flipping if you have a dropdown within a right
// aligned nav component. To enable the undoing of that, we provide an override
// to restore the default dropdown menu alignment.
//
// This is only for left-aligning a dropdown menu within a `.navbar-right` or
// `.pull-right` nav component.
.wphr-dropdown-menu-left {
  left: 0;
  right: auto;
}

// Dropdown section headers
.wphr-dropdown-header {
  display: block;
  padding: 3px 20px;
  font-size: @font-size-small;
  line-height: @line-height-base;
  color: @dropdown-header-color;
  white-space: nowrap; // as with > li > a
}

// Backdrop to catch body clicks on mobile, etc.
.wphr-dropdown-backdrop {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  top: 0;
  z-index: (@zindex-dropdown - 10);
}

// Right aligned dropdowns
.pull-right > .wphr-dropdown-menu {
  right: 0;
  left: auto;
}

// Allow for dropdowns to go bottom up (aka, dropup-menu)
//
// Just add .wphr-dropup after the standard .wphr-dropdown class and you're set, bro.
// TODO: abstract this so that the navbar fixed styles are not placed here?

.wphr-dropup,
.navbar-fixed-bottom .wphr-dropdown {
  // Reverse the caret
  .caret {
    border-top: 0;
    border-bottom: @caret-width-base dashed;
    border-bottom: @caret-width-base solid ~"\9"; // IE8
    content: "";
  }
  // Different positioning for bottom up menu
  .wphr-dropdown-menu {
    top: auto;
    bottom: 100%;
    margin-bottom: 2px;
  }
}


// Component alignment
//
// Reiterate per navbar.less and the modified component alignment there.

@media (min-width: @grid-float-breakpoint) {
  .navbar-right {
    .wphr-dropdown-menu {
      .wphr-dropdown-menu-right();
    }
    // Necessary for overrides of the default right aligned menu.
    // Will remove come v4 in all likelihood.
    .wphr-dropdown-menu-left {
      .wphr-dropdown-menu-left();
    }
  }
}


// fix for wordpress button-group
.wp-core-ui .button-group.wphr-button-group > .button:last-of-type {
  -webkit-border-radius: 0 3px 3px 0;
  border-radius: 0 3px 3px 0;
}

.button-group > .button.wphr-dropdown-toggle {
    padding-left: 6px;
    padding-right: 6px;
}
