/*---------------------------------------------------------------------------------------------
 *  Copyright (c) Microsoft Corporation. All rights reserved.
 *  Licensed under the MIT License. See License.txt in the project root for license information.
 *--------------------------------------------------------------------------------------------*/

.monaco-switch {
	position: relative;
	/* Lets the thumb size itself from the track's inner height with `cqh`. */
	container-type: size;
	flex: 0 0 auto;
	width: var(--vscode-spacing-size280);
	height: var(--vscode-spacing-size160);
	padding: 0;
	border: var(--vscode-strokeThickness) solid transparent;
	border-radius: var(--vscode-cornerRadius-circle);
	background: color-mix(in srgb, var(--vscode-descriptionForeground) 36%, transparent);
	cursor: pointer;
	transition: background-color 120ms ease, border-color 120ms ease;
}

.monaco-switch.checked {
	background: var(--vscode-button-background);
	border-color: var(--vscode-button-background);
}

.monaco-switch:disabled {
	cursor: default;
	opacity: 0.5;
}

.monaco-switch:focus-visible {
	outline: var(--vscode-strokeThickness) solid var(--vscode-focusBorder);
	outline-offset: var(--vscode-spacing-size20);
}

/* The thumb fills the track's inner height and is inset by its own transparent border,
 * so every gap around it is made of borders. Borders snap to whole device pixels, so
 * the gaps stay equal at any display scale or zoom, where fixed offsets round unevenly.
 * Style the thumb with `background-color`, as `background` would reset the clip. */
.monaco-switch-thumb {
	position: absolute;
	top: 0;
	bottom: 0;
	left: 0;
	box-sizing: border-box;
	width: 100cqh;
	border: var(--vscode-strokeThickness) solid transparent;
	border-radius: var(--vscode-cornerRadius-circle);
	background-color: var(--vscode-button-foreground);
	background-clip: padding-box;
	transition: left 120ms ease;
}

.monaco-switch.checked .monaco-switch-thumb {
	left: calc(100% - 100cqh);
}

/* The workbench marks high contrast with `.hc-black` / `.hc-light`; `.vscode-high-contrast`
 * is the webview equivalent, and the switch is rendered in both. */
.hc-black .monaco-switch,
.hc-light .monaco-switch,
.vscode-high-contrast .monaco-switch {
	border-color: var(--vscode-contrastBorder);
}

.monaco-reduce-motion .monaco-switch,
.monaco-reduce-motion .monaco-switch-thumb {
	transition: none;
}
