/* ===== Animated method walkthrough widget ===== */
.mw {
  background: #fbfcfe;
  border: 1px solid #e6ebf3;
  border-radius: 16px;
  padding: 1.8rem 1.4rem 1.4rem;
  box-shadow: 0 2px 16px rgba(20,30,60,0.05);
}

.mw-stage { position: relative; }

.mw-flow {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
}

.mw-col { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.5rem; }

/* Reveal animation: hidden until JS turns it on */
.mw [data-step] {
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.55s ease, transform 0.55s ease, box-shadow 0.3s ease;
}
.mw [data-step].is-on { opacity: 1; transform: translateY(0); }

/* Nodes */
.mw-node {
  background: #fff;
  border: 1.5px solid #e3e8f1;
  border-radius: 12px;
  padding: 0.8rem 0.9rem;
  min-width: 168px;
  max-width: 208px;
  text-align: center;
}
.mw-node-title { font-weight: 700; font-size: 0.9rem; color: #2b3a67; margin-bottom: 0.5rem; line-height: 1.25; }
.mw-node-title .mw-sub { display: block; font-weight: 600; font-size: 0.74rem; color: #6b7898; margin-top: 0.1rem; }
.mw-node.is-active { border-color: #2b3a67; box-shadow: 0 0 0 3px rgba(43,58,103,0.14); }
.mw-node-sub { font-size: 0.72rem; color: #6b7388; line-height: 1.4; margin-top: 0.45rem; text-align: left; }
.mw-node-sub .fml { font-size: 0.84em; white-space: nowrap; }
.mw-col-wide .mw-node { max-width: 240px; }

/* Live SVG cogmap inside the global-map node */
.mw-cog svg { width: 100%; height: auto; display: block; }

/* View-trajectory: all candidate views shown as boxes; Image 1 is selected */
.mw-vstrip { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; }
.mw-vt { position: relative; border-radius: 6px; overflow: hidden; border: 1px solid #dfe5f0; }
.mw-vt img { width: 100%; height: 44px; object-fit: cover; display: block; }
.mw-vt .vn {
  position: absolute; top: 2px; left: 2px; background: rgba(255,255,255,0.9); color: #1c2436;
  font-weight: 800; font-size: 0.66rem; border-radius: 3px; padding: 0 0.3em; line-height: 1.4;
}
.mw-vt .tick { position: absolute; bottom: 2px; right: 3px; font-size: 0.6rem; font-weight: 800; }
.mw-vt.sel { outline: 2.5px solid #e28c1c; outline-offset: -2px; border-color: #e28c1c; }
.mw-vt.sel .vn { background: #e28c1c; color: #fff; }
.mw-vt.sel .tick { color: #e28c1c; }
.mw-vt.skip { opacity: 0.92; }
.mw-vt.skip .tick { color: #b9c2d4; }
.mw-vt-sel-label { text-align: center; font-size: 0.68rem; font-weight: 700; color: #e28c1c; margin-top: 0.35rem; }

/* Egocentric grounding view */
.mw-egoline { position: relative; }
.mw-egoimg { width: 100%; border-radius: 7px; display: block; }
.mw-egotag { position: absolute; top: 4px; left: 4px; background: rgba(255,255,255,0.9); color: #1c2436; font-weight: 800; font-size: 0.68rem; border-radius: 4px; padding: 0 0.32em; }
.mw-egomap { margin-top: 0.5rem; background: #fff; border: 1px solid #e6ebf3; border-radius: 7px; padding: 0.2rem; }
.mw-egomap svg { width: 100%; height: auto; display: block; }

/* Real figure images inside nodes */
.mw-fig { width: 100%; border-radius: 8px; display: block; border: 1px solid #eef1f6; }
.mw-vfm .mw-fig { background: #f6f7fa; }

/* Input views */
.mw-views { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.mw-views img { width: 100%; height: 52px; object-fit: cover; border-radius: 5px; display: block; }
.mw-q {
  margin-top: 0.55rem; background: #eef2fb; border-radius: 7px;
  padding: 0.4rem 0.55rem; font-size: 0.74rem; color: #33405e; line-height: 1.35; text-align: left;
}

/* Cognitive map */
.mw-map {
  position: relative; width: 132px; height: 86px; margin: 0 auto; border-radius: 8px;
  border: 1px solid #dfe5f0;
  background:
    repeating-linear-gradient(0deg,#e9eef7 0 1px,transparent 1px 22px),
    repeating-linear-gradient(90deg,#e9eef7 0 1px,transparent 1px 22px),
    #fff;
}
.mw-map.ego { background:
    repeating-linear-gradient(0deg,#fdeede 0 1px,transparent 1px 22px),
    repeating-linear-gradient(90deg,#fdeede 0 1px,transparent 1px 22px),
    #fff; border-color:#f0d9b8; }
.mw-dot { position: absolute; width: 13px; height: 13px; border-radius: 50%; box-shadow: 0 1px 3px rgba(0,0,0,0.18); }
.mw-ego-cam {
  position: absolute; width: 0; height: 0;
  border-left: 7px solid transparent; border-right: 7px solid transparent; border-bottom: 13px solid #ea7a2e;
}

/* VFM chip */
.mw-vfm {
  background: #eaf1ff; border-color: #cfe0ff; color: #1f4fb0;
  font-weight: 700; font-size: 0.84rem; padding: 0.55rem 0.8rem; min-width: 0;
}
.mw-vfm .ic { margin-right: 0.3rem; }
.mw-down { width: 2px; height: 16px; background: #cfd8e8; }

/* Trajectory chips */
.mw-traj { display: flex; align-items: center; justify-content: center; gap: 0.3rem; }
.mw-traj span {
  background: #f4f7fb; border: 1px solid #dfe5f0; border-radius: 7px;
  padding: 0.2rem 0.5rem; font-size: 0.8rem; font-weight: 700; color: #2b3a67;
}
.mw-traj .seq { color: #b9c2d4; font-weight: 700; }
.mw-traj span.lit { background: #2b3a67; color: #fff; border-color: #2b3a67; }
.mw-plan-note { margin-top: 0.5rem; font-size: 0.72rem; color: #8a93a6; line-height: 1.3; }

/* Answer */
.mw-ans {
  margin-top: 0.55rem; background: #e9f7ef; color: #157a45; border-radius: 7px;
  padding: 0.35rem 0.5rem; font-weight: 700; font-size: 0.85rem;
}

/* Reward badges */
.mw-reward {
  border-radius: 999px; padding: 0.28em 0.8em; font-weight: 700; font-size: 0.78rem; color: #fff; white-space: nowrap;
}
.mw-reward.is-active { animation: mwPulse 1.1s ease-in-out infinite; }
.reward-global { background: #2563eb; } .reward-local { background: #ea7a2e; }
.reward-answer { background: #16a34a; } .reward-format { background: #6b7280; }
@keyframes mwPulse {
  0%,100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(0,0,0,0.0); }
  50% { transform: scale(1.06); box-shadow: 0 4px 14px rgba(0,0,0,0.18); }
}

/* Arrows between stages */
.mw-arrow { align-self: center; color: #b9c2d4; font-size: 1.3rem; line-height: 1; padding: 0 0.1rem; }
.mw-arrow.is-active { color: #2b3a67; }

/* GRPO bar */
.mw-grpo {
  margin-top: 1.1rem; border-radius: 12px; text-align: center;
  padding: 0.7rem 1rem; font-weight: 800; letter-spacing: 0.02em; color: #fff;
  background: linear-gradient(90deg, #2563eb, #2b3a67 45%, #ea7a2e);
}
.mw-grpo.is-active { box-shadow: 0 6px 20px rgba(43,58,103,0.28); }
.mw-grpo small { display: block; font-weight: 600; font-size: 0.78rem; opacity: 0.9; margin-top: 0.15rem; }

/* Caption */
.mw-caption {
  margin-top: 1.2rem; min-height: 3.4em; text-align: center;
  color: #33405e; font-size: 1.04rem; line-height: 1.5;
  max-width: 720px; margin-left: auto; margin-right: auto;
}
.mw-step-no {
  display: inline-block; background: #2b3a67; color: #fff; border-radius: 6px;
  font-weight: 700; font-size: 0.8rem; padding: 0.1em 0.55em; margin-right: 0.5em; vertical-align: middle;
}

/* Controls */
.mw-controls { display: flex; align-items: center; justify-content: center; gap: 0.5rem; margin-top: 1rem; flex-wrap: wrap; }
.mw-btn {
  border: 1px solid #d7deea; background: #fff; color: #2b3a67; font-weight: 700;
  border-radius: 999px; padding: 0.4rem 1rem; cursor: pointer; font-size: 0.9rem; transition: all 0.12s ease;
}
.mw-btn:hover { background: #2b3a67; color: #fff; border-color: #2b3a67; }
.mw-btn.mw-play { min-width: 92px; }
.mw-dots { display: flex; gap: 0.4rem; margin-left: 0.4rem; }
.mw-dots button {
  width: 11px; height: 11px; border-radius: 50%; border: none; background: #d2d9e6; cursor: pointer; padding: 0;
}
.mw-dots button.on { background: #2b3a67; transform: scale(1.15); }

.mw-hint { text-align: center; color: #9aa3b4; font-size: 0.82rem; margin-top: 0.6rem; }

.mw-details { margin-top: 1.6rem; }
.mw-details summary {
  cursor: pointer; color: #2b3a67; font-weight: 700; font-size: 0.95rem;
  text-align: center; list-style: none; padding: 0.5rem;
}
.mw-details summary::-webkit-details-marker { display: none; }
.mw-details summary::before { content: '\25B8  '; }
.mw-details[open] summary::before { content: '\25BE  '; }

@media screen and (max-width: 768px) {
  .mw-flow { flex-direction: column; align-items: center; }
  .mw-arrow { transform: rotate(90deg); }
  .mw-node { max-width: 280px; }
}

/* Narrow phones: tighten the stacked flow so it does not run on forever */
@media screen and (max-width: 600px) {
  .mw { padding: 1.3rem 1rem 1.1rem; }
  .mw-flow { gap: 0.45rem; }
  .mw-node { max-width: 300px; min-width: 0; padding: 0.7rem 0.8rem; }
  .mw-arrow { font-size: 1.1rem; }
  .mw-caption { font-size: 0.96rem; min-height: 0; }
  .mw-grpo { padding: 0.6rem 0.8rem; }
}

/* Reduced motion: reveal everything, no transitions/pulse */
@media (prefers-reduced-motion: reduce) {
  .mw [data-step] { opacity: 1 !important; transform: none !important; transition: none !important; }
  .mw-reward.is-active { animation: none; }
}
