/**
 * HEXAM frontend quiz styles.
 * Theme-agnostic, self-contained, light/dark aware.
 */

.hexam-quiz {
	--hexam-accent: #4f46e5;
	--hexam-accent-hover: #4338ca;
	--hexam-bg: #ffffff;
	--hexam-fg: #1f2430;
	--hexam-muted: #6b7280;
	--hexam-border: #e5e7eb;
	--hexam-surface: #f8fafc;
	--hexam-radius: 14px;
	--hexam-ok: #16a34a;
	--hexam-bad: #dc2626;

	box-sizing: border-box;
	max-width: 720px;
	margin: 1.5em auto;
	padding: clamp(1.1rem, 2vw, 1.75rem);
	background: var(--hexam-bg);
	color: var(--hexam-fg);
	border: 1px solid var(--hexam-border);
	border-radius: var(--hexam-radius);
	box-shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 8px 24px rgba(16, 24, 40, .06);
	font-size: 16px;
	line-height: 1.5;
}

.hexam-quiz *,
.hexam-quiz *::before,
.hexam-quiz *::after {
	box-sizing: border-box;
}

.hexam-quiz__title {
	margin: 0 0 .35em;
	font-size: 1.4rem;
	line-height: 1.25;
}

.hexam-quiz__desc {
	color: var(--hexam-muted);
	margin-bottom: 1rem;
}

.hexam-quiz__desc p:last-child { margin-bottom: 0; }

/* Progress bar (slide mode) */
.hexam-progress {
	height: 6px;
	border-radius: 999px;
	background: var(--hexam-border);
	overflow: hidden;
	margin: 0 0 1.1rem;
}
.hexam-progress__bar {
	height: 100%;
	width: 0;
	background: var(--hexam-accent);
	transition: width .25s ease;
}
.hexam-progress__label {
	font-size: .8rem;
	color: var(--hexam-muted);
	margin: -.6rem 0 1rem;
}

.hexam-field { margin-bottom: 1.25rem; }
.hexam-field label {
	display: block;
	font-weight: 600;
	margin-bottom: .35rem;
	font-size: .95rem;
}
.hexam-field input[type="text"],
.hexam-open {
	width: 100%;
	padding: .65rem .8rem;
	border: 1px solid var(--hexam-border);
	border-radius: 10px;
	font: inherit;
	color: inherit;
	background: var(--hexam-surface);
}
.hexam-open:focus,
.hexam-field input:focus {
	outline: 2px solid var(--hexam-accent);
	outline-offset: 1px;
}

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

.hexam-question {
	padding: 1.1rem 0;
	border-top: 1px solid var(--hexam-border);
}
.hexam-question:first-child { border-top: 0; padding-top: 0; }

.hexam-question__text {
	display: flex;
	gap: .5rem;
	font-weight: 600;
	margin-bottom: .8rem;
}
.hexam-question__num { color: var(--hexam-accent); }
.hexam-question__body img{max-width:100%}
.hexam-question__body p { margin: 0 0 .4em; }
.hexam-question__body p:last-child { margin: 0; }

.hexam-answers { display: grid; gap: .5rem; }

.hexam-answer {
	display: flex;
	align-items: flex-start;
	gap: .65rem;
	padding: .7rem .85rem;
	border: 1px solid var(--hexam-border);
	border-radius: 10px;
	cursor: pointer;
	background: var(--hexam-surface);
	transition: border-color .15s ease, background .15s ease;
}
.hexam-answer:hover { border-color: var(--hexam-accent); }
.hexam-answer input { margin-top: .2rem; accent-color: var(--hexam-accent); }
.hexam-answer:has(input:checked) {
	border-color: var(--hexam-accent);
	background: color-mix(in srgb, var(--hexam-accent) 8%, transparent);
}

.hexam-quiz__footer {
	display: flex;
	gap: .6rem;
	justify-content: flex-end;
	margin-top: 1.4rem;
	flex-wrap: wrap;
}

.hexam-btn,
.hexam-submit {
	appearance: none;
	border: 0;
	cursor: pointer;
	font: inherit;
	font-weight: 600;
	padding: .7rem 1.35rem;
	border-radius: 10px;
	background: var(--hexam-accent);
	color: #fff;
	transition: background .15s ease, opacity .15s ease;
}
.hexam-btn:hover,
.hexam-submit:hover { background: var(--hexam-accent-hover); }
.hexam-btn--ghost {
	background: transparent;
	color: var(--hexam-fg);
	border: 1px solid var(--hexam-border);
}
.hexam-btn--ghost:hover { background: var(--hexam-surface); }
.hexam-btn[hidden] { display: none; }

/* Slide mode: only the active question is visible */
.hexam-quiz[data-mode="slide"] .hexam-question { display: none; }
.hexam-quiz[data-mode="slide"] .hexam-question.is-active { display: block; }

.hexam-question.has-error .hexam-answers { animation: hexam-shake .3s; }
.hexam-question.has-error { border-left: 3px solid var(--hexam-bad); padding-left: .75rem; }
@keyframes hexam-shake {
	25% { transform: translateX(-4px); }
	75% { transform: translateX(4px); }
}

/* Result panel */
.hexam-result { text-align: center; }
.hexam-result__icon {
	width: 56px; height: 56px;
	margin: .25rem auto 1rem;
	border-radius: 50%;
	background: color-mix(in srgb, var(--hexam-ok) 15%, transparent);
	position: relative;
}
.hexam-result__icon::after {
	content: "";
	position: absolute; left: 20px; top: 14px;
	width: 12px; height: 22px;
	border: solid var(--hexam-ok);
	border-width: 0 4px 4px 0;
	transform: rotate(45deg);
}
.hexam-result__lead { font-weight: 600; font-size: 1.1rem; margin: 0 0 .4rem; }
.hexam-result__score { font-size: 1.35rem; font-weight: 700; margin: .3rem 0; }
.hexam-result__meter {
	height: 10px; border-radius: 999px; background: var(--hexam-border);
	overflow: hidden; max-width: 320px; margin: .8rem auto;
}
.hexam-result__meter span { display: block; height: 100%; background: var(--hexam-accent); }
.hexam-result__verdict { font-weight: 700; }
.hexam-result__verdict.is-pass { color: var(--hexam-ok); }
.hexam-result__verdict.is-fail { color: var(--hexam-bad); }

/* Notices */
.hexam-notice {
	text-align: center;
	color: var(--hexam-fg);
}
.hexam-notice--warning { border-color: #f5c26b; background: #fff8ec; color: #92400e; }
.hexam-notice--info { border-color: #93c5fd; background: #eff6ff; color: #1e40af; }

@media (max-width: 600px) {
	.hexam-quiz { margin: 1em 0; }
	.hexam-quiz__footer { justify-content: stretch; }
	.hexam-btn, .hexam-submit { flex: 1; text-align: center; }
}

/* Dark mode */
@media (prefers-color-scheme: dark) {
	.hexam-quiz {
		--hexam-bg: #14171f;
		--hexam-fg: #e5e7eb;
		--hexam-muted: #9aa4b2;
		--hexam-border: #2a2f3a;
		--hexam-surface: #1b1f29;
		box-shadow: 0 8px 24px rgba(0, 0, 0, .35);
	}
	.hexam-notice--warning { background: #2a2113; color: #fcd34d; border-color: #7c5b1e; }
	.hexam-notice--info { background: #10233f; color: #93c5fd; border-color: #1d4ed8; }
}
