/*
.button-select

Markup: <label class="button-select button">
  <select>
    <option value="1">One</option>
    <option value="2">Two</option>
    <option value="3">Three</option>
  </select>
</label>

Styleguide: 3.button-select
*/

.button-select {
	display: block;
	/* There should never be padding on button-select, it's padding should be
	   managed by the select within. */
	padding: 0 !important;
	border: 1px solid #cccccc;
	height: 2.5rem;
}

.button-select > select {
	display: block;

	/* This is the native select, we're making everything but the text invisible
	   so we can see the button styles in the wrapper. */
	width: calc(100% + 2px);
	max-width: none;
	height: calc(100% + 2px);
	margin: -1px;
	padding-top: 0;
	padding-bottom: 0;
	padding-left: 0.75rem;
	padding-right: 0;
	outline: none;
	border: 1px solid transparent;
	border-radius: inherit;

	/* Prefixed box-sizing rules necessary for older browsers */
	-webkit-box-sizing: border-box;
	   -moz-box-sizing: border-box;
	        box-sizing: border-box;
}

.button-select::before {
	content: '';
	box-sizing: border-box;
	position: absolute;
	top: 0;
	right: 0;
	width: 2.4375rem; /* Match-01 */
	height: 100%;
	border-width: 0;
	border-left-width: inherit;
	border-style: inherit;
	border-color: transparent;
	border-top-left-radius: 0;
	border-bottom-left-radius: 0;
	border-top-right-radius: inherit;
	border-bottom-right-radius: inherit;
	pointer-events: none;
}

.button-select::after {
	/* Custom arrow sits on top of the select - could be an image, SVG, icon
	   font, etc. or the arrow could just baked into the bg image on the select. */
	content: "";
	position: absolute;
	top: 50%;
	right: 0.875rem;
	height: 0;
	margin-top: -3px;
	border-top: 6px solid currentcolor;
	border-left: 6px solid rgba(0, 0, 0, 0);
	border-right: 6px solid rgba(0, 0, 0, 0);
	-webkit-transition: transform 200ms linear;
	transition: transform 200ms linear;
	z-index: 2;

	/* These hacks make the select behind the arrow clickable in some browsers */
	pointer-events: none;
	display: none;
	pointer-events: none;
}

@supports ( -webkit-appearance: none ) or ( appearance: none )
	/* Firefox <= 34 has a false positive on @supports( -moz-appearance: none )
	   @supports ( mask-type: alpha ) is Firefox 35+ */
	or ( ( -moz-appearance: none ) and ( mask-type: alpha ) ) {
	/* Show custom arrow */
	.button-select::after {
		display: block;
	}

	/* Remove select styling */
	.button-select > select {
		padding-right: 2.4375rem; /* Match-01 */
		/* inside @supports so that iOS <= 8 display the native arrow */
		background: none; /* Match-04 */
		/* inside @supports so that Android <= 4.3 display the native arrow */
		border-width: 1px; /* Match-05 */

		-webkit-appearance: none;
		   -moz-appearance: none;
		        appearance: none;
	}
}
