/**
 * Breakpoint mixins
 */

@mixin break-huge() {
	@media ( min-width: #{ ( $break-huge ) } ) {
		@content;
	}
}

@mixin break-wide() {
	@media ( min-width: #{ ( $break-wide ) } ) {
		@content;
	}
}

@mixin break-large() {
	@media ( min-width: #{ ( $break-large ) } ) {
		@content;
	}
}

@mixin break-medium() {
	@media ( min-width: #{ ( $break-medium ) } ) {
		@content;
	}
}

@mixin break-small() {
	@media ( min-width: #{ ( $break-small ) } ) {
		@content;
	}
}

@mixin break-mobile() {
	@media ( min-width: #{ ( $break-mobile ) } ) {
		@content;
	}
}


/**
 * Long content fade mixin
 *
 * Creates a fading overlay to signify that the content is longer
 * than the space allows.
 */

@mixin long-content-fade( $direction: right, $size: 20%, $color: #fff, $edge: 0px, $z-index: false) {
	content: '';
	display: block;
	position: absolute;
	-webkit-touch-callout: none;
	-webkit-user-select: none;
	-khtml-user-select: none;
	-moz-user-select: none;
	-ms-user-select: none;
	user-select: none;
	pointer-events: none;

	@if $z-index {
		z-index: $z-index;
	}

	@if $direction == 'bottom' {
		background: linear-gradient( to top, rgba( $color, 0 ), $color 90% );
		left: $edge;
		right: $edge;
		top: $edge;
		bottom: calc(100% - $size);
		width: auto;
	}

	@if $direction == 'top' {
		background: linear-gradient( to bottom, rgba( $color, 0 ), $color 90% );
		top: calc(100% - $size);
		left: $edge;
		right: $edge;
		bottom: $edge;
		width: auto;
	}

	@if $direction == 'left' {
		background: linear-gradient( to left, rgba( $color, 0 ), $color 90% );
		top: $edge;
		left: $edge;
		bottom: $edge;
		right: auto;
		width: $size;
		height: auto;
	}

	@if $direction == 'right' {
		background: linear-gradient( to right, rgba( $color, 0 ), $color 90% );
		top: $edge;
		bottom: $edge;
		right: $edge;
		left: auto;
		width: $size;
		height: auto;
	}
}

/**
 * Editor Width mixin
 *
 * This mixin seeks to take the vinegar out of the responsive alignments in the editor.
 */

@mixin editor-width( $width ) {
	@media ( min-width: #{ ( $width ) } ) {
		@content;
	}
}

$content-width-padding: $content-width + $block-side-ui-padding + $block-side-ui-padding;
$float-margin: calc( 50% - #{ $content-width-padding / 2 } );

/**
 * Button states and focus styles
 */

// Buttons with rounded corners
@mixin button-style__disabled {
	opacity: 0.6;
	cursor: default;
}

@mixin button-style__hover {
	color: $dark-gray-900;
	box-shadow: inset 0 0 0 1px $light-gray-500, inset 0 0 0 2px $white, 0 1px 1px rgba( $dark-gray-900, .2 );
}

@mixin button-style__active() {
	outline: none;
	color: $dark-gray-900;
	box-shadow: inset 0 0 0 1px $light-gray-700, inset 0 0 0 2px $white;
}

@mixin button-style__focus-active() {
	color: $dark-gray-900;
	box-shadow: inset 0 0 0 1px $dark-gray-300, inset 0 0 0 2px $white;

	// Windows High Contrast mode will show this outline, but not the box-shadow
	outline: 2px solid transparent;
	outline-offset: -2px;
}

// Switch
@mixin switch-style__focus-active() {
	box-shadow: 0 0 0 2px $white, 0 0 0 3px $dark-gray-300;

	// Windows High Contrast mode will show this outline, but not the box-shadow
	outline: 2px solid transparent;
	outline-offset: 2px;
}

// Formatting Buttons
@mixin formatting-button-style__hover {
	color: $dark-gray-500;
	box-shadow: inset 0 0 0 1px $dark-gray-500, inset 0 0 0 2px $white;
}

@mixin formatting-button-style__active() {
	outline: none;
	color: $white;
	box-shadow: none;
	background: $dark-gray-500;
}

@mixin formatting-button-style__focus() {
	box-shadow: inset 0 0 0 1px $dark-gray-500, inset 0 0 0 2px $white;

	// Windows High Contrast mode will show this outline, but not the box-shadow
	outline: 2px solid transparent;
	outline-offset: -2px;
}

// Tabs, Inputs, Square buttons
@mixin input-style__neutral() {
	outline-offset: -1px;
	box-shadow: 0 0 0 transparent;
	transition: box-shadow .05s linear;
}

@mixin input-style__focus() {
	color: $dark-gray-900;
	outline: 1px solid $blue-medium-600;
	box-shadow: 0 0 0 2px $blue-medium-200;
}

// Square buttons
@mixin square-style__neutral() {
	outline-offset: -1px;
}

@mixin square-style__focus() {
	color: $dark-gray-900;
	outline: 1px solid $dark-gray-300;
	box-shadow: none;
}

// Menu items
@mixin menu-style__neutral() {
	border: none;
	box-shadow: none;
}

@mixin menu-style__focus() {
	color: $dark-gray-900;
	border: none;
	box-shadow: none;
	outline-offset: -2px;
	outline: 1px dotted $dark-gray-500;
}


/**
 * Applies editor left position to the selector passed as argument
 */
@mixin editor-left( $selector ) {
	#{$selector} {	/* Set left position when auto-fold is not on the body element. */
		left: 0;
		
		@include break-medium() {
			left: $admin-sidebar-width;
		}
	}

	.auto-fold #{$selector} {		/* Auto fold is when on smaller breakpoints, nav menu auto colllapses */
		@include break-medium() {
			left: $admin-sidebar-width-collapsed;
		}

		@include break-large() {
			left: $admin-sidebar-width;
		}
	}

	/* Sidebar manually collapsed */
	.folded #{$selector} {
		left: 0;

		@include break-medium() {
			left: $admin-sidebar-width-collapsed;
		}
	}

	/* Mobile menu opened */
	@media ( max-width: #{ ( $break-medium ) } ) {
		.auto-fold .wp-responsive-open #{$selector} {
			left: $admin-sidebar-width-big;
		}
	}

	/* In small screens with resposive menu expanded there is small white space */
	@media ( max-width: #{ ( $break-small ) } ) {
		.auto-fold .wp-responsive-open #{$selector} {
			margin-left: -18px;
		}
	}
}

/**
 * Applies editor right position to the selector passed as argument
 */
 @mixin editor-right( $selector ) {
	#{ $selector } {
		right: 0;
	}

	.edit-post-layout.is-sidebar-opened #{ $selector } {
		right: $sidebar-width;
	}
}
