/* ═══════════════════════════════════════════════════════════════
   Nexus Gamification — XP Bar, Toasts, Badges, Daily Review
   ═══════════════════════════════════════════════════════════════ */

/* ── Gamification Bar ─────────────────────────────────────────── */
.nexus-gam-bar {
  position: sticky;
  top: 0;
  z-index: 99;
  background: oklch(from var(--color-surface) l c h / 0.92);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--color-divider);
  padding: 0.4rem 1.5rem;
}
.nexus-gam-bar__inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 1.25rem;
  font-family: var(--font-body, 'Cabinet Grotesk', sans-serif);
}

/* Streak */
.nexus-gam-bar__streak {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-weight: 700;
  font-size: 0.95rem;
  white-space: nowrap;
}
.nexus-gam-bar__streak-icon { font-size: 1.15rem; }
.nexus-gam-bar__streak-count {
  color: var(--color-text);
  min-width: 1.5ch;
  text-align: center;
}

/* XP block */
.nexus-gam-bar__xp-block {
  flex: 1;
  min-width: 0;
}
.nexus-gam-bar__level-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.15rem;
}
.nexus-gam-bar__xp-track {
  width: 100%;
  height: 6px;
  background: var(--color-divider);
  border-radius: 3px;
  overflow: hidden;
}
.nexus-gam-bar__xp-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}
.nexus-gam-bar__xp-text {
  font-size: 0.7rem;
  color: var(--color-text-muted);
  margin-top: 0.1rem;
}

/* Badges count */
.nexus-gam-bar__badges {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-weight: 600;
  font-size: 0.85rem;
  white-space: nowrap;
  cursor: default;
}
.nexus-gam-bar__badge-icon { font-size: 1.1rem; }
.nexus-gam-bar__badge-count { color: var(--color-text-muted); }

/* ── Toast Notifications ──────────────────────────────────────── */
.nexus-toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 10000;
  display: flex;
  flex-direction: column-reverse;
  gap: 0.5rem;
  pointer-events: none;
}
.nexus-toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1.25rem;
  border-radius: 0.75rem;
  font-size: 0.9rem;
  font-family: var(--font-body, 'Cabinet Grotesk', sans-serif);
  color: var(--color-text);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  box-shadow: 0 8px 32px oklch(0 0 0 / 0.25);
  transform: translateX(120%);
  opacity: 0;
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.35s ease;
  max-width: 360px;
}
.nexus-toast--visible {
  transform: translateX(0);
  opacity: 1;
}
.nexus-toast--exit {
  transform: translateX(120%);
  opacity: 0;
}

/* XP toast */
.nexus-toast--xp {
  border-left: 3px solid var(--color-primary);
}
.nexus-toast__xp {
  font-weight: 800;
  font-size: 1.1rem;
  color: var(--color-primary);
  white-space: nowrap;
}
.nexus-toast__reason {
  color: var(--color-text-muted);
  font-size: 0.8rem;
}

