/*
 * The body map (views/partials/body-map.ejs) on /players/:id and /profile/v2:
 * two figures side by side, where a player got hit and where they hit others.
 *
 * Colours are theme tokens only, so all twelve palettes carry it. Heat 1-5
 * runs from --sk-warning to --sk-danger; a part nobody hit is a muted tint of
 * the card, and every part is outlined in the card's own surface, so the
 * figure reads as separate parts in light and dark. The number on each part
 * carries the share of hits: colour only agrees with it.
 *
 * Two figures fit a 320px phone: each column is minmax(0, 1fr) with
 * `min-width: 0`, and the SVG scales to its column (its own text scales with
 * it: the viewBox keeps its aspect, so a label is never squashed).
 */

.bmap {
  --bmap-0: color-mix(in srgb, var(--sk-muted) 32%, var(--sk-surface));
  --bmap-1: var(--sk-warning);
  --bmap-2: color-mix(in srgb, var(--sk-warning) 75%, var(--sk-danger));
  --bmap-3: color-mix(in srgb, var(--sk-warning) 50%, var(--sk-danger));
  --bmap-4: color-mix(in srgb, var(--sk-warning) 25%, var(--sk-danger));
  --bmap-5: var(--sk-danger);
  --bmap-line: var(--sk-surface);
}

.bmap-pair {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  max-width: 30rem;
  margin-inline: auto;
}
.bmap-pair > *,
.bmap-fig { min-width: 0; }

.bmap-fig {
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}
.bmap-svg {
  display: block;
  width: 100%;
  max-width: 11rem;
  height: auto;
}
.bmap-fig figcaption {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.1rem;
  overflow-wrap: anywhere;
}

.bmap-shape { stroke: var(--bmap-line); stroke-width: 3; stroke-linejoin: round; }
.bmap-limb, .bmap-limb-out { stroke-linecap: round; fill: none; }
.bmap-limb-out { stroke: var(--bmap-line); }

.bmap-shape[data-heat="0"] { fill: var(--bmap-0); }
.bmap-shape[data-heat="1"] { fill: var(--bmap-1); }
.bmap-shape[data-heat="2"] { fill: var(--bmap-2); }
.bmap-shape[data-heat="3"] { fill: var(--bmap-3); }
.bmap-shape[data-heat="4"] { fill: var(--bmap-4); }
.bmap-shape[data-heat="5"] { fill: var(--bmap-5); }
.bmap-limb[data-heat="0"] { stroke: var(--bmap-0); }
.bmap-limb[data-heat="1"] { stroke: var(--bmap-1); }
.bmap-limb[data-heat="2"] { stroke: var(--bmap-2); }
.bmap-limb[data-heat="3"] { stroke: var(--bmap-3); }
.bmap-limb[data-heat="4"] { stroke: var(--bmap-4); }
.bmap-limb[data-heat="5"] { stroke: var(--bmap-5); }

.bmap-badge { fill: var(--sk-surface); stroke: var(--sk-text); stroke-width: 2; }
.bmap-badge-text {
  fill: var(--sk-text);
  font: 700 15px var(--sk-font, system-ui, sans-serif);
  text-anchor: middle;
  dominant-baseline: central;
}
.bmap-side {
  fill: var(--sk-muted);
  font: 700 15px var(--sk-font, system-ui, sans-serif);
  text-anchor: middle;
  dominant-baseline: central;
}

.bmap-muted { color: var(--sk-muted); }
.bmap-note { font-size: 0.85rem; margin: 0.75rem 0 0; }

.bmap-legend {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin: 1rem 0 0;
  font-size: 0.8rem;
  color: var(--sk-muted);
}
.bmap-scale { display: inline-flex; gap: 2px; }
.bmap-scale i { display: block; width: 1.25rem; height: 0.6rem; border-radius: 2px; }
.bmap-scale i[data-heat="1"] { background: var(--bmap-1); }
.bmap-scale i[data-heat="2"] { background: var(--bmap-2); }
.bmap-scale i[data-heat="3"] { background: var(--bmap-3); }
.bmap-scale i[data-heat="4"] { background: var(--bmap-4); }
.bmap-scale i[data-heat="5"] { background: var(--bmap-5); }

.bmap-table { margin: 0.75rem 0 0; }
.bmap-table > summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; color: var(--sk-primary-text); }
.bmap-table-wrap { overflow-x: auto; max-width: 100%; }
.bmap-table table { width: 100%; }
.bmap-table td, .bmap-table th { white-space: nowrap; }

/* When the figure arrives (html.skm-on, public/js/motion-v2.js), each part
   that was hit fades up from a faint outline in order of its share: the
   coolest first, the hottest last, then the badges pop. Opacity and scale
   only; with no script or reduced motion the figure is simply drawn. */
.skm-on .bmap-svg :is(.bmap-shape, .bmap-limb) { transition: opacity 0.5s ease-out; }
.skm-on .bmap-svg:not(.skm-in) :is(.bmap-shape, .bmap-limb):not([data-heat="0"]) { opacity: 0.18; }
.skm-on .bmap-svg [data-heat="1"] { transition-delay: 0.1s; }
.skm-on .bmap-svg [data-heat="2"] { transition-delay: 0.25s; }
.skm-on .bmap-svg [data-heat="3"] { transition-delay: 0.4s; }
.skm-on .bmap-svg [data-heat="4"] { transition-delay: 0.55s; }
.skm-on .bmap-svg [data-heat="5"] { transition-delay: 0.7s; }
.skm-on .bmap-svg :is(.bmap-badge, .bmap-badge-text) {
  transform-box: fill-box;
  transform-origin: center;
  transition: opacity 0.3s ease-out 0.95s, scale 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) 0.95s;
}
.skm-on .bmap-svg:not(.skm-in) :is(.bmap-badge, .bmap-badge-text) { opacity: 0; scale: 0.4; }
@media (prefers-reduced-motion: reduce) {
  .skm-on .bmap-svg * { opacity: 1 !important; scale: none !important; transition: none !important; }
}
