/* ============================================================
   Shared components: Top tabs nav + Medal / popup modals
   Works with every theme via design tokens.
   ============================================================ */

/* ---------- TOP TABS NAV ---------- */
.top-tabs {
  display: flex;
  align-items: center;
  gap: .25rem;
  padding: .375rem;
  background: var(--surface-2, var(--surface));
  border: 1px solid var(--border);
  border-radius: var(--radius-pill, 999px);
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  margin: 0 auto 1.5rem;
  max-width: max-content;
  box-shadow: var(--shadow-sm);
}
.top-tabs::-webkit-scrollbar { display: none; }

.top-tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  padding: .55rem 1.1rem;
  font-size: .8125rem;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
  border-radius: var(--radius-pill, 999px);
  text-decoration: none;
  transition: background .18s ease, color .18s ease;
}
.top-tab:hover { color: var(--text); background: var(--surface-3, rgba(0,0,0,.04)); }
.top-tab.active {
  color: #fff;
  background: var(--gradient-primary, var(--primary));
  box-shadow: 0 6px 18px -6px var(--primary);
}
.top-tab.active .top-tab-badge {
  background: rgba(255,255,255,.25); color:#fff;
}
.top-tab-badge {
  font-size: .68rem; font-weight: 700;
  padding: .1rem .45rem;
  border-radius: 999px;
  background: var(--surface-3, rgba(0,0,0,.08));
  color: var(--text-muted);
}

/* ---------- MODAL / MEDAL OVERLAY ---------- */
.medal-overlay {
  position: fixed; inset: 0;
  /* OPTIMIZATION: Replaced backdrop-filter blur with a solid dark background */
  background: rgba(15, 23, 42, .78);
  display: flex; align-items: center; justify-content: center;
  padding: 1.5rem;
  z-index: 1000;
  
  /* OPTIMIZATION: Added visibility to stop background animations when closed */
  visibility: hidden;
  opacity: 0; pointer-events: none;
  transition: opacity .28s ease, visibility .28s ease;
}
.medal-overlay.open { 
  visibility: visible;
  opacity: 1; 
  pointer-events: auto; 
}

.medal-modal {
  position: relative;
  width: 100%; max-width: 380px;
  background: var(--surface);
  border-radius: var(--radius-lg, 1.25rem);
  padding: 2.25rem 1.75rem 1.75rem;
  text-align: center;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  transform: translateY(16px) scale(.96);
  opacity: 0;
  transition: transform .32s cubic-bezier(.2,.9,.3,1.4), opacity .28s ease;
  overflow: hidden;
}
.medal-overlay.open .medal-modal { transform: translateY(0) scale(1); opacity: 1; }

/* Shimmer band on top of the modal */
.medal-modal::before {
  content: "";
  position: absolute; inset: 0 0 auto 0;
  height: 5px;
  background: var(--gradient-primary, var(--primary));
}

.medal-close {
  position: absolute; top: .75rem; right: .75rem;
  width: 2rem; height: 2rem; border-radius: 50%;
  background: transparent; border: none; cursor: pointer;
  color: var(--text-muted);
  font-size: 1.05rem; line-height: 1;
  transition: background .18s ease, color .18s ease;
}
.medal-close:hover { background: var(--surface-3); color: var(--text); }

/* The circular medal itself */
.medal-ring {
  width: 96px; height: 96px;
  border-radius: 50%;
  margin: 0 auto 1rem;
  display: flex; align-items: center; justify-content: center;
  font-size: 2.6rem;
  color: #fff;
  position: relative;
  box-shadow:
    0 0 0 6px color-mix(in srgb, var(--medal-color) 22%, transparent),
    0 14px 40px -12px var(--medal-color);
  background:
    radial-gradient(circle at 30% 25%, rgba(255,255,255,.55), transparent 45%),
    linear-gradient(135deg, color-mix(in srgb, var(--medal-color) 88%, #fff), var(--medal-color));
  animation: medalBounce .55s cubic-bezier(.2,.9,.3,1.4) both;
}
.medal-ring::after {
  content: "";
  position: absolute; inset: -14px;
  border-radius: 50%;
  border: 2px dashed color-mix(in srgb, var(--medal-color) 35%, transparent);
  opacity: .55;
  animation: medalSpin 18s linear infinite;
}
@keyframes medalBounce {
  0%   { transform: scale(.4) rotate(-20deg); }
  60%  { transform: scale(1.12) rotate(6deg); }
  100% { transform: scale(1) rotate(0); }
}
@keyframes medalSpin { to { transform: rotate(360deg); } }

.medal-title {
  font-family: var(--font-serif, Georgia, serif);
  font-size: 1.35rem;
  margin: 0 0 .35rem;
  color: var(--text);
}
.medal-subtitle {
  font-size: .875rem;
  color: var(--text-muted);
  margin: 0 0 1.35rem;
  line-height: 1.5;
}
.medal-actions { display: flex; gap: .625rem; }
.medal-actions .btn { flex: 1; }

/* Medal colour variants */
.medal-gold     { --medal-color: #f5b642; }
.medal-silver   { --medal-color: #b7c0d0; }
.medal-bronze   { --medal-color: #cd7f32; }
.medal-primary  { --medal-color: var(--primary); }
.medal-success  { --medal-color: #16a34a; }
.medal-danger   { --medal-color: #dc2626; }

/* Confetti burst (lightweight, pure CSS) */
.medal-modal .confetti {
  position: absolute; inset: 0; pointer-events: none; overflow: hidden;
}
.medal-modal .confetti span {
  position: absolute; top: -10%;
  width: 8px; height: 12px; border-radius: 2px;
  background: var(--confetti-color, #f5b642);
  animation: confettiFall 1.8s linear infinite;
  opacity: .85;
}
.medal-modal .confetti span:nth-child(1){left:12%;background:#f5b642;animation-delay:0s;}
.medal-modal .confetti span:nth-child(2){left:28%;background:#7c3aed;animation-delay:.25s;}
.medal-modal .confetti span:nth-child(3){left:44%;background:#10b981;animation-delay:.5s;}
.medal-modal .confetti span:nth-child(4){left:60%;background:#f43f5e;animation-delay:.15s;}
.medal-modal .confetti span:nth-child(5){left:76%;background:#3b82f6;animation-delay:.4s;}
.medal-modal .confetti span:nth-child(6){left:88%;background:#f59e0b;animation-delay:.65s;}
@keyframes confettiFall {
  to { transform: translateY(420px) rotate(540deg); opacity: 0; }
}