/**
 * XP & Leaderboard Styles
 * Animated toasts, leaderboard displays, and activity feeds
 */

/* ============================================
   XP TOAST NOTIFICATIONS
   ============================================ */

.xp-toast-container {
  position: fixed;
  top: 80px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 12px;
  pointer-events: none;
  max-width: 320px;
}

.xp-toast {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 20px;
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  border-radius: 14px;
  box-shadow:
    0 8px 32px rgba(99, 102, 241, 0.4),
    0 2px 8px rgba(0, 0, 0, 0.1);
  color: white;
  transform: translateX(120%);
  opacity: 0;
  transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: auto;
}

.xp-toast--visible {
  transform: translateX(0);
  opacity: 1;
}

.xp-toast--exiting {
  transform: translateX(120%);
  opacity: 0;
}

.xp-toast--big {
  background: linear-gradient(135deg, #f59e0b 0%, #ef4444 100%);
  box-shadow:
    0 8px 32px rgba(245, 158, 11, 0.4),
    0 0 20px rgba(239, 68, 68, 0.3);
}

.xp-toast__icon {
  font-size: 28px;
  animation: xp-icon-pulse 0.6s ease-out;
  flex-shrink: 0;
}

@keyframes xp-icon-pulse {
  0% { transform: scale(0.5); opacity: 0; }
  50% { transform: scale(1.4); }
  100% { transform: scale(1); opacity: 1; }
}

.xp-toast__content {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}

.xp-toast__amount {
  font-size: 22px;
  font-weight: 800;
  line-height: 1.2;
  animation: xp-amount-slide 0.5s ease-out 0.1s both;
}

.xp-toast__amount--negative {
  color: #fca5a5;
}

@keyframes xp-amount-slide {
  0% { transform: translateY(-10px); opacity: 0; }
  100% { transform: translateY(0); opacity: 1; }
}

.xp-toast__action {
  font-size: 13px;
  opacity: 0.9;
  animation: xp-action-fade 0.4s ease-out 0.2s both;
}

@keyframes xp-action-fade {
  0% { opacity: 0; }
  100% { opacity: 0.9; }
}

.xp-toast__total {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  padding-left: 14px;
  border-left: 1px solid rgba(255, 255, 255, 0.2);
  margin-left: auto;
}

.xp-toast__total-label {
  font-size: 10px;
  opacity: 0.7;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.xp-toast__total-value {
  font-size: 16px;
  font-weight: 700;
}

/* Level Up Effect */
.xp-level-up {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
  z-index: 10000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
}

.xp-level-up--visible {
  opacity: 1;
  pointer-events: auto;
}

.xp-level-up__content {
  text-align: center;
  transform: scale(0.8) translateY(30px);
  transition: transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.xp-level-up--visible .xp-level-up__content {
  transform: scale(1) translateY(0);
}

.xp-level-up__icon {
  font-size: 72px;
  animation: xp-levelup-bounce 0.8s ease-out;
}

@keyframes xp-levelup-bounce {
  0% { transform: scale(0) rotate(-30deg); }
  50% { transform: scale(1.3) rotate(10deg); }
  70% { transform: scale(0.9) rotate(-5deg); }
  100% { transform: scale(1) rotate(0deg); }
}

.xp-level-up__title {
  font-size: 32px;
  font-weight: 800;
  color: white;
  margin: 16px 0 8px;
  background: linear-gradient(90deg, #f59e0b, #ef4444, #ec4899);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.xp-level-up__level {
  font-size: 48px;
  font-weight: 800;
  color: white;
}

/* ============================================
   LEADERBOARD
   ============================================ */

.leaderboard {
  background: var(--wn-surface, #ffffff);
  border-radius: 16px;
  border: 1px solid var(--wn-border, #e5e7eb);
  overflow: hidden;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.06);
}

.leaderboard--loading,
.leaderboard--error {
  min-height: 300px;
}

.leaderboard__header {
  padding: 16px 20px;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.08), rgba(139, 92, 246, 0.04));
  border-bottom: 1px solid var(--wn-border, #e5e7eb);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.leaderboard__header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--wn-text, #1f2937);
}

.leaderboard__live-indicator {
  font-size: 11px;
  font-weight: 600;
  color: #10b981;
  animation: live-pulse 2s ease-in-out infinite;
}

@keyframes live-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.leaderboard__loading,
.leaderboard__error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 20px;
  gap: 12px;
  color: var(--wn-text-muted, #6b7280);
}

.leaderboard__spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--wn-border, #e5e7eb);
  border-top-color: var(--wn-primary, #6366f1);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.leaderboard__retry {
  padding: 8px 16px;
  background: var(--wn-primary, #6366f1);
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: background 0.2s;
}

.leaderboard__retry:hover {
  background: #4f46e5;
}

.leaderboard__list {
  padding: 0;
}

.leaderboard__empty {
  padding: 32px 20px;
  text-align: center;
  color: var(--wn-text-muted, #6b7280);
  font-size: 14px;
}

/* Leaderboard Entry */
.leaderboard__entry {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--wn-border, #e5e7eb);
  transition: background 0.2s;
}

.leaderboard__entry:last-child {
  border-bottom: none;
}

.leaderboard__entry:hover {
  background: rgba(99, 102, 241, 0.04);
}

.leaderboard__entry--current {
  background: rgba(99, 102, 241, 0.08);
  border-left: 3px solid var(--wn-primary, #6366f1);
}

.leaderboard__entry--top {
  background: linear-gradient(90deg, rgba(255, 215, 0, 0.05) 0%, transparent 100%);
}

.leaderboard__rank {
  width: 36px;
  font-weight: 700;
  font-size: 18px;
  text-align: center;
  flex-shrink: 0;
}

.leaderboard__avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--wn-border, #e5e7eb);
  flex-shrink: 0;
}

.leaderboard__entry--current .leaderboard__avatar {
  border-color: var(--wn-primary, #6366f1);
}

.leaderboard__user {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}

.leaderboard__name {
  font-weight: 600;
  color: var(--wn-text, #1f2937);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.leaderboard__you {
  color: var(--wn-primary, #6366f1);
  font-weight: 700;
}

.leaderboard__level {
  font-size: 12px;
  color: var(--wn-text-muted, #6b7280);
}

.leaderboard__xp {
  font-weight: 700;
  font-size: 16px;
  color: var(--wn-primary, #6366f1);
  white-space: nowrap;
}

/* Current User (when not in top 10) */
.leaderboard__current-rank {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: linear-gradient(135deg, var(--wn-primary, #6366f1) 0%, #8b5cf6 100%);
  color: white;
}

.leaderboard__current-rank-text {
  font-weight: 600;
}

.leaderboard__current-rank-xp {
  font-weight: 700;
  font-size: 18px;
}

/* Activity Feed */
.leaderboard__feed {
  padding: 16px 20px;
  background: rgba(0, 0, 0, 0.02);
  max-height: 240px;
  overflow-y: auto;
}

.leaderboard__feed h4 {
  margin: 0 0 14px;
  font-size: 14px;
  font-weight: 600;
  color: var(--wn-text-muted, #6b7280);
}

.activity-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.activity-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: white;
  border-radius: 10px;
  font-size: 13px;
  transition: transform 0.2s, opacity 0.3s;
}

.activity-item--empty {
  justify-content: center;
  color: var(--wn-text-muted, #6b7280);
  background: transparent;
}

.activity-item--new {
  opacity: 0;
  transform: translateY(-10px);
}

.activity-item--visible {
  opacity: 1;
  transform: translateY(0);
}

.activity-item__avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  flex-shrink: 0;
}

.activity-item__text {
  flex: 1;
  min-width: 0;
}

.activity-item__text strong {
  color: var(--wn-text, #1f2937);
}

.activity-item__xp {
  color: var(--wn-primary, #6366f1);
  font-weight: 700;
}

.activity-item__time {
  font-size: 11px;
  color: var(--wn-text-muted, #9ca3af);
  white-space: nowrap;
}

/* ============================================
   MOBILE RESPONSIVE
   ============================================ */

@media (max-width: 768px) {
  .xp-toast-container {
    top: auto;
    bottom: 20px;
    right: 12px;
    left: 12px;
    max-width: none;
  }

  .xp-toast {
    transform: translateY(120%);
    padding: 12px 16px;
  }

  .xp-toast--visible {
    transform: translateY(0);
  }

  .xp-toast--exiting {
    transform: translateY(120%);
  }

  .xp-toast__icon {
    font-size: 24px;
  }

  .xp-toast__amount {
    font-size: 18px;
  }

  .leaderboard__entry {
    padding: 12px 16px;
    gap: 10px;
  }

  .leaderboard__avatar {
    width: 36px;
    height: 36px;
  }

  .leaderboard__rank {
    width: 28px;
    font-size: 16px;
  }

  .leaderboard__xp {
    font-size: 14px;
  }

  .leaderboard__level {
    display: none;
  }

  .activity-item {
    padding: 8px 10px;
    font-size: 12px;
  }

  .activity-item__avatar {
    width: 24px;
    height: 24px;
  }

  .activity-item__time {
    display: none;
  }
}

/* ============================================
   DARK MODE SUPPORT
   ============================================ */

@media (prefers-color-scheme: dark) {
  .leaderboard {
    background: #1f2937;
    border-color: #374151;
  }

  .leaderboard__header {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.15), rgba(139, 92, 246, 0.08));
    border-color: #374151;
  }

  .leaderboard__header h3 {
    color: #f9fafb;
  }

  .leaderboard__entry {
    border-color: #374151;
  }

  .leaderboard__entry:hover {
    background: rgba(99, 102, 241, 0.1);
  }

  .leaderboard__entry--current {
    background: rgba(99, 102, 241, 0.15);
  }

  .leaderboard__name {
    color: #f9fafb;
  }

  .leaderboard__avatar {
    border-color: #4b5563;
  }

  .leaderboard__feed {
    background: rgba(0, 0, 0, 0.2);
  }

  .activity-item {
    background: #374151;
  }

  .activity-item__text strong {
    color: #f9fafb;
  }
}

/* ============================================
   ANIMATED BOOTLOADER
   ============================================ */

.wn-loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
  transition: opacity 0.4s ease, visibility 0.4s ease;
}

.wn-loading-overlay.wn-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.wn-bootloader {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  max-width: 320px;
  width: 100%;
  padding: 0 20px;
}

.wn-bootloader__logo {
  position: relative;
  width: 100px;
  height: 100px;
}

.wn-bootloader__ring {
  position: absolute;
  inset: 0;
  border: 3px solid transparent;
  border-top-color: #6366f1;
  border-radius: 50%;
  animation: bootloader-spin 1.2s cubic-bezier(0.5, 0, 0.5, 1) infinite;
}

.wn-bootloader__ring--2 {
  inset: 8px;
  border-top-color: #8b5cf6;
  animation-delay: -0.3s;
  animation-direction: reverse;
}

@keyframes bootloader-spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.wn-bootloader__icon {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #6366f1;
  animation: bootloader-pulse 2s ease-in-out infinite;
}

@keyframes bootloader-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.7; transform: scale(0.95); }
}

.wn-bootloader__text {
  text-align: center;
}

.wn-bootloader__text h3 {
  margin: 0 0 8px;
  font-size: 18px;
  font-weight: 700;
  color: #1f2937;
}

.wn-bootloader__text p {
  margin: 0;
  font-size: 14px;
  color: #6b7280;
}

.wn-bootloader__progress {
  width: 100%;
  height: 4px;
  background: #e5e7eb;
  border-radius: 4px;
  overflow: hidden;
}

.wn-bootloader__progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #6366f1, #8b5cf6);
  border-radius: 4px;
  transition: width 0.3s ease;
}

/* ============================================
   QUIZ START MODAL
   ============================================ */

.wn-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 9998;
  opacity: 1;
  transition: opacity 0.3s ease;
}

.wn-modal-backdrop.wn-hidden {
  opacity: 0;
  pointer-events: none;
}

.wn-quiz-start-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(1);
  z-index: 9999;
  background: white;
  border-radius: 20px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  width: 90%;
  max-width: 420px;
  overflow: hidden;
  opacity: 1;
  transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.wn-quiz-start-modal.wn-hidden {
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.9);
  pointer-events: none;
}

.wn-quiz-start__header {
  padding: 28px 24px 20px;
  text-align: center;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.08), rgba(139, 92, 246, 0.04));
  border-bottom: 1px solid #e5e7eb;
}

.wn-quiz-start__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 72px;
  height: 72px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  border-radius: 50%;
  color: white;
  margin-bottom: 16px;
}

.wn-quiz-start__header h2 {
  margin: 0 0 4px;
  font-size: 22px;
  font-weight: 800;
  color: #1f2937;
}

.wn-quiz-start__subtitle {
  margin: 0;
  font-size: 14px;
  color: #6b7280;
}

.wn-quiz-start__body {
  padding: 20px 24px;
}

.wn-quiz-start__stats {
  display: flex;
  gap: 16px;
  margin-bottom: 20px;
}

.wn-quiz-start__stat {
  flex: 1;
  text-align: center;
  padding: 14px;
  background: #f8fafc;
  border-radius: 12px;
  border: 1px solid #e5e7eb;
}

.wn-quiz-start__stat-value {
  display: block;
  font-size: 28px;
  font-weight: 800;
  color: #6366f1;
  line-height: 1.2;
}

.wn-quiz-start__stat-label {
  font-size: 12px;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.wn-quiz-start__xp-info {
  background: #f8fafc;
  border-radius: 12px;
  padding: 16px;
  border: 1px solid #e5e7eb;
}

.wn-quiz-start__xp-info h4 {
  margin: 0 0 12px;
  font-size: 14px;
  font-weight: 700;
  color: #1f2937;
  text-align: center;
}

.wn-quiz-start__xp-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.wn-quiz-start__xp-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 8px;
  border-radius: 10px;
  text-align: center;
}

.wn-quiz-start__xp-item--positive {
  background: rgba(34, 197, 94, 0.1);
}

.wn-quiz-start__xp-item--negative {
  background: rgba(239, 68, 68, 0.1);
}

.wn-quiz-start__xp-item--bonus {
  background: rgba(245, 158, 11, 0.1);
}

.wn-quiz-start__xp-icon {
  font-size: 18px;
  font-weight: 800;
  margin-bottom: 2px;
}

.wn-quiz-start__xp-item--positive .wn-quiz-start__xp-icon {
  color: #22c55e;
}

.wn-quiz-start__xp-item--negative .wn-quiz-start__xp-icon {
  color: #ef4444;
}

.wn-quiz-start__xp-value {
  font-size: 14px;
  font-weight: 700;
  color: #1f2937;
}

.wn-quiz-start__xp-label {
  font-size: 10px;
  color: #6b7280;
}

.wn-quiz-start__warning {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 12px;
  padding: 10px 12px;
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.2);
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  color: #dc2626;
}

.wn-quiz-start__warning svg {
  flex-shrink: 0;
  color: #ef4444;
}

.wn-quiz-start__resume {
  margin-top: 16px;
  padding: 12px 16px;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.1), rgba(139, 92, 246, 0.05));
  border-radius: 10px;
  border: 1px solid rgba(99, 102, 241, 0.2);
}

.wn-quiz-start__resume.wn-hidden {
  display: none;
}

.wn-quiz-start__resume-badge {
  display: inline-block;
  padding: 4px 10px;
  background: #6366f1;
  color: white;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-radius: 20px;
  margin-bottom: 8px;
}

.wn-quiz-start__resume p {
  margin: 0;
  font-size: 13px;
  color: #4b5563;
}

.wn-quiz-start__resume strong {
  color: #6366f1;
}

.wn-quiz-start__footer {
  display: flex;
  gap: 12px;
  padding: 16px 24px 24px;
  background: #fafafa;
}

.wn-quiz-start__footer .wn-btn {
  flex: 1;
}

.wn-quiz-start__footer .wn-btn--primary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

/* ============================================
   LIVE XP WIDGET (Bottom Center)
   ============================================ */

.wn-live-xp-widget {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border-radius: 16px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.12), 0 0 0 1px rgba(99, 102, 241, 0.1);
  transition: all 0.3s ease;
}

.wn-live-xp-widget:hover {
  transform: translateX(-50%) translateY(-2px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(99, 102, 241, 0.2);
}

.wn-live-xp__level {
  position: relative;
}

.wn-live-xp__level-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  border-radius: 50%;
  font-size: 14px;
  font-weight: 800;
  color: white;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.4);
}

