/* nummon.css —— 数学大陆的数妖（nummon.js）：几何积木兽的颜色、表情显隐与动画
 * 每只只带 --nm-hue（部族主色）与 --nm-t（动画错相）；正面 / 顶面 / 侧面按同一主色调深浅，描深色边——
 * 和草原软乎乎、没有硬边的团子一眼分得开。五种 mood 只切根节点 class：
 *   idle 悬浮上下 + 灯条眨眼 · taunt 一睁一眨 + 左右晃 · caught 网罩下来 + 眼睛 > < · tamed ^ ^ + 胸前一枚星星勋章 · sleep 灯条熄成一条线 + Zzz
 * 只动 transform / opacity。
 */

.mx-nummon {
  --nm-front: color-mix(in oklab, var(--nm-hue, #33a383) 80%, var(--paper));
  --nm-top: color-mix(in oklab, var(--nm-hue, #33a383) 48%, var(--paper));
  --nm-side: color-mix(in oklab, var(--nm-hue, #33a383) 78%, var(--ink));
  --nm-edge: color-mix(in oklab, var(--nm-hue, #33a383) 45%, var(--ink));
  --nm-t: 0s;
  display: block;
  overflow: visible;
  fill: none;
  -webkit-user-select: none;
  user-select: none;
}
.mx-monster-host > .mx-nummon { width: 100%; height: 100%; }

.mx-nummon__shadow { fill: var(--ink); opacity: .14; }
.mx-nummon__front { fill: var(--nm-front); stroke: var(--nm-edge); stroke-width: 2.4; stroke-linejoin: round; }
.mx-nummon__top { fill: var(--nm-top); stroke: var(--nm-edge); stroke-width: 2.4; stroke-linejoin: round; }
.mx-nummon__side { fill: var(--nm-side); stroke: var(--nm-edge); stroke-width: 2.4; stroke-linejoin: round; }
.mx-nummon__ring { fill: none; stroke: var(--gold); stroke-width: 4; stroke-linecap: round; opacity: .9; }
.mx-nummon__feet rect, .mx-nummon__arms rect { fill: var(--nm-side); stroke: var(--nm-edge); stroke-width: 1.6; }
.mx-nummon__antenna path { stroke: var(--nm-edge); stroke-width: 2.6; stroke-linecap: round; }
.mx-nummon__antenna circle { fill: var(--gold-2); stroke: color-mix(in oklab, var(--gold) 70%, var(--ink)); stroke-width: 1.6; }
.mx-nummon__antenna text {
  font-family: var(--font-math, ui-rounded, system-ui, sans-serif);
  font-size: 11px;
  font-weight: 800;
  text-anchor: middle;
  dominant-baseline: central;
  fill: color-mix(in oklab, var(--gold) 45%, var(--ink));
}

/* 显示屏：深色玻璃；眼睛是发光的灯条 */
.mx-nummon__screen { fill: #23293a; stroke: var(--nm-edge); stroke-width: 1.6; }
.mx-nummon__eyes rect { fill: #9ff3e4; }
.mx-nummon__eyes path { fill: none; stroke: #9ff3e4; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.mx-nummon__eyes { filter: drop-shadow(0 0 2px rgba(159, 243, 228, .7)); }
.mx-nummon--f4 .mx-nummon__eyes rect, .mx-nummon--f5 .mx-nummon__eyes rect { fill: #ffb48a; }
.mx-nummon--f4 .mx-nummon__eyes path, .mx-nummon--f5 .mx-nummon__eyes path { stroke: #ffb48a; }

/* 小黑板 + 粉笔字 */
.mx-nummon__board { fill: #2f4a40; stroke: color-mix(in oklab, var(--wood) 70%, var(--ink)); stroke-width: 2.4; }
.mx-nummon__glyph {
  font-family: var(--font-kai);
  text-anchor: middle;
  dominant-baseline: central;
  fill: #f6f1df;
  transition: opacity 260ms var(--ease-out, ease-out);
}
.mx-nummon__glyph--masked { opacity: .7; }

/* 凶的数妖头上冒电光 */
.mx-nummon__spark path { fill: var(--gold-2); stroke: color-mix(in oklab, var(--gold) 60%, var(--ink)); stroke-width: 1.4; stroke-linejoin: round; }

/* 驯服：胸前一枚星星勋章；睡着：Zzz；关住：网 */
.mx-nummon__medal circle { fill: var(--gold-2); stroke: color-mix(in oklab, var(--gold) 60%, var(--ink)); stroke-width: 1.4; }
.mx-nummon__medal path:first-child { fill: var(--coral); }
.mx-nummon__spark { transform-box: fill-box; }
.mx-nummon__medal path:last-child { fill: color-mix(in oklab, var(--gold) 55%, var(--ink)); }
.mx-nummon__zzz text { font-family: var(--font-display); font-size: 14px; fill: var(--sky-accent); }
.mx-nummon__net circle { fill: var(--paper); fill-opacity: .12; stroke: var(--wood-dark); stroke-width: 3; }
.mx-nummon__net path { fill: none; stroke: var(--wood-dark); stroke-width: 1.8; stroke-linecap: round; opacity: .5; }

/* ---------- 按 mood 显隐 ---------- */

.mx-nummon__eyes-shut, .mx-nummon__eyes-happy, .mx-nummon__eyes-doze, .mx-nummon__eyes-wink,
.mx-nummon__medal, .mx-nummon__zzz, .mx-nummon__net { display: none; }

.mx-nummon--caught .mx-nummon__eyes-open { display: none; }
.mx-nummon--caught .mx-nummon__eyes-shut { display: inline; }
.mx-nummon--caught .mx-nummon__net { display: inline; }
.mx-nummon--tamed .mx-nummon__eyes-open { display: none; }
.mx-nummon--tamed .mx-nummon__eyes-happy { display: inline; }
.mx-nummon--tamed .mx-nummon__medal { display: inline; }
.mx-nummon--tamed .mx-nummon__spark { display: none; }
.mx-nummon--sleep .mx-nummon__eyes-open { display: none; }
.mx-nummon--sleep .mx-nummon__eyes-doze { display: inline; }
.mx-nummon--sleep .mx-nummon__zzz { display: inline; }
.mx-nummon--sleep .mx-nummon__spark { display: none; }
.mx-nummon--sleep .mx-nummon__eyes { filter: none; opacity: .6; }
.mx-nummon--taunt .mx-nummon__eyes-open { display: none; }
.mx-nummon--taunt .mx-nummon__eyes-wink { display: inline; }

/* ---------- 动画 ---------- */

.mx-nummon--idle .mx-nummon__hover,
.mx-nummon--taunt .mx-nummon__hover { animation: mx-nummon-hover 2.8s ease-in-out infinite; animation-delay: var(--nm-t); }
.mx-nummon--idle .mx-nummon__eyes-open rect { animation: mx-nummon-blink 4.6s infinite; animation-delay: var(--nm-t); transform-box: fill-box; transform-origin: center; }
.mx-nummon--idle .mx-nummon__antenna circle,
.mx-nummon--idle .mx-nummon__antenna text { animation: mx-nummon-pulse 2.8s ease-in-out infinite; animation-delay: var(--nm-t); transform-box: fill-box; transform-origin: center; }
.mx-nummon--taunt .mx-nummon__rig { animation: mx-nummon-wobble .6s ease-in-out 2; transform-origin: 60px 106px; }
.mx-nummon--caught .mx-nummon__rig { animation: mx-nummon-caught .7s var(--ease-bounce, ease-out) both; transform-origin: 60px 106px; }
.mx-nummon--caught .mx-nummon__net { animation: mx-nummon-net .5s var(--ease-out, ease-out) both; }
.mx-nummon--tamed .mx-nummon__rig { animation: mx-nummon-sway 3.2s ease-in-out infinite; animation-delay: var(--nm-t); transform-origin: 60px 106px; }
.mx-nummon--tamed .mx-nummon__medal { animation: mx-nummon-medal .6s var(--ease-bounce, ease-out) both; transform-box: fill-box; transform-origin: center; }
.mx-nummon--sleep .mx-nummon__zzz text { animation: mx-nummon-zzz 2.6s ease-in-out infinite; }
.mx-nummon--sleep .mx-nummon__zzz text:last-child { animation-delay: .6s; }
.mx-nummon__spark { animation: mx-nummon-spark 1.4s steps(2) infinite; }

@keyframes mx-nummon-hover { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-3px); } }
@keyframes mx-nummon-blink { 0%, 92%, 100% { transform: scaleY(1); } 95% { transform: scaleY(.15); } }
@keyframes mx-nummon-pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.12); } }
@keyframes mx-nummon-wobble { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-5deg); } 75% { transform: rotate(5deg); } }
@keyframes mx-nummon-caught { 0% { transform: scale(1); } 30% { transform: scale(.9, 1.06); } 60% { transform: scale(1.04, .96); } 100% { transform: scale(1); } }
@keyframes mx-nummon-net { from { transform: translateY(-40px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes mx-nummon-sway { 0%, 100% { transform: rotate(-2deg); } 50% { transform: rotate(2deg); } }
@keyframes mx-nummon-medal { from { transform: scale(0) rotate(-30deg); } to { transform: scale(1) rotate(0); } }
@keyframes mx-nummon-zzz { 0%, 100% { transform: translateY(0); opacity: .4; } 50% { transform: translateY(-4px); opacity: 1; } }
@keyframes mx-nummon-spark { 0% { opacity: 1; } 50% { opacity: .55; } }

@media (prefers-reduced-motion: reduce) {
  .mx-nummon *, .mx-nummon { animation: none !important; }
}
