//
// Buttons
// ==============================




// Base styles
// ------------------------------

.Button {
	.user-select(none);
	background: none;
	border: 1px solid transparent;
	border-radius: @border-radius-base;
	cursor: pointer;
	display: inline-block;
	font-weight: @button-font-weight;
	line-height: @component-line-height;
	height: @component-height;
	margin-bottom: 0;
	overflow: hidden; // contain gradient on IE9
	padding: 0 @button-padding-horizontal;
	text-align: center;
	touch-action: manipulation;
	vertical-align: middle;
	white-space: nowrap;
	-webkit-appearance: none;

	&:hover,
	&:focus,
	&.focus,
	&.is-focus {
		color: @button-default-color;
		text-decoration: none;
	}

	&:active,
	&.active,
	&.is-active {
		background-image: none;
		outline: 0;
	}

	&.disabled,
	&[disabled] {
		opacity: .4;
		pointer-events: none;
	}
}




// Button Variants
// ------------------------------


// special case for the default button

.Button--default {
	#gradient .vertical(#fafafa, #eaeaea);
	border: 1px solid @input-border-color;
	border-color: @input-border-color darken(@input-border-color, 6%) darken(@input-border-color, 12%);
	color: @text-color;
	text-shadow: 0 1px 0 white;


	&:hover {
		#gradient .vertical(#fff, #eee);
		border-color: darken(@input-border-color, 5%) darken(@input-border-color, 5%) darken(@input-border-color, 10%);
		box-shadow: 0 1px 0 rgba(0,0,0,0.1);
		color: @text-color;
	}
	&:focus {
		border-color: @app-primary;
		box-shadow: 0 0 0 3px fade(@app-primary, 10%);
		color: @text-color;
		outline: none;
	}
	&.is-active,
	&:active {
		background: #e6e6e6;
		border-color: darken(@input-border-color, 10%);
		box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1);
		color: @text-color;
	}

	// yuck...
	&.is-active:focus:not(:active) {
		border-color: @app-primary;
		box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1), 0 0 0 3px fade(@app-primary, 10%);
	}

	&.disabled,
	&[disabled] {
		background-color: @button-default-disabled-bg;
	}
}

// default styles

.Button--default-primary {
	.button-default-variant(@button-primary-color);
}
.Button--default-success {
	.button-default-variant(@button-success-color);
}
.Button--default-warning {
	.button-default-variant(@button-warning-color);
}
.Button--default-danger {
	.button-default-variant(@button-danger-color);
}


// fill styles

.Button--primary {
	.button-variant(white; @button-primary-bg);
}
.Button--success {
	.button-variant(white; @button-success-bg);
}
.Button--warning {
	.button-variant(white; @button-warning-bg);
}
.Button--danger {
	.button-variant(white; @button-danger-bg);
}


// hollow styles

.Button--hollow-primary {
	.button-hollow-variant(@button-primary-color; @button-primary-border);
}
.Button--hollow-success {
	.button-hollow-variant(@button-success-color; @button-success-border);
}
.Button--hollow-warning {
	.button-hollow-variant(@button-warning-color; @button-warning-border);
}
.Button--hollow-danger {
	.button-hollow-variant(@button-danger-color; @button-danger-border);
}




// Link buttons
// -------------------------

// Make a button look and behave like a link
.Button--link {
	.button-link-variant(@link-color; @link-hover-color; @link-hover-decoration);
}

// Make a button look and behave like text.
.Button--link-text {
	.button-link-variant(@text-color; @app-primary; @link-hover-decoration);
}

.Button--link-primary {
	.button-link-variant(@app-primary; @app-primary; @link-hover-decoration);
}
.Button--link-success {
	.button-link-variant(@app-success; @app-success; @link-hover-decoration);
}
.Button--link-warning {
	.button-link-variant(@app-warning; @app-warning; @link-hover-decoration);
}
.Button--link-danger {
	.button-link-variant(@app-danger; @app-danger; @link-hover-decoration);
}

// Some special link button styles.
.Button--link-cancel {
	.button-link-variant(@gray-light; @app-danger; @link-hover-decoration);
}
.Button--link-delete {
	.button-link-variant(@gray-light; @app-danger; @link-hover-decoration);
	&:hover,
	&:focus {
		#gradient .vertical(lighten(@app-danger, 4%), darken(@app-danger, 4%));
		background-color: @app-danger;
		border-color: darken(@app-danger, 4%) darken(@app-danger, 8%) darken(@app-danger, 12%);
		box-shadow: 0 1px 0 rgba(0,0,0,0.1);
		color: white;
		text-decoration: none;
	}
	&:focus {
		box-shadow: 0 0 0 3px fade(@app-danger, 25%);
		outline: none;
	}
	&:active {
		background-color: darken(@app-danger, 4%);
		background-image: none !important;
		border-color: darken(@app-danger, 12%) darken(@app-danger, 8%) darken(@app-danger, 8%);
		box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1);
		color: white;
	}
}




// Button Sizes
// ------------------------------

.Button--lg { font-size: @font-size-lg; }
.Button--sm { font-size: @font-size-sm; }
.Button--xs {
	font-size: @font-size-xs;
	line-height: 1.9;
	padding-left: .66em;
	padding-right: .66em;
}




// Block button
// ------------------------------

.Button--block {
	display: block;
	padding-left: 0;
	padding-right: 0;
	width: 100%;
}




// Button Goups
// ------------------------------

.ButtonGroup {
	display: inline-block;
	position: relative;
	vertical-align: middle;

	> .Button {
		border-radius: 0;
		float: left;
		margin-left: -1px;

		&:first-child {
			.border-left-radius(@border-radius-base);
			margin-left: 0;
		}
		&:last-child {
			.border-right-radius(@border-radius-base);
		}
		&:hover,
		&:active,
		&:focus {
			position: relative;
		}
		// circumvent bug where adjacent siblings would overlap on hover
		&:focus {
			z-index: 1;
		}
	}
}




// Handle icons inside buttons
// ------------------------------

.Button > .octicon {
	&:first-child { margin-right: 0.5em; }
	&:last-child  { margin-left:  0.5em; }
	&:only-child {
		margin-left: 0;
		margin-right: 0;
	}
}
