@charset "UTF-8";
/* Miter Finder */

/* Some obligatory element resets. */
::before,
::after {
	box-sizing: inherit;
	margin: 0;
	padding: 0;
}

/* Remove default margins */
*:not(dialog) {
	margin: 0;
}

/* Enable keyword animations */
@media (prefers-reduced-motion: no-preference) {
	html {
		interpolate-size: allow-keywords;
	}
}

html {
	font-size: 16px;
	box-sizing: border-box;
}

:root {
	--bg: #f6f4f1;
	--card: #ffffff;
	--ink: #23201d;
	--muted: #6d675f;
	--line: #ddd7cf;
	--accent: #c2703f;
	--surf-a: #3d6b8e;
	--surf-b: #8a7220;
	--naive: #a24a86;
	--danger: #a8382c;
	--radius: 12px;
	--shadow: 0 1px 2px rgb(35 32 29 / 6%), 0 8px 24px rgb(35 32 29 / 5%);
}

@media (prefers-color-scheme: dark) {
	:root {
		--bg: #1a1917;
		--card: #232120;
		--ink: #ece8e3;
		--muted: #a09a92;
		--line: #3a3734;
		--accent: #e08b58;
		--surf-a: #7fb1d8;
		--surf-b: #d2b455;
		--naive: #d987bd;
		--danger: #e58b7f;
		--shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 8px 24px rgb(0 0 0 / 25%);
	}
}

body {
	margin: 0 auto;
	padding: clamp(1rem, 3vw, 2.5rem) clamp(1rem, 3vw, 2rem) 3rem;
	max-width: 68rem;
	font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
	font-size: 16px;
	line-height: 1.5;
	color: var(--ink);
	background: var(--bg);
	-webkit-text-size-adjust: 100%;
	text-rendering: optimizeLegibility;
	-webkit-font-smoothing: antialiased;
	font-variant-ligatures: common-ligatures;
	font-kerning: normal;
	scrollbar-gutter: stable;
}

h1 {
	margin: 0;
	font-size: clamp(1.6rem, 4vw, 2.2rem);
	letter-spacing: -0.02em;
}

.lede {
	margin: 0.35rem 0 1.5rem;
	max-width: 46rem;
	color: var(--muted);
}

.panel {
	padding: clamp(1rem, 2.5vw, 1.35rem);
	border: 1px solid var(--line);
	border-radius: var(--radius);
	background: var(--card);
	box-shadow: var(--shadow);
}

main {
	display: grid;
	gap: 1rem;
	grid-template-columns: minmax(17rem, 22rem) minmax(0, 1fr);
	align-items: stretch;   /* the illustration matches the height of the form */
}

@media (max-width: 46rem) {
	main {
		grid-template-columns: 1fr;
	}

	/* stacked, there is no form to match -- fall back to a fixed shape */
	.viz {
		grid-template-rows: auto auto;
	}

	.canvas-wrap {
		aspect-ratio: 4 / 3;
	}
}

/* ------------------------------------------------------------------ inputs */

form {
	display: grid;
	gap: 1rem;
	margin: 0;
}

.presets {
	display: flex;
	flex-wrap: wrap;
	gap: 0.4rem;
	align-items: center;
}

.presets-label {
	flex: 0 0 100%;   /* own line, buttons wrap underneath */
	font-size: 0.8rem;
	color: var(--muted);
}

.chip {
	padding: 0.28rem 0.6rem;
	font: inherit;
	font-size: 0.82rem;
	color: var(--ink);
	background: transparent;
	border: 1px solid var(--line);
	border-radius: 999px;
	cursor: pointer;
}

.chip:hover {
	border-color: var(--accent);
	color: var(--accent);
}

.surface {
	display: grid;
	gap: 0.55rem;
	margin: 0;
	padding: 0.9rem 0.9rem 1rem;
	border: 1px solid var(--line);
	border-radius: 10px;
}

.surface legend {
	display: flex;
	gap: 0.5rem;
	align-items: baseline;
	padding: 0 0.35rem;
}

.hint {
	font-size: 0.78rem;
	color: var(--muted);
}

.tag {
	padding: 0.1rem 0.45rem;
	font-size: 0.76rem;
	font-weight: 650;
	letter-spacing: 0.01em;
	color: #fff;
	border-radius: 5px;
	white-space: nowrap;
}

.tag-a {
	background: var(--surf-a);
}

.tag-b {
	background: var(--surf-b);
}

@media (prefers-color-scheme: dark) {
	.tag {
		color: #1a1917;
	}
}

.row {
	display: flex;
	gap: 0.5rem;
	align-items: center;
	justify-content: space-between;
	font-size: 0.9rem;
}

.row>span:first-child {
	color: var(--muted);
}

input[type="number"] {
	width: 5.5rem;
	padding: 0.3rem 0.45rem;
	font: inherit;
	font-variant-numeric: tabular-nums;
	text-align: right;
	color: var(--ink);
	background: var(--bg);
	border: 1px solid var(--line);
	border-radius: 7px;
}

