/* ─── Reset & Base ─────────────────────────────────────── */
*,
*::before,
*::after {
	box-sizing: border-box;
	margin: 0;
	padding: 0;
}

:root {
	--bg: #F5F1EB;
	--surface: #FFFFFF;
	--border: #E3DDD5;
	--border-hover: #C8C0B4;
	--text: #1C1917;
	--text-muted: #78716C;
	--text-faint: #A8A29E;
	--primary: #2D4CA3;
	--primary-light: #EEF2FF;
	--correct: #15803D;
	--correct-bg: #F0FDF4;
	--correct-border: #86EFAC;
	--wrong: #B91C1C;
	--wrong-bg: #FFF1F2;
	--wrong-border: #FECDD3;
	--radius: 12px;
	--radius-sm: 8px;
	--shadow: 0 1px 3px rgba(0, 0, 0, .07), 0 4px 16px rgba(0, 0, 0, .06);
	--shadow-hover: 0 2px 8px rgba(0, 0, 0, .10), 0 8px 24px rgba(0, 0, 0, .09);
	--transition: 170ms ease;
}

html {
	scroll-behavior: smooth;
}

body {
	font-family: 'Plus Jakarta Sans', sans-serif;
	background: var(--bg);
	color: var(--text);
	min-height: 100vh;
	line-height: 1.6;
}

/* ─── Header ────────────────────────────────────────────── */
header {
	background: var(--surface);
	border-bottom: 1px solid var(--border);
	position: sticky;
	top: 0;
	z-index: 100;
	box-shadow: 0 1px 0 var(--border), 0 2px 12px rgba(0, 0, 0, .04);
}

.header-inner {
	max-width: 1140px;
	margin: 0 auto;
	padding: 0 24px;
	height: 68px;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
}

.logo {
	display: flex;
	align-items: center;
	gap: 12px;
	flex-shrink: 0;
}

.logo-icon {
	font-size: 28px;
	line-height: 1;
}

.logo-text h1 {
	font-family: 'Fraunces', serif;
	font-size: 1.15rem;
	font-weight: 700;
	color: var(--text);
	line-height: 1.2;
	letter-spacing: -0.02em;
}

.logo-text p {
	font-size: 0.7rem;
	color: var(--text-faint);
	letter-spacing: 0.03em;
	text-transform: uppercase;
}

.header-controls {
	display: flex;
	align-items: center;
	gap: 14px;
}

/* ─── Mode Toggle ───────────────────────────────────────── */
.mode-toggle {
	display: flex;
	background: var(--bg);
	border: 1px solid var(--border);
	border-radius: 999px;
	padding: 3px;
	gap: 2px;
}

.mode-btn {
	border: none;
	background: transparent;
	cursor: pointer;
	font-family: 'Plus Jakarta Sans', sans-serif;
	font-size: 0.78rem;
	font-weight: 500;
	color: var(--text-muted);
	padding: 5px 14px;
	border-radius: 999px;
	transition: background var(--transition), color var(--transition);
	white-space: nowrap;
}

.mode-btn:hover {
	color: var(--text);
}

.mode-btn.active {
	background: var(--surface);
	color: var(--primary);
	font-weight: 600;
	box-shadow: 0 1px 4px rgba(0, 0, 0, .10);
}

/* ─── Score Pill ────────────────────────────────────────── */
.score-pill {
	display: flex;
	align-items: baseline;
	gap: 3px;
	background: var(--primary-light);
	color: var(--primary);
	border-radius: 999px;
	padding: 5px 14px;
	font-size: 0.85rem;
	font-weight: 600;
	white-space: nowrap;
}

.score-label {
	font-size: 0.72rem;
	font-weight: 500;
	opacity: 0.75;
	margin-left: 1px;
}

/* ─── Main Layout ───────────────────────────────────────── */
main {
	max-width: 1140px;
	margin: 0 auto;
	padding: 32px 24px 80px;
}

/* ─── Loading ───────────────────────────────────────────── */
.loading-state {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 16px;
	padding: 80px;
	color: var(--text-muted);
	font-size: 0.9rem;
}

.spinner {
	width: 32px;
	height: 32px;
	border: 2.5px solid var(--border);
	border-top-color: var(--primary);
	border-radius: 50%;
	animation: spin 0.75s linear infinite;
}

@keyframes spin {
	to {
		transform: rotate(360deg);
	}
}

