/* Lightning Design System 0.9.1 */
// Copyright (c) 2015, salesforce.com, inc. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
// Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
// Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
// Neither the name of salesforce.com, inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.



// If you have a horizontal list and want a dot as a list item separator
//
// Use - apply to repeating list items
@mixin gradient-horizontal($start, $end, $direction: right) {

  @if alpha($start) == 1 and alpha($end) == 1 {
    background-color: $start;
    background-image: linear-gradient(to $direction, rgba($start,0), $end);
  }

  @else {
    background-image: linear-gradient(to $direction, $start, $end);
  }
}



@mixin gradient-vertical($start, $end, $direction: bottom) {

  @if alpha($start) == 1 and alpha($end) == 1 {
    background-color: $start;
    background-image: linear-gradient(to $direction, rgba($start,0), $end);
  }

  @else {
    background-image: linear-gradient(to $direction, $start, $end);
  }
}



@mixin dot-separator($size: 4px, $color: $color-background-alt-inverse) {
  position: relative;

  &:after {
    @include square($size);
    content: '';
    display: inline-block;
    vertical-align: middle;
    margin: {
      left: $spacing-x-small;
      right: $spacing-x-small;
    }
    border-radius: $border-radius-circle;
    background-color: $color;
  }

  &:last-child {
    margin-right: 0;
    padding-right: 0;

    &:after {
      content: none;
    }
  }

  @include mq-medium-max {

    &:before {
      @include square($size);
      content: '';
      display: inline-block;
      vertical-align: middle;
      border-radius: $border-radius-circle;
      background-color: $color;
      margin-right: $spacing-small;
    }

    &:after {
      content: none;
    }
  }
}



// Inverse Links
@mixin inverse-links {
  color: $color-text-inverse;

  a:not(.#{$css-prefix}button--neutral) {
    color: $color-text-link-inverse;
    text-decoration: underline;

    &:link,
    &:visited {
      color: $color-text-link-inverse;
    }

    &:hover,
    &:focus {
      color: $color-text-link-inverse-hover;
    }

    &:active {
      color: $color-text-link-inverse-active;
    }

    &[disabled] {
      color: $color-text-link-inverse-disabled;
    }
  }
}



// Border Helper
@mixin border($borders: null) {

  @if $borders != null {

    @if $borders == around {
      border: $border-width-thin solid $color-border;
    }

    @else {

      @each $positions in $borders {

        @each $position in $positions {
          border-#{$position}: $border-width-thin solid $color-border;
        }
      }
    }
  }
}



// Theme Helper
@mixin theme($theme, $borders: null) {

  @if $theme == shade {
    background-color: $color-background;
  }

  @elseif $theme == inverse {
    background-color: $color-background-inverse;
    @include inverse-links;
  }

  @elseif $theme == alt-inverse {
    background-color: $color-background-alt-inverse;
    @include inverse-links;
  }

  @elseif $theme == brand {
    background-color: $color-background-modal-brand;
    @include inverse-links;
  }

  @else {
    background-color: $color-background-alt;
  }

  @include border($borders);
}



// Bounding Box for components
@mixin box($theme: null, $padding: $spacing-medium, $border-radius: $border-radius-medium, $borders: null) {
  padding: $padding;

  @if $border-radius != null {
    border-radius: $border-radius;
    background-clip: padding-box;
  }

  @if $theme != null and $borders == null {
    @include theme($theme);
  }

  @elseif $theme != null and $borders != null {
    @include theme($theme, $borders);
  }

  @elseif $theme == null and $borders != null {
    @include border($borders);
  }
}



// Apply theme on hover for list items
@mixin list-has-hovers {

  &:hover,
  &:focus {
    background-color: $color-background-row-hover;
    border-color: $color-border;
  }

  &:active {
    background-color: $color-background-row-active;
    box-shadow: $color-border 0 ($border-width-thin * -1) 0 inset;
  }
}



// Apply theme on selection for list items
@mixin list-has-selections {

  &.#{$css-prefix}is-selected {
    box-shadow: $color-border-selection 0 0 0 $border-width-thin inset;
    background-color: $color-background-row-selected;

    &:hover,
    &:focus {
      box-shadow: $color-border-selection-hover 0 ($border-width-thick * -1) 0 inset, $color-border-selection-hover 0 0 0 $border-width-thin inset;
    }
  }
}

@mixin list-has-bullets {
  margin-left: $spacing-large;
  list-style: disc;
}

@mixin list-has-numbers {
  margin-left: $spacing-large;
  list-style: decimal;
}



// Striped Gradient
@mixin gradient-striped($stripe_color: rgba(black, .035), $angle: 45deg, $color: null) {

  @if $color != null {
    background-color: $color;
  }

  background-image: linear-gradient($angle, $stripe_color 25%, transparent 25%, transparent 50%, $stripe_color 50%, $stripe_color 75%, transparent 75%, transparent);
  background-size: 64px 64px
}



// Page header
@mixin page-header {
  padding: $spacing-large $spacing-large $spacing-small;
  border-bottom: $border-width-thin solid $color-border;
  background: $color-background;
}
