// opacity
.opacity(@level: 0.5) {
  @opacityPercentage: @level * 100;
  -moz-opacity: @level;
  -khtml-opacity: @level;
  -webkit-opacity: @level;
  opacity: @level;
  -ms-filter: ~"progid:DXImageTransform.Microsoft.Alpha(opacity=(@{opacityPercentage}))";
  filter: ~"alpha(opacity = (@{opacityPercentage}))";
}

// box sizing
.box-sizing(@size: border-box) {
  -moz-box-sizing: @size;
  -webkit-box-sizing: @size;
  -ms-box-sizing: @size;
  box-sizing: @size;
}

// Convert to EMs (source: http://stackoverflow.com/a/23965840)
.convertEm(@amt) when (isem(@amt)) {
  font-size: @amt;
}

.convertEm(@amt, @emInPx: @font-size) when (ispixel(@amt)) {
  font-size: unit((@amt / @emInPx), em);
}

// font size
.font-size(@size) {
  .convertEm(@size);
  line-height: @line-height;
}

.bordered(@top-color: #EEE, @right-color: #EEE, @bottom-color: #EEE, @left-color: #EEE) {
  border-top: solid 1px @top-color;
  border-left: solid 1px @left-color;
  border-right: solid 1px @right-color;
  border-bottom: solid 1px @bottom-color;
}

// border radius
.border-radius(@radius: 2px) {
  -webkit-border-radius: @radius;
  -moz-border-radius: @radius;
  -ms-border-radius: @radius;
  -o-border-radius: @radius;
  border-radius: @radius;
}
.border-radius(@topright: 0, @bottomright: 0, @bottomleft: 0, @topleft: 0) {
  -webkit-border-top-right-radius: @topright;
  -webkit-border-bottom-right-radius: @bottomright;
  -webkit-border-bottom-left-radius: @bottomleft;
  -webkit-border-top-left-radius: @topleft;
  -moz-border-radius-topright: @topright;
  -moz-border-radius-bottomright: @bottomright;
  -moz-border-radius-bottomleft: @bottomleft;
  -moz-border-radius-topleft: @topleft;
  border-top-right-radius: @topright;
  border-bottom-right-radius: @bottomright;
  border-bottom-left-radius: @bottomleft;
  border-top-left-radius: @topleft;
  .background-clip(padding-box);
}

// box shadow
.box-shadow(@x, @y, @blur, @color) {
  -webkit-box-shadow: @arguments;
  -moz-box-shadow: @arguments;
  -ms-box-shadow: @arguments;
  -o-box-shadow: @arguments;
  box-shadow: @arguments;
}
.inner-shadow(@horizontal:0, @vertical:1px, @blur:2px, @alpha: 0.4) {
  -webkit-box-shadow: inset @horizontal @vertical @blur rgba(0, 0, 0, @alpha);
  -moz-box-shadow: inset @horizontal @vertical @blur rgba(0, 0, 0, @alpha);
  box-shadow: inset @horizontal @vertical @blur rgba(0, 0, 0, @alpha);
}
.drop-shadow(@x-axis: 0, @y-axis: 1px, @blur: 2px, @alpha: 0.1) {
  -webkit-box-shadow: @x-axis @y-axis @blur rgba(0, 0, 0, @alpha);
  -moz-box-shadow: @x-axis @y-axis @blur rgba(0, 0, 0, @alpha);
  box-shadow: @x-axis @y-axis @blur rgba(0, 0, 0, @alpha);
}

// outline
.outline(@style) {
  -moz-outline-style: @style;
  outline: @style;
}

// background
.background(@color, @image, @repeat, @scroll, @x, @y) {
  background: @color url(@image) @repeat @scroll @x @y;
}
.background-image(@image) {
  background: transparent url(@image) no-repeat scroll 0 0;
}

// text shadow
.text-shadow(@h-shadow, @v-shadow, @blur, @color) {
  text-shadow: @arguments;
}

