/* ==========================================================================
   BLOCKHAVEN -- badges.
   The profile's row of four, the Badge Inventory in the profile editor, the
   Badge tab of the avatar editor, the hover pop-up with the badge turning on
   a stand, and the "badge earned" toast.  Badges sit on dark velvet, the way
   medals sit in a case, so the metal of each tier is what you see first.
   ========================================================================== */

:root {
  --velvet-a: #2e4260;
  --velvet-b: #121b29;
  --bt-ink: #1b3d5f;
}
:root[data-theme="dark"] { --bt-ink: #e6f0fa; }
@media (prefers-color-scheme: dark) { :root[data-theme="auto"] { --bt-ink: #e6f0fa; } }

.panel-head.navy { background: linear-gradient(#41597a, #24364f 55%, #172539); border-bottom-color: #0d1828; }

/* ------------------------------------------------------------- the tiles */
.badge-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 560px) { .badge-row { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.badge-tile { position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 6px 6px 8px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel);
  text-align: center; cursor: pointer; outline: none; min-width: 0;
  transition: transform .18s, box-shadow .18s, border-color .18s; }
.badge-tile:hover, .badge-tile:focus-visible { transform: translateY(-3px); border-color: var(--tier);
  box-shadow: 0 0 0 1px var(--tier), 0 6px 18px color-mix(in srgb, var(--glow) 45%, transparent); }
.bt-stage { position: relative; width: 100%; aspect-ratio: 1 / 1; border-radius: 6px; overflow: hidden;
  background: radial-gradient(circle at 50% 38%, var(--velvet-a), var(--velvet-b) 72%);
  box-shadow: inset 0 2px 8px rgba(0,0,0,.6); }
.bt-stage::before { content: ""; position: absolute; left: 14%; right: 14%; bottom: 7%; height: 9%; border-radius: 50%;
  background: radial-gradient(rgba(0,0,0,.55), transparent 70%); }
.bt-stage::after { content: ""; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(circle at 50% 30%, color-mix(in srgb, var(--glow) 28%, transparent), transparent 55%);
  opacity: .8; }
.bt-stage canvas { position: relative; z-index: 1; width: 100%; height: 100%; display: block;
  transition: transform .25s; }
.badge-tile:hover .bt-stage canvas { transform: scale(1.06); }
.bt-name { font-size: 11px; color: var(--bt-ink); margin-top: 4px; white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; max-width: 100%; }
.bt-rank { font-size: 10px; color: var(--ink-soft); line-height: 1.3; }
.bt-pips { display: flex; gap: 3px; margin-top: 3px; }
.bt-pips i { width: 7px; height: 7px; transform: rotate(45deg); background: var(--line); border-radius: 1px; }
.bt-pips i.on { background: var(--tier); box-shadow: 0 0 4px var(--glow); }
.badge-tile.tier-mythic .bt-pips i.on { background: #ff4fd8; }
.badge-tile.tier-mythic { border-color: #a0307a; }
.badge-tile.tier-mythic::after { content: ""; position: absolute; inset: -1px; border-radius: 8px; pointer-events: none;
  padding: 1px; background: conic-gradient(from var(--spin, 0deg), #ff4fd8, #ffcf4a, #b26bff, #ff4fd8);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude; animation: bt-spin 4s linear infinite; }
@property --spin { syntax: '<angle>'; initial-value: 0deg; inherits: false; }
@keyframes bt-spin { to { --spin: 360deg; } }
.badge-tile.empty { cursor: default; border-style: dashed; background: transparent; }
.badge-tile.empty:hover { transform: none; box-shadow: none; border-color: var(--line); }
.bt-hole { position: absolute; left: 22%; top: 22%; width: 56%; height: 56%; border-radius: 50%;
  border: 2px dashed rgba(255,255,255,.22); }
.badge-tile.empty .bt-rank { margin-top: 4px; }

/* -------------------------------------------------------------- the pop-up */
.badge-pop { position: absolute; z-index: 9500; width: 290px; border-radius: 12px; overflow: hidden; color: #e9f1fb;
  background: linear-gradient(#1d2a3c, #101826); border: 1px solid color-mix(in srgb, var(--tier) 60%, #000);
  box-shadow: 0 16px 40px rgba(0,0,0,.55), 0 0 0 1px rgba(255,255,255,.06), 0 0 24px color-mix(in srgb, var(--glow) 35%, transparent);
  opacity: 0; transform: translateY(6px) scale(.94); transform-origin: var(--arrow, 50%) 100%;
  transition: opacity .16s, transform .2s cubic-bezier(.3, 1.4, .5, 1); }
.badge-pop.below { transform-origin: var(--arrow, 50%) 0; }
.badge-pop.in { opacity: 1; transform: none; }
.bp-stage { position: relative; height: 220px;
  background: radial-gradient(circle at 50% 42%, #3a5274, #121b29 70%); }
.bp-stage canvas { position: relative; display: block; width: 220px; height: 220px; margin: 0 auto;
  cursor: grab; touch-action: none; }
.bp-stage canvas:active { cursor: grabbing; }
.bp-hint { position: absolute; right: 8px; bottom: 6px; font-size: 9px; color: rgba(255,255,255,.45);
  text-transform: uppercase; letter-spacing: .5px; }
.bp-info { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 4px; }
.bp-name { font-size: 15px; letter-spacing: .2px; }
.bp-tier { font-size: 11px; font-weight: bold; color: color-mix(in srgb, var(--glow) 85%, #fff); }
.badge-pop.locked .bp-tier { color: #9fb0c2; }
.bp-info p { margin: 2px 0 2px; font-size: 11px; line-height: 1.45; color: #c9d6e6; }
.bp-ladder { display: flex; gap: 5px; margin: 2px 0; }
.bp-ladder i { width: 12px; height: 12px; transform: rotate(45deg); border-radius: 2px; opacity: .22;
  border: 1px solid rgba(255,255,255,.35); }
.bp-ladder i.on { opacity: 1; box-shadow: 0 0 6px currentColor; }
.bp-ladder .t-bronze { background: #b8743a; color: #ffb070; }
.bp-ladder .t-silver { background: #c9d2da; color: #e8f4ff; }
.bp-ladder .t-gold { background: #f0bd45; color: #ffe08a; }
.bp-ladder .t-platinum { background: #f1eef8; color: #d9ccff; }
.bp-ladder .t-diamond { background: #8fe6ff; color: #7fe3ff; }
.bp-ladder .t-mythic { background: linear-gradient(135deg, #ff4fd8, #ffcf4a); color: #ff4fd8; }
.bp-prog { height: 7px; border-radius: 4px; background: rgba(255,255,255,.12); overflow: hidden; margin-top: 2px; }
.bp-prog i { display: block; height: 100%; border-radius: 4px;
  background: linear-gradient(90deg, color-mix(in srgb, var(--tier) 70%, #fff), var(--glow)); }
.bp-prog.max i { background: linear-gradient(90deg, #ffcf4a, #ff4fd8, #7fe3ff); }
.bp-info small { font-size: 10px; color: #9fb0c2; }
.bp-game { font-size: 9px; text-transform: uppercase; letter-spacing: .6px; color: #6f86a3; margin-top: 2px; }
.badge-pop.locked .bp-stage canvas { filter: grayscale(1) brightness(.55) contrast(1.1); }

/* ----------------------------------------------------- the Badge Inventory */
.bi-intro { margin: 0 0 8px; }
.bi-empty { margin: 6px 0 10px; padding: 10px; text-align: center; border: 1px dashed var(--line-soft, #c9d4e2);
  border-radius: 6px; }
.bi-slots { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 12px; }
.bi-slot { position: relative; border-radius: 8px; border: 2px dashed var(--line); min-height: 128px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
  padding: 6px; color: var(--ink-soft); font-size: 10px; transition: border-color .15s, background .15s; }
.bi-slot .slot-n { position: absolute; left: 6px; top: 4px; font: bold 11px Verdana, sans-serif; color: var(--ink-soft); }
.bi-slot.over { border-color: var(--mk-hot-b, #f29a18); background: rgba(255, 190, 40, .12); }
.bi-slot.filled { border-style: solid; border-color: var(--tier); padding: 4px; }
.bi-slot.filled .bt-stage { width: 82%; }
.bi-slot .slot-clear { position: absolute; right: 4px; top: 2px; z-index: 2; border: 0; background: transparent;
  font-size: 16px; line-height: 1; color: var(--ink-soft); cursor: pointer; }
.bi-slot b { font-size: 10px; color: var(--bt-ink); margin-top: 3px; }
@media (max-width: 560px) { .bi-slots { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.bi-filter { display: flex; flex-wrap: wrap; gap: 4px; margin: 4px 0 8px; }
.bi-filter button { font-size: 10px; }
.bi-filter button.on { background: var(--head-blue, #2f6db5); color: #fff; }
.bi-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 8px; }
.bi-card { position: relative; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 2px;
  padding: 5px 5px 7px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel);
  cursor: grab; user-select: none; touch-action: none; transition: transform .15s, box-shadow .15s, opacity .2s; }
.bi-card:hover { transform: translateY(-2px); box-shadow: 0 4px 12px var(--shadow-lift, rgba(0,0,0,.2)); border-color: var(--tier); }
.bi-card .bt-stage { width: 100%; }
.bi-card b { font-size: 10px; color: var(--bt-ink); line-height: 1.25; }
.bi-card span { font-size: 9px; color: var(--ink-soft); }
.bi-card.on { box-shadow: 0 0 0 2px var(--tier); }
.bi-card.on::before { content: "\2605 shown"; position: absolute; z-index: 2; top: 8px; left: 8px; padding: 0 5px;
  font: bold 9px/14px Verdana, sans-serif; border-radius: 7px; color: #3b2200; background: linear-gradient(#ffd24a, #f29a18); }
.bi-card.locked { cursor: default; }
.bi-card.locked .bt-stage canvas { filter: grayscale(1) brightness(.45); opacity: .8; }
.bi-card.locked .bt-stage::after { content: "\1F512"; display: flex; align-items: center; justify-content: center;
  font-size: 22px; background: none; opacity: .9; }
.bi-card .bi-prog { width: 86%; height: 4px; border-radius: 2px; background: var(--line-soft); overflow: hidden; margin-top: 2px; }
.bi-card .bi-prog i { display: block; height: 100%; background: var(--tier); }
.bi-card.worn::after { content: "Worn"; position: absolute; z-index: 2; top: 8px; right: 8px; padding: 0 5px;
  font: bold 9px/14px Verdana, sans-serif; border-radius: 7px; color: #fff; background: #2f9e55; }
.bi-card.dragging { opacity: .35; }
.bi-ghost { position: fixed; z-index: 9999; left: 0; top: 0; width: 84px; pointer-events: none; text-align: center;
  filter: drop-shadow(0 8px 10px rgba(0,0,0,.45)); }
.bi-ghost canvas { width: 84px; height: 84px; }
body.bi-dragging, body.bi-dragging * { cursor: grabbing !important; }

/* the avatar editor's badge tab: one click wears it */
.bi-grid.wear .bi-card { cursor: pointer; }
.bi-card.none-card .bt-stage { display: flex; align-items: center; justify-content: center; color: rgba(255,255,255,.55);
  font-size: 11px; font-weight: bold; }

/* --------------------------------------------------------------- toasts */
#badge-toasts { position: fixed; left: 16px; bottom: 16px; z-index: 9600; display: flex; flex-direction: column;
  gap: 8px; max-width: calc(100vw - 32px); }
.badge-toast { display: flex; align-items: center; gap: 10px; width: 330px; max-width: 100%; padding: 8px 12px 8px 8px;
  border-radius: 12px; color: #fff; text-decoration: none;
  background: linear-gradient(#2a3d58, #142033); border: 1px solid #ffcf4a;
  box-shadow: 0 12px 30px rgba(0,0,0,.5), 0 0 18px rgba(255, 207, 74, .35);
  transform: translateX(-120%) rotate(-3deg); transition: transform .5s cubic-bezier(.3, 1.5, .5, 1), opacity .4s; }
.badge-toast:hover { text-decoration: none; }
.badge-toast.in { transform: none; }
.badge-toast.out { opacity: 0; transform: translateY(10px); }
.badge-toast canvas { width: 56px; height: 56px; flex: 0 0 56px; animation: bt-medal 2.4s ease-in-out infinite; }
@keyframes bt-medal { 0%, 100% { transform: rotateY(0) scale(1); } 50% { transform: rotateY(25deg) scale(1.06); } }
.badge-toast small { display: block; font-size: 9px; text-transform: uppercase; letter-spacing: .8px; color: #ffcf4a; }
.badge-toast b { display: block; font-size: 12px; }
.badge-toast span { display: block; font-size: 10px; color: #c9d6e6; line-height: 1.35; margin-top: 2px; }
.badge-toast.tier-mythic { border-color: #ff4fd8; box-shadow: 0 12px 30px rgba(0,0,0,.5), 0 0 22px rgba(255, 79, 216, .5); }

@media (prefers-reduced-motion: reduce) {
  .badge-tile.tier-mythic::after, .bp-stage::before, .badge-toast canvas { animation: none; }
  .badge-toast { transition: opacity .3s; transform: none; }
}
/* in the avatar editor "on" means worn, not shown on the profile */
.bi-grid.wear .bi-card.on::before { content: "\2713 wearing"; color: #fff; background: linear-gradient(#3cc46a, #2f9e55); }
