/* "O caminho de uma mensagem": the animated figure in #como-funciona, chapter 03.
   Driven by js/route.js, which sets data-tier and cumulative step classes (r1..r7) on .msgpath,
   plus .now on the node or wire being narrated. Every hidden part keeps its space, so the
   layout never jumps while the animation plays. */

.msgpath {
  margin: var(--s7) 0 var(--s6);
  padding: var(--s5) var(--s4);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 15px;
  line-height: 1.4;
}
.msgpath p { margin: 0; color: inherit; }
@media (min-width: 720px) {
  .msgpath { padding: var(--s6); margin-inline: calc(var(--s5) * -1); }
}

/* ---- Header: caption, tier toggle, replay ---- */
.mp-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s3) var(--s4); }
.mp-cap { color: var(--faint); }
.mp-controls { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); }
.mp-toggle { display: inline-flex; padding: 3px; gap: 3px; border: 1px solid var(--line-strong); border-radius: 8px; }
.mp-tier, .mp-replay {
  display: inline-flex; align-items: center; gap: var(--s2);
  min-height: 40px; padding: 0 var(--s3);
  background: none; border: 1px solid transparent; border-radius: 5px;
  font-family: var(--mono); font-size: 12px; letter-spacing: .04em; color: var(--muted);
  cursor: pointer; touch-action: manipulation;
  transition: color .2s, background-color .2s, border-color .2s;
}
.mp-tier .shield { width: 16px; height: 16px; flex: none; }
.mp-tier:hover { color: var(--text); }
.mp-tier[aria-pressed="true"] { color: var(--text); background: var(--tint); border-color: var(--accent); }
.mp-replay { border-color: var(--line-strong); border-radius: 6px; color: var(--text); padding: 0 var(--s4); }
.mp-replay svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.mp-replay:hover { border-color: var(--accent-text); color: var(--accent-soft); }
.mp-tier:focus-visible, .mp-replay:focus-visible { outline: 2px solid var(--accent-text); outline-offset: 2px; border-radius: 6px; }
html.rm .mp-replay { display: none; }

/* ---- Track: three nodes joined by two wires. Stacked on phones, a row from 720px. ---- */
.mp-track { display: grid; grid-template-columns: minmax(0, 1fr); margin-top: var(--s5); }
@media (min-width: 720px) {
  .mp-track { grid-template-columns: minmax(0, 1fr) 44px minmax(0, 1fr) 44px minmax(0, 1fr); align-items: stretch; }
}

.mp-node {
  display: flex; flex-direction: column; gap: var(--s3);
  min-width: 0;
  padding: var(--s4);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  opacity: .45;
  transition: opacity .5s var(--ease), border-color .4s var(--ease), box-shadow .4s var(--ease);
}
.mp-node.on { opacity: 1; border-color: var(--line-strong); }
.mp-node.now { border-color: var(--accent-text); box-shadow: 0 0 0 4px var(--tint); }

.mp-name { display: flex; flex-direction: column; gap: 2px; font-weight: 600; font-size: 16px; color: var(--text); letter-spacing: -.01em; }
.mp-num, .mp-role { font-family: var(--mono); font-weight: 400; font-size: 11px; letter-spacing: .06em; color: var(--faint); }
.mp-num { color: var(--accent-text); }
.mp-role { letter-spacing: .02em; }
.msgpath[data-tier="private"] .mp-only-a, .msgpath[data-tier="anon"] .mp-only-p { display: none; }

.mp-pkt { display: flex; flex-wrap: wrap; gap: 6px; }
.mp-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 9px;
  border: 1px solid var(--line-strong); border-radius: 999px;
  font-family: var(--mono); font-size: 11px; color: var(--accent-soft);
  transition: opacity .5s var(--ease), color .4s, border-color .4s, background-color .4s;
}
.mp-chip.mp-msg {
  display: block; width: 100%;
  padding: var(--s2) var(--s3);
  border-radius: 6px;
  font-family: var(--sans); font-size: 13.5px; line-height: 1.35; color: var(--text);
  background: var(--surface-2);
}
.mp-k { display: block; font-family: var(--mono); font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: var(--faint); }
.mp-chip .mp-k { display: inline; }

.mp-note {
  display: flex; flex-direction: column; gap: 2px;
  padding: var(--s2) var(--s3);
  border: 1px dashed var(--line-strong); border-radius: 6px;
  font-size: 13px; line-height: 1.35; color: var(--muted);
  opacity: 0; transform: translateY(-6px);
  transition: opacity .5s var(--ease), transform .5s var(--ease), border-color .4s, color .4s;
}
.mp-note b { font-family: var(--mono); font-size: 18px; font-weight: 500; color: var(--text); letter-spacing: -.01em; }
.mp-meta { font-family: var(--mono); font-size: 12px; color: var(--accent-soft); }

/* The history note sits at the foot of the device card. */
.mp-hist { margin-top: auto; }

