/* mathmap.css —— 口算妖怪地图（MATH-5 §7）
 * 只作用于 .mx-scene--mathmap 之下（弹窗挂在 body，用 .mx-map__sheet 限定）。
 * 顶栏（返回 · 标题 · 三个数字）· 田野里的小妖群 · 各地区（巢穴按层往北排，路画在后面）· 捣蛋鬼角落。
 */

.mx-scene--mathmap { font-family: var(--font-body); color: var(--ink); }

.mx-map__head { display: flex; flex-wrap: wrap; align-items: stretch; gap: 10px; }
.mx-map__titlebar { display: flex; align-items: center; gap: 8px; padding: 6px 18px 6px 8px; border-radius: 999px; }
.mx-map__title-icon { display: inline-flex; width: 28px; height: 28px; color: var(--wood-dark); }
.mx-map__title-icon svg { width: 100%; height: 100%; }
.mx-map__title { font-family: var(--font-display); font-size: 26px; line-height: 1; margin: 0; }
.mx-map__totals { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 16px; padding: 6px 18px; border-radius: 999px; font-size: 15px; }
.mx-map__total b { font-size: 22px; margin-right: 2px; }
.mx-map__total.is-shield b { color: var(--gold-text); }
.mx-map__total.is-caged b { color: var(--ok-text); }
.mx-map__total.is-tamed b { color: var(--wisteria-text); }

.mx-map__body { overflow-y: auto; padding: 12px 16px 120px; display: flex; flex-direction: column; gap: 14px; }
.mx-map__section { padding: 12px 16px 16px; }
.mx-map__section-title { font-family: var(--font-display); font-size: 20px; margin: 0 0 10px; color: var(--ink); }
.mx-map__empty { padding: 24px; text-align: center; font-size: 18px; }

/* ---------------------------------------------------------------- 小妖群 */

