/* The badge shelf (badge-shelf.js): a card over a dimmed room, four badges to a row; a sheet from the bottom
   on a phone, two to a row. The H1 tokens only: the card, the wells, one accent for what is worn and for the
   progress bars. Every card has the same rows at the same heights, so medals, names and buttons line up. */

.shelf-btn.away { display: none; }
/* nothing worn: the locked medal, dimmed as on the name plate */
.shelf-btn .ib.none img, .bs-head-icon .ib.none img { opacity: .5; }

.shelf-dim { position: fixed; z-index: 26; inset: 0; background: #14110d59; }
.shelf-dim[hidden], .shelf[hidden] { display: none; }
.shelf { position: fixed; z-index: 27; left: 50%; top: 50%; display: flex; flex-direction: column; width: min(880px, calc(100vw - 2 * var(--gap))); max-height: calc(100dvh - 2 * var(--gap)); overflow: hidden; color: var(--ink); transform: translate(-50%, -50%); animation: shelf-in .22s ease both; }
@keyframes shelf-in { from { opacity: 0; transform: translate(-50%, calc(-50% + 10px)); } }
.shelf .grab { display: none; }

.bs-head { flex: none; display: flex; align-items: center; gap: 12px; padding: 14px 14px 12px 18px; border-bottom: 1px solid var(--hud-line); }
.bs-head-icon { display: contents; }
.bs-head-text { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.bs-head-text b { font-size: 17px; font-weight: 800; letter-spacing: -.01em; }
.bs-head-text small { color: var(--hud-muted); font-size: 12.5px; font-weight: 600; }

.bs-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin: 0; padding: 16px 18px 6px; overflow-y: auto; overscroll-behavior: contain; list-style: none; }
.bs-card { display: grid; grid-template-rows: 80px 20px 34px 34px; justify-items: center; align-items: center; gap: 6px; padding: 14px 10px 12px; border: 1px solid var(--hud-line); border-radius: 16px; background: var(--well); text-align: center; }
.bs-card.worn { border-color: color-mix(in srgb, var(--accent) 55%, transparent); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 30%, transparent); }
/* the medal stands on a plank of the shelf */
.bs-medal { position: relative; display: grid; place-items: end center; width: 100%; height: 80px; }
.bs-medal::after { content: ""; position: absolute; left: 12%; right: 12%; bottom: 4px; height: 4px; border-radius: 2px; background: color-mix(in srgb, var(--ink) 12%, transparent); }
/* the picture's art ends 2.5 px above its box: it stands on the plank */
.bs-medal img { position: relative; z-index: 1; width: 72px; height: 72px; margin-bottom: 1px; filter: drop-shadow(0 3px 3px rgba(0, 0, 0, .3)); }
.bs-card:not(.earned) .bs-medal img { filter: grayscale(1); opacity: .38; }
.bs-name { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; font-weight: 800; line-height: 20px; }
.bs-how { display: -webkit-box; max-width: 100%; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 2; align-self: start; color: var(--hud-muted); font-size: 12px; line-height: 17px; }
.bs-wear { justify-content: center; min-width: 112px; height: 34px; min-height: 34px; border-radius: 12px; font-weight: 700; }
.bs-wear[hidden], .bs-meter[hidden] { display: none; }
.bs-wear .ui-ico { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.bs-wear[aria-pressed="true"] { border-color: color-mix(in srgb, var(--accent) 45%, transparent); background: var(--accent-soft); color: var(--accent); }
.bs-meter { display: flex; align-items: center; gap: 8px; height: 34px; }
.bs-meter .mini-bar { width: 84px; }
.bs-meter small { min-width: 3.4em; color: var(--hud-muted); font-size: 12px; font-weight: 700; text-align: left; font-variant-numeric: tabular-nums; }
.bs-said { flex: none; min-height: 1.4em; margin: 0; padding: 4px 18px 12px; color: var(--hud-muted); font-size: 12px; }

@media (max-width: 760px) {
  .shelf { left: 0; right: 0; top: auto; bottom: 0; width: auto; max-height: calc(100dvh - 3 * var(--gap)); border-bottom: 0; border-radius: 22px 22px 0 0; transform: none; animation-name: shelf-up; }
  @keyframes shelf-up { from { transform: translateY(24px); opacity: 0; } }
  .shelf .grab { display: block; flex: none; width: 38px; height: 4px; margin: 8px auto 0; border-radius: 4px; background: var(--faint); opacity: .6; }
  .bs-head { padding: 8px 12px 10px 14px; }
  .bs-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; padding: 12px 12px 4px; }
  .bs-card { padding: 12px 8px 10px; }
  .bs-wear { min-width: 0; width: 100%; }
  .bs-meter .mini-bar { width: 72px; }
  .bs-said { padding: 2px 14px calc(10px + env(safe-area-inset-bottom)); }
}
@media (prefers-reduced-motion: reduce) { .shelf { animation: none; } }
body.pip .shelf, body.pip .shelf-dim, body.record .shelf, body.record .shelf-dim { display: none !important; }
