/* MedWiki Quiz Engine 스타일 */

.quiz-choice {
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.12s, box-shadow 0.15s;
  user-select: none;
}
.quiz-choice:hover:not(.quiz-correct):not(.quiz-wrong) {
  background: #e3f2fd !important;
  border-color: #1565c0 !important;
  transform: translateX(3px);
  box-shadow: 0 2px 6px rgba(21, 101, 192, 0.15);
}
.quiz-choice:active:not(.quiz-correct):not(.quiz-wrong) {
  transform: translateX(1px);
}

.quiz-choice.quiz-correct {
  background: #c8e6c9 !important;
  border-color: #2e7d32 !important;
  font-weight: 700;
  color: #1b5e20 !important;
  animation: quizCorrectPulse 0.5s ease;
}
.quiz-choice.quiz-correct::after {
  content: " ✓";
  color: #2e7d32;
  font-weight: 900;
  margin-left: 6px;
  font-size: 13px;
}

.quiz-choice.quiz-wrong {
  background: #ffcdd2 !important;
  border-color: #c62828 !important;
  color: #b71c1c !important;
  animation: quizWrongShake 0.4s ease;
}
.quiz-choice.quiz-wrong::after {
  content: " ✗";
  color: #c62828;
  font-weight: 900;
  margin-left: 6px;
  font-size: 13px;
}

.quiz-answered .quiz-choice:not(.quiz-correct):not(.quiz-wrong) {
  opacity: 0.55;
  cursor: default;
  pointer-events: none;
}

