/* shared/quiz-engine.css — v5. One shared stylesheet for every quiz.
   Accent auto-resolves per module via body[data-module] → var(--accent). */
#quiz-app {
  max-width: 900px;
  margin: 2rem auto;
  font-family: Inter, -apple-system, sans-serif;
  color: var(--v5-ink);
}

/* Sticky header with an accent progress bar */
.quiz-header {
  background: #FFFFFF;
  padding: 1rem 1.25rem;
  border: 1px solid var(--v5-hairline-2);
  border-left: 4px solid var(--accent);
  border-radius: var(--v5-r);
  margin-bottom: 1.5rem;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--v5-shadow-1);
}
.quiz-header h2 {
  margin: 0 0 0.15rem 0;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--v5-ink);
}
.quiz-header p {
  margin: 0 0 0.75rem 0;
  color: var(--v5-muted);
  font-size: 0.9rem;
}
.quiz-best-score {
  float: right;
  background: var(--accent-tint);
  color: var(--v5-ink);
  padding: 0.3rem 0.7rem;
  border-radius: var(--v5-r-sm);
  font-weight: 700;
  font-size: 0.8rem;
  margin-left: 1rem;
}
.quiz-progress {
  position: relative;
  height: 10px;
  background: var(--v5-hairline);
  border-radius: 999px;
  overflow: hidden;
  clear: both;
}
.quiz-progress-fill {
  height: 100%;
  width: 0;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.25s ease;
}
.quiz-progress-text {
  display: block;
  margin-top: 0.4rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--v5-muted);
}

