/* ═══════════════════════════════════════════════════════
   Gamification Styles — Quiz, Scenario, Dashboard, Badges
   Loaded on chapter + course pages
   ═══════════════════════════════════════════════════════ */

/* ── Quiz Component ── */
.quiz-wrap { background: #fff; border: 1px solid var(--border); border-radius: var(--r-card); padding: 0; margin: 2.5rem 0; overflow: hidden; }
.quiz-header { display: flex; justify-content: space-between; align-items: center; padding: 16px 24px; background: var(--dark); color: #fff; }
.quiz-title { font-weight: 700; font-size: .92rem; }
.quiz-progress { font-size: .78rem; color: rgba(255,255,255,.8); }
.quiz-progress-bar { height: 3px; background: var(--border); }
.quiz-progress-fill { height: 100%; background: var(--primary); transition: width .4s ease; }
.quiz-question { padding: 24px; }
.quiz-q-text { font-size: 1rem; font-weight: 600; color: var(--text-h); margin-bottom: 16px; line-height: 1.55; }
.quiz-options { display: flex; flex-direction: column; gap: 10px; }
.quiz-option { display: flex; align-items: center; gap: 12px; padding: 14px 18px; border: 2px solid var(--border); border-radius: var(--r-sm); background: #fff; cursor: pointer; text-align: left; font-family: inherit; font-size: .9rem; color: var(--text-b); transition: all .2s; }
.quiz-option:hover { border-color: var(--primary); background: var(--primary-lt); }
.quiz-option-letter { display: flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: 50%; background: var(--bg-page); font-weight: 700; font-size: .8rem; color: var(--text-h); flex-shrink: 0; }
.quiz-option-text { line-height: 1.45; }
.quiz-option:disabled { cursor: default; }
.quiz-option.quiz-correct { border-color: #16a34a; background: #f0fdf4; }
.quiz-option.quiz-correct .quiz-option-letter { background: #16a34a; color: #fff; }
.quiz-option.quiz-wrong { border-color: #dc2626; background: #fef2f2; }
.quiz-option.quiz-wrong .quiz-option-letter { background: #dc2626; color: #fff; }

.quiz-feedback { padding: 16px 24px; font-size: .88rem; line-height: 1.55; }
.quiz-feedback strong { display: block; margin-bottom: 4px; }
.quiz-feedback p { margin: 4px 0 0; color: var(--text-b); }
.quiz-feedback-correct { background: #f0fdf4; border-top: 1px solid #bbf7d0; color: #166534; }
.quiz-feedback-wrong { background: #fef2f2; border-top: 1px solid #fecaca; color: #991b1b; }

.quiz-actions { display: flex; justify-content: flex-end; padding: 12px 24px 20px; }
.quiz-next-btn { padding: 10px 24px; border: none; border-radius: var(--r-btn); background: var(--primary); color: #fff; font-weight: 700; font-size: .88rem; cursor: pointer; font-family: inherit; transition: background .2s; }
.quiz-next-btn:hover { background: var(--primary-h); }

/* Quiz Results */
.quiz-results { text-align: center; padding: 32px 24px; }
.quiz-results-header { display: flex; align-items: center; justify-content: center; gap: 24px; margin-bottom: 20px; flex-wrap: wrap; }
.quiz-score-ring { position: relative; width: 100px; height: 100px; flex-shrink: 0; }
.quiz-ring-svg { width: 100%; height: 100%; }
.quiz-ring-progress { transition: stroke-dasharray .8s ease; }
.quiz-score-pct { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); font-size: 1.4rem; font-weight: 800; color: var(--text-h); }
.quiz-results-text { text-align: left; }
.quiz-results-text h3 { font-size: 1.2rem; font-weight: 800; color: var(--text-h); margin-bottom: 4px; }
.quiz-results-text p { font-size: .9rem; color: var(--text-b); margin: 2px 0; }
.quiz-pass-note { font-size: .82rem !important; color: #16a34a !important; }
.quiz-results-actions { margin-top: 16px; }
.quiz-retry-btn { padding: 10px 28px; border: 2px solid var(--border); border-radius: var(--r-btn); background: #fff; color: var(--text-h); font-weight: 700; font-size: .88rem; cursor: pointer; font-family: inherit; transition: all .2s; }
.quiz-retry-btn:hover { border-color: var(--primary); color: var(--primary); }

/* Quiz Placeholder */
.quiz-placeholder, .scenario-placeholder { text-align: center; padding: 40px 24px; background: var(--bg-page); border: 2px dashed var(--border); border-radius: var(--r-card); margin: 2.5rem 0; }
.quiz-placeholder-icon, .scenario-placeholder-icon { font-size: 2.5rem; display: block; margin-bottom: 8px; }
.quiz-placeholder-text, .scenario-placeholder-text { font-weight: 700; font-size: 1rem; color: var(--text-h); margin-bottom: 4px; }
.quiz-placeholder-sub, .scenario-placeholder-sub { font-size: .85rem; color: var(--text-b); }
.quiz-loading, .scenario-loading { text-align: center; padding: 32px; color: var(--text-b); font-size: .9rem; }

/* ── Scenario Player ── */
.scenario-wrap { background: #fff; border: 1px solid var(--border); border-radius: var(--r-card); margin: 2.5rem 0; overflow: hidden; }
.scenario-header { display: flex; justify-content: space-between; align-items: center; padding: 14px 24px; background: linear-gradient(135deg, #1C1C1C, #2a2a2a); }
.scenario-badge { font-size: .82rem; font-weight: 700; color: var(--primary); }
.scenario-count { font-size: .78rem; color: rgba(255,255,255,.8); }
.scenario-setup { padding: 24px 24px 16px; }
.scenario-title { font-size: 1.05rem; font-weight: 800; color: var(--text-h); margin-bottom: 8px; }
.scenario-context { font-size: .92rem; color: var(--text-b); line-height: 1.65; }
.scenario-choices { padding: 0 24px 20px; display: flex; flex-direction: column; gap: 10px; }
.scenario-choice { display: flex; flex-direction: column; gap: 2px; padding: 14px 18px; border: 2px solid var(--border); border-radius: var(--r-sm); background: #fff; cursor: pointer; text-align: left; font-family: inherit; transition: all .2s; }
.scenario-choice:hover { border-color: var(--primary); background: var(--primary-lt); }
.scenario-choice:disabled { cursor: default; }
.scenario-choice-label { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--text-b); }
.scenario-choice-text { font-size: .9rem; color: var(--text-h); line-height: 1.5; }
.scenario-choice.scenario-optimal { border-color: #16a34a; background: #f0fdf4; }
.scenario-choice.scenario-suboptimal { border-color: #d97706; background: #fffbeb; }

.scenario-feedback-panel { padding: 20px 24px; }
.scenario-fb-optimal { background: #f0fdf4; border-top: 1px solid #bbf7d0; }
.scenario-fb-suboptimal { background: #fffbeb; border-top: 1px solid #fde68a; }
.scenario-fb-header { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.scenario-fb-icon { font-size: 1.1rem; }
.scenario-fb-header strong { font-size: .92rem; color: var(--text-h); }
.scenario-feedback-panel p { font-size: .88rem; color: var(--text-b); line-height: 1.55; margin: 0 0 12px; }
.scenario-fb-actions { display: flex; justify-content: flex-end; }
.scenario-continue-btn { padding: 10px 24px; border: none; border-radius: var(--r-btn); background: var(--primary); color: #fff; font-weight: 700; font-size: .88rem; cursor: pointer; font-family: inherit; transition: background .2s; }
.scenario-continue-btn:hover { background: var(--primary-h); }

.scenario-done { text-align: center; padding: 32px 24px; }
.scenario-done-icon { font-size: 2.5rem; margin-bottom: 8px; }
.scenario-done h3 { font-size: 1.15rem; font-weight: 800; color: var(--text-h); margin-bottom: 6px; }
.scenario-done p { font-size: .9rem; color: var(--text-b); margin: 0 0 4px; }
.scenario-xp-note { font-weight: 700; color: var(--primary) !important; }
.scenario-replay-btn { margin-top: 12px; padding: 10px 28px; border: 2px solid var(--border); border-radius: var(--r-btn); background: #fff; color: var(--text-h); font-weight: 700; font-size: .88rem; cursor: pointer; font-family: inherit; transition: all .2s; }
.scenario-replay-btn:hover { border-color: var(--primary); color: var(--primary); }

/* ── Badge Unlock Animation ── */
.quiz-new-badges { display: flex; justify-content: center; gap: 16px; flex-wrap: wrap; margin: 16px 0; }
.badge-unlock-anim { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 12px 16px; background: var(--primary-lt); border-radius: var(--r-card); animation: badgeUnlock .6s cubic-bezier(.34,1.56,.64,1); }
.badge-icon-large { font-size: 2rem; }
.badge-unlock-name { font-size: .78rem; font-weight: 700; color: var(--text-h); }
.badge-unlock-xp { font-size: .72rem; font-weight: 600; color: var(--primary); }

@keyframes badgeUnlock {
  0% { opacity: 0; transform: scale(0.3); }
  50% { transform: scale(1.15); }
  100% { opacity: 1; transform: scale(1); }
}

/* Confetti burst for Course Graduate */
.confetti-burst { position: fixed; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; z-index: 9999; }
.confetti-piece { position: absolute; width: 8px; height: 8px; border-radius: 2px; animation: confettiFall 2.5s ease-out forwards; }
@keyframes confettiFall {
  0% { transform: translateY(-20px) rotate(0deg); opacity: 1; }
  100% { transform: translateY(100vh) rotate(720deg); opacity: 0; }
}

/* ── Progress Dashboard ── */
.dash-wrap { background: #fff; border: 1px solid var(--border); border-radius: var(--r-card); padding: 28px; margin: 2rem 0; }
.dash-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; flex-wrap: wrap; gap: 8px; }
.dash-header h2 { font-size: 1.25rem; font-weight: 800; color: var(--text-h); letter-spacing: -.02em; margin: 0; }
.dash-rank-badge { display: inline-flex; padding: 6px 14px; background: var(--primary-lt); border-radius: var(--r-btn); }
.dash-rank-title { font-size: .82rem; font-weight: 700; color: var(--primary-h); }

.dash-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 24px; }
.dash-stat-card { background: var(--bg-page); border-radius: var(--r-card); padding: 20px; text-align: center; }
.dash-stat-ring { position: relative; display: flex; flex-direction: column; align-items: center; }
.dash-ring-svg { width: 80px; height: 80px; margin-bottom: 8px; }
.dash-ring-progress { transition: stroke-dashoffset .8s ease; }
.dash-ring-pct { position: absolute; top: 32px; left: 50%; transform: translateX(-50%); font-size: 1.1rem; font-weight: 800; color: var(--text-h); }
.dash-stat-value { font-size: 1.6rem; font-weight: 800; color: var(--text-h); line-height: 1.2; }
.dash-stat-label { font-size: .82rem; font-weight: 600; color: var(--text-b); margin-top: 4px; }
.dash-stat-sub { font-size: .72rem; color: var(--text-b); margin-top: 2px; opacity: .7; }

.dash-section { margin-bottom: 24px; }
.dash-section:last-child { margin-bottom: 0; }
.dash-section h3 { font-size: 1rem; font-weight: 800; color: var(--text-h); margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.dash-badge-count { font-size: .78rem; font-weight: 600; color: var(--text-b); }

.dash-badge-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.dash-badge { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 14px 8px; border-radius: var(--r-card); text-align: center; transition: transform .2s; }
.dash-badge-earned { background: var(--primary-lt); }
.dash-badge-locked { background: var(--bg-page); opacity: .45; }
.dash-badge-icon { font-size: 1.5rem; }
.dash-badge-name { font-size: .72rem; font-weight: 700; color: var(--text-h); }
.dash-badge-xp { font-size: .68rem; color: var(--primary); font-weight: 600; }

.dash-module-list { display: flex; flex-direction: column; gap: 6px; }
.dash-module-row { display: flex; align-items: center; gap: 12px; padding: 10px 14px; background: var(--bg-page); border-radius: var(--r-sm); }
.dash-module-num { width: 24px; height: 24px; display: flex; align-items: center; justify-content: center; background: var(--dark); color: #fff; border-radius: 50%; font-size: .72rem; font-weight: 700; flex-shrink: 0; }
.dash-module-name { flex: 1; font-size: .85rem; font-weight: 500; color: var(--text-h); }
.dash-module-status { display: flex; gap: 6px; }
.dash-check { font-size: .85rem; opacity: .2; transition: opacity .2s; }
.dash-check.dash-done { opacity: 1; }

.dash-rank-track { display: flex; flex-direction: column; gap: 0; }
.dash-rank-step { display: flex; align-items: center; gap: 12px; padding: 8px 14px; position: relative; }
.dash-rank-step::before { content: ''; position: absolute; left: 24px; top: 0; width: 2px; height: 100%; background: var(--border); }
.dash-rank-step:first-child::before { top: 50%; height: 50%; }
.dash-rank-step:last-child::before { height: 50%; }
.dash-rank-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--border); flex-shrink: 0; position: relative; z-index: 1; }
.dash-rank-active .dash-rank-dot { background: var(--primary); }
.dash-rank-current .dash-rank-dot { box-shadow: 0 0 0 4px var(--primary-lt); }
.dash-rank-name { font-size: .85rem; font-weight: 600; color: var(--text-b); flex: 1; }
.dash-rank-active .dash-rank-name { color: var(--text-h); }
.dash-rank-current .dash-rank-name { color: var(--primary); font-weight: 700; }
.dash-rank-xp { font-size: .72rem; color: var(--text-b); }

/* ── Responsive ── */
@media (max-width: 640px) {
  .dash-stats { grid-template-columns: 1fr; }
  .dash-badge-grid { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); }
  .quiz-results-header { flex-direction: column; text-align: center; }
  .quiz-results-text { text-align: center; }
}
