:root {
	--paper: #f2efe7;
	--paper-deep: #e5dfd2;
	--ink: #17221f;
	--muted: #5e6864;
	--line: #b8b2a5;
	--teal: #176b68;
	--teal-dark: #0f4f4d;
	--coral: #d95f40;
	--gold: #d6a52f;
	--blue: #3f6887;
	--white: #fffdf8;
	--focus: #087f7a;
	--shadow: 0 14px 34px rgb(23 34 31 / 10%);
	color-scheme: light;
	font-family: "Trebuchet MS", "Aptos", sans-serif;
	font-synthesis: none;
}

* {
	box-sizing: border-box;
}

html {
	min-width: 320px;
	min-height: 100%;
	background: var(--paper);
}

body {
	min-height: 100vh;
	margin: 0;
	color: var(--ink);
	background-color: var(--paper);
	background-image:
		linear-gradient(rgb(23 34 31 / 5%) 1px, transparent 1px),
		linear-gradient(90deg, rgb(23 34 31 / 5%) 1px, transparent 1px);
	background-size: 32px 32px;
}

button,
input {
	font: inherit;
}

button,
a,
label {
	-webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible,
input:focus-visible + span,
input:focus-visible + .module-index {
	outline: 3px solid var(--focus);
	outline-offset: 3px;
}

.site-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	min-height: 72px;
	padding: 0 5vw;
	border-bottom: 1px solid var(--ink);
	background: rgb(242 239 231 / 92%);
	backdrop-filter: blur(10px);
}

.brand {
	color: var(--ink);
	font-family: Georgia, "Times New Roman", serif;
	font-size: 1.45rem;
	font-weight: 700;
	text-decoration: none;
}

.header-mark,
.eyebrow,
legend,
.difficulty-mark,
.module-index {
	font-size: 0.75rem;
	font-weight: 700;
	letter-spacing: 0;
	text-transform: uppercase;
}

.header-mark {
	color: var(--muted);
}

.app-main {
	width: min(1180px, calc(100% - 40px));
	margin: 0 auto;
	padding: 42px 0 64px;
}

.trainer {
	width: 100%;
	min-height: min(680px, calc(100vh - 178px));
	padding: 38px;
	border: 1px solid var(--ink);
	border-radius: 6px;
	background: var(--white);
	box-shadow: var(--shadow);
	animation: enter-workspace 360ms ease-out both;
}

