/*
 * Personality Sorter: styles.
 * Phone first, one column, generous tap targets. Colours come from a few
 * variables so a dark scheme is one block at the bottom.
 */

:root {
	--bg: #faf8f4;
	--fg: #22211f;
	--muted: #6b665e;
	--line: #ddd7cc;
	--accent: #7a3e1d;
	--accent-soft: #f3e7dd;
	--error: #9b2c2c;
	--error-soft: #fbeaea;
	--focus: #1d4ed8;
}

* {
	box-sizing: border-box;
}

html {
	-webkit-text-size-adjust: 100%;
}

body {
	margin: 0;
	padding: 0 16px 48px;
	background: var(--bg);
	color: var(--fg);
	font-family: Georgia, "Times New Roman", serif;
	font-size: 1.0625rem;
	line-height: 1.5;
	max-width: 44rem;
	margin-inline: auto;
}

h1, h2, h3 {
	font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
	line-height: 1.2;
	margin: 0 0 0.5rem;
}

h1 {
	font-size: 1.9rem;
	margin-top: 2rem;
}

h2 {
	font-size: 1.5rem;
}

h3 {
	font-size: 1.1rem;
	margin-top: 1.5rem;
}

p {
	margin: 0 0 0.75rem;
}

a {
	color: var(--accent);
}

/* Header */

.lede {
	font-size: 1.1rem;
}

.privacy {
	color: var(--muted);
	font-size: 0.95rem;
	border-left: 3px solid var(--line);
	padding-left: 0.75rem;
}

.progress {
	font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
	font-size: 0.9rem;
	color: var(--muted);
	position: sticky;
	top: 0;
	background: var(--bg);
	padding: 0.5rem 0;
	margin: 0;
	z-index: 1;
}

.loading {
	color: var(--muted);
}

/* Questions */

.questions {
	list-style: none;
	padding: 0;
	margin: 0;
}

.question {
	border-top: 1px solid var(--line);
	padding: 1rem 0;
}

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

.question legend {
	font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
	font-weight: 600;
	padding: 0;
	margin-bottom: 0.5rem;
}

.question-number {
	color: var(--muted);
	font-weight: normal;
}

.choice {
	display: flex;
	align-items: flex-start;
	gap: 0.75rem;
	margin: 0.25rem 0;
}

/* The whole label is the tap target, with room for a thumb. */
.choice label {
	flex: 1;
	padding: 0.5rem 0.75rem;
	border: 1px solid var(--line);
	border-radius: 0.5rem;
	cursor: pointer;
}

.choice input {
	margin-top: 0.9rem;
	width: 1.25rem;
	height: 1.25rem;
	flex: none;
	accent-color: var(--accent);
}

.choice input:checked + label {
	background: var(--accent-soft);
	border-color: var(--accent);
}

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

/* Submit */

.submit {
	margin-top: 2rem;
}

.button {
	font: inherit;
	font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
	font-weight: 600;
	background: var(--accent);
	color: #fff;
	border: 0;
	border-radius: 0.5rem;
	padding: 0.85rem 1.5rem;
	width: 100%;
	cursor: pointer;
}

.button:focus-visible,
a:focus-visible,
[tabindex="-1"]:focus-visible {
	outline: 3px solid var(--focus);
	outline-offset: 2px;
}

/* Errors */

.errors {
	background: var(--error-soft);
	border-left: 4px solid var(--error);
	padding: 0.75rem 1rem;
	margin: 1rem 0;
	border-radius: 0 0.5rem 0.5rem 0;
}

.errors-heading {
	font-weight: 600;
	margin-bottom: 0.25rem;
}

.errors ul {
	margin: 0;
	padding-left: 1.25rem;
	columns: 2;
}

/* Result */

.result {
	padding-top: 1rem;
}

.type {
	font-size: 1.3em;
	letter-spacing: 0.06em;
	color: var(--accent);
	white-space: nowrap;
}

.temperament {
	font-size: 1.1rem;
}

.counts {
	border-collapse: collapse;
	width: 100%;
	margin: 1.5rem 0;
}

.counts caption {
	text-align: left;
	color: var(--muted);
	font-size: 0.9rem;
	margin-bottom: 0.25rem;
}

.counts th,
.counts td {
	text-align: left;
	padding: 0.5rem 0.75rem 0.5rem 0;
	border-bottom: 1px solid var(--line);
	font-weight: normal;
}

.counts thead th {
	font-weight: 600;
	font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
	font-size: 0.9rem;
}

.counts td {
	white-space: nowrap;
	font-variant-numeric: tabular-nums;
}

.explainer {
	color: var(--muted);
	font-size: 0.95rem;
}

.tie-note {
	color: var(--fg);
	background: var(--accent-soft);
	padding: 0.75rem 1rem;
	border-radius: 0.5rem;
}

.actions {
	margin-top: 2rem;
}

.actions .button {
	display: inline-block;
	width: auto;
	text-decoration: none;
	text-align: center;
}

.actions-note {
	display: block;
	margin-top: 0.6rem;
	color: var(--muted);
	font-size: 0.95rem;
}

.again {
	margin-top: 2rem;
}

/* Footer */

.page-footer {
	margin-top: 3rem;
	padding-top: 1rem;
	border-top: 1px solid var(--line);
	color: var(--muted);
	font-size: 0.9rem;
}

/* Wider screens: a little more air. */
@media (min-width: 40rem) {
	body {
		padding-inline: 24px;
	}

	.button {
		width: auto;
	}
}

/* Dark scheme follows the device setting. */
@media (prefers-color-scheme: dark) {
	:root {
		--bg: #1c1b19;
		--fg: #ece8e1;
		--muted: #a8a197;
		--line: #3a3732;
		--accent: #e3a580;
		--accent-soft: #33281f;
		--error: #f28b8b;
		--error-soft: #3a2323;
		--focus: #8ab4ff;
	}

	.button {
		color: #1c1b19;
	}
}

@media (prefers-reduced-motion: reduce) {
	* {
		scroll-behavior: auto !important;
	}
}
