/* ==========================================================================
   Gamification UI
   XP counter, streak, hearts, daily goal, feedback animations, badges
   ========================================================================== */

/* ── XP Float Animation ── */
.xp-float {
  position: fixed;
  z-index: 10000;
  font-size: 18px;
  font-weight: 700;
  color: #FFD700;
  pointer-events: none;
  animation: xp-float 1s ease-out forwards;
  text-shadow: 0 1px 4px rgba(0,0,0,0.5);
}

@keyframes xp-float {
  0%   { opacity: 1; transform: translateY(0) scale(1); }
  50%  { opacity: 1; transform: translateY(-20px) scale(1.2); }
  100% { opacity: 0; transform: translateY(-50px) scale(0.8); }
}

/* ── Combo Banner ── */
.combo-banner {
  position: fixed;
  top: 60px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10000;
  padding: 8px 24px;
  border-radius: 24px;
  background: linear-gradient(135deg, #f5a623, #e94560);
  color: #fff;
  font-weight: 700;
  font-size: 16px;
  animation: combo-in 0.4s ease-out, combo-out 0.4s ease-in 1.6s forwards;
  pointer-events: none;
  box-shadow: 0 4px 16px rgba(245, 166, 35, 0.4);
}

@keyframes combo-in {
  0%   { opacity: 0; transform: translateX(-50%) scale(0.5); }
  100% { opacity: 1; transform: translateX(-50%) scale(1); }
}

@keyframes combo-out {
  0%   { opacity: 1; }
  100% { opacity: 0; transform: translateX(-50%) translateY(-20px); }
}

/* ── Correct/Incorrect Flash ── */
.feedback-correct {
  animation: correct-flash 0.6s ease;
}

.feedback-incorrect {
  animation: shake 0.4s ease;
}

@keyframes correct-flash {
  0%   { background-color: transparent; }
  30%  { background-color: rgba(78, 205, 196, 0.25); }
  100% { background-color: transparent; }
}

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

/* ── Combo Pulse ── */
.combo-pulse {
  animation: combo-pulse 0.6s ease;
}

@keyframes combo-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(245, 166, 35, 0.5); }
  70%  { box-shadow: 0 0 0 10px rgba(245, 166, 35, 0); }
  100% { box-shadow: 0 0 0 0 rgba(245, 166, 35, 0); }
}

/* ── Progress Bar XP Extension ── */
.progress-bar-xp {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: 12px;
  font-size: 12px;
  color: var(--text-muted, #718096);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.progress-bar-xp .xp-level {
  padding: 1px 8px;
  border-radius: 10px;
  background: var(--accent-muted, rgba(97, 218, 251, 0.15));
  color: var(--accent, #61dafb);
  font-weight: 600;
  font-size: 11px;
}

.progress-bar-xp .xp-count {
  color: #FFD700;
  font-weight: 600;
}

/* ── Sidebar Gamification Widget ── */
.sidebar-gamification {
  padding: 12px 16px;
  margin: 8px 12px;
  border-radius: 12px;
  background: var(--bg-card, #22223b);
  border: 1px solid var(--border-color, rgba(255,255,255,0.1));
  transition: background-color 0.3s ease;
}

.sidebar-gamification .streak-display {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary, #e0e0e0);
}

.sidebar-gamification .streak-fire {
  font-size: 20px;
  animation: fire-pulse 2s ease-in-out infinite;
}

@keyframes fire-pulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.15); }
}

.sidebar-gamification .streak-count {
  color: #f5a623;
}

.sidebar-gamification .streak-freeze {
  font-size: 11px;
  color: var(--text-muted, #718096);
  margin-top: 2px;
}

/* ── Daily Goal Circular Gauge ── */
.daily-goal-widget {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border-color, rgba(255,255,255,0.08));
}

.daily-goal-circle {
  position: relative;
  width: 48px;
  height: 48px;
  flex-shrink: 0;
}

.daily-goal-circle svg {
  transform: rotate(-90deg);
}

