/* wrapper to center the switch */
.power-wrapper {
	display: flex;
	justify-content: center;
	align-items: center;
	padding: 2rem 0;
}

/* switch base */
.power-switch {
	position: relative;
	display: inline-block;
	width: 64px;
	height: 32px;
}

/* hide the checkbox */
.power-switch input {
	opacity: 0;
	width: 0;
	height: 0;
}

/* slider background */
.power-slider {
	position: absolute;
	cursor: pointer;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	background: linear-gradient(to bottom, #2c2c2c, #1a1a1a);
	border-radius: 6px;
	box-shadow: inset 1px 1px 4px rgba(255, 255, 255, 0.2),
		inset -1px -1px 2px rgba(0, 0, 0, 0.5);
	transition: background 0.4s;
}

/* metallic knob */
.power-slider::before {
	position: absolute;
	content: '';
	height: 24px;
	width: 24px;
	left: 4px;
	bottom: 4px;
	background: radial-gradient(circle at 20% 20%, #cfcfcf, #777);
	box-shadow: inset -1px -1px 1px #333, inset 1px 1px 1px #fff,
		2px 2px 4px rgba(0, 0, 0, 0.5);
	border-radius: 4px;
	transition: 0.4s;
}

/* move knob when checked */
.power-switch input:checked + .power-slider::before {
	transform: translateX(32px);
}

/* label styling */
.power-slider .label-i,
.power-slider .label-o {
	position: absolute;
	top: 50%;
	transform: translateY(-50%);
	font-size: 18px;
	font-family: 'Oxanium', sans-serif;
	font-weight: 700;
	pointer-events: none;
	transition: opacity 0.3s;
}

/* light mode text */
body:not(.dark) .power-slider .label-i {
	left: 8px;
	color: white;
}

body:not(.dark) .power-slider .label-o {
	right: 8px;
	color: black;
}

/* dark mode text */
body.dark .power-slider .label-i {
	left: 8px;
	color: white;
}

body.dark .power-slider .label-o {
	right: 8px;
	color: white;
}

/* show/hide I and O depending on checked state */
.power-switch input:checked + .power-slider .label-i {
	opacity: 0;
}

.power-switch input:checked + .power-slider .label-o {
	opacity: 1;
}

.power-switch input:not(:checked) + .power-slider .label-i {
	opacity: 1;
}

.power-switch input:not(:checked) + .power-slider .label-o {
	opacity: 0;
}