@keyframes enter-workspace {
	from {
		opacity: 0;
		transform: translateY(10px);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

h1,
h2,
p {
	margin-top: 0;
}

h1,
h2 {
	font-family: Georgia, "Times New Roman", serif;
	letter-spacing: 0;
}

h1 {
	margin-bottom: 0;
	font-size: 2.5rem;
	line-height: 1.08;
}

h2 {
	margin-bottom: 0;
	font-size: 1.55rem;
	line-height: 1.15;
}

.eyebrow {
	margin-bottom: 8px;
	color: var(--teal);
}

.section-heading {
	padding-bottom: 28px;
	border-bottom: 1px solid var(--line);
}

.setup-form {
	display: grid;
	grid-template-columns: minmax(0, 1fr) 240px;
	gap: 30px 42px;
	padding-top: 34px;
}

fieldset {
	min-width: 0;
	margin: 0;
	padding: 0;
	border: 0;
}

legend {
	width: 100%;
	margin-bottom: 12px;
	color: var(--muted);
}

.module-picker {
	display: grid;
	grid-column: 1;
	grid-row: 1 / span 2;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 14px;
}

.module-picker legend {
	grid-column: 1 / -1;
}

.module-option {
	position: relative;
	display: grid;
	grid-template-columns: 40px minmax(0, 1fr);
	gap: 7px 13px;
	min-height: 152px;
	padding: 20px;
	overflow: hidden;
	border: 1px solid var(--line);
	border-radius: 6px;
	background: var(--paper);
	cursor: pointer;
	transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.module-option:hover {
	border-color: var(--ink);
	transform: translateY(-2px);
}

.module-option:has(input:checked) {
	border: 2px solid var(--teal);
	box-shadow: inset 6px 0 0 var(--gold);
}

.module-option input {
	position: absolute;
	width: 1px;
	height: 1px;
	opacity: 0;
}

.module-index {
	grid-row: 1 / span 2;
	display: grid;
	place-items: center;
	width: 36px;
	height: 36px;
	border: 1px solid currentColor;
	border-radius: 50%;
	color: var(--teal);
}

.module-option strong {
	align-self: end;
	font-family: Georgia, "Times New Roman", serif;
	font-size: 1.2rem;
}

.module-option small {
	color: var(--muted);
	font-size: 0.88rem;
	line-height: 1.45;
}

.difficulty-picker {
	align-self: start;
}

.segmented-control {
	display: grid;
	grid-template-columns: repeat(5, 1fr);
	border: 1px solid var(--ink);
	border-radius: 4px;
	overflow: hidden;
}

.segmented-control label {
	cursor: pointer;
}

.segmented-control input {
	position: absolute;
	width: 1px;
	height: 1px;
	opacity: 0;
}

.segmented-control span {
	display: grid;
	place-items: center;
	min-height: 44px;
	border-right: 1px solid var(--ink);
	background: var(--white);
	font-weight: 700;
}

.segmented-control label:last-child span {
	border-right: 0;
}

.segmented-control input:checked + span {
	color: var(--white);
	background: var(--teal);
}

.primary-action {
	display: inline-flex;
	align-items: center;
	justify-content: space-between;
	gap: 28px;
	min-height: 52px;
	padding: 0 20px;
	border: 1px solid var(--ink);
	border-radius: 4px;
	color: var(--white);
	background: var(--ink);
	font-weight: 700;
	text-decoration: none;
	cursor: pointer;
	transition: background 160ms ease, transform 160ms ease;
}

.primary-action:hover {
	background: var(--teal-dark);
	transform: translateY(-1px);
}

.primary-action:disabled {
	cursor: wait;
	opacity: 0.55;
	transform: none;
}

.progress-strip {
	display: grid;
	grid-template-columns: 190px minmax(140px, 1fr) 90px;
	gap: 24px;
	align-items: center;
	padding-bottom: 20px;
	border-bottom: 1px solid var(--line);
}

.progress-strip > div:first-child {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 16px;
}

.progress-strip .eyebrow {
	margin: 0;
}

.progress-track {
	height: 8px;
	overflow: hidden;
	border: 1px solid var(--ink);
	border-radius: 2px;
	background: var(--paper-deep);
}

.progress-track span {
	display: block;
	height: 100%;
	background: var(--gold);
}

.difficulty-mark {
	color: var(--muted);
	text-align: right;
}

.question-form {
	display: flex;
	flex-direction: column;
	min-height: 540px;
	padding-top: 34px;
}

.question-prompt h1 {
	font-size: 2rem;
}

.answer-action {
	align-self: flex-end;
	margin-top: auto;
}

.arithmetic-prompt {
	display: grid;
	place-items: center;
	min-height: 260px;
	text-align: center;
}

.arithmetic-prompt .eyebrow {
	align-self: end;
}

.arithmetic-prompt h1 {
	display: flex;
	flex-wrap: wrap;
	gap: 16px;
	align-items: center;
	justify-content: center;
	font-family: Georgia, "Times New Roman", serif;
	font-size: 4rem;
	font-variant-numeric: tabular-nums;
}

.operator-blank {
	display: grid;
	place-items: center;
	width: 72px;
	height: 72px;
	border: 2px solid var(--coral);
	border-radius: 4px;
	color: var(--coral);
	background: #fff8f4;
}

.operator-choices {
	display: grid;
	grid-template-columns: repeat(4, 84px);
	gap: 14px;
	justify-content: center;
	margin-bottom: 34px;
}

.operator-choices legend {
	grid-column: 1 / -1;
	text-align: center;
}

.operator-choices label,
.silhouette-choices label {
	position: relative;
	cursor: pointer;
}

.operator-choices input,
.silhouette-choices input {
	position: absolute;
	width: 1px;
	height: 1px;
	opacity: 0;
}

.operator-choices span {
	display: grid;
	place-items: center;
	width: 84px;
	height: 72px;
	border: 1px solid var(--ink);
	border-radius: 4px;
	background: var(--paper);
	font-family: Georgia, "Times New Roman", serif;
	font-size: 2rem;
	transition: color 140ms ease, background 140ms ease, transform 140ms ease;
}

.operator-choices label:hover span {
	transform: translateY(-2px);
}

.operator-choices input:checked + span {
	color: var(--white);
	background: var(--teal);
}

.shape-prompt {
	display: flex;
	align-items: end;
	justify-content: space-between;
	gap: 24px;
	margin-bottom: 18px;
}

.shape-prompt .eyebrow {
	flex: 0 0 auto;
	margin-bottom: 5px;
}

.shape-prompt h1 {
	max-width: 660px;
	text-align: right;
}

.dissection-workspace {
	display: grid;
	grid-template-columns: minmax(320px, 1.15fr) minmax(280px, 0.85fr);
	gap: 28px;
	align-items: center;
	margin-bottom: 28px;
}

.fragment-board,
.reconstruction-board {
	display: block;
	width: min(100%, 500px);
	aspect-ratio: 1;
	margin: 0 auto;
	border: 1px solid var(--ink);
	border-radius: 4px;
	background-color: #f8f5ed;
	background-image:
		linear-gradient(rgb(23 34 31 / 6%) 1px, transparent 1px),
		linear-gradient(90deg, rgb(23 34 31 / 6%) 1px, transparent 1px);
	background-size: 10px 10px;
}

.fragment-board path,
.reconstruction-board [data-animation-piece] path {
	stroke: var(--ink);
	stroke-width: 0.65;
	vector-effect: non-scaling-stroke;
}

.silhouette-choices {
	display: grid;
	grid-template-columns: repeat(2, minmax(112px, 1fr));
	gap: 12px;
}

.silhouette-choices legend {
	grid-column: 1 / -1;
}

.silhouette-choices span {
	position: relative;
	display: grid;
	place-items: center;
	aspect-ratio: 1;
	border: 1px solid var(--line);
	border-radius: 4px;
	background: var(--paper);
	transition: border-color 140ms ease, background 140ms ease, transform 140ms ease;
}

.silhouette-choices label:hover span {
	border-color: var(--ink);
	transform: translateY(-2px);
}

.silhouette-choices input:checked + span {
	border: 2px solid var(--teal);
	background: #e8f2ef;
}

.silhouette-choices svg {
	width: 84%;
	aspect-ratio: 1;
}

.silhouette-choices path {
	fill: var(--ink);
}

.silhouette-choices b {
	position: absolute;
	right: 8px;
	bottom: 6px;
	display: grid;
	place-items: center;
	width: 24px;
	height: 24px;
	border-radius: 50%;
	color: var(--white);
	background: var(--teal);
	font-size: 0.75rem;
}

.feedback-view {
	display: grid;
	grid-template-columns: minmax(0, 1fr) auto;
	gap: 28px;
	align-items: end;
}

.feedback-heading,
.feedback-view > :not(form) {
	grid-column: 1 / -1;
}

.feedback-heading {
	padding-bottom: 22px;
	border-bottom: 1px solid var(--line);
}

.feedback-heading.is-correct h1 {
	color: var(--teal);
}

.feedback-heading.is-incorrect h1 {
	color: var(--coral);
}

.feedback-view > form {
	grid-column: 2;
}

.worked-solution {
	align-self: center;
	width: min(720px, 100%);
	margin: 32px auto;
}

.solution-equation {
	padding: 30px;
	border-top: 1px solid var(--ink);
	border-bottom: 1px solid var(--ink);
	font-family: Georgia, "Times New Roman", serif;
	font-size: 3rem;
	text-align: center;
}

.worked-solution ol {
	display: grid;
	gap: 8px;
	margin: 24px 0 0;
	padding-left: 24px;
	color: var(--muted);
	line-height: 1.55;
}

.dissection-solution {
	width: min(780px, 100%);
	margin: 18px auto 0;
}

.solution-toolbar {
	display: flex;
	align-items: end;
	justify-content: space-between;
	gap: 20px;
	margin-bottom: 14px;
}

.solution-toolbar .eyebrow {
	margin-bottom: 4px;
}

.animation-controls {
	display: flex;
	gap: 8px;
}

.animation-controls button {
	display: grid;
	place-items: center;
	width: 42px;
	height: 42px;
	padding: 0;
	border: 1px solid var(--ink);
	border-radius: 4px;
	color: var(--ink);
	background: var(--paper);
	cursor: pointer;
}

.animation-controls button:hover {
	color: var(--white);
	background: var(--teal);
}

.animation-controls button[hidden] {
	display: none;
}

.reconstruction-board {
	width: min(100%, 560px);
}

.cut-seams {
	opacity: 0;
	transition: opacity 260ms ease;
}

.cut-seams.is-visible {
	opacity: 1;
}

.cut-seams path {
	fill: none;
	stroke: var(--white);
	stroke-dasharray: 2 1.5;
	stroke-width: 1.2;
	vector-effect: non-scaling-stroke;
}

.summary-view {
	display: flex;
	flex-direction: column;
}

.summary-metrics {
	display: grid;
	grid-template-columns: repeat(3, 1fr);
	margin: 52px 0;
	border-top: 1px solid var(--ink);
	border-bottom: 1px solid var(--ink);
}

.summary-metrics div {
	display: grid;
	gap: 8px;
	place-items: center;
	min-height: 190px;
	border-right: 1px solid var(--line);
}

.summary-metrics div:last-child {
	border-right: 0;
}

.summary-metrics strong {
	font-family: Georgia, "Times New Roman", serif;
	font-size: 3rem;
}

.summary-metrics span {
	color: var(--muted);
	font-size: 0.75rem;
	font-weight: 700;
	text-transform: uppercase;
}

.summary-view .primary-action {
	align-self: flex-end;
	margin-top: auto;
}

.htmx-request .primary-action,
.htmx-request.primary-action {
	cursor: wait;
	opacity: 0.55;
}

@media (max-width: 820px) {
	.app-main {
		width: min(100% - 24px, 720px);
		padding-top: 24px;
	}

	.trainer {
		min-height: calc(100vh - 130px);
		padding: 24px;
	}

	.setup-form,
	.dissection-workspace {
		grid-template-columns: 1fr;
	}

	.module-picker {
		grid-column: auto;
		grid-row: auto;
	}

	.difficulty-picker {
		width: min(100%, 360px);
	}

	.setup-form .primary-action {
		justify-self: start;
	}

	.progress-strip {
		grid-template-columns: 1fr auto;
	}

	.progress-track {
		grid-column: 1 / -1;
		grid-row: 2;
	}

	.difficulty-mark {
		grid-column: 2;
		grid-row: 1;
	}

	.shape-prompt {
		display: block;
	}

	.shape-prompt h1 {
		text-align: left;
	}

	.fragment-board {
		width: min(100%, 440px);
	}

	.silhouette-choices {
		grid-template-columns: repeat(3, minmax(94px, 1fr));
	}
}

@media (max-width: 560px) {
	.site-header {
		min-height: 60px;
		padding: 0 16px;
	}

	.header-mark {
		display: none;
	}

	.app-main {
		width: 100%;
		padding: 0;
	}

	.trainer {
		min-height: calc(100vh - 60px);
		padding: 22px 16px 28px;
		border: 0;
		border-radius: 0;
		box-shadow: none;
	}

	h1 {
		font-size: 2rem;
	}

	.module-picker {
		grid-template-columns: 1fr;
	}

	.module-option {
		min-height: 130px;
	}

	.setup-form .primary-action,
	.answer-action,
	.feedback-view > form,
	.feedback-view .primary-action,
	.summary-view .primary-action {
		width: 100%;
	}

	.question-form {
		min-height: calc(100vh - 165px);
	}

	.progress-strip {
		gap: 14px;
	}

	.progress-strip > div:first-child {
		display: block;
	}

	.progress-strip .eyebrow {
		display: block;
		margin-bottom: 5px;
	}

	.arithmetic-prompt {
		min-height: 230px;
	}

	.arithmetic-prompt h1 {
		gap: 9px;
		font-size: 2.55rem;
	}

	.operator-blank {
		width: 54px;
		height: 54px;
	}

	.operator-choices {
		grid-template-columns: repeat(4, 1fr);
		gap: 8px;
		width: 100%;
	}

	.operator-choices span {
		width: 100%;
		height: 62px;
	}

	.silhouette-choices {
		grid-template-columns: repeat(2, 1fr);
	}

	.feedback-view {
		display: flex;
		flex-direction: column;
		align-items: stretch;
	}

	.solution-equation {
		padding: 24px 8px;
		font-size: 2.15rem;
	}

	.solution-toolbar {
		align-items: center;
	}

	.solution-toolbar h2 {
		font-size: 1.25rem;
	}

	.summary-metrics {
		grid-template-columns: 1fr;
		margin: 34px 0;
	}

	.summary-metrics div {
		grid-template-columns: 1fr 1fr;
		min-height: 100px;
		border-right: 0;
		border-bottom: 1px solid var(--line);
	}

	.summary-metrics div:last-child {
		border-bottom: 0;
	}
}

@media (prefers-reduced-motion: reduce) {
	*,
	*::before,
	*::after {
		scroll-behavior: auto !important;
		animation-duration: 1ms !important;
		animation-iteration-count: 1 !important;
		transition-duration: 1ms !important;
	}
}