/* Bayle: what the proxy strips off. */
.mp-strip { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.mp-strip li {
  padding: 3px 9px; border: 1px solid var(--line); border-radius: 6px;
  font-family: var(--mono); font-size: 11px; color: var(--faint);
  text-decoration: line-through; text-decoration-color: var(--accent-text);
  opacity: 0; transform: translateY(-6px);
  transition: opacity .5s var(--ease), transform .5s var(--ease);
}
.mp-strip li + li { transition-delay: .25s; }
.mp-dest .mp-in { opacity: 0; transform: translateY(-6px); transition: opacity .5s var(--ease), transform .5s var(--ease); }

/* ---- Wires ---- */
.mp-wire { position: relative; height: 44px; }
.mp-wire::before { content: ""; position: absolute; left: 50%; top: 0; bottom: 0; width: 1px; background: var(--line-strong); }
.mp-wire i {
  position: absolute; left: 50%; top: 0; width: 9px; height: 9px; margin-left: -4px;
  border-radius: 50%; background: var(--accent-soft); box-shadow: 0 0 0 4px var(--tint);
  opacity: 0; pointer-events: none;
}
.mp-tls {
  position: absolute; left: calc(50% + 12px); top: 50%; transform: translateY(-50%);
  font-family: var(--mono); font-size: 10px; letter-spacing: .1em; color: var(--faint);
}
.mp-wire.fwd i { animation: mp-down 1s var(--ease-io) both; }
.mp-wire.back i { animation: mp-up 1s var(--ease-io) both; }
.mp-wire.lit::before { background: var(--accent-text); }
@keyframes mp-down { 0% { top: 0; opacity: 0; } 15%, 85% { opacity: 1; } 100% { top: calc(100% - 9px); opacity: 0; } }
@keyframes mp-up { 0% { top: calc(100% - 9px); opacity: 0; } 15%, 85% { opacity: 1; } 100% { top: 0; opacity: 0; } }
@media (min-width: 720px) {
  .mp-wire { height: auto; }
  .mp-wire::before { left: 0; right: 0; top: 50%; bottom: auto; width: auto; height: 1px; }
  .mp-wire i { left: 0; top: 50%; margin: -4px 0 0; }
  .mp-tls { left: 50%; top: calc(50% - 20px); transform: translateX(-50%); }
  .mp-wire.fwd i { animation-name: mp-right; }
  .mp-wire.back i { animation-name: mp-left; }
}
@keyframes mp-right { 0% { left: 0; opacity: 0; } 15%, 85% { opacity: 1; } 100% { left: calc(100% - 9px); opacity: 0; } }
@keyframes mp-left { 0% { left: calc(100% - 9px); opacity: 0; } 15%, 85% { opacity: 1; } 100% { left: 0; opacity: 0; } }

/* ---- Steps (cumulative) ---- */
.msgpath.r2 .mp-strip li,
.msgpath.r3 .mp-disk,
.msgpath.r4 .mp-ledger,
.msgpath.r5 .mp-dest .mp-in,
.msgpath.r6 .mp-after,
.msgpath.r7 .mp-hist { opacity: 1; transform: none; }

.msgpath.r3 .mp-disk { border-color: var(--line-strong); }
.msgpath.r4 .mp-ledger { border-style: solid; border-color: var(--accent); background: var(--tint); }
.msgpath.r7 .mp-hist { border-style: solid; border-color: var(--accent); background: var(--tint); color: var(--text); }

/* Private: once inference ends the content is gone. Anonymous: the provider still holds it. */
.msgpath[data-tier="private"].r6 .mp-dest .mp-msg { opacity: .3; text-decoration: line-through; text-decoration-color: var(--accent-text); }
.msgpath[data-tier="anon"].r6 .mp-dest .mp-msg { border-color: var(--accent-text); box-shadow: 0 0 0 3px var(--tint); }
.msgpath[data-tier="anon"].r6 .mp-after { border-style: solid; border-color: var(--line-strong); color: var(--text); }
.msgpath.r5 .mp-from { color: var(--text); border-color: var(--accent); background: var(--tint); }

/* ---- Footer: progress ticks and the narrated status line ---- */
.mp-foot { margin-top: var(--s5); padding-top: var(--s4); border-top: 1px solid var(--line); }
.mp-prog { list-style: none; margin: 0 0 var(--s3); padding: 0; display: flex; gap: 4px; }
.mp-prog li { flex: 1; height: 2px; background: var(--line-strong); transition: background-color .4s; }
.mp-prog li.on { background: var(--accent-text); }
.msgpath .mp-status { min-height: 4.2em; font-size: 15px; line-height: 1.4; color: var(--muted); }
@media (min-width: 720px) { .msgpath .mp-status { min-height: 2.8em; } }

/* Phones: the figure is taller than the screen, so the narration rides along under the header. */
@media (max-width: 719px) {
  .mp-foot {
    position: sticky; top: var(--header-h); z-index: 2;
    margin-inline: calc(var(--s4) * -1); padding: var(--s3) var(--s4) var(--s2);
    background: var(--surface);
  }
  .mp-track { margin-top: var(--s3); }
  .mp-wire { height: 36px; }
}