.wn-live-xp__info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.wn-live-xp__total {
  display: flex;
  align-items: baseline;
  gap: 4px;
}

.wn-live-xp__value {
  font-size: 18px;
  font-weight: 800;
  color: #1f2937;
  transition: transform 0.2s ease;
}

.wn-live-xp__value.wn-xp-bump {
  transform: scale(1.1);
}

.wn-live-xp__label {
  font-size: 12px;
  font-weight: 600;
  color: #6b7280;
}

.wn-live-xp__session {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-weight: 600;
}

.wn-live-xp__session-value--positive {
  color: #22c55e;
}

.wn-live-xp__session-value--negative {
  color: #ef4444;
}

.wn-live-xp__streak {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.15), rgba(239, 68, 68, 0.1));
  border-radius: 20px;
  animation: streak-pulse 1.5s ease-in-out infinite;
}

.wn-live-xp__streak.wn-hidden {
  display: none;
}

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

.wn-live-xp__streak-icon {
  font-size: 14px;
}

.wn-live-xp__streak-count {
  font-size: 13px;
  font-weight: 800;
  color: #ea580c;
}

/* XP Widget - Hidden state for celebration */
.wn-live-xp-widget.wn-hidden {
  opacity: 0;
  transform: translateX(-50%) translateY(20px);
  pointer-events: none;
}

