@use "@wordpress/base-styles/colors" as *;
@use "@wordpress/base-styles/variables" as *;
@use "@wordpress/base-styles/mixins" as *;

$components-custom-gradient-picker__padding: $grid-unit-20; // Center 16px handles in the 48px bar.

.components-custom-gradient-picker__gradient-bar {
	border-radius: $radius-small;
	width: 100%;
	height: $grid-unit-60;
	position: relative;
	z-index: 1;

	&.has-gradient {
		@include checkerboard-background( 12px );
	}

	.components-custom-gradient-picker__gradient-bar-background {
		position: absolute;
		inset: 0;
	}

	.components-custom-gradient-picker__markers-container {
		position: relative;
		width: calc(100% - #{ $grid-unit-60 });
		margin-left: auto;
		margin-right: auto;
	}

	.components-custom-gradient-picker__control-point-dropdown {
		position: absolute;
		height: $grid-unit-20;
		width: $grid-unit-20;
		top: $components-custom-gradient-picker__padding;
		// Trim any internal white spacing that would be cause d by inline positioned elements
		display: flex;
	}

	.components-custom-gradient-picker__insert-point-dropdown,
	.components-custom-gradient-picker__control-point-button {
		&::before {
			content: "";
			position: absolute;
			// Use the dropdown as the containing block to cover the bar's full
			// height without changing the handle or overlapping adjacent points.
			inset: -$components-custom-gradient-picker__padding 0;
		}
	}

	.components-custom-gradient-picker__insert-point-dropdown {
		// Same size as the .components-custom-gradient-picker__control-point-dropdown parent
		height: inherit;
		width: inherit;
		min-width: $grid-unit-20 !important;
		border-radius: $radius-round;

		background: $white;
		padding: 2px;

		color: $gray-900;

		svg {
			height: 100%;
			width: 100%;
		}
	}

	.components-custom-gradient-picker__control-point-button {
		// Same size as the .components-custom-gradient-picker__control-point-dropdown parent
		height: inherit;
		width: inherit;
		border-radius: $radius-round;
		padding: 0;

		// Shadow and stroke.
		box-shadow:
			inset 0 0 0 var(--wp-admin-border-width-focus) $white,
			0 0 $border-width-focus-fallback 0 rgba($black, 0.25);

		&.is-active {
			box-shadow:
				inset 0 0 0 calc(var(--wp-admin-border-width-focus) * 2) $white,
				0 0 $border-width-focus-fallback 0 rgba($black, 0.25);
		}

		&:focus:not(:active) {
			// Back Button's focus outline with 1px of solid color on both sides.
			outline-offset: 1px;
			box-shadow:
				inset 0 0 0 var(--wp-admin-border-width-focus) $white,
				0 0 $border-width-focus-fallback 0 rgba($black, 0.25),
				0 0 0 calc(var(--wpds-border-width-focus) + 2px)
				var(--wpds-color-background-surface-neutral-strong);

			&.is-active {
				box-shadow:
					inset 0 0 0 calc(var(--wp-admin-border-width-focus) * 2)
					$white,
					0 0 $border-width-focus-fallback 0 rgba($black, 0.25),
					0 0 0 calc(var(--wpds-border-width-focus) + 2px)
					var(--wpds-color-background-surface-neutral-strong);
			}
		}
	}
}

.components-custom-gradient-picker__remove-control-point-wrapper {
	padding-bottom: $grid-unit-10;
}

.components-custom-gradient-picker__inserter {
	/*rtl:ignore*/
	direction: ltr;
}

.components-custom-gradient-picker__liner-gradient-indicator {
	display: inline-block;
	flex: 0 auto;
	width: 20px;
	height: 20px;
}

.components-custom-gradient-picker__ui-line {
	position: relative;
	z-index: 0;
}
