/*
 * Matches the language practice app: system font, cool canvas, blue accent,
 * outline choice buttons, and a solid accent action button.
 */

.aptitude-test {
	--bg: #e7eef6;
	--surface: #f4f5f7;
	--surface-raised: #ffffff;
	--border: #c3c7ce;
	--border-strong: #6b7280;
	--text: #14161a;
	--text-muted: #4b5058;
	--accent: #0b5fa5;
	--accent-text: #ffffff;
	--danger: #a3232a;
	--ok: #1c6b45;
	--radius: 10px;
	--gap: 1rem;
	--focus: 3px solid #0b5fa5;
	--focus-offset: 2px;

	box-sizing: border-box;
	max-width: 30rem;
	margin: 1.5rem auto;
	padding: 1.25rem;
	background: var(--bg);
	color: var(--text);
	border-radius: var(--radius);
	font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
	font-size: 1rem;
	line-height: 1.5;
}

@media (prefers-color-scheme: dark) {
	.aptitude-test {
		--bg: #14161a;
		--surface: #1e2127;
		--surface-raised: #262a31;
		--border: #3d434d;
		--border-strong: #8b929e;
		--text: #f2f4f7;
		--text-muted: #b6bcc6;
		--accent: #7fb6ee;
		--accent-text: #0b1119;
		--danger: #ff9a9f;
		--ok: #79d3a8;
		--focus: 3px solid #7fb6ee;
	}
}

.aptitude-test *,
.aptitude-test *::before,
.aptitude-test *::after {
	box-sizing: border-box;
}

.aptitude-test__title {
	margin: 0 0 0.5em;
	color: inherit;
	font-family: inherit;
	font-size: 1.5rem;
	font-weight: 700;
	letter-spacing: normal;
	line-height: 1.2;
	text-align: center;
	text-transform: none;
}

.aptitude-test p {
	margin: 0 0 var(--gap);
}

.aptitude-test form.aptitude-test__languages {
	display: flex;
	flex-wrap: wrap;
	gap: 0.4rem;
	margin: 0 0 0.85rem;
}

.aptitude-test button.aptitude-test__flag {
	appearance: none;
	width: 2.1rem;
	height: 1.45rem;
	min-height: 0;
	margin: 0;
	padding: 0;
	border: 2px solid transparent;
	border-radius: 3px;
	background: transparent;
	box-shadow: none;
	line-height: 0;
	cursor: pointer;
	overflow: hidden;
}

.aptitude-test button.aptitude-test__flag.is-selected,
.aptitude-test button.aptitude-test__flag:focus {
	border-color: var(--accent);
	outline: none;
}

.aptitude-test button.aptitude-test__flag svg {
	display: block;
	width: 100%;
	height: 100%;
}

.aptitude-test__intro {
	margin: 0 0 var(--gap);
	color: var(--text-muted);
	font-size: 0.95rem;
	line-height: 1.45;
}

.aptitude-test__meta {
	margin-bottom: 0.35rem;
	color: var(--text-muted);
	font-size: 0.9rem;
	text-align: center;
}

.aptitude-test img.aptitude-test__image {
	display: block;
	width: auto;
	max-width: 100%;
	height: auto;
	/* Four answer buttons at 52px, plus the three gaps between them. */
	max-height: calc(52px * 4 + 0.5rem * 3);
	object-fit: contain;
	margin: 0 auto var(--gap);
	border-radius: var(--radius);
	background: var(--surface-raised);
}

.aptitude-test__text {
	margin: 0;
	color: var(--text);
	font-size: 1.05rem;
	font-weight: 600;
	line-height: 1.4;
	text-align: center;
	overflow-wrap: break-word;
}

.aptitude-test__prompt {
	margin: 0 0 var(--gap);
	color: var(--text);
	font-size: clamp(1.15rem, 5vw, 1.5rem);
	font-weight: 700;
	line-height: 1.35;
	overflow-wrap: break-word;
	text-align: center;
}

.aptitude-test__question {
	display: flex;
	flex-direction: column;
	gap: 0.5rem;
}

.aptitude-test__choice {
	display: flex;
	align-items: center;
	width: 100%;
	min-height: 52px;
	margin: 0;
	padding: 0.7rem 1.1rem;
	background: transparent;
	color: var(--text);
	border: 1px solid var(--border-strong);
	border-radius: var(--radius);
	font-family: inherit;
	font-size: 1.05rem;
	font-weight: 600;
	line-height: 1.35;
	text-align: left;
	cursor: pointer;
}

.aptitude-test__choice:hover {
	border-color: var(--accent);
}

.aptitude-test__choice--correct {
	border-color: var(--ok);
	background: var(--surface-raised);
}

.aptitude-test--review {
	margin-top: 2.5rem;
}

.aptitude-test__review-nav {
	display: flex;
	gap: 0.5rem;
}

