/**
 * QI Test Engine — front-end styles.
 *
 * Self-contained and theme-agnostic: every colour is a custom property with a
 * sane fallback, so the quiz looks deliberate in any theme and follows the
 * host theme's palette when it defines one. Dark mode is handled by the same
 * tokens, once.
 */

.qit {
	--qit-accent: var(--wp--preset--color--primary, #3d5afe);
	--qit-accent-ink: #fff;
	--qit-ink: var(--wp--preset--color--foreground, #16181d);
	--qit-muted: #6b7280;
	--qit-line: #d8dbe2;
	--qit-line-soft: #eceef2;
	--qit-surface: #fff;
	--qit-surface-2: #f7f8fa;
	--qit-ok: #1a7f52;
	--qit-ko: #b3261e;
	--qit-radius: 14px;

	color: var(--qit-ink);
	max-width: 46rem;
	margin-inline: auto;
	font-size: 1.0625rem;
	line-height: 1.6;
}

@media (prefers-color-scheme: dark) {
	.qit {
		--qit-ink: #e9eaee;
		--qit-muted: #9aa1ad;
		--qit-line: #363b45;
		--qit-line-soft: #272b33;
		--qit-surface: #1b1e24;
		--qit-surface-2: #23272f;
		--qit-ok: #4ade80;
		--qit-ko: #ff8a80;
	}
}

/* ---------------------------------------------------------------- Intro -- */

.qit-lede {
	font-size: 1.15rem;
	margin: 0 0 .5rem;
}

.qit-hint {
	color: var(--qit-muted);
	margin: 0 0 1.5rem;
}

/* --------------------------------------------------------------- Button -- */

.qit-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: .5rem;
	min-height: 52px;
	padding: 0 1.6rem;
	border: 1px solid transparent;
	border-radius: 999px;
	background: var(--qit-accent);
	color: var(--qit-accent-ink);
	font: inherit;
	font-weight: 600;
	text-decoration: none;
	cursor: pointer;
	transition: filter .15s ease, transform .15s ease;
}

.qit-btn:hover { filter: brightness(1.08); }
.qit-btn:active { transform: translateY(1px); }

.qit-btn:focus-visible {
	outline: 3px solid var(--qit-accent);
	outline-offset: 3px;
}

.qit-ghost {
	background: transparent;
	border-color: var(--qit-line);
	color: var(--qit-ink);
}

.qit-big {
	min-height: 60px;
	font-size: 1.1rem;
	width: 100%;
}

@media (min-width: 40rem) {
	.qit-big { width: auto; min-width: 16rem; }
}

/* ------------------------------------------------------------------ HUD -- */

.qit-hud {
	position: sticky;
	top: 0;
	z-index: 5;
	padding: .75rem 0 .5rem;
	background: var(--qit-surface);
	background: color-mix(in srgb, var(--qit-surface) 92%, transparent);
	backdrop-filter: blur(6px);
	margin-bottom: 1rem;
}

.qit-progress {
	height: 6px;
	border-radius: 999px;
	background: var(--qit-line-soft);
	overflow: hidden;
}

.qit-progress-fill {
	display: block;
	height: 100%;
	width: 0;
	border-radius: 999px;
	background: var(--qit-accent);
	transition: width .25s ease;
}

.qit-hud-row {
	display: flex;
	justify-content: space-between;
	align-items: baseline;
	margin-top: .4rem;
	font-size: .875rem;
	color: var(--qit-muted);
}

.qit-timer { font-variant-numeric: tabular-nums; }
.qit-timer.is-low { color: var(--qit-ko); font-weight: 600; }

/* ---------------------------------------------------------------- Steps -- */

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

.qit-step { margin: 0 0 2.5rem; }

/* Stepped mode is switched on by the script; without JS every question is
   simply visible and the form still submits. */
.qit-js .qit-step { display: none; }
.qit-js .qit-step.is-current { display: block; }
.qit-js .qit-steps { margin-bottom: 1.5rem; }

/* The sticky HUD already shows the position, so the per-question counter is
   only there for the no-JavaScript rendering. */
.qit-js .qit-step-n { display: none; }

/* The question heading is focused programmatically when a step opens, so
   screen readers announce it. That is not a keyboard focus and must not paint
   a focus ring. */
.qit-prompt:focus { outline: none; }

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

.qit-legend {
	display: flex;
	flex-wrap: wrap;
	gap: .5rem .75rem;
	align-items: baseline;
	padding: 0;
	margin-bottom: .6rem;
	font-size: .8125rem;
	color: var(--qit-muted);
}

.qit-cat {
	padding: .1rem .55rem;
	border-radius: 999px;
	background: var(--qit-surface-2);
	border: 1px solid var(--qit-line-soft);
}

.qit-prompt {
	font-size: 1.25rem;
	font-weight: 600;
	line-height: 1.35;
	margin: 0 0 1.1rem;
}

/* ------------------------------------------------------------- Stimulus -- */

.qit-stim,
.qit-model {
	margin: 0 0 1.25rem;
	padding: 1rem;
	border: 1px solid var(--qit-line-soft);
	border-radius: var(--qit-radius);
	background: var(--qit-surface-2);
	text-align: center;
	overflow-x: auto;
}

.qit-model figcaption {
	font-size: .75rem;
	text-transform: uppercase;
	letter-spacing: .06em;
	color: var(--qit-muted);
	margin-bottom: .4rem;
}

.qit-gallery {
	display: flex;
	flex-wrap: wrap;
	gap: .75rem;
	justify-content: center;
	margin: 0 0 1.25rem;
	padding: 1rem;
	border: 1px solid var(--qit-line-soft);
	border-radius: var(--qit-radius);
	background: var(--qit-surface-2);
}

.qit-gallery-cell {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: .35rem;
}

.qit-fig { max-width: 100%; height: auto; }
.qit-fig-matrix { max-width: 100%; }

/* SVG primitives. Everything inherits currentColor, so figures stay legible
   in light and dark mode without a second set of rules. */
.qit-none { fill: none; stroke: currentColor; stroke-width: 4; stroke-linejoin: round; }
.qit-solid { fill: currentColor; stroke: none; }
.qit-hatch { fill: none; stroke: currentColor; stroke-width: 4; }
.qit-dots { fill: none; stroke: currentColor; stroke-width: 4; stroke-dasharray: 6 6; }

.qit-cell { fill: none; stroke: var(--qit-line); stroke-width: 2; }
.qit-cell-blank { stroke-dasharray: 7 6; }

.qit-qmark {
	fill: var(--qit-muted);
	font-size: 46px;
	font-weight: 700;
	font-family: inherit;
}

/* -------------------------------------------------------------- Options -- */

.qit-options {
	display: grid;
	gap: .6rem;
}

.qit-options-figure {
	grid-template-columns: repeat(2, minmax(0, 1fr));
}

@media (min-width: 34rem) {
	.qit-options-figure { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

.qit-option { position: relative; display: block; cursor: pointer; }

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

.qit-option-body {
	display: flex;
	align-items: center;
	gap: .75rem;
	min-height: 56px;
	padding: .7rem .9rem;
	border: 2px solid var(--qit-line);
	border-radius: var(--qit-radius);
	background: var(--qit-surface);
	transition: border-color .12s ease, background-color .12s ease;
}

.qit-options-figure .qit-option-body {
	flex-direction: column;
	justify-content: center;
	gap: .4rem;
	padding: .8rem .5rem;
}

.qit-option:hover .qit-option-body { border-color: var(--qit-muted); }

.qit-option input:checked + .qit-option-body {
	border-color: var(--qit-accent);
	background: color-mix(in srgb, var(--qit-accent) 8%, var(--qit-surface));
}

.qit-option input:focus-visible + .qit-option-body {
	outline: 3px solid var(--qit-accent);
	outline-offset: 2px;
}

.qit-key {
	flex: none;
	display: inline-grid;
	place-items: center;
	width: 26px;
	height: 26px;
	border-radius: 50%;
	background: var(--qit-surface-2);
	border: 1px solid var(--qit-line-soft);
	font-size: .8125rem;
	font-weight: 700;
	color: var(--qit-muted);
}

.qit-option input:checked + .qit-option-body .qit-key {
	background: var(--qit-accent);
	border-color: var(--qit-accent);
	color: var(--qit-accent-ink);
}

.qit-option-text { font-weight: 500; }

/* ----------------------------------------------------------------- Nav --- */

.qit-nav {
	display: flex;
	gap: .75rem;
	justify-content: space-between;
	margin-bottom: 1.5rem;
}

.qit-nav .qit-next { margin-inline-start: auto; }

.qit-submit { margin-top: 1rem; }

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

/* -------------------------------------------------------------- Results -- */

.qit-card {
	padding: 1.5rem;
	margin: 0 0 1.25rem;
	border: 1px solid var(--qit-line-soft);
	border-radius: var(--qit-radius);
	background: var(--qit-surface);
}

.qit-h2 { font-size: 1.35rem; margin: 0 0 .35rem; }

.qit-sub {
	color: var(--qit-muted);
	margin: 0 0 1.25rem;
	font-size: .95rem;
}

.qit-score { text-align: center; }

.qit-score-label {
	margin: 0;
	font-size: .8125rem;
	text-transform: uppercase;
	letter-spacing: .08em;
	color: var(--qit-muted);
}

.qit-score-value {
	margin: .2rem 0 0;
	font-size: clamp(3.5rem, 14vw, 5rem);
	font-weight: 800;
	line-height: 1;
	letter-spacing: -.02em;
	font-variant-numeric: tabular-nums;
}

.qit-score-range { margin: .4rem 0 0; color: var(--qit-muted); }

.qit-score-band {
	margin: .75rem 0 0;
	font-weight: 600;
	font-size: 1.05rem;
}

.qit-score-pct { margin: .25rem 0 1rem; color: var(--qit-muted); }

.qit-facts {
	list-style: none;
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: .4rem .75rem;
	margin: 0;
	padding: 0;
	font-size: .875rem;
	color: var(--qit-muted);
}

.qit-facts li {
	padding: .2rem .7rem;
	border-radius: 999px;
	background: var(--qit-surface-2);
}

.qit-warn {
	padding: .9rem 1.1rem;
	margin: 0 0 1.25rem;
	border-radius: var(--qit-radius);
	background: color-mix(in srgb, var(--qit-ko) 10%, var(--qit-surface));
	border: 1px solid color-mix(in srgb, var(--qit-ko) 30%, transparent);
	font-size: .95rem;
}

/* Bell curve */
.qit-bell { width: 100%; height: auto; margin: 1rem 0 .5rem; }
.qit-bell-area { fill: color-mix(in srgb, var(--qit-ink) 9%, transparent); stroke: none; }
.qit-bell-ci { fill: color-mix(in srgb, var(--qit-accent) 16%, transparent); }
.qit-bell-mark { stroke: var(--qit-accent); stroke-width: 3; stroke-linecap: round; }
.qit-axis { stroke: var(--qit-line); stroke-width: 1.5; }
.qit-axis-label { fill: var(--qit-muted); font-size: 13px; font-family: inherit; }

/* Sub-scores */
.qit-subscores { display: grid; gap: 1.25rem; }

.qit-subscore-head {
	display: flex;
	justify-content: space-between;
	align-items: baseline;
	gap: 1rem;
}

.qit-subscore-name { font-weight: 600; }

.qit-subscore-val {
	font-variant-numeric: tabular-nums;
	font-weight: 700;
	font-size: 1.1rem;
}

.qit-meter {
	position: relative;
	height: 10px;
	margin: .45rem 0 .35rem;
	border-radius: 999px;
	background: var(--qit-line-soft);
	overflow: hidden;
}

.qit-meter-fill {
	display: block;
	height: 100%;
	border-radius: 999px;
	background: var(--qit-accent);
}

.qit-meter-mid {
	position: absolute;
	left: 50%;
	top: -3px;
	bottom: -3px;
	width: 2px;
	background: var(--qit-muted);
	opacity: .5;
	z-index: 1;
}

.qit-subscore-meta {
	margin: 0;
	font-size: .875rem;
	color: var(--qit-muted);
}

/* Correction */
.qit-corr {
	border: 1px solid var(--qit-line-soft);
	border-radius: var(--qit-radius);
	margin-bottom: .6rem;
	background: var(--qit-surface-2);
}

.qit-corr summary {
	display: flex;
	align-items: center;
	gap: .75rem;
	padding: .85rem 1rem;
	cursor: pointer;
	list-style: none;
	font-size: .95rem;
}

.qit-corr summary::-webkit-details-marker { display: none; }

.qit-corr-n {
	flex: none;
	display: inline-grid;
	place-items: center;
	width: 28px;
	height: 28px;
	border-radius: 50%;
	font-size: .8125rem;
	font-weight: 700;
	background: var(--qit-surface);
	border: 1px solid var(--qit-line);
}

.qit-corr-prompt {
	flex: 1;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.qit-corr-flag {
	flex: none;
	font-size: .75rem;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: .04em;
}

.qit-corr.is-ok .qit-corr-flag { color: var(--qit-ok); }
.qit-corr.is-ko .qit-corr-flag { color: var(--qit-ko); }
.qit-corr.is-ok .qit-corr-n { border-color: var(--qit-ok); color: var(--qit-ok); }
.qit-corr.is-ko .qit-corr-n { border-color: var(--qit-ko); color: var(--qit-ko); }

.qit-corr-body {
	padding: 0 1rem 1.1rem;
	border-top: 1px solid var(--qit-line-soft);
	padding-top: 1rem;
}

.qit-corr-answers p { margin: 0 0 .4rem; }

.qit-inline-answer {
	display: inline-flex;
	align-items: center;
	gap: .45rem;
	vertical-align: middle;
}

.qit-why {
	margin: .9rem 0 0;
	padding: .9rem 1rem;
	border-radius: 10px;
	background: var(--qit-surface);
	border: 1px solid var(--qit-line-soft);
}

.qit-honest p { margin: 0 0 .75rem; }

.qit-after {
	display: flex;
	flex-wrap: wrap;
	gap: .75rem;
	margin-top: 1.5rem;
}

/* ------------------------------------------------------------------ CTA -- */

.qit-cta {
	max-width: 46rem;
	margin: 2rem auto;
	padding: 1.4rem 1.5rem;
	border: 1px solid var(--qit-line, #d8dbe2);
	border-radius: 14px;
	background: var(--qit-surface-2, #f7f8fa);
}

.qit-cta-title { margin: 0 0 .35rem; font-size: 1.15rem; }
.qit-cta-text { margin: 0 0 1rem; color: var(--qit-muted, #6b7280); }

/* ---------------------------------------------------------------- Print -- */

@media print {
	.qit-after,
	.qit-hud,
	.qit-nav { display: none !important; }

	.qit-corr[open] .qit-corr-body { display: block; }
	.qit-card { break-inside: avoid; border-color: #ccc; }
}

@media (prefers-reduced-motion: reduce) {
	.qit * { transition: none !important; }
}