/* Mobile adjustments */
@media (max-width: 768px) {
  .wn-live-xp-widget {
    bottom: 80px;
    padding: 8px 14px;
    gap: 10px;
  }

  .wn-live-xp__level-badge {
    width: 32px;
    height: 32px;
    font-size: 12px;
  }

  .wn-live-xp__value {
    font-size: 16px;
  }

  .wn-quiz-start-modal {
    width: 95%;
    max-width: 380px;
  }

  .wn-quiz-start__header {
    padding: 20px 16px 16px;
  }

  .wn-quiz-start__icon {
    width: 60px;
    height: 60px;
  }

  .wn-quiz-start__icon svg {
    width: 36px;
    height: 36px;
  }

  .wn-quiz-start__body {
    padding: 16px;
  }

  .wn-quiz-start__xp-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
  }

  .wn-quiz-start__xp-item {
    padding: 8px 6px;
  }

  .wn-quiz-start__footer {
    padding: 12px 16px 20px;
    flex-direction: column;
  }
}

/* Quiz start modal - prevent body scroll */
body.wn-modal-open {
  overflow: hidden;
}

/* ============================================
   XP HUB - CENTRAL STATS BAR
   ============================================ */

.wn-xp-hub {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 14px 24px;
  background: linear-gradient(135deg,
    rgba(99, 102, 241, 0.12) 0%,
    rgba(139, 92, 246, 0.08) 100%);
  border-radius: 16px;
  border: 1px solid rgba(99, 102, 241, 0.15);
  margin-bottom: 20px;
  position: relative;
  overflow: visible;
}