/* ─── Single View ───────────────────────────────────────── */
.single-view {
	max-width: 680px;
	margin: 0 auto;
	display: flex;
	flex-direction: column;
	gap: 20px;
}

/* Progress bar */
.progress-track {
	height: 5px;
	background: var(--border);
	border-radius: 999px;
	overflow: hidden;
}

.progress-fill {
	height: 100%;
	background: linear-gradient(90deg, var(--primary), #6B8CFF);
	border-radius: 999px;
	transition: width 0.4s cubic-bezier(.4, 0, .2, 1);
}

/* Breadcrumb row */
.q-meta {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
}

.subsection-tag {
	font-size: 0.72rem;
	font-weight: 600;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	color: var(--primary);
	background: var(--primary-light);
	padding: 3px 10px;
	border-radius: 999px;
}

.q-counter {
	font-size: 0.8rem;
	color: var(--text-faint);
	font-weight: 500;
}

.q-counter em {
	font-style: normal;
	margin: 0 2px;
}

/* Navigation buttons */
.single-nav {
	position: fixed;
	bottom: 0;
	left: 0;
	right: 0;
	display: flex;
	justify-content: space-between;
	gap: 12px;
	padding: 12px 24px;
	background: var(--surface);
	border-top: 1px solid var(--border);
	box-shadow: 0 -4px 16px rgba(0, 0, 0, .06);
	z-index: 50;
	/* keep buttons aligned with the card above */
	max-width: 680px;
	margin-left: auto;
	margin-right: auto;
	border-top-left-radius: var(--radius);
	border-top-right-radius: var(--radius);
}

.btn-nav {
	border: 1px solid var(--border);
	background: var(--surface);
	color: var(--text);
	font-family: 'Plus Jakarta Sans', sans-serif;
	font-size: 0.85rem;
	font-weight: 600;
	padding: 10px 24px;
	border-radius: var(--radius-sm);
	cursor: pointer;
	transition: background var(--transition), border-color var(--transition), box-shadow var(--transition), transform var(--transition);
}

.btn-nav:hover:not(:disabled) {
	background: var(--bg);
	border-color: var(--border-hover);
	box-shadow: var(--shadow-hover);
	transform: translateY(-1px);
}

.btn-nav:disabled {
	opacity: 0.35;
	cursor: not-allowed;
}

.btn-next {
	background: var(--primary);
	color: #fff;
	border-color: var(--primary);
}

.btn-next:hover:not(:disabled) {
	background: #2440A0;
	border-color: #2440A0;
	color: #fff;
}

/* ─── List View ─────────────────────────────────────────── */
.list-view {
	display: flex;
	flex-direction: column;
	gap: 40px;
}

.section-heading {
	font-family: 'Fraunces', serif;
	font-size: 1.1rem;
	font-weight: 700;
	color: var(--text);
	letter-spacing: -0.02em;
	margin-bottom: 16px;
	padding-bottom: 10px;
	border-bottom: 2px solid var(--border);
}

.question-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(460px, 1fr));
	gap: 16px;
}

/* ─── Question Card ─────────────────────────────────────── */
.question-card {
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	padding: 24px;
	box-shadow: var(--shadow);
	transition: box-shadow var(--transition), border-color var(--transition);
	position: relative;
	overflow: hidden;
	/* for emoji burst */
}

.question-card:hover {
	box-shadow: var(--shadow-hover);
}

.question-card.card-correct {
	border-color: var(--correct-border);
	background: var(--correct-bg);
}

.question-card.card-wrong {
	border-color: var(--wrong-border);
	background: var(--wrong-bg);
}

/* Subtle top stripe indicating status */
.question-card.card-correct::before,
.question-card.card-wrong::before {
	content: '';
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	height: 3px;
	border-radius: var(--radius) var(--radius) 0 0;
}

.question-card.card-correct::before {
	background: var(--correct);
}

.question-card.card-wrong::before {
	background: var(--wrong);
}

.question-text {
	font-family: 'Fraunces', serif;
	font-size: 1.05rem;
	font-weight: 500;
	line-height: 1.55;
	color: var(--text);
	margin-bottom: 18px;
	letter-spacing: -0.01em;
}

