/* ==========================================================================
   iWAM animation widgets: #anim-flow ("From noise to a future") and
   #anim-pipeline ("Where the policy's features come from").
   Self-contained: everything here is scoped to .anim; only the font is inherited.
   ========================================================================== */

.anim {
  --an-text: #1a1a2e;
  --an-text-2: #4a4a6a;
  --an-muted: #6b6b84;
  --an-border: #e5e7eb;
  --an-soft: #f8f9fa;
  --an-brand: #a3214f;
  --an-brand-soft: #fbeef3;
  --an-tone: var(--an-brand);
  --an-tone-soft: var(--an-brand-soft);
  --an-tone-ink: var(--an-brand);

  position: relative;
  max-width: 960px;
  margin: 32px auto;
  padding: 20px 24px 18px;
  background: #fff;
  border: 1px solid var(--an-border);
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .08);
  color: var(--an-text);
  font-family: inherit;
  text-align: left;
}

/* ---------------------------------------------------------------- header */

.anim-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  margin: 0 0 6px;
}
.anim-title {
  margin: 0;
  font-size: 1.02rem;
  font-weight: 700;
  line-height: 1.4;
  letter-spacing: -0.01em;
  color: var(--an-text);
}
.anim-context {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 100%;
  margin: 0;
  padding: 3px 14px 3px 3px;
  border: 1px solid var(--an-border);
  border-radius: 999px;
  background: var(--an-soft);
  font-size: .82rem;
  line-height: 1.3;
  color: var(--an-text-2);
}
.anim-context img {
  display: block;
  flex: none;
  width: 48px;
  height: 27px;
  object-fit: cover;
  border-radius: 999px;
}

/* ----------------------------------------------------------------- stage */

.anim-stage { position: relative; }
.anim-svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
  font-family: inherit;
  -webkit-user-select: none;
  user-select: none;
}
.anim.is-narrow .anim-svg { max-width: 480px; margin: 0 auto; }
/* Pipeline widget, phones: Training and Inference panels stacked, each no wider than this
   (keeps both panels close to one screen tall). */
#anim-pipeline.is-narrow .anim-svg { max-width: 380px; }