.wn-xp-hub__total {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 22px;
  font-weight: 800;
  color: var(--wn-primary, #6366f1);
}

.wn-xp-hub__icon {
  font-size: 26px;
  filter: drop-shadow(0 0 8px rgba(99, 102, 241, 0.4));
  animation: xp-icon-glow 2s ease-in-out infinite;
}

@keyframes xp-icon-glow {
  0%, 100% { filter: drop-shadow(0 0 8px rgba(99, 102, 241, 0.4)); }
  50% { filter: drop-shadow(0 0 12px rgba(99, 102, 241, 0.7)); }
}

.wn-xp-hub__value {
  font-variant-numeric: tabular-nums;
  min-width: 50px;
  text-align: right;
  transition: transform 0.2s ease, color 0.2s ease;
}

.wn-xp-hub__label {
  font-size: 14px;
  font-weight: 600;
  color: var(--wn-text-muted, #6b7280);
  margin-left: -4px;
}

/* XP Hub value update animation */
.wn-xp-hub__value.xp-updating,
.xp-updating {
  animation: xp-hub-tick 0.35s ease-out;
}

@keyframes xp-hub-tick {
  0% { transform: scale(1); color: inherit; }
  40% { transform: scale(1.25); color: #22c55e; }
  100% { transform: scale(1); color: inherit; }
}

/* Streak section */
.wn-xp-hub__streak {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.15), rgba(239, 68, 68, 0.1));
  border-radius: 24px;
  border: 1px solid rgba(245, 158, 11, 0.2);
}

.wn-xp-hub__fire {
  font-size: 20px;
  animation: fire-flicker 0.5s ease-in-out infinite alternate;
}

@keyframes fire-flicker {
  0% { transform: scale(1) rotate(-2deg); }
  100% { transform: scale(1.1) rotate(2deg); }
}

.wn-xp-hub__streak span:last-child {
  font-size: 18px;
  font-weight: 800;
  color: #ea580c;
}

.wn-xp-hub__streak.wn-hidden {
  display: none;
}

/* Score section */
.wn-xp-hub__score {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 16px;
  font-weight: 700;
}

.wn-xp-hub__correct {
  color: #22c55e;
}

.wn-xp-hub__wrong {
  color: #ef4444;
}

.wn-xp-hub__score span span {
  margin-left: 4px;
  font-variant-numeric: tabular-nums;
}

/* Divider */
.wn-xp-hub__divider {
  width: 1px;
  height: 28px;
  background: rgba(99, 102, 241, 0.2);
}

/* ============================================
   FLYING XP ANIMATION
   ============================================ */

/* Flying XP Orb */
.xp-orb {
  position: fixed;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
  box-shadow:
    0 0 20px rgba(99, 102, 241, 0.6),
    0 0 40px rgba(99, 102, 241, 0.3),
    inset 0 0 10px rgba(255, 255, 255, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  pointer-events: none;
}

.xp-orb span {
  font-size: 12px;
  font-weight: 800;
  color: white;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

/* Orb trail particles */
.xp-orb-trail {
  position: fixed;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.8), rgba(168, 85, 247, 0.6));
  box-shadow: 0 0 8px rgba(99, 102, 241, 0.5);
  pointer-events: none;
  z-index: 9999;
}

/* Absorption burst at destination */
.xp-absorb-burst {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: radial-gradient(circle,
    rgba(99, 102, 241, 0.5) 0%,
    rgba(168, 85, 247, 0.2) 40%,
    transparent 70%);
  animation: absorb-burst 0.45s ease-out forwards;
  pointer-events: none;
  z-index: 10001;
}

@keyframes absorb-burst {
  0% {
    transform: translate(-50%, -50%) scale(0.3);
    opacity: 1;
  }
  100% {
    transform: translate(-50%, -50%) scale(2.5);
    opacity: 0;
  }
}

/* Target glow when absorbing XP */
.xp-absorbing {
  animation: absorb-glow 0.4s ease-out;
}

@keyframes absorb-glow {
  0% { box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.4); }
  50% { box-shadow: 0 0 20px 8px rgba(99, 102, 241, 0.6); }
  100% { box-shadow: 0 0 0 0 rgba(99, 102, 241, 0); }
}

