/* Joint-training diagram (#fig-joint): two passes, animated by assets/js/joint-diagram.js */

#fig-joint .jd { font-family: var(--sans); text-align: left; }

/* Controls row: pass buttons + pause button */
.jd-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 0 0 10px; }
.jd-switch { display: flex; flex-wrap: wrap; gap: 6px; }
.jd-switch button {
  font: inherit; font-size: 0.8rem; color: var(--muted);
  padding: 3px 10px; border: 0; border-radius: 999px; background: var(--soft); cursor: pointer;
  transition: background-color .3s, color .3s;
}
.jd-switch button:hover { color: var(--ink); }
.jd-switch button[aria-pressed="true"] { background: var(--ink); color: #fff; }
.jd-switch button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.jd-toggle {
  display: inline-flex; align-items: center; gap: 6px; flex: none;
  font: inherit; font-size: 0.82rem; font-weight: 500; color: var(--ink);
  padding: 5px 12px; border: 1px solid var(--rule); border-radius: 999px; background: #fff; cursor: pointer;
}
.jd-toggle:hover { border-color: #c9c9c9; }
.jd-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.jd-toggle svg { width: 10px; height: 10px; fill: currentColor; }
.jd-toggle .i-play, .jd-toggle.is-paused .i-pause { display: none; }
.jd-toggle.is-paused .i-play { display: block; }

/* Panels: side by side, stacked on phones */
.jd-panels { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.jd-pass { background: #f5ebe0; border-radius: 12px; padding: 10px 6px 4px; transition: opacity .5s ease; }
.jd-pass.is-dim { opacity: .4; cursor: pointer; }
.jd-head { margin: 0 0 4px; padding: 0 6px; line-height: 1.35; }
.jd-name { display: block; font-weight: 600; font-size: 1rem; }
.jd-sub { display: block; font-size: 0.85rem; color: var(--muted); }
.jd-pass svg { display: block; width: 100%; height: auto; }

/* SVG content */
.jd svg text { font-family: var(--sans); font-size: 15.5px; fill: var(--ink); text-anchor: middle; dominant-baseline: central; }
.jd .node rect { stroke: var(--ink); stroke-width: 1.2; transition: stroke .2s, stroke-width .2s; }
.jd .module rect { fill: #b9f6e1; }
.jd .module text { font-weight: 600; font-size: 15.5px; }
.jd .input rect { fill: #d9d9d9; }
.jd .encoder rect { fill: #f2f2f2; }
.jd .latent rect { fill: #2fe6a8; }
.jd .rep rect { fill: #ffb3b3; }
.jd .robot rect { fill: #90cdf4; }
.jd .node.hit rect { stroke: #8b7cf6; stroke-width: 3; }

.jd .loss rect { fill: #fff8dc; stroke: var(--ink); stroke-width: 1; transition: fill .25s, stroke-width .25s; }
.jd .loss text { font-size: 17px; }
.jd .loss .sub { font-family: var(--serif); font-size: 12.5px; }
.jd .loss.on rect { fill: #ffdf7e; stroke-width: 2; }

.jd .flow path { fill: none; stroke: var(--ink); stroke-width: 1.3; }
.jd .sup path { fill: none; stroke: var(--ink); stroke-width: 1.2; stroke-dasharray: 4 3; }
.jd .grad path { fill: none; stroke: #8b7cf6; stroke-width: 5; opacity: .35; transition: opacity .3s; }
.jd .is-grad .grad path, .jd.is-static .grad path { opacity: .7; }
.jd .grad path.minor { stroke-width: 3; opacity: .25; }
.jd .is-grad .grad path.minor, .jd.is-static .grad path.minor { opacity: .4; }
.jd .dot { fill: var(--ink); }
.jd .pulse { fill: #8b7cf6; }
.jd .pulse.minor { opacity: .6; }

.jd .ghost rect { fill: none; stroke: #b9ada0; stroke-width: 1.2; stroke-dasharray: 4 3; }
.jd .ghost text { fill: var(--muted); font-size: 13px; }

/* Legend */
.jd-legend { list-style: none; display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 18px; margin: 10px 0 0; padding: 0; font-size: 0.82rem; color: var(--muted); }
.jd-legend li { display: inline-flex; align-items: center; gap: 6px; margin: 0; }
.jd-legend svg { width: 28px; height: 12px; flex: none; }
.jd-legend svg.icon { width: 14px; height: 14px; }

.jd.is-static .jd-bar { display: none; }

@media (max-width: 640px) {
  .jd-panels { grid-template-columns: 1fr; gap: 12px; }
  .jd-pass { padding: 10px 6px 4px; }
  .jd-head { padding: 0 6px; }
  .jd-switch { gap: 4px; }
  .jd-switch button { font-size: 0.75rem; padding: 3px 8px; }
}