.aptitude-test__review-nav form {
	flex: 1 1 0;
}

.aptitude-test__review-nav form.aptitude-test__review-restart {
	flex: 1 1 100%;
}

.aptitude-test__review-nav .aptitude-test__button {
	margin-top: 0;
}

.aptitude-test p.aptitude-test__choice {
	margin: 0;
}

.aptitude-test strong {
	font-weight: 700;
}

.aptitude-test em {
	font-style: italic;
}

.aptitude-test__choice:focus-within {
	outline: var(--focus);
	outline-offset: var(--focus-offset);
}

.aptitude-test__choice:has(input:checked) {
	background: var(--accent);
	color: var(--accent-text);
	border-color: var(--accent);
}

.aptitude-test input[type="radio"] {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0 0 0 0);
	white-space: nowrap;
	border: 0;
}

.aptitude-test__letter {
	display: none;
}

.aptitude-test__audio {
	margin-bottom: 0.75rem;
}

.aptitude-test button.aptitude-test__play {
	appearance: none;
	display: block;
	width: 100%;
	min-height: 56px;
	margin: 0;
	padding: 0.7rem 1.1rem;
	background: var(--accent);
	color: var(--accent-text);
	border: 1px solid transparent;
	border-radius: var(--radius);
	box-shadow: none;
	font-family: inherit;
	font-size: 1.1rem;
	font-weight: 600;
	line-height: 1.2;
	text-align: center;
	cursor: pointer;
}

.aptitude-test button.aptitude-test__play:hover,
.aptitude-test button.aptitude-test__play:focus {
	background: var(--accent);
	color: var(--accent-text);
	filter: brightness(1.08);
}

.aptitude-test button.aptitude-test__play:focus {
	outline: var(--focus);
	outline-offset: var(--focus-offset);
}

.aptitude-test__audio-error {
	margin: 0.5rem 0 0;
	color: var(--danger);
}

.aptitude-test button.aptitude-test__button,
.aptitude-test a.aptitude-test__button {
	appearance: none;
	display: block;
	width: 100%;
	min-height: 48px;
	margin-top: var(--gap);
	padding: 0.7rem 1.1rem;
	background: var(--accent);
	color: var(--accent-text);
	border: 1px solid transparent;
	border-radius: var(--radius);
	box-shadow: none;
	font-family: inherit;
	font-size: 1.15rem;
	font-weight: 600;
	letter-spacing: normal;
	line-height: 1.2;
	text-align: center;
	text-decoration: none;
	text-transform: none;
	cursor: pointer;
	box-sizing: border-box;
}

.aptitude-test button.aptitude-test__button:hover,
.aptitude-test button.aptitude-test__button:focus,
.aptitude-test a.aptitude-test__button:hover,
.aptitude-test a.aptitude-test__button:focus {
	background: var(--accent);
	color: var(--accent-text);
	filter: brightness(1.08);
}

.aptitude-test button.aptitude-test__button:focus,
.aptitude-test a.aptitude-test__button:focus {
	outline: var(--focus);
	outline-offset: var(--focus-offset);
}

.aptitude-test__score {
	margin-bottom: 0.75rem;
	text-align: center;
}

.aptitude-test__result {
	padding: 0.7rem 0.9rem;
	border: 1px solid currentcolor;
	border-radius: var(--radius);
	background: transparent;
}

.aptitude-test__result--fail {
	color: var(--danger);
}

.aptitude-test__result--pass {
	color: var(--ok);
}

.aptitude-test__flash {
	padding: 0.7rem 0.9rem;
	background: var(--surface-raised);
	color: var(--text);
	border: 1px solid var(--border-strong);
	border-radius: var(--radius);
}

.aptitude-test__reset {
	margin-top: var(--gap);
}

.aptitude-test button.aptitude-test__text-button {
	appearance: none;
	width: auto;
	min-height: 36px;
	padding: 0.35rem 0.6rem;
	background: transparent;
	color: var(--text);
	border: 1px solid var(--border-strong);
	border-radius: var(--radius);
	box-shadow: none;
	font-family: inherit;
	font-size: 0.85rem;
	font-weight: 600;
	letter-spacing: normal;
	line-height: 1.2;
	text-decoration: none;
	text-transform: none;
	cursor: pointer;
}

.aptitude-test button.aptitude-test__text-button:hover,
.aptitude-test button.aptitude-test__text-button:focus {
	background: transparent;
	color: var(--text);
	border-color: var(--accent);
}

.aptitude-test.is-busy,
.aptitude-test-root.is-busy {
	opacity: 0.55;
	pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
	.aptitude-test button.aptitude-test__button:hover,
	.aptitude-test button.aptitude-test__button:focus,
	.aptitude-test a.aptitude-test__button:hover,
	.aptitude-test a.aptitude-test__button:focus {
		filter: none;
	}
}
