/* Exam page — reuses base vars from styles.css */

.exam-body {
  padding-top: 70px;
  background: linear-gradient(180deg, #f5f5f4 0%, #fff 200px);
  min-height: 100vh;
}

.exam-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: linear-gradient(135deg, var(--teal) 0%, var(--teal-dark) 100%);
  color: #fff;
  padding: 14px 0;
  z-index: 50;
  box-shadow: var(--shadow);
}

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

.back-link {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: rgba(255,255,255,0.15);
  color: #fff;
  text-decoration: none;
  flex-shrink: 0;
  transition: background 0.15s;
}

.back-link:hover {
  background: rgba(255,255,255,0.25);
}

.exam-title {
  flex: 1;
  min-width: 0;
}

.exam-title h1 {
  font-size: 17px;
  font-weight: 800;
  line-height: 1.2;
}

.exam-title p {
  font-size: 12px;
  opacity: 0.85;
  margin-top: 2px;
}

.exam-meta {
  background: rgba(255,255,255,0.18);
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 700;
  flex-shrink: 0;
}

/* ============ Screens ============ */
.screen {
  padding: 24px 0 60px;
  animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ============ Setup Screen ============ */
.setup-card {
  background: #fff;
  border-radius: 18px;
  padding: 28px 22px;
  box-shadow: 0 8px 32px rgba(15,118,110,0.10);
  border: 1px solid var(--gray-200);
  max-width: 560px;
  margin: 12px auto;
}

.setup-icon {
  font-size: 48px;
  text-align: center;
  margin-bottom: 8px;
}

.setup-card h2 {
  text-align: center;
  font-size: 22px;
  font-weight: 800;
  color: var(--gray-900);
  margin-bottom: 8px;
}

.setup-desc {
  text-align: center;
  color: var(--gray-500);
  font-size: 14px;
  margin-bottom: 26px;
  line-height: 1.6;
}

.setup-group {
  margin-bottom: 22px;
}

.setup-group label {
  display: block;
  font-size: 14px;
  font-weight: 700;
  color: var(--gray-700);
  margin-bottom: 10px;
}

.option-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 8px;
}

.opt-btn {
  background: var(--gray-100);
  border: 2px solid transparent;
  border-radius: 10px;
  padding: 12px 8px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  color: var(--gray-700);
  cursor: pointer;
  transition: all 0.15s;
}

.opt-btn:hover {
  background: var(--gray-200);
}

.opt-btn.opt-selected {
  background: var(--teal-bg);
  border-color: var(--teal);
  color: var(--teal-dark);
}

.primary-btn {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: linear-gradient(135deg, var(--teal) 0%, var(--teal-dark) 100%);
  color: #fff;
  border: 0;
  border-radius: 12px;
  padding: 15px 24px;
  font-family: inherit;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  margin-top: 8px;
  transition: all 0.15s;
  box-shadow: 0 4px 12px rgba(15,118,110,0.25);
}

.primary-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(15,118,110,0.35);
}

.primary-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.ghost-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: var(--gray-700);
  border: 2px solid var(--gray-300);
  border-radius: 12px;
  padding: 13px 22px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s;
}

.ghost-btn:hover {
  background: var(--gray-100);
  border-color: var(--gray-500);
}

/* ============ Quiz Screen ============ */
.progress-wrap {
  margin-bottom: 18px;
}

.progress-bar {
  height: 6px;
  background: var(--gray-200);
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--teal-light) 0%, var(--teal) 100%);
  border-radius: 999px;
  width: 0;
  transition: width 0.3s ease;
}

.quiz-card {
  background: #fff;
  border-radius: 16px;
  padding: 24px 22px;
  box-shadow: 0 8px 32px rgba(15,118,110,0.08);
  border: 1px solid var(--gray-200);
}

.q-chapter-tag {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  color: var(--gold);
  background: var(--gold-light);
  padding: 3px 10px;
  border-radius: 999px;
  margin-bottom: 12px;
}

.quiz-question {
  font-size: 18px;
  font-weight: 700;
  color: var(--gray-900);
  line-height: 1.7;
  margin-bottom: 22px;
}

.quiz-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 20px;
}

.quiz-opt {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: #fff;
  border: 2px solid var(--gray-200);
  border-radius: 12px;
  font-size: 15px;
  line-height: 1.55;
  cursor: pointer;
  font-family: inherit;
  color: var(--gray-900);
  text-align: right;
  transition: all 0.15s;
}

.quiz-opt:hover:not(.opt-locked) {
  border-color: var(--teal);
  background: var(--teal-bg);
}

.quiz-opt-letter {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--gray-100);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 15px;
  color: var(--gray-700);
  transition: all 0.15s;
}

.quiz-opt-text {
  flex: 1;
}

.quiz-opt.opt-selected {
  border-color: var(--teal);
  background: var(--teal-bg);
}

.quiz-opt.opt-selected .quiz-opt-letter {
  background: var(--teal);
  color: #fff;
}

/* instant-mode states */
.quiz-opt.opt-correct {
  border-color: var(--green);
  background: var(--green-bg);
  color: #14532d;
}

.quiz-opt.opt-correct .quiz-opt-letter {
  background: var(--green);
  color: #fff;
}

.quiz-opt.opt-wrong {
  border-color: #ef4444;
  background: #fef2f2;
  color: #991b1b;
}

.quiz-opt.opt-wrong .quiz-opt-letter {
  background: #ef4444;
  color: #fff;
}

.quiz-opt.opt-locked {
  cursor: default;
}