.daily-goal-circle .circle-bg {
  fill: none;
  stroke: var(--bg-tertiary, #2d3748);
  stroke-width: 4;
}

.daily-goal-circle .circle-fill {
  fill: none;
  stroke: var(--accent, #61dafb);
  stroke-width: 4;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.5s ease;
}

.daily-goal-circle .circle-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 10px;
  font-weight: 700;
  color: var(--text-primary, #e0e0e0);
}

.daily-goal-info {
  font-size: 12px;
  color: var(--text-muted, #718096);
  line-height: 1.4;
}

.daily-goal-info .goal-label {
  font-weight: 600;
  color: var(--text-primary, #e0e0e0);
}

/* ── Hearts Display ── */
.hearts-display {
  display: flex;
  align-items: center;
  gap: 2px;
  font-size: 16px;
}

.hearts-display .heart {
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.hearts-display .heart.empty {
  opacity: 0.3;
  filter: grayscale(1);
}

.hearts-display .heart.lost {
  animation: heart-break 0.4s ease forwards;
}

@keyframes heart-break {
  0%   { transform: scale(1); opacity: 1; }
  50%  { transform: scale(1.3); opacity: 0.8; }
  100% { transform: scale(0.6); opacity: 0.3; filter: grayscale(1); }
}

.hearts-lock-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 9999;
  background: rgba(233, 69, 96, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(2px);
}

.hearts-lock-modal {
  background: var(--bg-card, #22223b);
  border: 1px solid var(--border-color, rgba(255,255,255,0.1));
  border-radius: 16px;
  padding: 32px;
  text-align: center;
  max-width: 400px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}

.hearts-lock-modal .heart-icon {
  font-size: 48px;
  margin-bottom: 12px;
}

.hearts-lock-modal h3 {
  color: var(--text-primary, #e0e0e0);
  margin: 0 0 8px;
}

.hearts-lock-modal p {
  color: var(--text-muted, #718096);
  font-size: 14px;
  margin: 0 0 20px;
}

.hearts-lock-modal .btn-row {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.hearts-lock-modal button {
  padding: 10px 20px;
  border-radius: 8px;
  border: none;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease;
}

.hearts-lock-modal button:active { transform: scale(0.97); }

.hearts-lock-modal .btn-review {
  background: var(--accent, #61dafb);
  color: var(--text-inverse, #1a1a2e);
}

.hearts-lock-modal .btn-wait {
  background: var(--bg-tertiary, #2d3748);
  color: var(--text-primary, #e0e0e0);
}

/* ── Level Up Overlay ── */
.levelup-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 99998;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.3s ease;
}

.levelup-modal {
  text-align: center;
  padding: 40px;
  animation: levelup-pop 0.5s ease;
}

.levelup-modal .level-icon {
  font-size: 64px;
  margin-bottom: 16px;
}

.levelup-modal h2 {
  color: #FFD700;
  font-size: 28px;
  margin: 0 0 8px;
}

.levelup-modal .level-title {
  color: var(--text-primary, #e0e0e0);
  font-size: 20px;
  margin: 0 0 24px;
}

.levelup-modal button {
  padding: 12px 32px;
  border-radius: 8px;
  border: none;
  background: var(--accent, #61dafb);
  color: var(--text-inverse, #1a1a2e);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
}

@keyframes levelup-pop {
  0%   { transform: scale(0.5); opacity: 0; }
  70%  { transform: scale(1.1); }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes fadeIn {
  0%   { opacity: 0; }
  100% { opacity: 1; }
}

/* ── Badge Earned Toast ── */
.badge-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 10001;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-radius: 12px;
  background: var(--bg-card, #22223b);
  border: 1px solid #FFD700;
  box-shadow: 0 4px 24px rgba(255, 215, 0, 0.2);
  animation: badge-slide-in 0.4s ease, badge-slide-out 0.4s ease 3.6s forwards;
  color: var(--text-primary, #e0e0e0);
}

.badge-toast .badge-icon { font-size: 32px; }
.badge-toast .badge-info { font-size: 13px; }
.badge-toast .badge-title { font-weight: 700; font-size: 14px; color: #FFD700; }

@keyframes badge-slide-in {
  0% { transform: translateX(120%); opacity: 0; }
  100% { transform: translateX(0); opacity: 1; }
}

@keyframes badge-slide-out {
  0% { opacity: 1; }
  100% { transform: translateX(120%); opacity: 0; }
}

/* ── Badge Grid (Profile/Dashboard) ── */
.badge-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.badge-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 8px;
  border-radius: 12px;
  background: var(--bg-card, #22223b);
  border: 1px solid var(--border-color, rgba(255,255,255,0.1));
  text-align: center;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.badge-card:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.3); }
.badge-card .badge-icon { font-size: 36px; margin-bottom: 8px; }
.badge-card .badge-name { font-size: 12px; color: var(--text-primary, #e0e0e0); font-weight: 600; }
.badge-card .badge-desc { font-size: 10px; color: var(--text-muted, #718096); margin-top: 4px; }

.badge-card.locked {
  opacity: 0.4;
  filter: grayscale(0.8);
}

.badge-card.locked .badge-icon {
  filter: grayscale(1);
}

/* ── Review Notification ── */
.review-notification {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  padding: 6px 10px;
  border-radius: 8px;
  background: rgba(97, 218, 251, 0.1);
  cursor: pointer;
  font-size: 12px;
  color: var(--accent, #61dafb);
  transition: background-color 0.2s ease;
}

.review-notification:hover {
  background: rgba(97, 218, 251, 0.2);
}

.review-badge-count {
  background: var(--error, #e94560);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
}

/* ── Onboarding Modal ── */
.onboarding-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 99999;
  background: rgba(0,0,0,0.8);
  display: flex;
  align-items: center;
  justify-content: center;
}

.onboarding-modal {
  background: var(--bg-card, #22223b);
  border-radius: 16px;
  padding: 32px;
  max-width: 420px;
  text-align: center;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}

.onboarding-modal h2 {
  color: var(--text-primary, #e0e0e0);
  margin: 0 0 8px;
}

.onboarding-modal p {
  color: var(--text-muted, #718096);
  font-size: 14px;
  margin: 0 0 20px;
}

.goal-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.goal-option {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 8px;
  border: 1px solid var(--border-color, rgba(255,255,255,0.1));
  background: transparent;
  color: var(--text-primary, #e0e0e0);
  cursor: pointer;
  font-size: 14px;
  transition: border-color 0.2s ease, background-color 0.2s ease;
}

.goal-option:hover {
  border-color: var(--accent, #61dafb);
  background: var(--accent-muted, rgba(97, 218, 251, 0.1));
}

.goal-option .goal-emoji { font-size: 20px; }
.goal-option .goal-info { text-align: left; }
.goal-option .goal-name { font-weight: 600; }
.goal-option .goal-desc { font-size: 12px; color: var(--text-muted, #718096); }

/* ── Responsive ── */
@media (max-width: 768px) {
  .sidebar-gamification { margin: 4px 8px; padding: 10px 12px; }
  .badge-grid { grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); gap: 8px; }
  .badge-card { padding: 12px 6px; }
  .badge-card .badge-icon { font-size: 28px; }
  .combo-banner { font-size: 14px; padding: 6px 18px; }
  .hearts-lock-modal { padding: 24px; margin: 0 16px; }
  .onboarding-modal { margin: 0 16px; padding: 24px; }
}
