/* Badges (badge-art.js, badge-view.js, badge-note.js): plaque colours, the profile grid with its detail panel, the
 * earning line on the end screens and the small plaques on the leaderboard. The classic look paints enamel and
 * metal; the dither looks keep to their two inks (tier = dot screen density, marble = ink veins on paper). Sizes
 * grow with big buttons and TV mode; the only motion (a fade-in on earning) respects reduced motion. */

/* ------------------------------------------------------------------ plaque colours */
.badge-plaque { --b-rim: #6f4a27; --b-face: #b9783f; --b-disc: #f6eedb; --b-ink: #3a2414; display: block; flex: none; overflow: visible; }
.badge-plaque.tier-silver { --b-rim: #6e757c; --b-face: #c3c9ce; --b-ink: #262b30; }
.badge-plaque.tier-gold { --b-rim: #8a6511; --b-face: #e0b445; --b-ink: #45320a; }
.badge-plaque.tier-olymp { --b-disc: #fbfaf6; --b-ink: #3b3830; }
.badge-plaque.tier-none { --b-disc: transparent; --b-ink: var(--muted); }

.badge-rim { fill: var(--b-rim); }
.badge-face { fill: var(--b-face); }
.badge-screen { display: none; }
.badge-disc { fill: var(--b-disc); stroke: var(--b-ink); stroke-width: .8; }
.badge-ink { fill: var(--b-ink); }
.badge-ink-line { fill: none; stroke: var(--b-ink); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.badge-glyph-text { fill: var(--b-ink); font-family: var(--font); font-size: 12px; font-weight: 800; }
.badge-secret-mark { font-size: 19px; }

.tier-none .badge-rim { fill: none; stroke: var(--line-strong); stroke-width: 1.4; stroke-dasharray: 3 3; }
.tier-none .badge-face { fill: none; }
.tier-none .badge-disc { stroke: var(--line-strong); stroke-dasharray: 2 2; }

/* Olymp: white marble with soft veins, an olive laurel wreath, the hero's name cut in */
.badge-marble { fill: #f1eee6; }
.badge-veins path { fill: none; stroke: #c9c1b1; stroke-width: 1.2; stroke-linecap: round; }
.badge-marble-edge { fill: none; stroke: #a59c8a; stroke-width: 2; }
.badge-leaf { fill: #66753f; }
.badge-hero-name { fill: #3b3830; font-family: var(--font); font-size: 8.5px; font-weight: 700; letter-spacing: .04em; }

/* dither: paper and ink only; the tier is the density of the dot screen on the ring */
.theme-dither .badge-plaque { --b-rim: var(--ink); --b-face: var(--paper); --b-disc: var(--paper); --b-ink: var(--ink); }
.theme-dither .badge-screen { display: inline; }
.theme-dither .badge-screen-dot { fill: var(--ink); }
.theme-dither .badge-marble { fill: var(--paper); }
.theme-dither .badge-veins path { stroke: var(--ink); stroke-width: .8; stroke-dasharray: 4 3; }
.theme-dither .badge-marble-edge { stroke: var(--ink); }
.theme-dither .badge-leaf, .theme-dither .badge-hero-name { fill: var(--ink); }
.theme-dither .tier-none .badge-rim, .theme-dither .tier-none .badge-disc { stroke: var(--ink); }

/* ------------------------------------------------------------------ profile grid */
.badge-summary { margin: 0 0 8px; color: var(--muted); font-variant-numeric: tabular-nums; }
.badge-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 8px; list-style: none; margin: 0; padding: 0; }
.badge-item {
  display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; align-items: center; gap: 2px 10px;
  width: 100%; min-height: 72px; padding: 8px 10px; text-align: left;
  background: transparent; color: var(--text); border: 1px solid var(--line); border-radius: 10px;
}
.badge-item .badge-plaque { grid-row: 1 / span 2; }
.badge-name { font-weight: 700; align-self: end; overflow-wrap: break-word; hyphens: auto; }
.badge-line { font-size: .82rem; color: var(--muted); align-self: start; font-variant-numeric: tabular-nums; }
.badge-item:not(.is-earned) .badge-name { color: var(--muted); font-weight: 600; }
.badge-item[aria-expanded="true"] { border: 2px solid var(--gold); padding: 7px 9px; }
.badge-note { margin: 10px 0 0; }

/* the detail panel right below the grid */
.badge-detail { display: grid; grid-template-columns: auto 1fr; gap: 4px 16px; align-items: start; margin: 10px 0 0; padding: 12px 14px;
  border: 1px solid var(--line-strong); border-radius: 12px; background: var(--card); }
.badge-detail > .badge-plaque { grid-row: 1 / span 7; }
.badge-detail > :not(.badge-plaque) { grid-column: 2; margin: 0; }
.badge-detail h4 { font-size: 1.1rem; margin: 0; }
.badge-detail-tier { font-weight: 700; color: var(--gold); }
.badge-detail-hero { font-style: italic; color: var(--muted); }
.badge-detail-progress { font-variant-numeric: tabular-nums; font-weight: 600; }
.badge-dates { margin: 0; padding: 0 0 0 1.1em; color: var(--muted); font-size: .9rem; }
.badge-detail-close { justify-self: start; min-height: 44px; margin-top: 6px; }
.theme-dither .badge-detail-tier { color: var(--ink); }
.theme-dither .badge-item[aria-expanded="true"] { border-color: var(--ink); }

@media (max-width: 600px) {
  .badge-grid { grid-template-columns: 1fr; }
  .badge-item { min-height: 64px; }
  .badge-detail { grid-template-columns: 1fr; justify-items: start; }
  .badge-detail > .badge-plaque { grid-row: auto; justify-self: center; }
  .badge-detail > :not(.badge-plaque) { grid-column: 1; }
}

/* big buttons / TV: larger plaques and targets */
.big-ui .badge-grid { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.big-ui .badge-item { min-height: 96px; font-size: 1.05rem; }
.big-ui .badge-item .badge-plaque { width: 72px; height: auto; }
.big-ui .badge-line { font-size: .95rem; }
.big-ui .badge-detail-close { min-height: 64px; }

/* ------------------------------------------------------------------ earning line (end card, final card) */
.badge-award { margin: 6px auto 10px; max-width: 400px; }
.badge-award-line { display: flex; align-items: center; justify-content: center; gap: 12px; margin: 4px 0; text-align: left; font-weight: 600; }
.badge-award-line.is-olymp { flex-direction: column; text-align: center; gap: 6px; padding: 8px 0; }
.badge-award-hero { font-weight: 400; font-style: italic; color: var(--muted); font-size: .9rem; }
.result-card:not([data-kind="final"]) .ov-award { display: none; }
.big-ui .badge-award-line .badge-plaque { width: 56px; height: auto; }
.big-ui .badge-award-line.is-olymp .badge-plaque { width: 104px; }

@media (prefers-reduced-motion: no-preference) {
  .badge-award-line { animation: badge-in .6s ease-out both; }
  .badge-award-line.is-olymp { animation-duration: 1.2s; }
}
@keyframes badge-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.theme-dither .badge-award-line { animation: none; }   /* two inks: no fades */

/* ------------------------------------------------------------------ leaderboard */
.board-badges { display: inline-flex; align-items: center; gap: 2px; margin-left: 8px; vertical-align: middle; }
.board-badges .badge-plaque { width: 22px; height: auto; }
.big-ui .board-badges .badge-plaque { width: 30px; }
