/* xPix — page-specific pieces on top of xstudio.css */

/* ---------------------------------------------------------------- math sheet */

.px-field {
	display: flex;
	align-items: center;
	gap: 10px;
	height: 56px;
	padding: 0 14px;
	margin: 4px 4px 0;
	background: #000;
	border: 1px solid var(--rule-hi);
	--brk: var(--hl);
	--brk-inset: -4px;
	transition: border-color 160ms;
}

.px-field:focus-within {
	border-color: color-mix(in srgb, var(--hl) 50%, transparent);
}

.px-field.bad {
	--brk: var(--err);
	border-color: rgba(255, 45, 45, 0.5);
}

.px-out {
	flex: none;
	font-size: 10px;
	letter-spacing: 0.22em;
	color: var(--faint);
}

.px-field input {
	flex: 1;
	min-width: 0;
	height: 100%;
	background: none;
	border: 0;
	outline: none;
	font-size: 19px;
	letter-spacing: 0.04em;
	caret-color: var(--hl);
	user-select: text;
	-webkit-user-select: text;
}

.px-chan {
	display: grid;
	grid-template-columns: repeat(3, minmax(0, 1fr));
	gap: 1px;
	margin: 10px 4px 0;
	background: var(--rule);
	border: 1px solid var(--rule);
}

.px-chan div {
	background: var(--panel);
	padding: 6px 8px 7px;
	min-width: 0;
}

.px-chan small {
	display: flex;
	align-items: center;
	gap: 6px;
	font-size: 9px;
	letter-spacing: 0.24em;
	color: var(--dim);
}

.px-chan small i {
	width: 6px;
	height: 6px;
	background: var(--c);
}

.px-chan code {
	display: block;
	margin-top: 3px;
	font: inherit;
	font-size: 12px;
	color: var(--ink);
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.px-msg {
	margin: 8px 6px 0;
	min-height: 16px;
	font-size: 10.5px;
	letter-spacing: 0.06em;
	color: var(--dim);
}

.px-msg.bad {
	color: var(--err);
}

.px-msg b {
	color: var(--hl);
	font-weight: 400;
}

.px-label {
	margin: 14px 6px 8px;
	font-size: 9px;
	letter-spacing: 0.34em;
	color: var(--faint);
	text-transform: uppercase;
}

.px-presets {
	display: flex;
	gap: 8px;
	overflow-x: auto;
	padding: 4px 4px 8px;
	scrollbar-width: none;
	touch-action: pan-x;
	scroll-snap-type: x proximity;
}

.px-presets::-webkit-scrollbar {
	display: none;
}

.px-preset {
	flex: none;
	width: 84px;
	scroll-snap-align: start;
	border: 1px solid var(--rule-hi);
	background: #000;
	text-align: left;
	--brk-inset: -4px;
}

.px-preset img {
	display: block;
	width: 100%;
	height: 52px;
	object-fit: cover;
}

.px-preset span {
	display: block;
	padding: 5px 7px 6px;
	font-size: 9px;
	letter-spacing: 0.18em;
	color: var(--dim);
	text-transform: uppercase;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.px-preset em {
	display: block;
	padding: 0 7px 6px;
	margin-top: -3px;
	font-size: 8px;
	font-style: normal;
	letter-spacing: 0.2em;
	color: var(--faint);
}

.px-preset:hover {
	border-color: var(--dim);
}

.px-preset.on {
	border-color: var(--hl);
	box-shadow: var(--hl-glow);
}

.px-preset.on span {
	color: var(--hl);
}

.px-preset:not(.on)::after {
	display: none;
}

/* Keypad: hidden in the compact phone sheet, always shown when full / docked. */
.px-keywrap {
	display: none;
	margin-top: 6px;
}

.px-math.full .px-keywrap {
	display: block;
}

@media (min-width: 900px) {
	.px-keywrap {
		display: block;
	}
}

.px-fns {
	display: flex;
	gap: 6px;
	overflow-x: auto;
	padding: 4px 4px 8px;
	scrollbar-width: none;
	touch-action: pan-x;
}

.px-fns::-webkit-scrollbar {
	display: none;
}

.px-fns button {
	flex: none;
	height: 32px;
	padding: 0 11px;
	border: 1px solid var(--rule-hi);
	font-size: 12px;
	color: var(--dim);
}

.px-fns button:active {
	color: #000;
	background: var(--hl);
	border-color: var(--hl);
}

.px-keys {
	display: grid;
	grid-template-columns: repeat(6, minmax(0, 1fr));
	gap: 4px;
	padding: 0 4px;
}

.px-keys button {
	position: relative;
	height: 44px;
	background: var(--panel-2);
	border: 1px solid var(--rule);
	font-size: 17px;
	color: var(--ink);
	transition: background 90ms, color 90ms;
}

.px-keys button.op {
	color: var(--dim);
}

.px-keys button.var {
	font-weight: 700;
	background: #000;
	border-color: var(--rule-hi);
}

.px-keys button.var::before {
	content: "";
	position: absolute;
	left: 30%;
	right: 30%;
	bottom: 6px;
	height: 2px;
	background: var(--c, var(--faint));
	opacity: 0.8;
}

.px-keys button.var.dim {
	color: var(--faint);
}

.px-keys button:active,
.px-keys button.flash {
	background: var(--hl);
	color: #000;
	border-color: var(--hl);
}

/* Phone, full height: the keypad replaces the presets so the preview keeps room. */
@media (max-width: 899px) {
	.px-math.full .px-chan,
	.px-math.full .px-presets,
	.px-math.full .px-label {
		display: none;
	}

	.px-math.full .px-msg {
		margin-top: 6px;
	}

	body.math-on .xs-hud {
		display: none;
	}
}

@media (min-width: 900px) {
	#padBtn {
		display: none;
	}
}

#padBtn span {
	display: inline;
	font-size: 10px;
}