// gradient
.gradient(@color: #F5F5F5, @start: #EEE, @stop: #FFF) {
  background: @color;
  background: -webkit-gradient(linear,
                               left bottom,
                               left top,
                               color-stop(0, @start),
                               color-stop(1, @stop));
  background: -ms-linear-gradient(bottom,
                                  @start,
                                  @stop);
  background: -moz-linear-gradient(center bottom,
                                   @start 0%,
                                   @stop 100%);
  background: -o-linear-gradient(@stop,
                                 @start);
  filter: e(%("progid:DXImageTransform.Microsoft.gradient(startColorstr='%d', endColorstr='%d', GradientType=0)",@stop,@start));
}
.bw-gradient(@color: #F5F5F5, @start: 0, @stop: 255) {
  background: @color;
  background: -webkit-gradient(linear,
                               left bottom,
                               left top,
                               color-stop(0, rgb(@start,@start,@start)),
                               color-stop(1, rgb(@stop,@stop,@stop)));
  background: -ms-linear-gradient(bottom,
                                  rgb(@start,@start,@start) 0%,
                                  rgb(@stop,@stop,@stop) 100%);
  background: -moz-linear-gradient(center bottom,
                                   rgb(@start,@start,@start) 0%,
                                   rgb(@stop,@stop,@stop) 100%);
  background: -o-linear-gradient(rgb(@stop,@stop,@stop),
                                 rgb(@start,@start,@start));
  filter: e(%("progid:DXImageTransform.Microsoft.gradient(startColorstr='%d', endColorstr='%d', GradientType=0)",rgb(@stop,@stop,@stop),rgb(@start,@start,@start)));
}
.linear-gradient(@start, @end) {
  background: @start;
  background: -webkit-gradient(linear, 0 0, 0 100%, from(@start) to(@end));
  background: -webkit-linear-gradient(@start, @end);
  background: -moz-linear-gradient(@start, @end);
  background: -ms-linear-gradient(@start, @end);
  background: -o-linear-gradient(@start, @end);
  background: linear-gradient(@start, @end);
  filter: e(%("progid:DXImageTransform.Microsoft.gradient(startColorstr='%d', endColorstr='%d', GradientType=0)",rgb(@end,@end,@end),rgb(@start,@start,@start)));
}

.transform(@arguments) {
  -webkit-transform: @arguments;
  -moz-transform: @arguments;
  -o-transform: @arguments;
  -ms-transform: @arguments;
  transform: @arguments;
}
.translate(@x: 0, @y: 0) {
  .transform(translate(@x, @y));
}
.scale(@ratio: 1.5){
  .transform(scale(@ratio));
}
.rotation(@deg: 5deg){
  .transform(rotate(@deg));
}

.user-select(@argument: none) {
  -webkit-user-select: @argument;
  -moz-user-select: @argument;
  -ms-user-select: @argument;
  user-select: @argument;
}

// background clip
.background-clip(@type: padding-box) {
  -webkit-background-clip: @type;
  -moz-background-clip: @type;
  background-clip: @type;
}

// transitions
.transition(@duration: 0.2s, @ease: ease-out) {
  -webkit-transition: all @duration @ease;
  -moz-transition: all @duration @ease;
  -ms-transition: all @duration @ease;
  -o-transition: all @duration @ease;
  transition: all @duration @ease;
}

.transition-duration(@duration: 0.2s) {
  -moz-transition-duration: @duration;
  -webkit-transition-duration: @duration;
  -o-transition-duration: @duration;
  transition-duration: @duration;
}

.inline-block(@percent: auto) {
  display: inline-block;
  width: @percent;
  padding-right: 2%;
  box-sizing: border-box;
  vertical-align: top;
  zoom: 1;

  .lt-ie8 & {
    display: inline;
  }

  &.last {
    padding-right: 0;
  }
}
