:root {
	--primary-color: #204f6e;
	--secondary-color: #6c757d;
	--dark-color: #333333;
	--light-color: #f4f4f4;
	--danger-color: #dc3545;
	--success-color: #28a745;

	--header-height: 2rem;
}

* {
	box-sizing: border-box;
	margin: 0;
	padding: 0;
}

body {
	font-family: Arial, Helvetica, sans-serif;
	overscroll-behavior-y: none;
	/* overscroll-behavior: none; */
	overscroll-behavior-block: none;
	/* touch-action: pan-y pan-x; */
	touch-action: none;
}

/* ======================= Backdrop ===================== */
#distCalcBackdrop {
	display: flex;
	align-items: center;
	justify-content: center;
	position: fixed;
	top: 0;
	left: 0;
	width: 100vw;
	height: 100dvh;
	background-color: rgba(0, 0, 0, 0.3);
	transition: 300ms;
	overflow: hidden;
}

/* ======================= Calculator ===================== */
#distCalc {
	position: relative;
	display: grid;
	grid-template-rows: auto auto minmax(0, 1fr);
	width: 80%;
	min-width: 250px;
	max-width: 350px;
	/* height: 50%; */
	min-height: 575px;
	background-color: #9ea3a8;
	padding: 8px;
	border: 5px solid #888;
	border-radius: 10px;
	overflow: hidden;

	overscroll-behavior-y: none;
	overscroll-behavior-block: none;
	touch-action: none;
}

/* ======================= Nav ===================== */
#distCalc nav {
	display: grid;
	grid-template-columns: 1fr auto 1fr;
	grid-template-rows: var(--header-height);
	align-items: center;
	margin-bottom: 0.25rem;
	font-size: 1.2rem;
	line-height: 1.2rem;
	white-space: nowrap;
	overflow: hidden;
}

#distCalc nav .center {
	font-weight: bold;
}

#distCalc nav > *:last-child {
	display: flex;
	justify-content: end;
	text-align: right;
}

#cwLogo {
	height: var(--header-height);
}

/* ======================= Calc. Display ===================== */
#distCalc .display {
	background-color: black;
	color: white;
	margin-bottom: 0.5rem;
	border-radius: 3px;
	overflow: hidden;
}

#distCalc .display .header {
	display: flex;
	height: 1.5rem;
	line-height: 1.5rem;
	font-size: 1.1rem;
	/* border-bottom: 1px solid white; */
	justify-content: space-between;
	padding: 0 0.25rem;
}

#distCalc .input {
	display: flex;
	justify-content: end;
	height: 3.5rem;
	line-height: 3.5rem;
	font-size: 2.5rem;
	text-align: right;
}

#distCalc .display .main {
	padding: 0 0.5rem;
	white-space: nowrap;
	overflow-x: auto;
	overflow-y: hidden;
}

#distCalc .display .main.invalid {
	color: red;
}

#distCalc .display .equation {
	display: flex;
	justify-content: end;
	height: 1.5rem;
	line-height: 1.5rem;
	font-size: 1.1rem;
	/* border-top: 1px solid white; */
	text-align: right;
	padding: 0 0.25rem;
}

#distCalc .display .equation .operator,
#distCalc .display .equation .equals {
	padding: 0 0.25rem;
}

/* #distCalc .display .history {
	height: 1.5rem;
	line-height: 1.5rem;
	border-top: 1px solid white;
	text-align: right;
	padding: 0 0.25rem;
} */

/* ======================= Keyboard ===================== */
#distCalc .keyboard {
	display: grid;
	grid-template-rows: 0.8fr 1fr 6fr auto;
	min-height: 100%;
}
/* ======================= All Keyboard buttons ===================== */
#distCalc .keyboard [data-keyval] {
	font-size: 2.2rem;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	/* border-width: 1px; */
	/* border-style: outset; */
	/* border-radius: 5px; */
}

/* ======================= Calc. Keyboard ===================== */
#distCalc .keyboard .calculator {
	display: grid;
	grid-template-columns: repeat(4, 1fr);
	grid-template-rows: repeat(5, minmax(50px, auto));
	gap: 0.5rem;
}

#distCalc .calculator button {
	border-width: 1px;
	border-style: outset;
	border-radius: 2px;
	background-color: #bbb;
	user-select: none;
}