.instant-feedback {
  padding: 14px 16px;
  border-radius: 12px;
  font-size: 14.5px;
  line-height: 1.65;
  margin-bottom: 16px;
}

.instant-feedback.fb-correct {
  background: var(--green-bg);
  border-right: 4px solid var(--green);
  color: #14532d;
}

.instant-feedback.fb-wrong {
  background: #fef2f2;
  border-right: 4px solid #ef4444;
  color: #991b1b;
}

.fb-title {
  font-weight: 800;
  margin-bottom: 6px;
  font-size: 14px;
}

.quiz-actions {
  display: flex;
  gap: 10px;
  justify-content: space-between;
}

.quiz-actions .primary-btn,
.quiz-actions .ghost-btn {
  flex: 1;
  margin-top: 0;
  padding: 13px 20px;
}

/* ============ Result Screen ============ */
.result-card {
  background: #fff;
  border-radius: 18px;
  padding: 32px 22px;
  box-shadow: 0 8px 32px rgba(15,118,110,0.10);
  border: 1px solid var(--gray-200);
  text-align: center;
  max-width: 560px;
  margin: 12px auto;
}

.result-emoji {
  font-size: 56px;
  margin-bottom: 8px;
}

.result-card h2 {
  font-size: 22px;
  font-weight: 800;
  color: var(--gray-900);
  margin-bottom: 6px;
}

.result-subtitle {
  color: var(--gray-500);
  font-size: 14px;
  margin-bottom: 22px;
  line-height: 1.6;
}

.score-circle-wrap {
  position: relative;
  width: 180px;
  height: 180px;
  margin: 0 auto 24px;
}

.score-circle {
  transform: rotate(-90deg);
  width: 100%;
  height: 100%;
}

.score-track,
.score-progress {
  fill: none;
  stroke-width: 8;
}

.score-track {
  stroke: var(--gray-200);
}

.score-progress {
  stroke: var(--teal);
  stroke-linecap: round;
  stroke-dasharray: 283;
  stroke-dashoffset: 283;
  transition: stroke-dashoffset 1s ease-out, stroke 0.3s;
}

.score-text {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  align-content: center;
}

.score-percent {
  font-size: 38px;
  font-weight: 800;
  color: var(--gray-900);
  line-height: 1;
}

.score-fraction {
  font-size: 14px;
  color: var(--gray-500);
  margin-top: 4px;
  font-weight: 600;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 24px;
}

.stat-card {
  padding: 14px 8px;
  border-radius: 12px;
  border: 1px solid var(--gray-200);
}

.stat-correct {
  background: var(--green-bg);
  border-color: var(--green-border);
}

.stat-wrong {
  background: #fef2f2;
  border-color: #fecaca;
}

.stat-skipped {
  background: var(--gray-100);
}

.stat-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--gray-700);
  margin-bottom: 4px;
}

.stat-correct .stat-label { color: #15803d; }
.stat-wrong .stat-label { color: #b91c1c; }

.stat-value {
  font-size: 24px;
  font-weight: 800;
  color: var(--gray-900);
}

.result-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.result-actions .primary-btn,
.result-actions .ghost-btn {
  margin-top: 0;
  padding: 13px 22px;
}

/* ============ Review Section ============ */
.review-section {
  margin-top: 32px;
  max-width: 760px;
  margin-left: auto;
  margin-right: auto;
  animation: fadeIn 0.3s ease-out;
}

.review-section h3 {
  font-size: 18px;
  font-weight: 800;
  margin-bottom: 14px;
  color: var(--gray-900);
}

.review-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.review-item {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: 12px;
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
}

.review-item.review-wrong {
  border-right: 4px solid #ef4444;
}

.review-item.review-correct {
  border-right: 4px solid var(--green);
}

.review-item.review-skipped {
  border-right: 4px solid var(--gray-300);
}

.review-q {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 10px;
  color: var(--gray-900);
  line-height: 1.6;
}

.review-meta {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.review-badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
}

.badge-correct { background: var(--green-bg); color: #15803d; }
.badge-wrong { background: #fef2f2; color: #b91c1c; }
.badge-skipped { background: var(--gray-100); color: var(--gray-700); }
.badge-chapter { background: var(--gold-light); color: var(--gold); }

.review-answers {
  font-size: 14px;
  line-height: 1.7;
}

.review-answers .ans-row {
  display: flex;
  gap: 6px;
  margin-bottom: 4px;
}

.review-answers .ans-label {
  font-weight: 700;
  color: var(--gray-700);
  flex-shrink: 0;
}

.review-explanation {
  margin-top: 10px;
  background: var(--teal-bg);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13.5px;
  color: var(--gray-900);
  line-height: 1.6;
}

/* ============ Responsive ============ */
@media (max-width: 600px) {
  .exam-body { padding-top: 64px; }
  .exam-header { padding: 11px 0; }
  .exam-title h1 { font-size: 15px; }
  .exam-title p { font-size: 11px; }
  .back-link { width: 34px; height: 34px; }
  .setup-card { padding: 22px 18px; }
  .setup-card h2 { font-size: 19px; }
  .opt-btn { padding: 11px 6px; font-size: 13px; }
  .quiz-card { padding: 18px 16px; }
  .quiz-question { font-size: 16px; }
  .quiz-opt { padding: 12px 14px; font-size: 14.5px; gap: 12px; }
  .quiz-opt-letter { width: 28px; height: 28px; font-size: 14px; }
  .result-card { padding: 24px 18px; }
  .score-circle-wrap { width: 150px; height: 150px; }
  .score-percent { font-size: 32px; }
  .stat-value { font-size: 20px; }
}