/* Badge toast */
.nexus-toast--badge {
  border-left: 3px solid #ffd93d;
  background: linear-gradient(135deg, var(--color-surface), oklch(from #ffd93d l c h / 0.06));
}
.nexus-toast__badge-icon {
  font-size: 1.8rem;
}
.nexus-toast__badge-info strong {
  color: #ffd93d;
}

/* Level toast */
.nexus-toast--level {
  border-left: 3px solid #6c5ce7;
  background: linear-gradient(135deg, var(--color-surface), oklch(from #6c5ce7 l c h / 0.08));
}
.nexus-toast__level-icon { font-size: 1.6rem; }
.nexus-toast__level-info strong { color: #6c5ce7; }

/* Streak toast */
.nexus-toast--streak {
  border-left: 3px solid #ff6b6b;
}
.nexus-toast__streak-icon { font-size: 1.4rem; }
.nexus-toast__streak-info strong { color: #ff6b6b; }

/* Break toast */
.nexus-toast--break {
  border-left: 3px solid #00b894;
  background: linear-gradient(135deg, var(--color-surface), oklch(from #00b894 l c h / 0.06));
}
.nexus-toast__break-icon { font-size: 1.4rem; }
.nexus-toast__break-info strong { color: #00b894; }

/* ── Daily Review Prompt ──────────────────────────────────────── */
.nexus-daily-review {
  margin-bottom: 1.5rem;
  border-radius: 0.75rem;
  border: 1px solid oklch(from var(--color-primary) l c h / 0.3);
  background: linear-gradient(135deg,
    oklch(from var(--color-primary) l c h / 0.06),
    oklch(from var(--color-primary) l c h / 0.02)
  );
  padding: 1.25rem 1.5rem;
  animation: nexus-slide-down 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}
.nexus-daily-review--dismissed {
  animation: nexus-slide-up 0.3s ease forwards;
}
.nexus-daily-review__inner {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}
.nexus-daily-review__icon { font-size: 2rem; }
.nexus-daily-review__text {
  flex: 1;
  min-width: 200px;
}
.nexus-daily-review__text strong {
  font-size: 1rem;
  display: block;
  margin-bottom: 0.25rem;
}
.nexus-daily-review__text p {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin: 0;
}
.nexus-daily-review__btn {
  padding: 0.5rem 1.25rem;
  border-radius: var(--radius-md, 0.5rem);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.2s ease;
}
.nexus-daily-review__btn--start {
  background: var(--color-primary);
  color: #fff;
}
.nexus-daily-review__btn--start:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}
.nexus-daily-review__btn--dismiss {
  background: transparent;
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
}

/* ── Review Modal ─────────────────────────────────────────────── */
.nexus-review-modal {
  position: fixed;
  inset: 0;
  z-index: 10001;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s ease;
}
.nexus-review-modal--open { opacity: 1; }
.nexus-review-modal__backdrop {
  position: absolute;
  inset: 0;
  background: oklch(0 0 0 / 0.6);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}
.nexus-review-modal__content {
  position: relative;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 1rem;
  padding: 2rem;
  width: min(90vw, 520px);
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 24px 80px oklch(0 0 0 / 0.4);
}
.nexus-review-modal__header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.nexus-review-modal__header h2 {
  flex: 1;
  font-family: var(--font-display, 'Boska', serif);
  font-size: 1.3rem;
  margin: 0;
}
.nexus-review-modal__count {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  font-weight: 600;
}
.nexus-review-modal__close {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--color-text-muted);
  cursor: pointer;
  padding: 0.25rem;
  line-height: 1;
  transition: color 0.2s;
}
.nexus-review-modal__close:hover { color: var(--color-text); }

/* Review card */
.nexus-review-card {
  background: var(--color-bg);
  border: 1px solid var(--color-divider);
  border-radius: 0.75rem;
  padding: 2rem;
  text-align: center;
  min-height: 180px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}
.nexus-review-card__front p {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 1rem;
}
.nexus-review-card__flip-btn {
  background: var(--color-primary);
  color: #fff;
  border: none;
  padding: 0.6rem 1.5rem;
  border-radius: var(--radius-md, 0.5rem);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.nexus-review-card__flip-btn:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}
.nexus-review-card__back {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--color-divider);
}
.nexus-review-card__back p {
  font-size: 0.95rem;
  color: var(--color-text-muted);
  line-height: 1.6;
}

/* SRS Rating buttons */
.nexus-review-modal__rating {
  margin-top: 1.5rem;
  text-align: center;
}
.nexus-review-modal__rating > p {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin-bottom: 0.75rem;
}
.nexus-review-modal__rating-btns {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
}
.nexus-rating-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  padding: 0.6rem 1rem;
  border: 1px solid var(--color-border);
  border-radius: 0.5rem;
  background: var(--color-bg);
  color: var(--color-text);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  min-width: 70px;
}
.nexus-rating-btn span { font-size: 1.3rem; }
.nexus-rating-btn:hover {
  border-color: var(--color-primary);
  background: oklch(from var(--color-primary) l c h / 0.08);
  transform: translateY(-2px);
}
.nexus-rating-btn[data-q="1"]:hover { border-color: #ff6b6b; }
.nexus-rating-btn[data-q="3"]:hover { border-color: #e8a83a; }
.nexus-rating-btn[data-q="4"]:hover { border-color: #7ab894; }
.nexus-rating-btn[data-q="5"]:hover { border-color: #5ba8b0; }

/* Review done */
.nexus-review-done {
  text-align: center;
  padding: 2rem;
}
.nexus-review-done__icon { font-size: 3rem; display: block; margin-bottom: 0.75rem; }
.nexus-review-done h3 { font-size: 1.3rem; margin-bottom: 0.5rem; }
.nexus-review-done p { color: var(--color-text-muted); font-size: 0.9rem; }
.nexus-review-done__next { font-size: 0.8rem !important; margin-top: 0.5rem; }

/* ── Animations ───────────────────────────────────────────────── */
@keyframes nexus-slide-down {
  from { transform: translateY(-20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
@keyframes nexus-slide-up {
  from { transform: translateY(0); opacity: 1; }
  to { transform: translateY(-20px); opacity: 0; }
}
@keyframes nexus-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}
@keyframes nexus-confetti-pop {
  0% { transform: scale(0) rotate(0deg); opacity: 0; }
  50% { transform: scale(1.2) rotate(180deg); opacity: 1; }
  100% { transform: scale(1) rotate(360deg); opacity: 1; }
}

/* ── Responsive ───────────────────────────────────────────────── */
@media (max-width: 640px) {
  .nexus-gam-bar { padding: 0.35rem 0.75rem; }
  .nexus-gam-bar__inner {
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 0.5rem 0.75rem;
  }
  .nexus-gam-bar__streak { font-size: 0.82rem; }
  .nexus-gam-bar__badges { font-size: 0.78rem; }
  .nexus-gam-bar__xp-block {
    flex: 1 1 100%;
    min-width: 0;
    order: 3;
  }
  .nexus-gam-bar__xp-text { font-size: 0.6rem; }
  .nexus-gam-bar__level-label { font-size: 0.65rem; margin-bottom: 0.1rem; }
  .nexus-toast-container { bottom: 0.75rem; right: 0.75rem; left: 0.75rem; }
  .nexus-toast { max-width: 100%; font-size: 0.8rem; padding: 0.6rem 1rem; }
  .nexus-review-modal__content { padding: 1.25rem; }
  .nexus-review-modal__rating-btns { flex-wrap: wrap; }
  .nexus-rating-btn { min-width: 60px; padding: 0.5rem 0.75rem; }
  .nexus-daily-review__inner { flex-direction: column; text-align: center; }
}

@media (prefers-reduced-motion: reduce) {
  .nexus-toast { transition: opacity 0.2s ease; transform: none !important; }
  .nexus-toast--visible { transform: none !important; }
  .nexus-toast--exit { transform: none !important; }
  .nexus-daily-review { animation: none; }
  .nexus-daily-review--dismissed { animation: none; display: none; }
}