#distCalc .calculator button:hover {
	background-color: #ccc;
}

#distCalc .calculator button:active {
	border-style: inset;
}

#distCalc .calculator [data-keyval="C"],
#distCalc .calculator [data-keyval="AC"] {
	background-color: darkorange;
	color: var(--light-color);
}

#distCalc .calculator [data-keyval="C"]:hover,
#distCalc .calculator [data-keyval="AC"]:hover {
	background-color: rgb(255, 149, 20);
}

#distCalc [data-keyval="C"],
#distCalc [data-keyval="AC"],
#distCalc [data-keyval="="] {
	grid-column: span 2;
}

/* ======================= Unit None/Imperial Keyboard ===================== */

/* Only on non-touch screen */
@media not screen and (any-pointer: coarse) {
	#distCalc .keyboard .system::-webkit-scrollbar {
		height: 0.5rem;
		translate:
			0,
			-10px;
		/* transform: translateY(-10px); */
	}

	#distCalc .keyboard .system::-webkit-scrollbar-track {
		background-color: darkslategray;
		border-radius: 100vw;
		/* border: 3px dashed hotpink; */
	}

	#distCalc .keyboard .system::-webkit-scrollbar-thumb {
		background-color: lightgray;
		border-radius: 100vw;
	}

	#distCalc .keyboard .system::-webkit-scrollbar-thumb:hover {
		background-color: white;
	}

	#distCalc .keyboard .system .photoContainer {
		padding-bottom: 0.5rem;
	}
}

#distCalc .keyboard .system {
	/* display: grid; */
	/* grid-template-rows: 1fr; */

	display: grid;
	grid-template-columns: 100% 100%;
	gap: 8px;
	overflow-x: scroll;
	scroll-behavior: smooth;
	scroll-snap-type: x mandatory;
}

#distCalc .keyboard .system > * {
	display: grid;
	grid-template-columns: repeat(4, 1fr);
	gap: 0.5rem;
	margin-bottom: 0.5rem;
	scroll-snap-align: start;
}

#distCalc .keyboard .system button {
	border-width: 1px;
	border-style: outset;
	border-radius: 2px;
	background-color: #28a745;
}

#distCalc .keyboard .system button sup {
	font-size: 1rem;
	align-self: start;
}

#distCalc .keyboard .system button .superScript {
	font-size: 1rem;
	vertical-align: top;
}

#distCalc .keyboard .system button:hover {
	background-color: #3ad05d;
}

#distCalc .keyboard .system button:active {
	border-style: inset;
}

/* ======================= Memory Keyboard ===================== */

#distCalc .keyboard .memory {
	display: grid;
	grid-template-columns: repeat(4, 1fr);
	grid-template-rows: repeat(1, minmax(40px, auto));
	gap: 0.5rem;
	margin-bottom: 0.5rem;
}

#distCalc .keyboard .memory button {
	font-size: 2rem;
	border-width: 1px;
	border-style: outset;
	border-radius: 2px;
	background-color: #2848a7;
	color: white;
}

#distCalc .keyboard .memory button:hover {
	background-color: #365ccd;
}

#distCalc .keyboard .memory button:active {
	border-style: inset;
}

/* ======================= Resolve Keyboard ===================== */

#distCalc .keyboard .resolve {
	display: grid;
	grid-template-columns: repeat(2, 1fr);
	grid-template-rows: repeat(1, minmax(40px, auto));
	gap: 0.5rem;
	margin-top: 0.5rem;
}

/* ======================= Slide out menu ===================== */

#slideOutOpenBtn,
#slideOut .closeBtn {
	cursor: pointer;
}

#slideOutBackdrop {
	position: absolute;
	width: 100%;
	height: 100%;
	background-color: rgba(0, 0, 0, 0.5);
	transform: translateX(-105%);
	transition: transform 200ms ease-in-out;
	border-radius: 5px;
}

#slideOutBackdrop.show {
	transform: translateX(0);
}

#slideOut {
	position: absolute;
	max-width: 60%;
	height: 100%;
	background-color: rgba(248, 249, 250, 0.9);
	transform: translateX(-105%);
	padding: 0.25rem 0.25rem;
	transition: transform 200ms ease-in-out;
	/* border-top-left-radius: 5px; */
	/* border-bottom-left-radius: 5px; */
}

