/**
 * Frontend quiz styling.
 *
 * References the `mentaladvices` theme's CSS custom properties
 * (--color-accent, --font-serif, etc.) with hardcoded fallback values
 * matching the same palette, so the quiz still looks intentional even
 * if a different theme is active — this plugin's frontend must not
 * hard-depend on the theme being present.
 *
 * Loaded only on singular quiz pages.
 */

.quiz {
	padding-block: 2rem 4rem;
}

.quiz-header {
	margin-bottom: 1.5rem;
}

.quiz-intro {
	color: var( --color-ink-soft, #4b5157 );
	font-family: var( --font-serif, Georgia, serif );
	font-size: 1.125rem;
	line-height: 1.7;
}

.quiz-disclaimer {
	border: 1px solid var( --color-line, #ddddd5 );
	border-left: 3px solid var( --color-accent, #2f5d57 );
	border-radius: 4px;
	padding: 0.75rem 1rem;
	margin-bottom: 1.5rem;
	font-size: 0.875rem;
	color: var( --color-ink-soft, #4b5157 );
}

.quiz-disclaimer p {
	margin: 0;
}

.quiz-empty-notice {
	color: var( --color-ink-soft, #4b5157 );
}

/* Progress */
.quiz-progress {
	margin-bottom: 1.5rem;
}

.quiz-progress__text {
	font-size: 0.875rem;
	color: var( --color-ink-soft, #4b5157 );
	margin-bottom: 0.5rem;
}

.quiz-progress__bar {
	height: 6px;
	border-radius: 999px;
	background-color: var( --color-accent-soft, #e3ece9 );
	overflow: hidden;
}

.quiz-progress__fill {
	height: 100%;
	background-color: var( --color-accent, #2f5d57 );
	transition: width 200ms ease;
	width: 0%;
}

/* Question */
.quiz-question {
	border: none;
	margin: 0 0 1.5rem;
	padding: 0;
}

.quiz-question legend {
	font-family: var( --font-serif, Georgia, serif );
	font-size: 1.25rem;
	font-weight: 600;
	color: var( --color-ink, #23272b );
	margin-bottom: 1rem;
	padding: 0;
}

.quiz-question legend:focus {
	outline: 2px solid var( --color-accent, #2f5d57 );
	outline-offset: 4px;
}

.quiz-answer {
	display: flex;
	align-items: flex-start;
	gap: 0.75rem;
	padding: 0.75rem 1rem;
	border: 1px solid var( --color-line, #ddddd5 );
	border-radius: 8px;
	margin-bottom: 0.75rem;
	cursor: pointer;
	transition: border-color 150ms ease, background-color 150ms ease;
}

.quiz-answer:hover {
	border-color: var( --color-accent, #2f5d57 );
	background-color: var( --color-accent-soft, #e3ece9 );
}

.quiz-answer input[type="radio"] {
	margin-top: 0.2em;
	flex-shrink: 0;
}

.quiz-answer.is-selected {
	border-color: var( --color-accent, #2f5d57 );
	background-color: var( --color-accent-soft, #e3ece9 );
}

/* Native radio focus rings are already accessible on their own; no
   :has()-based parent styling needed here. */
.quiz-answer input[type="radio"]:focus-visible {
	outline: 2px solid var( --color-accent, #2f5d57 );
	outline-offset: 2px;
}

/* Validation */
.quiz-validation {
	color: #a3342f;
	font-size: 0.875rem;
	margin-bottom: 1rem;
}

/* Navigation */
.quiz-nav {
	display: flex;
	justify-content: space-between;
	gap: 1rem;
	margin-top: 1.5rem;
}

.quiz-nav button {
	padding: 0.6rem 1.25rem;
	border-radius: 6px;
	font-size: 0.9375rem;
	cursor: pointer;
	border: 1px solid transparent;
}

.quiz-nav__next,
.quiz-nav__finish {
	background-color: var( --color-accent, #2f5d57 );
	color: #fff;
	margin-left: auto;
}

.quiz-nav__next:hover,
.quiz-nav__finish:hover {
	background-color: #24473f;
}

.quiz-nav__prev {
	background: none;
	border-color: var( --color-line, #ddddd5 );
	color: var( --color-ink, #23272b );
}

.quiz-nav__prev:hover {
	border-color: var( --color-accent, #2f5d57 );
}

/* Result */
.quiz-result {
	border: 1px solid var( --color-line, #ddddd5 );
	border-radius: 8px;
	padding: 1.5rem;
	background-color: var( --color-surface, #fff );
}

.quiz-result__intro {
	color: var( --color-ink-soft, #4b5157 );
	margin-bottom: 0.75rem;
}

.quiz-result__title {
	font-family: var( --font-serif, Georgia, serif );
	margin-bottom: 0.75rem;
}

.quiz-result__description {
	line-height: 1.7;
	margin-bottom: 1.5rem;
}

.quiz-result__no-match {
	color: var( --color-ink-soft, #4b5157 );
	background-color: var( --color-accent-soft, #e3ece9 );
	border-radius: 6px;
	padding: 0.75rem 1rem;
	margin-bottom: 1.5rem;
}

.quiz-restart {
	padding: 0.6rem 1.25rem;
	border-radius: 6px;
	border: 1px solid var( --color-accent, #2f5d57 );
	background: none;
	color: var( --color-accent, #2f5d57 );
	cursor: pointer;
	font-size: 0.9375rem;
}

.quiz-restart:hover {
	background-color: var( --color-accent-soft, #e3ece9 );
}

/* Related articles (used when the active theme has no article-card part) */
.quiz-related-articles {
	margin-top: 3rem;
}

.quiz-related-articles__grid {
	display: grid;
	grid-template-columns: 1fr;
	gap: 1.5rem;
}

.quiz-related-articles__card {
	border: 1px solid var( --color-line, #ddddd5 );
	border-radius: 8px;
	overflow: hidden;
}

.quiz-related-articles__card img {
	width: 100%;
	height: auto;
	display: block;
}

.quiz-related-articles__card h3,
.quiz-related-articles__card p {
	padding-inline: 1rem;
}

/* Quiz archive grid + card */
.quiz-grid {
	display: grid;
	grid-template-columns: 1fr;
	gap: 1.5rem;
}

.quiz-card {
	display: flex;
	flex-direction: column;
	border: 1px solid var( --color-line, #ddddd5 );
	border-radius: 8px;
	overflow: hidden;
	background-color: var( --color-surface, #fff );
}

.quiz-card__media {
	display: block;
	aspect-ratio: 16 / 10;
	background-color: var( --color-accent-soft, #e3ece9 );
}

.quiz-card__media img {
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.quiz-card__body {
	padding: 1.5rem;
	display: flex;
	flex-direction: column;
	flex: 1;
}

.quiz-card__title {
	margin-bottom: 0.5rem;
}

.quiz-card__title a {
	text-decoration: none;
	color: var( --color-ink, #23272b );
}

.quiz-card__excerpt {
	color: var( --color-ink-soft, #4b5157 );
	flex: 1;
	margin-bottom: 1rem;
}

.quiz-card__cta {
	align-self: flex-start;
	padding: 0.5rem 1.1rem;
	border-radius: 999px;
	background-color: var( --color-accent, #2f5d57 );
	color: #fff;
	text-decoration: none;
	font-size: 0.875rem;
}

.quiz-card__cta:hover {
	background-color: #24473f;
}

/* Responsive */
@media ( min-width: 48em ) {
	.quiz-related-articles__grid,
	.quiz-grid {
		grid-template-columns: repeat( 2, 1fr );
	}
}

@media ( min-width: 64em ) {
	.quiz-related-articles__grid,
	.quiz-grid {
		grid-template-columns: repeat( 3, 1fr );
	}
}

@media ( prefers-reduced-motion: reduce ) {
	.quiz-progress__fill {
		transition: none;
	}
}