.mx-map__meadows { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; }
.mx-map__meadow {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 16px;
  border: 1.5px solid color-mix(in srgb, var(--grass) 35%, var(--card-stroke));
  background: color-mix(in srgb, var(--hill-mid) 16%, var(--paper));
  text-align: left;
  font: inherit;
  color: inherit;
  cursor: pointer;
}
.mx-map__meadow-glyph {
  flex: 0 0 auto;
  display: grid; place-items: center;
  min-width: 46px; height: 46px; padding: 0 6px;
  border-radius: 14px;
  background: var(--paper);
  font-size: 20px;
  color: var(--grass);
  box-shadow: var(--shadow-soft);
}
.mx-map__meadow-info { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.mx-map__meadow-name { font-size: 15px; font-weight: 600; }
.mx-map__meadow-sub { font-size: 13px; line-height: 1.3; color: var(--ink-soft); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.mx-map__meadow-sub b { color: var(--ok-text); font-size: 15px; }
.mx-map__meadow.is-done { border-color: var(--gold); background: color-mix(in srgb, var(--gold-2) 22%, var(--paper)); }
.mx-map__meadow.is-fog { filter: grayscale(.8); opacity: .62; background: color-mix(in srgb, var(--ink-soft) 8%, var(--paper)); }
.mx-map__bar { display: block; height: 6px; border-radius: 3px; background: color-mix(in srgb, var(--ink-soft) 14%, transparent); overflow: hidden; }
.mx-map__bar-fill { display: block; height: 100%; border-radius: 3px; background: var(--ok); }

/* ---------------------------------------------------------------- 地区与巢穴 */

.mx-map__regions { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; align-items: start; }
.mx-map__region { padding: 12px 12px 14px; background: color-mix(in srgb, var(--hill-far) 14%, var(--paper)); }
.mx-map__region-title { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; font-family: var(--font-display); font-size: 19px; margin: 0 4px 6px; }
.mx-map__region-title small { font-family: var(--font-body); font-size: 13px; color: var(--ink-soft); }
.mx-map__region.is-deepfog { background: color-mix(in srgb, var(--ink-soft) 10%, var(--paper)); opacity: .75; }
.mx-map__fogtext { margin: 2px 4px 6px; font-size: 13px; color: var(--ink-soft); text-align: center; }

.mx-map__field { position: relative; display: flex; flex-direction: column; gap: 6px; }
.mx-map__roads { position: absolute; inset: 0; pointer-events: none; overflow: visible; }
.mx-map__road { fill: none; stroke: color-mix(in srgb, var(--wood) 60%, transparent); stroke-width: 5; stroke-linecap: round; }
.mx-map__road.is-bridge { stroke: color-mix(in srgb, var(--ink-soft) 30%, transparent); stroke-dasharray: 2 9; }
.mx-map__row { position: relative; display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }

.mx-map__lair {
  position: relative;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  width: 92px;
  padding: 4px 2px 6px;
  border: 0; border-radius: 14px;
  background: transparent;
  font: inherit; color: inherit;
  cursor: pointer;
}
.mx-map__lair:hover, .mx-map__lair:focus-visible { background: color-mix(in srgb, var(--paper) 70%, transparent); }
.mx-map__lair-name { font-size: 13px; line-height: 1.2; text-align: center; max-width: 100%; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.mx-map__lair-sub { font-size: 12px; color: var(--ink-soft); }
.mx-map__lair.is-open .mx-map__lair-sub { color: var(--ok-text); font-weight: 600; }
.mx-map__lair.is-fighting .mx-map__lair-sub { color: var(--coral-text); }
.mx-map__lair.is-caged .mx-map__lair-sub { color: var(--ok-text); }
.mx-map__lair.is-tamed .mx-map__lair-sub, .mx-map__lair.is-skip .mx-map__lair-sub { color: var(--wisteria-text); }
.mx-map__lair.is-fog .mx-map__monster { filter: grayscale(1) brightness(.85); opacity: .38; }
.mx-map__lair.is-fog .mx-map__lair-name { color: var(--ink-soft); }
.mx-map__lair.is-open .mx-map__monster { animation: mx-map-bob 2.4s ease-in-out infinite; }
@keyframes mx-map-bob { 50% { transform: translateY(-3px); } }
@media (prefers-reduced-motion: reduce) { .mx-map__lair.is-open .mx-map__monster { animation: none; } }
.mx-map__flag { position: absolute; top: 2px; right: 12px; width: 14px; height: 18px; border-left: 2px solid var(--wood-dark); }
.mx-map__flag::after { content: ''; position: absolute; left: 0; top: 0; width: 12px; height: 8px; background: var(--wisteria); clip-path: polygon(0 0, 100% 50%, 0 100%); }

/* 盾牌小点：形状像盾 */
.mx-map__pips { display: flex; flex-wrap: wrap; justify-content: center; gap: 2px; max-width: 88px; }
.mx-map__pip {
  display: inline-block; width: 10px; height: 12px;
  clip-path: polygon(0 0, 100% 0, 100% 55%, 50% 100%, 0 55%);
  background: color-mix(in srgb, var(--ink-soft) 22%, transparent);
}
.mx-map__pip.is-fluent, .mx-map__pip.is-skip { background: var(--gold); }
.mx-map__pip.is-learning { background: var(--coral); }
.mx-map__pip.is-claimed { background: color-mix(in srgb, var(--gold) 45%, var(--paper)); }
.mx-map__pip.is-paused { background: var(--sky-accent); }
.mx-map__pip.is-open { background: color-mix(in srgb, var(--ok) 55%, var(--paper)); }

/* ---------------------------------------------------------------- 捣蛋鬼角落 */

.mx-map__habits { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; }
.mx-map__habit { display: grid; grid-template-columns: 64px 1fr; column-gap: 10px; font-size: 15px; }
.mx-map__habit b { grid-row: 1 / span 2; font-family: var(--font-display); font-weight: 400; color: var(--coral-text); }
.mx-map__habit.is-better b { color: var(--ok-text); }
.mx-map__habit small { color: var(--ink-soft); font-size: 12px; }

.mx-map__mascot-anchor { position: absolute; left: 24px; bottom: 16px; width: 1px; height: 1px; pointer-events: none; }

/* ---------------------------------------------------------------- 弹窗（挂在 body） */

.mx-map__sheet { max-width: 460px; }
.mx-map__sheet-lead { margin: 0 0 10px; color: var(--ink-soft); }
.mx-map__needs { margin: 0; padding-left: 20px; font-size: 17px; line-height: 1.8; }
.mx-map__shields { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; }
.mx-map__shield { display: grid; grid-template-columns: 14px 1fr auto; column-gap: 8px; align-items: center; font-size: 16px; }
.mx-map__shield small { grid-column: 2 / span 2; color: var(--ink-soft); font-size: 13px; }
.mx-map__shield-state { font-size: 13px; color: var(--ink-soft); }
.mx-map__shield.is-fluent .mx-map__shield-state, .mx-map__shield.is-skip .mx-map__shield-state { color: var(--gold-text); font-weight: 600; }
.mx-map__shield.is-learning .mx-map__shield-state { color: var(--coral-text); }
.mx-map__shield.is-locked { opacity: .7; }
.mx-map__facts { display: flex; flex-wrap: wrap; gap: 6px; max-height: 50vh; overflow-y: auto; }
.mx-map__fact { padding: 3px 8px; border-radius: 8px; font-family: var(--font-math, inherit); font-size: 15px; background: color-mix(in srgb, var(--ink-soft) 10%, var(--paper)); color: var(--ink-soft); }
.mx-map__fact.is-fluent { background: color-mix(in srgb, var(--gold-2) 50%, var(--paper)); color: var(--gold-text); }
.mx-map__fact.is-claimed { background: color-mix(in srgb, var(--gold-2) 22%, var(--paper)); color: var(--gold-text); }
.mx-map__fact.is-learning { background: color-mix(in srgb, var(--coral) 18%, var(--paper)); color: var(--coral-text); }

@media (max-width: 600px) {
  .mx-map__regions { grid-template-columns: 1fr; }
  .mx-map__lair { width: 84px; }
}