/* ─── Choices ───────────────────────────────────────────── */
.choices {
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.choice {
	display: flex;
	align-items: center;
	gap: 12px;
	background: var(--bg);
	border: 1.5px solid var(--border);
	border-radius: var(--radius-sm);
	padding: 10px 14px;
	cursor: pointer;
	text-align: left;
	width: 100%;
	font-family: 'Plus Jakarta Sans', sans-serif;
	font-size: 0.875rem;
	font-weight: 500;
	color: var(--text);
	transition: background var(--transition), border-color var(--transition),
		transform var(--transition), box-shadow var(--transition);
}

.choice:hover:not(:disabled) {
	background: var(--primary-light);
	border-color: var(--primary);
	transform: translateX(3px);
}

.choice:disabled {
	cursor: default;
}

.choice-key {
	font-size: 0.7rem;
	font-weight: 700;
	letter-spacing: 0.05em;
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: 5px;
	width: 22px;
	height: 22px;
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	color: var(--text-muted);
	transition: background var(--transition), border-color var(--transition), color var(--transition);
}

.choice-text {
	flex: 1;
	line-height: 1.4;
}

/* Choice states after answering */
.choice.choice-correct {
	background: var(--correct-bg);
	border-color: var(--correct);
	color: var(--correct);
}

.choice.choice-correct .choice-key {
	background: var(--correct);
	border-color: var(--correct);
	color: #fff;
}

.choice.choice-wrong {
	background: var(--wrong-bg);
	border-color: var(--wrong);
	color: var(--wrong);
}

.choice.choice-wrong .choice-key {
	background: var(--wrong);
	border-color: var(--wrong);
	color: #fff;
}

.choice.choice-dim {
	opacity: 0.45;
}

/* ─── Feedback Banner ───────────────────────────────────── */
.answer-feedback {
	margin-top: 14px;
	padding: 10px 14px;
	border-radius: var(--radius-sm);
	font-size: 0.83rem;
	font-weight: 600;
	display: flex;
	align-items: center;
	gap: 8px;
	animation: feedbackIn 0.25s ease both;
}

@keyframes feedbackIn {
	from {
		opacity: 0;
		transform: translateY(4px);
	}

	to {
		opacity: 1;
		transform: translateY(0);
	}
}

.feedback-correct {
	background: #DCFCE7;
	color: var(--correct);
	border: 1px solid #86EFAC;
}

.feedback-wrong {
	background: #FFE4E6;
	color: var(--wrong);
	border: 1px solid var(--wrong-border);
}

.feedback-wrong strong {
	font-weight: 700;
}

/* ─── Shake Animation ───────────────────────────────────── */
@keyframes shake {

	0%,
	100% {
		transform: translateX(0) rotate(0deg);
	}

	12% {
		transform: translateX(-9px) rotate(-0.4deg);
	}

	24% {
		transform: translateX(9px) rotate(0.4deg);
	}

	36% {
		transform: translateX(-7px) rotate(-0.3deg);
	}

	48% {
		transform: translateX(7px) rotate(0.3deg);
	}

	60% {
		transform: translateX(-4px);
	}

	72% {
		transform: translateX(4px);
	}

	84% {
		transform: translateX(-2px);
	}
}

.shake {
	animation: shake 0.55s cubic-bezier(.36, .07, .19, .97) both;
}

/* ─── Emoji Burst ───────────────────────────────────────── */
.emoji-burst {
	position: absolute;
	pointer-events: none;
	font-size: 1.4rem;
	bottom: 40%;
	animation: emojiFloat 0.9s ease-out forwards;
	z-index: 10;
}

@keyframes emojiFloat {
	0% {
		opacity: 1;
		transform: translateY(0) scale(0.8);
	}

	60% {
		opacity: 1;
		transform: translateY(-52px) scale(1.2);
	}

	100% {
		opacity: 0;
		transform: translateY(-80px) scale(1.0);
	}
}

/* ─── Responsive ────────────────────────────────────────── */
@media (max-width: 640px) {
	.header-inner {
		height: auto;
		padding: 12px 16px;
		flex-wrap: wrap;
		gap: 10px;
	}

	.logo-text p {
		display: none;
	}

	main {
		padding: 20px 16px 60px;
	}

	.question-grid {
		grid-template-columns: 1fr;
	}

	.question-text {
		font-size: 0.97rem;
	}

	.mode-btn {
		font-size: 0.73rem;
		padding: 5px 10px;
	}

	.score-pill {
		font-size: 0.78rem;
		padding: 4px 10px;
	}
}
