/* Inspector chrome. Dark grey glass over the warm studio; small, upper-case,
   letter-spaced labels; tabular monospace for numbers. */

:root {
	--chrome: rgba(24, 24, 25, 0.87);
	--chrome-line: rgba(255, 255, 255, 0.075);
	--ink: #e1ded6;
	--ink-dim: #9d9a92;
	--ink-faint: #7d7a73;
	--accent: #e6a94f;
	--accent-soft: #f1b962;
	--accent-ink: #1c1a16;
	--chip: #ece7db;
	--radius: 8px;
	--ui: "Inter", "SF Pro Text", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	--mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

html, body { height: 100%; margin: 0; }

body { overflow: hidden; background: #cfc5b5; font-family: var(--ui); -webkit-font-smoothing: antialiased; }

/* the backdrop is painted before WebGL starts so the page never opens on an empty frame */
.hv-viewer {
	position: fixed;
	inset: 0;
	overflow: hidden;
	background: radial-gradient(120% 100% at 50% 18%, #ece4d4 0%, #d8cebd 46%, #bfb39f 100%);
}

#hv-view {
	position: absolute;
	inset: 0;
	display: block;
	width: 100%;
	height: 100%;
	touch-action: none;
	outline: none;
	opacity: 0;
	transition: opacity 0.7s ease;
}

.hv-viewer.is-ready #hv-view { opacity: 1; }

.hv-sr-only {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0 0 0 0);
	white-space: nowrap;
	border: 0;
}

/* ---------- top bar ---------- */

.hv-topbar {
	position: absolute;
	inset: 12px 12px auto 12px;
	z-index: 3;
	display: grid;
	grid-template-columns: 1fr auto 1fr;
	align-items: start;
	gap: 8px;
	pointer-events: none;
}

.hv-topbar > * { pointer-events: auto; }
.hv-topbar-spacer { pointer-events: none; }

.hv-topbar-centre { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }

.hv-seg {
	display: inline-flex;
	align-items: stretch;
	padding: 3px;
	background: var(--chrome);
	border: 1px solid var(--chrome-line);
	border-radius: 7px;
	box-shadow: 0 8px 22px rgba(56, 42, 24, 0.17), inset 0 1px 0 rgba(255, 255, 255, 0.035);
	-webkit-backdrop-filter: blur(12px) saturate(1.1);
	backdrop-filter: blur(12px) saturate(1.1);
}

.hv-seg-label {
	align-self: center;
	margin-right: 4px;
	padding: 0 10px 0 8px;
	border-right: 1px solid var(--chrome-line);
	color: var(--ink-faint);
	font: 600 9.5px/1 var(--ui);
	letter-spacing: 0.16em;
	text-transform: uppercase;
	user-select: none;
}

.hv-seg-btn {
	appearance: none;
	border: 0;
	background: transparent;
	color: var(--ink-dim);
	font: 600 10.5px/1 var(--ui);
	letter-spacing: 0.12em;
	text-transform: uppercase;
	padding: 8px 11px;
	border-radius: 5px;
	cursor: pointer;
	display: inline-flex;
	align-items: baseline;
	gap: 6px;
	white-space: nowrap;
	-webkit-tap-highlight-color: transparent;
	transition: background-color 0.14s ease, color 0.14s ease, transform 0.07s ease;
}

.hv-seg-btn kbd { font: 500 9px/1 var(--mono); letter-spacing: 0; opacity: 0.5; }
.hv-seg-btn:hover { color: var(--ink); background: rgba(255, 255, 255, 0.055); }
.hv-seg-btn:active { transform: scale(0.95); }
.hv-seg-btn[aria-checked="true"] { background: var(--chip); color: #1c1c1e; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.4); }
.hv-seg-btn[aria-checked="true"]:hover { background: #f6f2e8; color: #1c1c1e; }
.hv-seg-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.hv-icon-btn {
	width: 34px;
	height: 34px;
	display: grid;
	place-items: center;
	border: 1px solid var(--chrome-line);
	border-radius: 7px;
	background: var(--chrome);
	color: var(--ink-dim);
	cursor: pointer;
	-webkit-backdrop-filter: blur(12px);
	backdrop-filter: blur(12px);
	box-shadow: 0 8px 22px rgba(56, 42, 24, 0.17);
	transition: color 0.12s ease, background-color 0.12s ease, transform 0.07s ease;
}

.hv-icon-btn svg { fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.hv-icon-btn:hover { color: var(--ink); background: rgba(38, 38, 39, 0.9); }
.hv-icon-btn:active { transform: scale(0.94); }
.hv-icon-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.hv-icon-btn--sm { width: 24px; height: 24px; border: 0; background: transparent; box-shadow: none; -webkit-backdrop-filter: none; backdrop-filter: none; }

/* ---------- inspector panel ---------- */

.hv-panel {
	position: absolute;
	top: 62px;
	left: 12px;
	z-index: 2;
	width: 238px;
	max-height: calc(100% - 74px);
	overflow: auto;
	scrollbar-width: thin;
	color: var(--ink);
	background: var(--chrome);
	border: 1px solid var(--chrome-line);
	border-radius: var(--radius);
	box-shadow: 0 12px 30px rgba(56, 42, 24, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.035);
	-webkit-backdrop-filter: blur(14px) saturate(1.1);
	backdrop-filter: blur(14px) saturate(1.1);
	transition: opacity 0.18s ease, transform 0.22s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.hv-panel.is-closed {
	opacity: 0;
	transform: translateX(-14px);
	pointer-events: none;
	visibility: hidden;
	transition: opacity 0.18s ease, transform 0.22s cubic-bezier(0.2, 0.8, 0.2, 1), visibility 0s 0.22s;
}

.hv-panel-head {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 7px 8px 7px 12px;
	color: #f2efe7;
	font: 600 11px/1 var(--ui);
	letter-spacing: 0.18em;
	text-transform: uppercase;
}

.hv-group + .hv-group { border-top: 1px solid var(--chrome-line); }

.hv-group-head {
	width: 100%;
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 11px 12px 7px;
	border: 0;
	background: none;
	color: var(--ink-faint);
	font: 600 10px/1 var(--ui);
	letter-spacing: 0.16em;
	text-transform: uppercase;
	cursor: pointer;
	transition: color 0.12s ease;
}

.hv-group-head:hover { color: var(--ink); }
.hv-group-head:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: 6px; }
.hv-group-head svg { fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; transition: transform 0.18s ease; }
.hv-group-head[aria-expanded="false"] svg { transform: rotate(-90deg); }
.hv-group-head[aria-expanded="false"] + .hv-group-body { display: none; }

.hv-group-body { padding: 4px 12px 12px; animation: hv-group-in 0.16s ease; }

.hv-stats { margin: 0; display: grid; grid-template-columns: 1fr auto; column-gap: 12px; row-gap: 6px; }
.hv-stats > div { display: contents; }
.hv-stats dt { color: var(--ink-dim); font: 500 10px/1.35 var(--ui); letter-spacing: 0.12em; text-transform: uppercase; }
.hv-stats dd { margin: 0; color: #f4f1e9; font: 500 11.5px/1.35 var(--mono); font-variant-numeric: tabular-nums; text-align: right; }

.hv-build { margin-top: 12px; padding-top: 11px; border-top: 1px solid var(--chrome-line); }
.hv-build[hidden] { display: none; }
.hv-build-label { display: flex; align-items: center; gap: 7px; color: var(--ink-dim); font: 500 10px/1 var(--ui); letter-spacing: 0.12em; text-transform: uppercase; }
.hv-pulse { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); animation: hv-pulse 1.1s ease-in-out infinite; }
.hv-bar { height: 3px; margin-top: 9px; border-radius: 2px; background: rgba(255, 255, 255, 0.09); overflow: hidden; }
.hv-bar i { display: block; width: 0; height: 100%; border-radius: 2px; background: var(--accent); transition: width 0.25s ease; }

.hv-hint { margin: 4px 0 10px; color: var(--ink); font: 400 12px/1.4 var(--ui); }

/* ---------- toggles ---------- */

.hv-toggles { display: grid; }

.hv-toggle {
	position: relative;
	display: flex;
	align-items: center;
	gap: 9px;
	margin: 0 -6px;
	padding: 5px 6px;
	border-radius: 5px;
	cursor: pointer;
	user-select: none;
	-webkit-tap-highlight-color: transparent;
	transition: background-color 0.12s ease;
}

.hv-toggle:hover { background: rgba(255, 255, 255, 0.05); }

.hv-toggle input {
	position: absolute;
	top: 50%;
	left: 13.5px;
	width: 15px;
	height: 15px;
	margin: -7.5px 0 0 -7.5px;
	opacity: 0;
	cursor: pointer;
}

.hv-toggle .hv-box {
	flex: none;
	position: relative;
	width: 15px;
	height: 15px;
	border: 1.5px solid #7b7871;
	border-radius: 3.5px;
	background: rgba(255, 255, 255, 0.02);
	transition: background-color 0.13s ease, border-color 0.13s ease, transform 0.08s ease;
}

.hv-toggle .hv-box::after {
	content: "";
	position: absolute;
	left: 3.5px;
	top: 0.5px;
	width: 5px;
	height: 9px;
	border: solid var(--accent-ink);
	border-width: 0 2px 2px 0;
	opacity: 0;
	transform: rotate(42deg) scale(0.4);
	transition: transform 0.14s cubic-bezier(0.2, 0.9, 0.3, 1.3), opacity 0.1s ease;
}

.hv-toggle:hover .hv-box { border-color: #cbc8c0; }
.hv-toggle:active .hv-box { transform: scale(0.86); }
.hv-toggle input:checked + .hv-box { background: var(--accent); border-color: var(--accent); }
.hv-toggle:hover input:checked + .hv-box { background: var(--accent-soft); border-color: var(--accent-soft); }
.hv-toggle input:checked + .hv-box::after { opacity: 1; transform: rotate(42deg) scale(1); }
.hv-toggle input:focus-visible + .hv-box { outline: 2px solid var(--accent); outline-offset: 2px; }
.hv-toggle input:focus-visible ~ .hv-lbl { color: #fff; }
.hv-toggle .hv-lbl { color: var(--ink); font: 400 12px/1.3 var(--ui); }

.hv-text-btn {
	width: 100%;
	margin-top: 10px;
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 7px 9px;
	border: 1px solid rgba(255, 255, 255, 0.11);
	border-radius: 5px;
	background: rgba(255, 255, 255, 0.03);
	color: var(--ink);
	font: 600 10.5px/1 var(--ui);
	letter-spacing: 0.12em;
	text-transform: uppercase;
	cursor: pointer;
	transition: background-color 0.12s ease, border-color 0.12s ease, transform 0.07s ease;
}

.hv-text-btn:hover { background: rgba(255, 255, 255, 0.08); border-color: rgba(255, 255, 255, 0.18); }
.hv-text-btn:active { transform: scale(0.985); }
.hv-text-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.hv-text-btn kbd { font: 500 10px/1 var(--mono); opacity: 0.6; border: 1px solid rgba(255, 255, 255, 0.16); border-radius: 3px; padding: 2px 4px; }

/* ---------- tooltip ---------- */

.hv-tooltip {
	position: absolute;
	left: 0;
	top: 0;
	z-index: 6;
	max-width: 236px;
	padding: 6px 9px;
	border: 1px solid rgba(255, 255, 255, 0.11);
	border-radius: 5px;
	background: #111112;
	color: #dcd9d1;
	font: 400 11.5px/1.4 var(--ui);
	box-shadow: 0 8px 20px rgba(0, 0, 0, 0.32);
	pointer-events: none;
	opacity: 0;
	transition: opacity 0.12s ease;
}

.hv-tooltip[hidden] { display: none; }
.hv-tooltip[data-show="1"] { opacity: 1; }

@keyframes hv-pulse {
	0%, 100% { opacity: 0.35; transform: scale(0.8); }
	50% { opacity: 1; transform: scale(1); }
}

@keyframes hv-group-in {
	from { opacity: 0; transform: translateY(-2px); }
	to { opacity: 1; transform: none; }
}

/* ---------- small screens ---------- */

@media (max-width: 900px) {
	.hv-topbar { inset: 8px 8px auto 8px; grid-template-columns: auto 1fr; }
	.hv-topbar-centre { flex-direction: column; align-items: stretch; gap: 6px; }
	.hv-seg { justify-content: center; }
	.hv-seg-label { display: none; }
	.hv-panel { top: 88px; left: 8px; max-height: calc(100% - 96px); }
}

@media (max-width: 420px) {
	.hv-seg-btn { padding: 7px 9px; font-size: 9.5px; letter-spacing: 0.08em; }
	.hv-seg-btn kbd { display: none; }
}

/* short, wide windows: the inspector tightens so both of its groups still fit beside the model */
@media (min-width: 901px) and (max-height: 560px) {
	.hv-panel-head { padding: 5px 8px 5px 12px; }
	.hv-group-head { padding: 7px 12px 4px; }
	.hv-group-body { padding: 2px 12px 8px; }
	.hv-stats { row-gap: 3px; }
	.hv-hint { margin: 2px 0 6px; }
	.hv-toggle { padding: 3px 6px; }
	.hv-text-btn { margin-top: 6px; padding: 5px 9px; }
}

@media (pointer: coarse) {
	.hv-seg-btn kbd, .hv-text-btn kbd { display: none; }
}

@media (prefers-reduced-motion: reduce) {
	*, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
	#hv-view { transition: none; }
}
