/* 暴打选举 — 地图方案 A「肿包地图」（js/maps/bump-map.js）。所有选择器都挂在 bm- 前缀下 */

/* 注册成数字属性：高度、悬停抬起、挤压、鼓胀才能平滑过渡 / 被 Web Animations 插值 */
@property --bm-h { syntax: '<number>'; inherits: true; initial-value: 0; }
@property --bm-up { syntax: '<number>'; inherits: true; initial-value: 0; }
@property --bm-sq { syntax: '<number>'; inherits: true; initial-value: 1; }
@property --bm-b { syntax: '<number>'; inherits: true; initial-value: 0; }

.bm {
  position: relative;
  container-type: inline-size;
  /* 横向裁掉：从画面外扔进来的 emoji、震屏、靠边的 zzz 不许把手机页面撑出横向滚动条（竖向照样溢出，肿包和牌子能往上长） */
  overflow-x: clip;
  --bm-k: 1.3;   /* 每个屏幕像素等于多少 viewBox 单位，JS 按宽度更新，线宽靠它保持粗细一致 */
  color: var(--ink);
}

/* ── 顶上一行：最肿的州 + 总伤害 ───────────────── */
.bm-head {
  position: relative; z-index: 2;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 14px;
  margin-bottom: 6px;
}
.bm-swell {
  margin: 0; display: inline-flex; align-items: center; gap: 7px;
  padding: 4px 13px 4px 7px;
  background: var(--pow); border: 2.5px solid var(--line); border-radius: 999px; box-shadow: var(--shadow-sm);
  font-size: 12.5px; font-weight: 700; line-height: 1.2;
  /* 以左边为轴转和放大：贴着 .bm 的左边，绕中心放大的话左边框会被横向裁剪切掉一截 */
  transform: rotate(-1.6deg); transform-origin: 0 50%;
}
.bm-swell-ic { display: inline-block; font-size: 16px; line-height: 1; transform: rotate(-18deg); }
.bm-swell b { font: 400 17px/1 var(--font-comic); letter-spacing: .05em; }
.bm-swell.is-new { animation: bm-wiggle .6s cubic-bezier(.3, 1.6, .5, 1); }
@keyframes bm-wiggle {
  0%, 100% { transform: rotate(-1.6deg) scale(1); }
  30% { transform: rotate(3deg) scale(1.08); }
  60% { transform: rotate(-3.5deg) scale(.98); }
}
.bm-tally { margin: 0; display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--ink-2); }
.bm-tally b { font-size: 14px; font-weight: 800; color: var(--ink); }

/* ── 桌面：整张纸板往后仰。仰了以后上面空出一条，用负 margin 收回来 ── */
.bm-stage { position: relative; z-index: 1; pointer-events: none; }
.bm-board {
  margin-top: -10cqw;
  transform-origin: 50% 100%;
  transform: perspective(1400px) rotateX(20deg);
  transform: perspective(170cqw) rotateX(20deg);
}
.bm-svg {
  display: block; width: 100%; height: auto; overflow: visible;
  user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent;
}
.bm-lump, .bm-pin { pointer-events: auto; cursor: pointer; }