.unit {
	width: 0.9rem;
	font-size: 0.85rem;
	color: var(--muted);
}

input[type="range"] {
	width: 100%;
	margin: 0;
	accent-color: var(--accent);
}

.seg {
	display: flex;
	border: 1px solid var(--line);
	border-radius: 7px;
	overflow: hidden;
}

.seg input {
	position: absolute;
	opacity: 0;
	pointer-events: none;
}

.seg label {
	padding: 0.28rem 0.5rem;
	font-size: 0.82rem;
	color: var(--muted);
	cursor: pointer;
	white-space: nowrap;
}

.seg label+input+label {
	border-left: 1px solid var(--line);
}

.seg input:checked+label {
	color: var(--card);
	background: var(--accent);
}

.seg input:focus-visible+label {
	outline: 2px solid var(--accent);
	outline-offset: -2px;
}

:is(input, button):focus-visible {
	outline: 2px solid var(--accent);
	outline-offset: 2px;
}

.note {
	margin: 0;
	font-size: 0.8rem;
	color: var(--muted);
}

/* ------------------------------------------------------------- illustration */

.viz {
	display: grid;
	gap: 0.75rem;
	grid-template-rows: minmax(0, 1fr) auto;   /* canvas takes the slack, legend keeps its size */
}

.canvas-wrap {
	position: relative;
	min-height: 15rem;
}

/* out of flow, so the canvas never feeds its own size back into the row height */
canvas {
	position: absolute;
	inset: 0;
	display: block;
	width: 100%;
	height: 100%;
}

.legend {
	display: flex;
	flex-wrap: wrap;
	gap: 0.35rem 1rem;
	margin: 0;
	padding: 0;
	list-style: none;
	font-size: 0.78rem;
	color: var(--muted);
}

.legend li {
	display: flex;
	gap: 0.4rem;
	align-items: center;
}

.sw {
	width: 1.1rem;
	height: 0.55rem;
	border-radius: 2px;
}

.sw-a {
	background: color-mix(in srgb, var(--surf-a) 35%, transparent);
	border: 1px solid var(--surf-a);
}

.sw-b {
	background: color-mix(in srgb, var(--surf-b) 35%, transparent);
	border: 1px solid var(--surf-b);
}

.sw-cut {
	height: 0;
	border-top: 3px solid var(--accent);
	border-radius: 0;
}

.sw-naive {
	height: 0;
	border-top: 2px dashed var(--naive);
	border-radius: 0;
}

/* ----------------------------------------------------------------- results */

.results {
	margin-top: 1rem;
}

.numbers {
	display: grid;
	gap: 1rem;
	grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
}

.number {
	display: grid;
	gap: 0.15rem;
	justify-items: start;
}

.number output {
	font-size: clamp(2rem, 7vw, 3rem);
	font-weight: 600;
	font-variant-numeric: tabular-nums;
	letter-spacing: -0.02em;
	line-height: 1.1;
}

/* every readout is click-to-copy */
.copy {
	position: relative;
	width: fit-content;
	border-radius: 6px;
	cursor: pointer;
	transition: background-color 0.15s, box-shadow 0.15s;
}

/* the spread shadow widens the highlight without any padding, so the numbers
   stay flush with the labels above them */
.copy:hover,
.copy:focus-visible {
	background: var(--bg);
	box-shadow: 0 0 0 0.25rem var(--bg);
}

.copy:focus-visible {
	outline: 2px solid var(--accent);
	outline-offset: 5px;
}

.copy::after {
	content: "Copied ✓";
	position: absolute;
	top: 50%;
	left: 100%;
	transform: translate(0.6rem, -50%);
	padding: 0.1rem 0.4rem;
	font-size: 0.7rem;
	font-weight: 500;
	line-height: 1.4;
	letter-spacing: normal;
	white-space: nowrap;
	color: var(--card);
	background: var(--accent);
	border-radius: 5px;
	opacity: 0;
	pointer-events: none;
	transition: opacity 0.15s;
}

.copy.copied::after {
	opacity: 1;
}

.convention {
	margin: 1rem 0 0;
	max-width: 52rem;
	font-size: 0.85rem;
	color: var(--muted);
}

.convention strong {
	color: var(--ink);
	font-weight: 600;
}

.meta {
	display: grid;
	gap: 0.5rem 1.5rem;
	grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
	margin: 1rem 0 0;
	padding-top: 0.9rem;
	border-top: 1px solid var(--line);
	font-size: 0.85rem;
}

.meta dt {
	color: var(--muted);
}

.meta dd {
	margin: 0;
	font-weight: 600;
	font-variant-numeric: tabular-nums;
}

.share {
	margin-top: 1rem;
}

.error {
	margin: 0 0 0.75rem;
	padding: 0.5rem 0.7rem;
	font-size: 0.88rem;
	color: var(--danger);
	background: color-mix(in srgb, var(--danger) 10%, transparent);
	border-radius: 8px;
}

.error[hidden] {
	display: none;
}

footer {
	margin-top: 2rem;
	font-size: 0.78rem;
	color: var(--muted);
}

footer a {
	color: inherit;
}