/* Negative XP indicator */
.xp-negative {
  position: fixed;
  font-size: 18px;
  font-weight: 800;
  color: #ef4444;
  text-shadow: 0 2px 8px rgba(239, 68, 68, 0.4);
  z-index: 10000;
  pointer-events: none;
}

/* Shake animation for negative XP */
.xp-shake {
  animation: xp-shake 0.4s ease-out;
}

@keyframes xp-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

/* Streak bonus burst */
.xp-streak-burst {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 16px 24px;
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.95), rgba(239, 68, 68, 0.9));
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(245, 158, 11, 0.5);
  z-index: 10001;
  pointer-events: none;
}

.xp-streak-burst .streak-fire {
  font-size: 36px;
  animation: streak-fire-dance 0.3s ease-in-out infinite alternate;
}

@keyframes streak-fire-dance {
  0% { transform: scale(1) rotate(-5deg); }
  100% { transform: scale(1.15) rotate(5deg); }
}

.xp-streak-burst .streak-count {
  font-size: 20px;
  font-weight: 800;
  color: white;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.xp-streak-burst .streak-bonus {
  font-size: 16px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.9);
}

/* ============================================
   XP HUB MOBILE RESPONSIVE
   ============================================ */

@media (max-width: 768px) {
  .wn-xp-hub {
    position: fixed;
    /* Position above quiz nav (which is also fixed at bottom) */
    bottom: var(--wn-nav-height, 60px);
    left: 0;
    right: 0;
    border-radius: 0;
    margin: 0;
    padding: 10px 16px;
    gap: 12px;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(20px);
    z-index: 99;
    border: none;
    border-top: 1px solid rgba(99, 102, 241, 0.2);
    border-bottom: 1px solid rgba(99, 102, 241, 0.1);
    justify-content: space-around;
  }

  .wn-xp-hub__total {
    font-size: 18px;
    gap: 6px;
  }

  .wn-xp-hub__icon {
    font-size: 22px;
  }

  .wn-xp-hub__label {
    display: none;
  }

  .wn-xp-hub__streak {
    padding: 6px 10px;
  }

  .wn-xp-hub__fire {
    font-size: 16px;
  }

  .wn-xp-hub__streak span:last-child {
    font-size: 14px;
  }

  .wn-xp-hub__score {
    gap: 12px;
    font-size: 14px;
  }

  .wn-xp-hub__divider {
    height: 24px;
  }

  /* Prevent keyboard overlap */
  .wn-xp-hub.keyboard-open {
    transform: translateY(100%);
    transition: transform 0.3s ease;
  }

  /* Add extra padding to quiz main when XP hub is above nav */
  body.wn-has-xp-hub .wn-quiz-main {
    padding-bottom: calc(var(--wn-nav-height, 60px) + 60px + var(--wn-space-4, 16px));
  }
}