@keyframes quizCorrectPulse {
  0% { transform: scale(1); }
  30% { transform: scale(1.02); background: #a5d6a7 !important; }
  100% { transform: scale(1); }
}

@keyframes quizWrongShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

/* Sticky control bar */
.quiz-controls {
  position: sticky;
  top: 0;
  background: #4527a0;
  color: #fff;
  padding: 8px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 1000;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
  margin: -22px -14px 18px -14px;
  flex-wrap: wrap;
  gap: 8px;
}

.quiz-stats {
  display: flex;
  gap: 8px;
  font-size: 11.5px;
  flex-wrap: wrap;
}
.quiz-stat {
  padding: 4px 10px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.15);
  font-weight: 600;
  font-size: 11px;
}
.quiz-stat b { font-weight: 800; margin-left: 2px; }
.quiz-stat-correct { background: #2e7d32; }
.quiz-stat-wrong { background: #c62828; }
.quiz-stat-total { background: #424242; }

.quiz-btns {
  display: flex;
  gap: 6px;
  align-items: center;
}
.quiz-btn {
  background: #fff;
  color: #4527a0;
  padding: 5px 12px;
  border-radius: 4px;
  border: none;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  transition: background 0.15s, color 0.15s;
  font-family: inherit;
}
.quiz-btn:hover {
  background: #ffecb3;
  color: #bf360c;
}
.quiz-btn-mode { background: #ef6c00; color: #fff; }
.quiz-btn-mode:hover { background: #e65100; color: #fff; }
.quiz-btn-bookmark { background: #fbc02d; color: #5d4037; }
.quiz-btn-bookmark:hover { background: #f9a825; color: #5d4037; }
.quiz-reset { background: #b71c1c; color: #fff; }
.quiz-reset:hover { background: #880e4f; color: #fff; }

/* 즐겨찾기·노트 컨트롤 (qcard 우측 상단 절대 배치) */
.qcard { position: relative; }
.quiz-card-controls {
  position: absolute;
  top: 8px;
  right: 10px;
  display: flex;
  gap: 4px;
  z-index: 5;
}
.quiz-bookmark-btn, .quiz-note-btn {
  background: #f5f5f5;
  color: #999;
  border: 1.5px solid #e0e0e0;
  border-radius: 5px;
  padding: 3px 9px;
  font-size: 14px;
  cursor: pointer;
  font-family: inherit;
  line-height: 1;
  transition: background 0.15s, color 0.15s, border-color 0.15s, transform 0.1s;
}
.quiz-bookmark-btn:hover, .quiz-note-btn:hover {
  background: #fff8e1;
  border-color: #fbc02d;
  transform: translateY(-1px);
}
.quiz-bookmark-btn.active {
  background: #fff3c4;
  color: #ef6c00;
  border-color: #fbc02d;
  font-weight: 700;
}
.quiz-note-btn.active {
  background: #e3f2fd;
  color: #1565c0;
  border-color: #64b5f6;
  font-weight: 700;
  font-size: 12px;
}
.quiz-note-wrap {
  margin-top: 10px;
  padding: 8px 10px;
  background: #f5faff;
  border-left: 3px solid #1565c0;
  border-radius: 4px;
}
.quiz-note-ta {
  width: 100%;
  min-height: 60px;
  padding: 7px 10px;
  font-family: inherit;
  font-size: 13px;
  border: 1px solid #cfd8dc;
  border-radius: 4px;
  resize: vertical;
  background: #fff;
  color: #222;
  line-height: 1.5;
}
.quiz-note-ta:focus {
  outline: none;
  border-color: #1565c0;
  box-shadow: 0 0 0 2px rgba(21, 101, 192, 0.15);
}

@media print {
  .quiz-card-controls, .quiz-note-wrap { display: none !important; }
}

.quiz-empty-msg {
  background: #fff8e1;
  border: 2px dashed #ef6c00;
  padding: 20px 22px;
  border-radius: 8px;
  text-align: center;
  margin: 14px 0 24px;
}
.quiz-empty-msg h3 { margin: 0 0 6px; color: #bf360c; font-size: 15px; }
.quiz-empty-msg p { margin: 0 0 12px; color: #6d4c41; font-size: 12px; }

@media (max-width: 620px) {
  .quiz-controls { padding: 7px 10px; }
  .quiz-stat { font-size: 10px; padding: 3px 7px; }
  .quiz-btn { font-size: 10px; padding: 4px 8px; }
}

@media print {
  .quiz-controls { display: none !important; }
  .quiz-choice { cursor: default; }
}

/* Interactive 모드에선 문제 제목·태그(질환명 힌트) 숨김 — PDF 재생성 시엔 유지 */
@media screen {
  .qheader { display: none !important; }
  /* 정답 볼드 스포일러 방지 — screen만 적용, PDF는 원래대로 유지 */
  .choices li b,
  .choices li strong {
    font-weight: normal !important;
    color: inherit !important;
  }
}

/* ============= MedWiki Quiz Engine v2 — 서술형 (essay) 추가 스타일 ============= */

/* essay 카드 컨테이너 */
.qcard.essay {
  border-left: 4px solid #5e35b1;
}
.qcard.essay::before {
  content: "✍️ 서술형";
  display: inline-block;
  background: #5e35b1;
  color: white;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 3px;
  margin-bottom: 8px;
}

/* 답안 입력 textarea */
.essay-input {
  width: 100%;
  min-height: 120px;
  padding: 10px;
  margin: 10px 0;
  border: 2px solid #ddd;
  border-radius: 6px;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.5;
  resize: vertical;
  box-sizing: border-box;
  transition: border-color 0.15s;
}
.essay-input:focus {
  outline: none;
  border-color: #5e35b1;
  box-shadow: 0 0 0 3px rgba(94, 53, 177, 0.15);
}

/* "모범답안 보기" 버튼 */
.essay-reveal-btn {
  background: #5e35b1;
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 5px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  margin: 8px 0;
  transition: background 0.15s, transform 0.1s;
}
.essay-reveal-btn:hover {
  background: #4527a0;
  transform: translateY(-1px);
}
.essay-reveal-btn:active {
  transform: translateY(0);
}

/* 모범답안 박스 */
.essay-model {
  background: #f3e5f5;
  border-left: 4px solid #5e35b1;
  padding: 12px 16px;
  margin: 10px 0;
  border-radius: 4px;
  animation: essayModelReveal 0.4s ease;
}
.essay-model::before {
  content: "📖 모범답안";
  display: block;
  font-weight: 700;
  color: #4527a0;
  margin-bottom: 6px;
  font-size: 13px;
}
@keyframes essayModelReveal {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* 자체 채점 버튼 그룹 */
.essay-grade-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  flex-wrap: wrap;
}
.essay-grade-label {
  font-size: 13px;
  font-weight: 600;
  color: #555;
}
.essay-grade-btn {
  padding: 6px 14px;
  border: 2px solid #ddd;
  background: white;
  border-radius: 5px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.essay-grade-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.essay-grade-correct { color: #2e7d32; }
.essay-grade-correct:hover, .essay-grade-correct.active { background: #c8e6c9; border-color: #2e7d32; }
.essay-grade-partial { color: #f57c00; }
.essay-grade-partial:hover, .essay-grade-partial.active { background: #ffe0b2; border-color: #f57c00; }
.essay-grade-wrong { color: #c62828; }
.essay-grade-wrong:hover, .essay-grade-wrong.active { background: #ffcdd2; border-color: #c62828; }

/* 카드 전체 채점 상태 표시 (좌측 보더) */
.qcard.essay.quiz-essay-correct { border-left-color: #2e7d32; }
.qcard.essay.quiz-essay-partial { border-left-color: #f57c00; }
.qcard.essay.quiz-essay-wrong { border-left-color: #c62828; }

/* ============= MedWiki Quiz Engine v3 — 다중 선택 (multi) ============= */
.qcard.multi {
  border-left: 4px solid #f57c00;
}
.qcard.multi::before {
  content: "🔘 다중 선택";
  display: inline-block;
  background: #f57c00;
  color: white;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 3px;
  margin-bottom: 8px;
}
.multi-hint {
  background: #fff3e0;
  color: #ef6c00;
  padding: 8px 12px;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 600;
  margin: 10px 0;
}
.quiz-multi-choice.multi-selected {
  background: #ffe0b2 !important;
  border-color: #f57c00 !important;
  font-weight: 600;
  transform: translateX(3px);
}
.quiz-multi-choice.multi-selected::before {
  content: "☑ ";
  color: #ef6c00;
  font-weight: 900;
  margin-right: 4px;
}
.multi-grade-btn {
  background: #f57c00;
  color: white;
  border: none;
  padding: 9px 22px;
  border-radius: 5px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  margin: 10px 0;
  transition: background 0.15s, transform 0.1s;
  font-family: inherit;
}
.multi-grade-btn:hover:not(:disabled) {
  background: #e65100;
  transform: translateY(-1px);
}
.multi-grade-btn:disabled {
  background: #ccc;
  cursor: not-allowed;
}
.qcard.multi.quiz-answered::before {
  background: #4caf50;
  content: "✅ 채점 완료";
}
