/* ── Badge notification system ────────────────────────────────────
   Usage:  Loaded by badge-notifications.js on every page for students.
   Shows celebratory slide-in cards when new badges are earned.
   z-index: 98500 (above Prof Mode 10000, below toasts 99000)
   ──────────────────────────────────────────────────────────────── */

.badge-notif-container {
  position: fixed;
  top: 1.5rem;
  right: 1.5rem;
  z-index: 98500;
  pointer-events: none;
  max-width: min(400px, calc(100vw - 2rem));
}

.badge-notif {
  pointer-events: auto;
  border-radius: 16px;
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.12),
    0 2px 8px rgba(0, 0, 0, 0.06);
  overflow: hidden;
  opacity: 0;
  transform: translateX(120%);
  animation: badgeSlideIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
  position: relative;
}
.badge-notif.dismiss {
  animation: badgeSlideOut 0.35s ease forwards;
}

/* Tier-tinted card backgrounds */
.badge-notif.tier-bronze   { background: linear-gradient(135deg, #fef3c7 0%, #fff7ed 60%, #ffffff 100%); }
.badge-notif.tier-silver   { background: linear-gradient(135deg, #f1f5f9 0%, #f8fafc 60%, #ffffff 100%); }
.badge-notif.tier-gold     { background: linear-gradient(135deg, #fef9c3 0%, #fffbeb 60%, #ffffff 100%); }
.badge-notif.tier-legendary { background: linear-gradient(135deg, #f3e8ff 0%, #fdf2f8 40%, #ffffff 100%); }

/* Tier accent stripe (left edge) */
.badge-notif-accent {
  position: absolute;
  top: 0; left: 0; bottom: 0;
  width: 5px;
}
.badge-notif-accent.bronze   { background: linear-gradient(180deg, #d97706, #92400e); }
.badge-notif-accent.silver   { background: linear-gradient(180deg, #9ca3af, #6b7280); }
.badge-notif-accent.gold     { background: linear-gradient(180deg, #f59e0b, #d97706); }
.badge-notif-accent.legendary { background: linear-gradient(180deg, #7c3aed, #a855f7, #ec4899); }

/* Inner layout */
.badge-notif-inner {
  display: flex;
  gap: 1rem;
  padding: 1.1rem 1.25rem 1rem 1.5rem;
}

/* Badge icon circle */
.badge-notif-icon-wrap {
  flex-shrink: 0;
  width: 56px; height: 56px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.7rem;
  animation: badgeIconBounce 0.6s 0.45s ease both;
  position: relative;
}
.badge-notif-icon-wrap.bronze   { background: linear-gradient(135deg, #d97706 0%, #92400e 100%); }
.badge-notif-icon-wrap.silver   { background: linear-gradient(135deg, #9ca3af 0%, #6b7280 100%); }
.badge-notif-icon-wrap.gold     { background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%); }
.badge-notif-icon-wrap.legendary {
  background: linear-gradient(135deg, #7c3aed 0%, #a855f7 50%, #ec4899 100%);
}

/* Legendary shimmer overlay on icon */
.badge-notif-icon-wrap.legendary::after {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; bottom: 0;
  border-radius: 50%;
  background: linear-gradient(45deg, transparent 40%, rgba(255,255,255,0.25) 50%, transparent 60%);
  animation: badgeShine 2.5s infinite;
}

.badge-notif-icon {
  position: relative; z-index: 1;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.15));
}

/* Text column */
.badge-notif-body {
  flex: 1;
  min-width: 0;
  padding-right: 1rem;
}
.badge-notif-hype {
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.2rem;
}
.badge-notif-hype.bronze   { color: #92400e; }
.badge-notif-hype.silver   { color: #6b7280; }
.badge-notif-hype.gold     { color: #b45309; }
.badge-notif-hype.legendary { color: #7c3aed; }

.badge-notif-name {
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.25;
  margin-bottom: 0.25rem;
  color: #1f2a37;
}
.badge-notif-desc {
  font-size: 0.82rem;
  color: #5f6b7a;
  line-height: 1.4;
  margin-bottom: 0.6rem;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* CTA link */
.badge-notif-cta {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: #2a7de1;
  text-decoration: none;
  cursor: pointer;
  transition: color 0.15s;
}
.badge-notif-cta:hover { color: #1a5fb4; }
.badge-notif-cta::after { content: '\2192'; }

/* Close button */
.badge-notif-close {
  position: absolute;
  top: 0.6rem; right: 0.7rem;
  background: none; border: none;
  color: #9ca3af; font-size: 1.15rem;
  cursor: pointer; padding: 0.2rem;
  line-height: 1; border-radius: 4px;
  transition: color 0.15s, background 0.15s;
}
.badge-notif-close:hover {
  color: #1f2a37;
  background: rgba(0,0,0,0.05);
}
.badge-notif-close:focus-visible {
  outline: 2px solid #2a7de1;
  outline-offset: 2px;
}

/* Progress bar (auto-dismiss countdown) */
.badge-notif-timer {
  height: 3px;
  background: rgba(0,0,0,0.06);
  overflow: hidden;
}
.badge-notif-timer-bar {
  height: 100%;
  width: 100%;
  transform-origin: left;
  transition: transform linear;
}
.badge-notif-timer-bar.bronze   { background: linear-gradient(90deg, #d97706, #92400e); }
.badge-notif-timer-bar.silver   { background: linear-gradient(90deg, #9ca3af, #6b7280); }
.badge-notif-timer-bar.gold     { background: linear-gradient(90deg, #f59e0b, #d97706); }
.badge-notif-timer-bar.legendary { background: linear-gradient(90deg, #7c3aed, #a855f7, #ec4899); }

/* Paused state — tier-colored glow */
.badge-notif.paused {
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.12),
    0 2px 8px rgba(0, 0, 0, 0.06),
    0 0 0 2px rgba(42, 125, 225, 0.3);
}
.badge-notif.paused.tier-bronze {
  box-shadow: 0 8px 32px rgba(0,0,0,0.12), 0 0 0 2px rgba(217,119,6,0.35);
}
.badge-notif.paused.tier-silver {
  box-shadow: 0 8px 32px rgba(0,0,0,0.12), 0 0 0 2px rgba(107,114,128,0.35);
}
.badge-notif.paused.tier-gold {
  box-shadow: 0 8px 32px rgba(0,0,0,0.12), 0 0 0 2px rgba(245,158,11,0.4);
}
.badge-notif.paused.tier-legendary {
  box-shadow: 0 8px 32px rgba(0,0,0,0.12), 0 0 0 2px rgba(124,58,237,0.4);
}

/* Confetti burst (CSS particles) */
.badge-confetti {
  position: absolute;
  top: 50%; left: 50%;
  width: 6px; height: 6px;
  border-radius: 2px;
  pointer-events: none;
  animation: confettiBurst 0.8s 0.3s ease-out both;
}

/* ── Animations ───────────────────────────────────────── */
@keyframes badgeSlideIn {
  0%   { opacity: 0; transform: translateX(120%); }
  60%  { opacity: 1; transform: translateX(-6px); }
  80%  { transform: translateX(3px); }
  100% { opacity: 1; transform: translateX(0); }
}
@keyframes badgeSlideOut {
  0%   { opacity: 1; transform: translateX(0); }
  100% { opacity: 0; transform: translateX(120%); }
}
@keyframes badgeIconBounce {
  0%   { transform: scale(0.3); opacity: 0; }
  50%  { transform: scale(1.15); opacity: 1; }
  70%  { transform: scale(0.92); }
  100% { transform: scale(1); opacity: 1; }
}
@keyframes badgeShine {
  0%   { background-position: -200% center; }
  100% { background-position: 200% center; }
}
@keyframes confettiBurst {
  0%   { opacity: 1; transform: translate(-50%, -50%) scale(0); }
  40%  { opacity: 1; }
  100% { opacity: 0; transform: translate(var(--cx), var(--cy)) scale(1) rotate(var(--cr)); }
}

/* ── Reduced motion ───────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .badge-notif {
    animation: badgeFadeIn 0.3s ease forwards;
  }
  .badge-notif.dismiss {
    animation: badgeFadeOut 0.2s ease forwards;
  }
  .badge-notif-icon-wrap { animation: none; }
  .badge-confetti { display: none; }
  @keyframes badgeFadeIn {
    from { opacity: 0; transform: translateX(0); }
    to   { opacity: 1; transform: translateX(0); }
  }
  @keyframes badgeFadeOut {
    from { opacity: 1; }
    to   { opacity: 0; }
  }
}

/* ── Responsive ───────────────────────────────────────── */
@media (max-width: 480px) {
  .badge-notif-container {
    right: 0.75rem;
    left: 0.75rem;
    max-width: none;
  }
  .badge-notif-inner { padding: 1rem; gap: 0.75rem; }
  .badge-notif-icon-wrap { width: 44px; height: 44px; font-size: 1.3rem; }
  .badge-notif-name { font-size: 0.92rem; }
}