.questions-container {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* Each question is its own v5 card */
.question-block {
  background: #FFFFFF;
  border: 1px solid var(--v5-hairline-2);
  border-radius: var(--v5-r);
  padding: 1.25rem;
  box-shadow: var(--v5-shadow-1);
  line-height: 1.6;
}
.question-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}
.question-number {
  background: var(--v5-hairline);
  color: var(--v5-muted);
  padding: 0.2rem 0.55rem;
  border-radius: var(--v5-r-sm);
  font-weight: 700;
  font-size: 0.85rem;
  min-width: 30px;
  text-align: center;
}
.question-number.answered {
  background: var(--accent);
  color: #FFFFFF;
}
.module-link {
  font-size: 0.72rem;
  color: var(--v5-muted);
  text-decoration: none;
  margin-left: auto;
}
.module-link:hover { text-decoration: underline; color: var(--v5-ink); }
.category-badge {
  padding: 0.15rem 0.55rem;
  border-radius: var(--v5-r-sm);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--v5-ink);
  background: var(--accent-tint);
  border: 1px solid var(--accent);
}
.difficulty-badge {
  padding: 0.15rem 0.55rem;
  border-radius: var(--v5-r-sm);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border: 1px solid transparent;
}
.difficulty-badge.difficulty-simple    { color: #166534; background: #E1F4EC; border-color: #16A34A; }
.difficulty-badge.difficulty-medium    { color: #92400E; background: #FDEBE0; border-color: #D97706; }
.difficulty-badge.difficulty-challenge { color: #7F1D1D; background: #FCEBEA; border-color: #DC2626; }
.question-text {
  font-weight: 600;
  margin-bottom: 0.75rem;
  font-size: 0.98rem;
  line-height: 1.5;
}
.options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}
.option {
  display: flex;
  align-items: flex-start;
  background: #FFFFFF;
  border: 1px solid var(--v5-hairline-2);
  border-radius: var(--v5-r-sm);
  padding: 0.75rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.option:hover {
  background: var(--accent-tint);
  border-color: var(--accent);
}
.option:focus-within {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.option.selected {
  background: var(--accent-tint);
  border-color: var(--accent);
}
.option input[type="radio"] {
  margin-right: 0.5rem;
  margin-top: 0.15rem;
  cursor: pointer;
  accent-color: var(--accent);
}
.option-label {
  font-size: 0.9rem;
  line-height: 1.4;
  cursor: pointer;
}
.submit-section {
  margin-top: 2rem;
  text-align: center;
}
.quiz-button {
  background: var(--accent);
  color: #FFFFFF;
  border: none;
  padding: 0.75rem 2rem;
  border-radius: var(--v5-r);
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  transition: filter 0.15s, transform 0.15s;
}
.quiz-button:hover:not(:disabled) {
  filter: brightness(0.92);
  transform: translateY(-1px);
}
.quiz-button:disabled {
  background: var(--v5-hairline-2);
  color: var(--v5-muted);
  cursor: not-allowed;
}
.warning {
  color: #7F1D1D;
  font-size: 0.85rem;
  margin-top: 0.5rem;
}

/* Results */
.results-container {
  background: #FFFFFF;
  border: 1px solid var(--v5-hairline-2);
  border-radius: var(--v5-r);
  padding: 2rem;
}
.score-display {
  text-align: center;
  padding: 2rem;
  background: var(--accent-tint);
  border: 1px solid var(--accent);
  border-radius: var(--v5-r);
  margin-bottom: 2rem;
}
.score-display h2 { margin: 0 0 0.5rem 0; color: var(--v5-ink); }
.score-percentage { font-size: 1.5rem; margin-top: 0.5rem; font-weight: 700; color: var(--v5-ink); }
.results-grid {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.result-item {
  background: #FFFFFF;
  border: 1px solid var(--v5-hairline-2);
  border-radius: var(--v5-r-sm);
  padding: 1rem;
}
.result-item.correct {
  border-left: 4px solid #059669;
  background: #ECFDF5;
}
.result-item.incorrect {
  border-left: 4px solid #7F1D1D;
  background: #FEF2F2;
}
.result-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
}
.result-question {
  font-weight: 600;
  margin-bottom: 0.5rem;
  font-size: 0.95rem;
}
.result-answer {
  padding: 0.3rem 0.55rem;
  border-radius: var(--v5-r-sm);
  font-size: 0.85rem;
  margin-bottom: 0.25rem;
}
.user-answer { background: #FEE2E2; color: #7F1D1D; }
.correct-answer { background: #D1FAE5; color: #059669; }
.explanation {
  padding: 0.6rem 0.75rem;
  background: var(--v5-hairline);
  border-radius: var(--v5-r-sm);
  border-left: 3px solid var(--accent);
  margin-top: 0.5rem;
  font-size: 0.85rem;
  line-height: 1.55;
  color: var(--v5-ink);
}
.restart-btn {
  background: var(--accent);
  color: #FFFFFF;
  margin: 2rem auto;
  display: block;
}

/* Numeric input */
.numeric-input-container { max-width: 300px; }
.numeric-input {
  width: 100%;
  padding: 0.75rem 1rem;
  font-size: 1rem;
  font-family: 'JetBrains Mono', monospace;
  border: 1px solid var(--v5-hairline-2);
  border-radius: var(--v5-r-sm);
  background: #FFFFFF;
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
  box-sizing: border-box;
}
.numeric-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-tint);
}
.numeric-input::placeholder {
  color: var(--v5-muted);
  font-family: Inter, -apple-system, sans-serif;
  font-size: 0.9rem;
}

/* Ordering */
.ordering-items {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.ordering-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: #FFFFFF;
  border: 1px solid var(--v5-hairline-2);
  border-radius: var(--v5-r-sm);
  padding: 0.6rem 0.75rem;
  transition: background 0.15s, border-color 0.15s;
}
.ordering-item:hover {
  background: var(--accent-tint);
  border-color: var(--accent);
}
.ordering-select {
  width: 52px;
  padding: 0.4rem 0.25rem;
  font-size: 0.9rem;
  font-weight: 700;
  border: 1px solid var(--v5-hairline-2);
  border-radius: var(--v5-r-sm);
  background: #FFFFFF;
  text-align: center;
  cursor: pointer;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  flex-shrink: 0;
}
.ordering-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-tint);
}
.ordering-item-text { font-size: 0.9rem; line-height: 1.4; }

@media (max-width: 768px) {
  .options { grid-template-columns: 1fr; }
}

/* Image-MCQ options (conflict graphs / WAL state tables). The option value is
   an image; show it in the label with its letter. */
.option-image {
  display: block;
  max-width: 320px;
  width: 100%;
  height: auto;
  margin: 0.35rem 0 0.15rem 0;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #fff;
}
.option-letter {
  font-weight: 600;
  margin-right: 0.35rem;
}
.result-answer .option-image {
  max-width: 220px;
  display: inline-block;
  vertical-align: middle;
}

/* Scenario-sets: render the shared stimulus once, group the parts under it */
.scenario-stem {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-left: 4px solid #7C3AED;
  border-radius: 8px;
  padding: 16px 20px;
  margin: 28px 0 0;
  font-size: 0.95rem;
  line-height: 1.5;
  overflow-x: auto;
}
.question-block.in-scenario {
  border-left: 4px solid #e2e8f0;
  margin-left: 8px;
}
.part-badge {
  display: inline-block;
  background: #7C3AED;
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 9px;
  border-radius: 10px;
  letter-spacing: 0.02em;
}

/* Optional hint (e.g. which concepts a synthesis question connects) - not part of the problem statement */
.q-hint { margin: 8px 0 4px; font-size: 0.85rem; color: #64748b; }
.q-hint summary { cursor: pointer; color: #2563eb; font-weight: 600; width: max-content; }
.q-hint summary:hover { text-decoration: underline; }
.q-hint[open] summary { margin-bottom: 4px; }

/* Instructor preview: answer + explanation shown inline (only for instructor logins) */
.instructor-answer {
  margin-top: 12px;
  border: 1px dashed #16A34A;
  background: #F0FDF4;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 0.9rem;
}
.instructor-answer .ia-label {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #166534;
  margin-bottom: 4px;
}
.instructor-answer .ia-ans { font-weight: 600; color: #14532d; }
.instructor-answer .ia-expl { margin-top: 6px; color: #3f3f46; line-height: 1.5; }