/* Tablet adjustments */
@media (min-width: 769px) and (max-width: 1023px) {
  .wn-xp-hub {
    gap: 20px;
    padding: 12px 20px;
  }

  .wn-xp-hub__total {
    font-size: 20px;
  }
}

/* ============================================
   REDUCED MOTION SUPPORT
   ============================================ */

@media (prefers-reduced-motion: reduce) {
  .xp-orb,
  .xp-orb-trail,
  .xp-absorb-burst,
  .wn-xp-hub__fire,
  .wn-xp-hub__icon {
    animation: none !important;
  }

  .wn-xp-hub__value.xp-updating,
  .xp-updating {
    animation: none !important;
    color: #22c55e;
  }

  .xp-absorbing {
    animation: none !important;
    box-shadow: 0 0 12px 4px rgba(99, 102, 241, 0.5);
  }

  .xp-streak-burst .streak-fire {
    animation: none !important;
  }
}

/* ============================================
   DARK MODE - XP HUB
   ============================================ */

@media (prefers-color-scheme: dark) {
  .wn-xp-hub {
    background: linear-gradient(135deg,
      rgba(99, 102, 241, 0.2) 0%,
      rgba(139, 92, 246, 0.12) 100%);
    border-color: rgba(99, 102, 241, 0.25);
  }

  .wn-xp-hub__label {
    color: #9ca3af;
  }

  .wn-xp-hub__streak {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.2), rgba(239, 68, 68, 0.15));
    border-color: rgba(245, 158, 11, 0.3);
  }
}