@media (max-height: 700px) {
	.px-keys button {
		height: 38px;
		font-size: 15px;
	}
}

/* ---------------------------------------------------------------- colour sheet */

.px-sv {
	position: relative;
	height: 168px;
	margin: 4px 4px 0;
	touch-action: none;
	--brk: var(--rule-hi);
	--brk-inset: -4px;
}

.px-sv canvas,
.px-hue canvas {
	display: block;
	width: 100%;
	height: 100%;
}

.px-sv i,
.px-hue i {
	position: absolute;
	width: 16px;
	height: 16px;
	margin: -8px 0 0 -8px;
	border: 1.5px solid #fff;
	box-shadow: 0 0 0 1px #000, var(--hl-glow);
	pointer-events: none;
}

.px-hue {
	position: relative;
	height: 26px;
	margin: 14px 4px 0;
	touch-action: none;
}

.px-hue i {
	top: 50%;
	height: 32px;
	width: 10px;
	margin: -16px 0 0 -5px;
}

.px-readout {
	display: grid;
	grid-template-columns: 44px repeat(2, minmax(0, 1fr));
	gap: 1px;
	margin: 14px 4px 0;
	background: var(--rule);
	border: 1px solid var(--rule);
	font-size: 11px;
}

.px-readout > * {
	background: var(--panel);
	padding: 8px 10px;
}

.px-readout .big {
	background: var(--c);
}

.px-readout small {
	display: block;
	font-size: 8.5px;
	letter-spacing: 0.26em;
	color: var(--faint);
	margin-bottom: 2px;
}

.px-recent {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(36px, 1fr));
	gap: 6px;
	padding: 0 4px;
}

.px-recent button {
	height: 36px;
	background: var(--c);
	border: 1px solid rgba(255, 255, 255, 0.15);
	--brk-inset: -4px;
}

.px-recent button:not(.on)::after {
	display: none;
}

/* ---------------------------------------------------------------- loupe */

.px-loupe {
	position: fixed;
	z-index: 120;
	width: 134px;
	background: #000;
	border: 1px solid var(--hl);
	box-shadow: var(--hl-glow), 0 10px 30px rgba(0, 0, 0, 0.7);
	pointer-events: none;
	transform: translate(-50%, 0);
	--brk-inset: -6px;
}

.px-loupe canvas {
	display: block;
	width: 132px;
	height: 132px;
	image-rendering: pixelated;
}

.px-loupe-read {
	border-top: 1px solid var(--rule-hi);
	padding: 6px 8px 7px;
	font-size: 10px;
	line-height: 1.5;
	color: var(--dim);
}

.px-loupe-read b {
	display: flex;
	align-items: center;
	gap: 6px;
	color: var(--ink);
	font-size: 12px;
	letter-spacing: 0.06em;
}

.px-loupe-read b i {
	width: 10px;
	height: 10px;
	background: var(--c);
	box-shadow: 0 0 0 1px var(--rule-hi);
}

/* ---------------------------------------------------------------- misc */

.px-ripple {
	position: fixed;
	z-index: 6;
	width: 12px;
	height: 12px;
	margin: -6px 0 0 -6px;
	border: 1.5px solid var(--hl);
	border-radius: 50%;
	pointer-events: none;
	animation: ripple 620ms var(--ease) forwards;
}

@keyframes ripple {
	to {
		transform: scale(16);
		opacity: 0;
		border-width: 0.3px;
	}
}

.px-drop {
	position: absolute;
	inset: 12px;
	z-index: 10;
	display: grid;
	place-items: center;
	border: 1px dashed var(--hl);
	background: rgba(0, 20, 24, 0.7);
	font-size: 12px;
	letter-spacing: 0.4em;
	color: var(--hl);
	pointer-events: none;
}

/* Math preview sits over the document while the sheet is open. */
body:not(.math-on) #cvPrev {
	display: none;
}

body.math-on #doc {
	visibility: hidden;
}

.xs-stage.panning {
	cursor: grab;
}

.xs-stage.grabbing {
	cursor: grabbing;
}

.px-msg .dim {
	color: var(--faint);
}

/* The failing part of the expression, underlined in red. */
.px-err {
	display: block;
	margin-top: 4px;
	font: inherit;
	font-size: 12px;
	color: var(--dim);
	white-space: pre;
	overflow: hidden;
	text-overflow: ellipsis;
}

.px-err u {
	color: var(--err);
	text-decoration: none;
	border-bottom: 2px solid var(--err);
	background: rgba(255, 45, 45, 0.12);
}

.px-fns button.v {
	color: var(--ink);
	font-weight: 700;
	border-color: var(--dim);
}