.bm-mat { fill: #EFE7D6; }
.bm-mat-sh { fill: var(--line); }
.bm-mat-edge { fill: none; stroke: var(--line); stroke-width: calc(var(--bm-k) * 2.2px); }
.bm-dot { fill: rgba(21, 18, 15, .13); }
.bm-cast { fill: var(--line); opacity: .13; }
.bm-rim { fill: var(--line); stroke: var(--line); stroke-width: calc(var(--bm-k) * 3.4px); stroke-linejoin: round; }
.bm-thick { fill: #BBAD91; stroke: #BBAD91; stroke-width: 1; stroke-linejoin: round; }
.bm-paper { stroke: var(--card); stroke-width: calc(var(--bm-k) * .85px); stroke-linejoin: round; }
.bm-hatch-bg { fill: #E2D8C4; }
.bm-hatch-ln { stroke: rgba(21, 18, 15, .08); stroke-width: 1.3; }

/* DC：大西洋上的小纸托 + 虚线引线 */
.bm-dcl { display: none; }
.bm.has-dc .bm-dcl { display: inline; }
.bm-dcl-ln {
  fill: none; stroke: var(--line); stroke-linecap: round;
  stroke-width: calc(var(--bm-k) * 1.3px);
  stroke-dasharray: calc(var(--bm-k) * 3.5px) calc(var(--bm-k) * 3px);
}
.bm-dcl-dot { fill: var(--line); stroke: var(--card); stroke-width: calc(var(--bm-k) * 1.1px); }

/* ── 肿包 ─────────────────────────────────────── */
/* 每一层 = 同一个州形往上挪 H×f，再按"发面"曲线 g 往外鼓一点；--bm-b 是挨打瞬间的横向挤压 */
.bm-lump, .bm-pin {
  --bm-H: calc((var(--bm-h, 0) + var(--bm-up, 0)) * var(--bm-sq, 1));
  transition: --bm-h .95s cubic-bezier(.3, 1.45, .55, 1), --bm-up .24s cubic-bezier(.3, 1.6, .5, 1);
}
.bm-lump { outline: none; }
.bm-lump:focus, .bm-lump:focus-visible { outline: none; }
.bm-lump use {
  transform-box: fill-box; transform-origin: 50% 50%;
  transform:
    translateY(calc(var(--bm-H) * var(--f) * -1px))
    scale(calc(1 + (var(--bm-H) * var(--g) * .16 + var(--bm-b, 0) * var(--f) * 3.5) / var(--bm-r, 40)));
}
/* 影子只平移不缩放，整层一起半透明（不会在州界上叠出深缝） */
.bm-lump .bm-shade {
  fill: var(--line); stroke: none; opacity: .15; pointer-events: none;
  transform: translate(calc(var(--bm-H) * .36px), calc(var(--bm-H) * .1px));
}
.bm-ink { fill: var(--line); stroke: var(--line); stroke-width: calc(var(--bm-k) * 4.4px); stroke-linejoin: round; }
.bm-side { fill: color-mix(in oklab, var(--bm-c), var(--bm-s) var(--dk)); stroke: none; transition: fill .45s ease; }
.bm-top {
  fill: var(--bm-c); stroke: var(--line); stroke-linejoin: round;
  stroke-width: calc(var(--bm-k) * 1.7px);
  transition: fill .45s ease;
}
.bm-gloss { stroke: none; pointer-events: none; }
.bm-flash { fill: #fff; stroke: none; opacity: 0; pointer-events: none; }
.bm-lump.is-flash .bm-flash { opacity: .55; }
.bm-deco { pointer-events: none; transform: translateY(calc(var(--bm-H) * -1px)); }
.bm-glint { fill: #fff; opacity: .9; }

/* 色阶：顶面颜色 + 侧壁最深处的颜色（往暗处偏色相，不是简单加黑） */
.bm-lump, .bm-pin, .bm-sw, .bm-ch, .bm-verdict { --bm-c: var(--card); --bm-s: #B9AB8F; }
.bm-d2 { --bm-c: var(--dem); --bm-s: #0B1D6B; }
.bm-d1 { --bm-c: #9DB4FF; --bm-s: #2F4BB3; }
.bm-mid { --bm-c: var(--pow); --bm-s: #9A5A00; }
.bm-r1 { --bm-c: #FFA59E; --bm-s: #B23B32; }
.bm-r2 { --bm-c: var(--rep); --bm-s: #6F0C07; }

/* 有比赛但没人投票：平躺、虚线、打呼噜 */
.bm-quiet .bm-shade, .bm-quiet .bm-ink, .bm-quiet .bm-side, .bm-quiet .bm-gloss, .bm-quiet .bm-glint { visibility: hidden; }
.bm-lump.bm-quiet .bm-top {
  fill: var(--card);
  stroke-width: calc(var(--bm-k) * 1.5px);
  stroke-dasharray: calc(var(--bm-k) * 5px) calc(var(--bm-k) * 3.5px);
}
.bm-zzz { display: none; }
.bm-lump.bm-quiet .bm-zzz { display: inline; }
.bm-z { font: 400 11px var(--font-comic); letter-spacing: .04em; fill: var(--ink-2); animation: bm-z 2.4s ease-in-out infinite backwards; }
.bm-z:nth-child(2) { animation-delay: .8s; }
.bm-z:nth-child(3) { animation-delay: 1.6s; font-size: 13px; }
@keyframes bm-z {
  0% { opacity: 0; transform: translate(0, 3px); }
  25%, 60% { opacity: .9; }
  100% { opacity: 0; transform: translate(5px, -7px); }
}

/* 悬停 / 键盘聚焦抬起一点；打开信息卡的那个包浮起来轻轻上下晃 */
.bm-lump.is-hover, .bm-pin.is-hover, .bm-lump.is-focus, .bm-pin.is-focus { --bm-up: 4; }
.bm-lump.is-open, .bm-pin.is-open { --bm-up: 9; animation: bm-bob 1.7s ease-in-out .3s infinite; }
@keyframes bm-bob {
  0%, 100% { --bm-up: 9; }
  50% { --bm-up: 13; }
}
.bm-lump.is-open .bm-top, .bm-lump.is-focus .bm-top { stroke-width: calc(var(--bm-k) * 2.6px); }

/* 最肿的州：交叉创可贴；最惨那位快成猪了：猪鼻子贴纸 */
.bm-band, .bm-snout {
  opacity: 0; transform: scale(.3) rotate(-30deg);
  transform-box: fill-box; transform-origin: 50% 50%;
  transition: opacity .2s ease, transform .5s cubic-bezier(.3, 1.7, .5, 1);
}
.bm-lump.is-top .bm-band, .bm-lump.has-snout .bm-snout { opacity: 1; transform: none; }
.bm-ba { fill: #F3C48D; stroke: var(--line); stroke-width: 1.3; }
.bm-ba-pad { fill: #DFA061; stroke: rgba(21, 18, 15, .4); stroke-width: .8; }
.bm-ba-h { fill: rgba(21, 18, 15, .3); }
.bm-sn { fill: var(--pig); stroke: var(--line); stroke-width: 1.4; }
.bm-sn-n { fill: var(--line); }
.bm-sn-g { fill: #fff; opacity: .75; }

/* ── 插在包顶上的小牌子 ─────────────────────────── */
.bm-pinlift { transform: translateY(calc(var(--bm-H) * -1px)); }
.bm-stick { stroke: var(--line); stroke-width: calc(var(--bm-k) * 1.2px); stroke-linecap: round; }
.bm-tack { fill: var(--line); }
.bm-pill-sh { fill: var(--line); }
.bm-pill-bg { fill: var(--card); stroke: var(--line); stroke-width: 1.6; transition: fill .2s ease; }
.bm-pill-cap { fill: var(--bm-c); transition: fill .45s ease; }
.bm-pill-code { font: 400 14px var(--font-comic); letter-spacing: .06em; text-anchor: middle; fill: var(--ink); }
/* 12 号：牌子缩放后屏幕上约 10.5px，北边的州再被仰角压一点也还认得出（11 号只剩 8～9px） */
.bm-pill-pct { font: 800 12px var(--font-mono); letter-spacing: -.04em; text-anchor: middle; fill: var(--ink); }
.bm-pin.bm-d2 .bm-pill-pct, .bm-pin.bm-r2 .bm-pill-pct { fill: #fff; }
.bm-pill-c { display: none; }
.bm.is-narrow .bm-pill-f, .bm-pin.bm-quiet .bm-pill-f { display: none; }
.bm.is-narrow .bm-pill-c, .bm-pin.bm-quiet .bm-pill-c { display: inline; }
.bm-pin.bm-quiet .bm-pill-bg { stroke-dasharray: 3 2.2; }
.bm-pin.bm-quiet .bm-pill-sh { display: none; }
.bm-pin.is-hover .bm-pill-bg, .bm-pin.is-focus .bm-pill-bg, .bm-pin.is-open .bm-pill-bg { fill: var(--pow); }

/* ── 挨打特效 ─────────────────────────────────── */
.bm-fxl { pointer-events: none; }
.bm-fx-e {
  font-family: 'Segoe UI Emoji', 'Apple Color Emoji', 'Noto Color Emoji', sans-serif;
  text-anchor: middle;
  transform-box: fill-box; transform-origin: 50% 100%;
}
.bm-fx-rot { transform-box: fill-box; transform-origin: 50% 50%; }
.bm-fx-puff { fill: var(--card); stroke: var(--line); stroke-width: 1.3; opacity: 0; transform-box: fill-box; transform-origin: 50% 50%; }
.bm-fx-star { fill: var(--pow); stroke: var(--line); stroke-width: 1.1; stroke-linejoin: round; opacity: 0; transform-box: fill-box; transform-origin: 50% 50%; }
.bm-fx-pop {
  font-family: var(--font-comic); letter-spacing: .05em; text-anchor: middle;
  fill: var(--pow); stroke: var(--line); stroke-width: 3.4px; stroke-linejoin: round; paint-order: stroke;
  opacity: 0; transform-box: fill-box; transform-origin: 50% 100%;
}
.bm-fx-splat { stroke: var(--line); stroke-width: 1.2; opacity: 0; transform-box: fill-box; transform-origin: 50% 50%; }
.bm-fx-splat.is-tomato { fill: #F2552C; }
.bm-fx-splat.is-cream { fill: #FFFDF4; }

/* ── 信息卡：宽屏飘在州旁边，窄屏贴在地图下面 ──────── */
.bm-card {
  position: absolute; left: 0; top: 0; z-index: 6;
  width: min(340px, calc(100% - 16px));
  background: var(--card); border: 2.5px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  pointer-events: auto; outline: none;
}
.bm-card[hidden] { display: none; }
/* 左右各让出几像素给聚焦光圈和投影（.bm 横向裁剪，贴满宽度的话会被切掉） */
.bm-card.is-dock { position: relative; left: auto; top: auto; width: auto; margin: 16px 4px 0 3px; }
.bm-card:focus-visible { box-shadow: 0 0 0 3px var(--pow), var(--shadow); }
.bm-card-in { position: relative; overflow: auto; overscroll-behavior: contain; padding: 12px 14px 8px; border-radius: inherit; }
.bm-tail {
  position: absolute; width: 15px; height: 15px; pointer-events: none;
  background: var(--card); border: 2.5px solid var(--line);
}
.bm-card.is-tail-l .bm-tail { left: -9.5px; top: var(--bm-ty, 40px); transform: translateY(-50%) rotate(45deg); border-top-color: transparent; border-right-color: transparent; }
.bm-card.is-tail-r .bm-tail { right: -9.5px; top: var(--bm-ty, 40px); transform: translateY(-50%) rotate(45deg); border-bottom-color: transparent; border-left-color: transparent; }
.bm-card.is-dock .bm-tail { top: -9.5px; left: var(--bm-tx, 50%); transform: translateX(-50%) rotate(45deg); border-bottom-color: transparent; border-right-color: transparent; }
.bm-card.is-pop { animation: bm-pop .28s cubic-bezier(.3, 1.6, .5, 1); }
.bm-card.is-tail-l { transform-origin: 0 var(--bm-ty, 40px); }
.bm-card.is-tail-r { transform-origin: 100% var(--bm-ty, 40px); }
.bm-card.is-dock { transform-origin: var(--bm-tx, 50%) 0; }
@keyframes bm-pop { from { opacity: 0; transform: scale(.86); } to { opacity: 1; transform: none; } }

.bm-x {
  position: absolute; top: 8px; right: 8px;
  display: grid; place-items: center; width: 28px; height: 28px; padding: 0;
  border: 2px solid var(--line); border-radius: 50%; background: var(--card);
  font-size: 15px; font-weight: 900; line-height: 1; cursor: pointer;
}
.bm-x:hover { background: var(--pow); }
.bm-ch { display: flex; align-items: center; gap: 8px; padding-right: 34px; }
.bm-code {
  flex-shrink: 0; padding: 2px 7px; border: 2px solid var(--line); border-radius: 7px;
  background: var(--bm-c); box-shadow: 0 2px 0 var(--bm-s), 0 2px 0 2px var(--line);
  font-size: 12px; font-weight: 800; line-height: 1.3;
}
.bm-ch.bm-d2 .bm-code, .bm-ch.bm-r2 .bm-code { color: #fff; }
.bm-name { margin: 0; min-width: 0; font: 400 22px/1.15 var(--font-display); }
.bm-meta { margin: 8px 0 6px; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; font-size: 12px; color: var(--ink-3); }
.bm-verdict { padding: 1px 8px; border: 2px solid var(--line); border-radius: 999px; background: var(--bm-c); color: var(--ink); font-size: 12px; font-weight: 800; }
.bm-verdict.bm-d2, .bm-verdict.bm-r2 { color: #fff; }
.bm-verdict.bm-quiet { color: var(--ink-2); border-style: dashed; }
.bm-dmg b { color: var(--ink); font-weight: 800; }
.bm-races { list-style: none; margin: 0; padding: 0; }
.bm-race { padding: 8px 0 4px; border-top: 2px dashed var(--paper-2); }
.bm-rh { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.bm-rt { min-width: 0; font-size: 13.5px; font-weight: 900; line-height: 1.3; }
.bm-rate {
  flex-shrink: 0; max-width: 55%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  padding: 2px 8px; border: 2px solid var(--line); border-radius: 999px;
  background: var(--paper-2); color: var(--ink-2);
  font: 800 10.5px/1.3 var(--font-mono);
}
.bm-rate-tossup { background: var(--pow); color: var(--ink); }
.bm-rate-lean.bm-rate-d { background: var(--dem-soft); color: var(--dem); }
.bm-rate-lean.bm-rate-r { background: var(--rep-soft); color: var(--rep); }
.bm-rate-likely.bm-rate-d { background: #9DB4FF; color: var(--ink); }
.bm-rate-likely.bm-rate-r { background: #FFA59E; color: var(--ink); }
.bm-rate-safe.bm-rate-d { background: var(--dem); color: #fff; }
.bm-rate-safe.bm-rate-r { background: var(--rep); color: #fff; }
.bm-rs { margin: 2px 0 2px; font-size: 11.5px; font-style: italic; line-height: 1.35; color: var(--ink-3); }
.bm-cand { display: grid; grid-template-columns: 38px minmax(0, 1fr) auto auto; align-items: center; gap: 4px 9px; padding: 5px 0; }
.bm-face {
  display: block; width: 38px; height: 42px; overflow: hidden;
  border: 2px solid var(--line); border-radius: 10px; background: var(--dem-soft);
  /* 越像猪，粉色光圈越粗 */
  box-shadow: 0 0 0 calc(var(--bm-pig, 0) * 3.5px) var(--pig);
  transition: box-shadow .4s ease;
}
.bm-cand-r .bm-face { background: var(--rep-soft); }
.bm-face svg { display: block; width: 100%; height: 100%; }
.bm-who { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.bm-nm { display: flex; align-items: center; gap: 6px; min-width: 0; font-size: 13px; font-weight: 800; line-height: 1.2; }
.bm-nm .tag-d, .bm-nm .tag-r { flex-shrink: 0; min-width: 18px; height: 18px; padding: 0 4px; border-width: 1.5px; border-radius: 5px; font-size: 10.5px; }
.bm-cn { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bm-bar { display: block; height: 7px; overflow: hidden; border: 1.5px solid var(--line); border-radius: 999px; background: var(--paper-2); }
.bm-bar i { display: block; height: 100%; background: var(--dem); transition: width .6s ease; }
.bm-cand-r .bm-bar i { background: var(--rep); }
.bm-p { min-width: 3.4ch; font-size: 16px; font-weight: 800; text-align: right; }
.bm-smack.btn-sm { min-height: 28px; padding: 0 10px; font-size: 12px; }

/* ── 图例 ─────────────────────────────────────── */
.bm-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 18px; margin-top: 14px; }
.bm-key { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 18px; font-size: 12px; font-weight: 700; color: var(--ink-2); }
.bm-key li { display: inline-flex; align-items: center; gap: 6px; }
.bm-key-scale { gap: 5px; }
.bm-key-end { font-size: 11.5px; }
.bm-sw {
  display: inline-block; width: 16px; height: 10px; margin-bottom: 4px;
  border: 2px solid var(--line); border-radius: 4px; background: var(--bm-c);
  box-shadow: 0 3px 0 0 var(--bm-s), 0 3px 0 2px var(--line);
}
.bm-mini { display: inline-flex; align-items: flex-end; gap: 2px; height: 16px; }
.bm-mini i { display: block; width: 7px; border: 1.5px solid var(--line); border-radius: 3px 3px 1.5px 1.5px; background: linear-gradient(var(--pow) 0 3px, #C08A00 3px); }
.bm-mini i:nth-child(1) { height: 6px; }
.bm-mini i:nth-child(2) { height: 10px; }
.bm-mini i:nth-child(3) { height: 15px; }
.bm-mini-q {
  display: inline-grid; place-items: center; min-width: 24px; height: 15px; padding: 0 3px;
  border: 2px dashed var(--line); border-radius: 5px; background: var(--card);
  font: 400 11px/1 var(--font-comic); letter-spacing: .06em; color: var(--ink-2);
}
.bm-joke { margin: 0; max-width: 46ch; font-size: 11.5px; font-style: italic; color: var(--ink-3); }

/* ── 窄容器：纸板仰得少一点，小字收起来 ──────────── */
@container (max-width: 559.98px) {
  .bm-board {
    margin-top: -5.5cqw;
    transform: perspective(1400px) rotateX(12deg);
    transform: perspective(170cqw) rotateX(12deg);
  }
  .bm-head { gap: 6px 10px; }
  .bm-swell { font-size: 11.5px; padding: 3px 11px 3px 6px; }
  .bm-swell b { font-size: 15px; }
  .bm-tally { font-size: 11.5px; }
  .bm-tally b { font-size: 12.5px; }
  .bm-key { gap: 8px 14px; }
  .bm-joke { display: none; }
  .bm-name { font-size: 20px; }
}
@container (max-width: 360px) {
  /* 只收掉 "get it"，两头的 Donkeys / Elephants 留着：不然五个色块看不出哪头是谁 */
  .bm-key-x { display: none; }
  .bm-cand { grid-template-columns: 34px minmax(0, 1fr) auto auto; gap: 4px 7px; }
  .bm-face { width: 34px; height: 38px; }
  .bm-p { font-size: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  .bm-z { animation: none; opacity: .85; }
  .bm-lump.is-open, .bm-pin.is-open { animation: none; }
  .bm-swell.is-new, .bm-card.is-pop { animation: none; }
}