.anim-svg text { font-family: inherit; }
.anim-svg .a-t { font-weight: 600; fill: var(--an-text); }
.anim-svg .a-t2 { font-weight: 500; fill: var(--an-text-2); }
.anim-svg .a-tm { font-weight: 500; fill: var(--an-muted); }
.anim-svg .a-band { font-weight: 600; fill: #fff; letter-spacing: .01em; }
.anim-svg .a-halo {
  paint-order: stroke;
  stroke: #fff;
  stroke-width: 5px;
  stroke-linejoin: round;
}
.anim-svg .a-clip-edge { fill: none; stroke: rgba(15, 18, 30, .14); stroke-width: 1; }
.anim-svg .a-particle, .anim-svg .a-chip { pointer-events: none; }

/* Pipeline widget (#anim-pipeline): neutral parts are drawn here; what differs between Training and
   Inference uses the tab colour, set by flow-anim.js as --p-tone / --p-soft / --p-ink / --p-line. */
#anim-pipeline { --p-tone: #a3214f; --p-soft: #fbeef3; --p-ink: #a3214f; --p-line: #a3214f; }
.anim-svg .a-panel-bg { fill: #fafbfc; stroke: #eceef2; stroke-width: 1; }   /* Training / Inference panels */
/* Video model = blue, action network = warm red, as in the paper's figures; both stand out from the panel. */
.anim-svg .a-vm { fill: #dce9f8; stroke: #6f9bd1; stroke-width: 1.6; }
.anim-svg .a-vm-t { fill: #1d3b63; }
.anim-svg .a-an { fill: #fbe9e6; stroke: #d98a7c; stroke-width: 1.6; }
.anim-svg .a-an-t { fill: #8f2f22; }
.anim-svg .a-card { fill: #e8ebf0; stroke: rgba(15, 18, 30, .12); stroke-width: 1; }
.anim-svg .a-ph { fill: rgba(255, 255, 255, .8); stroke: #c5cad5; stroke-width: 1.25; stroke-dasharray: 6 5; }
.anim-svg .a-slot { fill: #fff; stroke: #d9dce3; stroke-width: 1.25; }
.anim-svg .a-tok { fill: #3f4659; }
.anim-svg .a-tok-demo { fill: #a9b0be; }
.anim-svg .a-cmp { fill: none; stroke: #b6bcc8; stroke-width: 1.25; stroke-dasharray: 2 3; }

.anim-noscript { margin: 8px 0; font-size: .9rem; color: var(--an-muted); }

/* -------------------------------------------------------------- captions */

.anim-captions {
  display: grid;
  max-width: 700px;
  margin: 12px auto 14px;
  text-align: center;
}
.anim-cap {
  grid-area: 1 / 1;
  align-self: center;
  margin: 0;
  font-size: 1rem;
  line-height: 1.6;
  color: var(--an-text-2);
  text-wrap: pretty;
}
.anim.is-ready .anim-cap {
  opacity: 0;
  visibility: hidden;
  transition: opacity .35s ease, visibility 0s linear .35s;
}
.anim.is-ready .anim-cap.is-active {
  opacity: 1;
  visibility: visible;
  transition: opacity .5s ease .12s, visibility 0s;
}
/* Without JavaScript every caption is shown, one under the other. */
.anim:not(.is-ready) .anim-cap { grid-area: auto; margin-bottom: .5em; }

/* -------------------------------------------------------------- controls */

.anim-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.anim-pills {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}
/* Icon-only pause / play button. */
.anim-play {
  flex: none;
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 1px solid var(--an-border);
  border-radius: 50%;
  background: rgba(255, 255, 255, .92);
  color: var(--an-text-2);
  cursor: pointer;
  transition: border-color .2s, color .2s, background-color .2s;
}
.anim-control-label { display: none; }
.anim-play:hover { border-color: var(--an-brand); color: var(--an-brand); }
.anim-play svg { display: block; width: 14px; height: 14px; fill: currentColor; }
.anim-play .i-pause { display: none; }
.anim-play.is-playing .i-pause { display: block; }
.anim-play.is-playing .i-play { display: none; }
.anim.is-static .anim-play { display: none; }

.anim-pill {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin: 0;
  padding: 5px 15px;
  border: 1px solid var(--an-border);
  border-radius: 999px;
  background: #fff;
  color: var(--an-text-2);
  font: inherit;
  font-size: .86rem;
  font-weight: 600;
  line-height: 1.4;
  white-space: nowrap;
  cursor: pointer;
  overflow: hidden;
  transition: border-color .2s, color .2s, background-color .2s;
}
.anim-pill:hover { border-color: var(--an-tone); color: var(--an-tone-ink); }
.anim-pill[aria-pressed="true"] {
  border-color: var(--an-tone);
  background: var(--an-tone-soft);
  color: var(--an-tone-ink);
}
.anim-pill-n {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 19px;
  height: 19px;
  border-radius: 50%;
  background: var(--an-soft);
  color: var(--an-muted);
  font-size: .72rem;
  font-weight: 700;
  line-height: 1;
  transition: background-color .2s, color .2s;
}
.anim-pill[aria-pressed="true"] .anim-pill-n { background: var(--an-tone); color: #fff; }
.anim-pill-dot {
  flex: none;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--an-tone);
}
/* autoplay progress, under the active pill's label */
.anim-pill-bar {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 2px;
  height: 2px;
  border-radius: 2px;
  background: var(--an-tone);
  opacity: .55;
  transform: scaleX(0);
  transform-origin: 0 50%;
  pointer-events: none;
}

/* method colours (match the results charts) */
.anim-pill[data-tone="fastwam"] { --an-tone: #EE8866; --an-tone-soft: #fdf0ea; --an-tone-ink: #a5432a; }
.anim-pill[data-tone="idm"] { --an-tone: #77AADD; --an-tone-soft: #eef5fc; --an-tone-ink: #2f6496; }
.anim-pill[data-tone="iwam"] { --an-tone: #a3214f; --an-tone-soft: #fbeef3; --an-tone-ink: #a3214f; }

.anim button:focus-visible { outline: 2px solid #2563eb; outline-offset: 2px; }

/* ------------------------------------------------------------- small screens */

/* Step pills of the flow widget: numbers only, the active step also shows its name. All five
   names need about 700px on one row; above 860px the row has 760px or more. This roughly matches
   the stacked layout (NARROW_BELOW in flow-anim.js). */
@media (max-width: 860px) {
  #anim-flow .anim-pill { padding: 5px 8px; }
  #anim-flow .anim-pill:not([aria-pressed="true"]) .anim-pill-t { display: none; }
  #anim-flow .anim-pill[aria-pressed="true"] { padding-right: 12px; }
}

@media (max-width: 640px) {
  .anim { margin: 24px 0; padding: 14px 12px 14px; }
  .anim-head { margin-bottom: 4px; }
  .anim-context { font-size: .78rem; }
  .anim-cap { font-size: .95rem; }
  .anim-controls { gap: 6px; }
  .anim-pills { gap: 6px; }
  .anim-pill { padding: 5px 11px; font-size: .8rem; gap: 6px; }
}

@media (prefers-reduced-motion: reduce) {
  .anim *, .anim *::before, .anim *::after { transition: none !important; }
}