/* ============================================
   XP BREAKDOWN MODAL
   ============================================ */

.leaderboard__entry {
  cursor: pointer;
  position: relative;
}

.leaderboard__expand-icon {
  margin-left: auto;
  font-size: 10px;
  color: var(--wn-text-muted, #9ca3af);
  transition: transform 0.2s, color 0.2s;
}

.leaderboard__entry:hover .leaderboard__expand-icon {
  color: var(--wn-primary, #6366f1);
  transform: translateX(2px);
}

.xp-breakdown-modal {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s, visibility 0.3s;
}

.xp-breakdown-modal--visible {
  opacity: 1;
  visibility: visible;
}

.xp-breakdown-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
}

.xp-breakdown-modal__content {
  position: relative;
  width: 90%;
  max-width: 400px;
  max-height: 85vh;
  overflow-y: auto;
  background: var(--wn-card-bg, #ffffff);
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
  transform: scale(0.9) translateY(20px);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.xp-breakdown-modal--visible .xp-breakdown-modal__content {
  transform: scale(1) translateY(0);
}

.xp-breakdown__header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 20px;
  border-bottom: 1px solid var(--wn-border, #e5e7eb);
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.08) 0%, rgba(139, 92, 246, 0.04) 100%);
}

.xp-breakdown__avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--wn-primary, #6366f1);
}