#slideOut.show {
	transform: translateX(0);
}

#slideOut .closeBtn {
	text-align: right;
	font-size: 1.5rem;
	cursor: pointer;
	position: sticky;
	top: 0;
}

#slideOut fieldset {
	padding: 0 0.25rem 0.25rem;
	border-radius: 0.2rem;
	margin-bottom: 0.5rem;
	line-height: 1.25rem;
}

#slideOut #settingPrecision {
	width: 4ch;
}

#slideOut input[type="checkbox"],
#slideOut input[type="checkbox"] + label,
#slideOut input[type="radio"],
#slideOut input[type="radio"] + label,
#slideOut input[type="range"] {
	cursor: pointer;
}

#slideOut #settingPrecision {
	width: 100%;
}

#slideOut #showHistoryBtn {
	width: 100%;
	font-size: 1.25rem;
	color: var(--light-color);
	background-color: var(--primary-color);
	margin-bottom: 0.5rem;
	cursor: pointer;
}

#slideOut #showHelpBtn {
	width: 100%;
	font-size: 1.25rem;
	color: var(--light-color);
	background-color: var(--primary-color);
	cursor: pointer;
}

#slideOut #versionBadge {
	position: absolute;
	bottom: 0;
	right: 0;
	font-size: 0.75rem;
	padding: 0 0.25rem;
}

/* ======================= Help ===================== */

#help {
	position: absolute;
	min-width: 100%;
	height: 100%;
	background-color: rgba(248, 249, 250, 1);
	/* transform: translateX(105%); */
	transform: translateX(calc(100% + 2px));
	transition: transform 200ms ease-in-out;
	padding: 0.25rem 0.5rem;
	/* border-radius: 5px; */
	overflow: auto;
}

#help.show {
	transform: translateX(0);
}

#help .closeBtn {
	text-align: right;
	font-size: 1.5rem;
	cursor: pointer;
	position: sticky;
	top: 0;
}

#help .versionUpdate {
	font-weight: bold;
}

#help .helpContent ul {
	/* list-style-position: inside; */
	margin-left: 1rem;
}

/* ======================= History ===================== */

#distCalc .history .header {
	font-size: 1.25rem;
	font-weight: bold;
	text-align: center;
	background-color: black;
	border-bottom: 5px double var(--light-color);
}

#distCalc .history {
	display: grid;
	grid-template-rows: auto minmax(0, 1fr) auto;
	height: 100%;
	/* min-height: 100%; */
	/* max-height: 100%; */
	color: var(--light-color);
	background-color: var(--dark-color);
}

#distCalc .history .itemGrp {
	overflow-x: hidden;
	overflow-y: auto;
}

#distCalc .history .buttonGrp {
	display: grid;
	grid-template-columns: 1fr 1fr;
}

#distCalc .history button {
	cursor: pointer;
	font-size: 1rem;
	padding: 0.5rem 0;
}

#distCalc .history .buttonGrp .clear {
	color: var(--light-color);
	background-color: var(--secondary-color);
}

#distCalc .history .buttonGrp .close {
	color: var(--light-color);
	background-color: var(--primary-color);
}

#distCalc .history .equation {
	display: flex;
	justify-content: end;
	height: 1.5rem;
	line-height: 1.5rem;
	font-size: 1.1rem;
	border-bottom: 1px solid var(--light-color);
	text-align: right;
	padding: 0 0.25rem;
}

#distCalc .history .equation .operator,
#distCalc .history .equation .equals {
	padding: 0 0.25rem;
}

#distCalc .history .timeStamp {
	padding: 0.25rem 0 0 0.25rem;
	font-size: 0.75rem;
}
/* ======================= Media Query ===================== */

@media (max-width: 576px) {
	#distCalc {
		width: 100vw;
		height: 100dvh;
		max-width: 100vw;
		max-height: 100dvh;
		border: none;
		border-radius: 0;
	}

	#slideOut,
	#slideOutBackdrop,
	#help {
		border-radius: 0;
	}
}

/* ======================= Utility ===================== */
.d-none {
	display: none !important;
}

.pe-none {
	pointer-events: none !important;
}

.scale-0 {
	scale: 0 !important;
}
