/* Badges wherever they appear: the medal, the shelf on the homepage and leaderboard, the
   award card on the finish sheet, and the fireworks when a level is new. Loaded by
   index.html, join.html and leaderboard.html; badges.js builds the markup. The medal's
   ink is fixed dark because every level colour is light, on light and dark pages alike. */

.badge-medal {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--medal, #e2d7b9);
  color: #133c38;
  font: 700 18px/1 var(--serif, Georgia, serif);
  box-shadow: inset 0 0 0 3px #ffffff80, 0 1px 3px #082d2840;
  opacity: .55;
}
.badge-medal.earned { opacity: 1; }
.badge-medal.large { width: 54px; height: 54px; font-size: 24px; }

.badge-shelf {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  padding: 0;
  margin: 0;
  list-style: none;
}
.badge-shelf-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  text-align: center;
  min-width: 0;
}
.badge-shelf-name { font-size: 12px; font-weight: 700; line-height: 1.2; }
.badge-shelf-level { font-size: 11px; color: var(--muted); }
.badge-shelf-item.is-new .badge-medal { animation: medal-pop 900ms ease-out 2; }
.badge-shelf-item.is-new .badge-shelf-level::after { content: " · New"; font-weight: 700; color: var(--ink); }

@keyframes medal-pop {
  0% { transform: scale(1); }
  40% { transform: scale(1.25) rotate(-8deg); }
  100% { transform: scale(1); }
}

/* The finish sheet. */
.sheet-badges { margin: 0 0 18px; position: relative; }
.badge-award {
  padding: 14px 16px;
  margin-bottom: 12px;
  border: 2px solid #e5bc60;
  border-radius: 14px;
  background: #e5bc6026;
}
.badge-award-heading { margin: 0 0 10px; font: 700 1.25rem/1.2 var(--serif, Georgia, serif); }
.badge-award-list { margin: 0; padding: 0; list-style: none; display: grid; gap: 10px; }
.badge-award-list li { display: flex; align-items: center; gap: 12px; font-weight: 700; }
.badge-award-list .badge-medal { animation: medal-pop 900ms ease-out 2; }
.badge-next-line { margin: 0 0 8px; font-weight: 600; }
.badge-next progress {
  display: block;
  width: 100%;
  height: 8px;
  margin: 0 0 12px;
  accent-color: #174c3c;
}
.badge-next-actions { display: grid; gap: 8px; }
.badge-link { font-size: .9rem; font-weight: 600; color: inherit; }

/* The homepage shelf. */
.home-badges {
  display: grid;
  gap: 14px;
  padding: 18px 20px;
  margin: 0 0 18px;
}
.home-badges-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.home-badges-head h2 { margin: 0; font: 700 1.25rem/1.2 var(--serif, Georgia, serif); }
.home-badges-head a { font-size: .9rem; font-weight: 600; color: inherit; }
.home-badges-goal { margin: 0; font-weight: 600; }
.home-badges progress { display: block; width: 100%; height: 8px; accent-color: #174c3c; }
.home-badges .home-button { justify-self: start; }

/* Fireworks: each shell bursts into sparks flying out along their own angle. */
.fireworks {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 5;
}
body > .fireworks { position: fixed; z-index: 30; }
.firework { position: absolute; width: 0; height: 0; }
.firework i {
  position: absolute;
  left: -3px;
  top: -3px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  opacity: 0;
  transform: rotate(var(--angle)) translateY(0);
  animation: spark 1.3s ease-out forwards;
}
@keyframes spark {
  0% { opacity: 1; transform: rotate(var(--angle)) translateY(0) scale(1); }
  70% { opacity: 1; }
  100% { opacity: 0; transform: rotate(var(--angle)) translateY(-90px) scale(.4); }
}

@media (prefers-reduced-motion: reduce) {
  .fireworks { display: none; }
  .badge-award-list .badge-medal, .badge-shelf-item.is-new .badge-medal { animation: none; }
}

@media (max-width: 420px) {
  .badge-shelf { grid-template-columns: repeat(2, minmax(0, 1fr)); row-gap: 14px; }
}

/* Rank honors (0065): a medal image or a ribbon of text beside a name, and the shelf of
   the honors this player holds. The ribbon's ink is fixed dark on fixed gold, like the
   medal's, so it reads the same on light and dark pages. */
.honor-tags { display: inline-flex; align-items: center; flex-wrap: wrap; gap: 4px 6px; margin-left: 8px; vertical-align: middle; }
.honor-medal { display: block; width: 24px; height: 24px; }
.honor-ribbon {
  display: inline-block;
  padding: 3px 11px;
  background: linear-gradient(#f8da7c, #e3b54c);
  color: #133c38;
  font: 800 10px/1.25 system-ui, -apple-system, "Segoe UI", sans-serif;
  letter-spacing: .06em;
  white-space: nowrap;
  clip-path: polygon(0 0, 100% 0, calc(100% - 6px) 50%, 100% 100%, 0 100%, 6px 50%);
}
.honor-shelf { display: flex; flex-wrap: wrap; gap: 10px 18px; list-style: none; padding: 0; margin: 14px 0 0; }
.honor-shelf[hidden] { display: none; }
.honor-shelf-item { display: flex; align-items: center; gap: 10px; min-width: 0; }
.honor-shelf-item img { flex: none; width: 56px; height: 56px; }
.honor-shelf-title { display: block; font-size: 14px; font-weight: 800; }
.honor-shelf-detail { display: block; font-size: 12px; color: var(--muted); }