.xp-breakdown__header h3 {
  flex: 1;
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: var(--wn-text, #1f2937);
}

.xp-breakdown__close {
  width: 32px;
  height: 32px;
  border: none;
  background: rgba(107, 114, 128, 0.1);
  border-radius: 50%;
  font-size: 20px;
  color: var(--wn-text-muted, #6b7280);
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.xp-breakdown__close:hover {
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
}

.xp-breakdown__body {
  padding: 20px;
}

.xp-breakdown__loading,
.xp-breakdown__error {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 40px 20px;
  color: var(--wn-text-muted, #6b7280);
}

.xp-breakdown__summary {
  margin-bottom: 20px;
}

.xp-breakdown__total {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  border-radius: 12px;
  color: white;
}

.xp-breakdown__total-label {
  font-size: 14px;
  opacity: 0.9;
}

.xp-breakdown__total-value {
  font-size: 28px;
  font-weight: 700;
}

.xp-breakdown__level {
  margin-top: 12px;
  padding: 8px 16px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.9);
  text-align: center;
}

.xp-breakdown__categories h4,
.xp-breakdown__recent h4 {
  margin: 0 0 12px 0;
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--wn-text-muted, #6b7280);
}

.xp-breakdown__row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--wn-border, #f3f4f6);
}

.xp-breakdown__row:last-child {
  border-bottom: none;
}

.xp-breakdown__icon {
  font-size: 20px;
  width: 32px;
  text-align: center;
}

.xp-breakdown__label {
  flex: 1;
  font-size: 14px;
  color: var(--wn-text, #1f2937);
}

.xp-breakdown__count {
  font-size: 13px;
  color: var(--wn-text-muted, #9ca3af);
  padding: 2px 8px;
  background: var(--wn-bg-subtle, #f3f4f6);
  border-radius: 10px;
}

.xp-breakdown__xp {
  font-size: 14px;
  font-weight: 600;
  color: #10b981;
  min-width: 60px;
  text-align: right;
}

.xp-breakdown__xp--negative {
  color: #ef4444;
}

.xp-breakdown__empty {
  padding: 20px;
  text-align: center;
  color: var(--wn-text-muted, #9ca3af);
  font-size: 14px;
}

.xp-breakdown__recent {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--wn-border, #e5e7eb);
}

.xp-breakdown__activity {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  font-size: 13px;
}

.xp-breakdown__activity-type {
  flex: 1;
  color: var(--wn-text, #374151);
}

.xp-breakdown__activity-xp {
  font-weight: 600;
  color: #10b981;
}

.xp-breakdown__activity-time {
  color: var(--wn-text-muted, #9ca3af);
  font-size: 12px;
}

/* Mobile responsive */
@media (max-width: 480px) {
  .xp-breakdown-modal__content {
    width: 95%;
    max-height: 90vh;
    border-radius: 16px;
  }

  .xp-breakdown__header {
    padding: 16px;
  }

  .xp-breakdown__body {
    padding: 16px;
  }

  .xp-breakdown__total-value {
    font-size: 24px;
  }
}

/* Dark mode */
@media (prefers-color-scheme: dark) {
  .xp-breakdown-modal__content {
    background: #1f2937;
  }

  .xp-breakdown__header {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.15) 0%, rgba(139, 92, 246, 0.08) 100%);
    border-color: rgba(255, 255, 255, 0.1);
  }

  .xp-breakdown__header h3 {
    color: #f9fafb;
  }

  .xp-breakdown__close {
    background: rgba(255, 255, 255, 0.1);
    color: #9ca3af;
  }

  .xp-breakdown__row {
    border-color: rgba(255, 255, 255, 0.1);
  }

  .xp-breakdown__label {
    color: #f3f4f6;
  }

  .xp-breakdown__count {
    background: rgba(255, 255, 255, 0.1);
    color: #9ca3af;
  }

  .xp-breakdown__recent {
    border-color: rgba(255, 255, 255, 0.1);
  }

  .xp-breakdown__activity-type {
    color: #e5e7eb;
  }
}
