
/* Basic layout */

:root {
	--settings-height: 40vh;
}

* {
	margin: 0;
	padding: 0;
}

html {
	font-family: -apple-system, BlinkMacSystemFont, "Roboto", "Helvetica Neue", sans-serif;
}

body {
	background: #444;
	text-align: center;
}

button {
	color: #888;
	background: none;
	border: .3vh solid #888;
	border-radius: 1vh;
	outline: none;
	cursor: pointer;
}




/* Content */

.content {
	opacity: 0.3;
	transition: opacity .5s, fill .5s;
}

body.connected .content {
	opacity: 1;
}




/* BB8 */

.content > div {
	position: absolute;
	top: 10vh;
	left: 10vw;
	width: 80vw;
	height: calc(100vh - var(--settings-height) - 28vh);
}

.content svg {
	position: absolute;
	left: 0;
	width: 100%;
	height: 100%;
}


/* Animation */

@keyframes rotate {
	0% {
		transform: rotate(360deg);
	}

	100% {
		transform: rotate(0deg);
	}
}


svg #ball {
	animation: 1s infinite linear paused rotate;
	transform-origin: 51% 65%;
}



@keyframes wobble {
	0% {
		transform: rotate(0deg);
	}

	50% {
		transform: rotate(15deg);
	}

	100% {
		transform: rotate(0deg);
	}
}

svg #head {
	animation: 3s infinite ease-in-out paused wobble;
	transform-origin: 51% 65%;
}

.forward svg #head,
.reverse svg #head,
.left svg #head,
.right svg #head,
.rolling svg #head {
	animation-play-state: running;
}



/* Settings */

.settings {
	position: absolute;
	top: calc(100vh - var(--settings-height));
	width: 100%;
	min-height: var(--settings-height);
	background: #333;

	transition: opacity .3s ease-in-out;
	opacity: 0.3;
	pointer-events: none;
}
body.connected .settings {
	opacity: 1;
	pointer-events: auto;
}



/* Pills */

.pills {
	margin-top: -2.4vh;
	margin-bottom: 0;
	display: flex;
}
.pills button {
	margin: 0;
	padding: 1vh 2vh;
	border-radius: 0;
	border-left: none;
	font-size: 2vh;
	background: #333;
}
.pills button:first-of-type {
	border-left: .3vh solid #888;
	border-top-left-radius: 1vh;
	border-bottom-left-radius: 1vh;
	margin-left: auto;
}
.pills button:last-of-type {
	border-top-right-radius: 1vh;
	border-bottom-right-radius: 1vh;
	margin-right: auto;
}

body.control button#control,
body.calibrate button#calibrate,
body.map button#map {
	background: #888;
	color: #fff;
}





/* Views */

.views {
	padding: 6vh 0;
	min-height: 6vh;
	display: block;
}
.views > div {
	display: none;
}

body.control div#controlView {
	display: flex;
	justify-content: center;
	padding: 3vh 0;
}

body.calibrate div#calibrateView,
body.map div#mapView {
	display: block;
}











/* Calibrate */

#calibrateView {
	padding-top: 2vh;
}
#calibrateView div {
	display: flex;
	flex-direction: column;
}
#calibrateView div > * {
	margin: 0 auto;
}
#calibrateView svg {
	fill: #fff;
	width: 20vh;
	height: 20vh;
	margin-bottom: 5vh;

	transition: transform 0.3s linear;
}

input[type=range] {
	-webkit-appearance: none;
	width: 50vw;
	background: transparent;
  }

  input[type=range]::-webkit-slider-thumb {
	-webkit-appearance: none;
  }

  input[type=range]:focus {
	outline: none;
  }

  input[type=range]::-webkit-slider-thumb {
	-webkit-appearance: none;

	background: #444;
	border: .3vh solid #888;
	border-radius: 1vh;
	height: 6vh;
	width: 3vh;
	cursor: pointer;

	margin-top: -3vh;
}

  input[type=range]::-webkit-slider-runnable-track {
	width: 100%;
	height: .3vh;
	cursor: pointer;
	background: #888;
	border-radius: .3vh;
	border: 10px solid #333;
	box-sizing: content-box;
  }

  input[type=range]:focus::-webkit-slider-runnable-track {
	background: #367ebd;
  }



/* Emulation display */

#emulationInfo {
	display: none;
	position: absolute;
	bottom: calc(var(--settings-height) + 5vh);
	left: 50%;
	transform: translateX(-50%);
	flex-direction: column;
	align-items: center;
	color: #888;
	gap: 1vh;
}

body.emulate #emulationInfo {
	display: flex;
}

#emulationArrow {
	font-size: 6vh;
	line-height: 1;
	display: block;
	transition: transform 0.15s ease;
}

#emulationStats {
	display: flex;
	gap: 3vh;
}

.emulationStat {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 0.3vh;
}

.emulationStat span {
	font-size: 3vh;
	font-weight: bold;
}

.emulationStat label {
	font-size: 1.5vh;
	color: #666;
}



/* Map */

#mapView button {
	padding: 1vh 2vh;
	border: 0;
	font-size: 2vh;
	color: #ddd;
}
#mapView button svg {
	fill: #ddd;
	width: 4vh;
	height: 4vh;
	vertical-align: top;
	margin-top: -0.9vh;
}

#mapView canvas {
	cursor: crosshair;
	width: 100vw;
	height: 49vh;
  }



/* Joystick */

#joystickBase {
	position: relative;
	width: 24vh;
	height: 24vh;
	border-radius: 50%;
	border: .3vh solid #888;
	touch-action: none;
	user-select: none;
}

#joystickHandle {
	position: absolute;
	width: 10vh;
	height: 10vh;
	border-radius: 50%;
	background: #888;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	pointer-events: none;
}



