/* Metaphor project page: pair-highlighting demo + two small charts.
   Colors validated (light surface #FAFAF7): blue #2F6DB0 = literal / model,
   amber #C47A2C = metaphor. Human agreement is a neutral gray reference. */
.mx {
  --mx-metaphor: #C47A2C;
  --mx-metaphor-tint: #F6E7D6;
  --mx-literal: #2F6DB0;
  --mx-literal-tint: #DFE8F4;
  --mx-ref: #8A8A8A;
  --mx-grid: #E2E0DB;
}

/* --- Demo: which words is it judging? (ambient loop) --- */
.mx-demo {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2.4rem 1.5rem 0.9rem;
  margin: 2rem 0;
}
.mx-stage { position: relative; display: flex; align-items: center; min-height: 8.4rem; }
.mx-arcs { position: absolute; inset: 0; overflow: visible; pointer-events: none; }
.mx-sentence {
  font-family: var(--serif);
  font-size: 1.45rem;
  line-height: 2.7;            /* headroom for the arcs */
  color: var(--text);
  margin: 0;
}
.mx-w {
  position: relative;
  display: inline-block;
  padding: 0 0.12em;
  border-radius: 4px;
  line-height: 1.3;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.6s ease, transform 0.6s ease, color 0.5s ease,
              background-color 0.5s ease, box-shadow 0.5s ease;
}
.mx-in .mx-w { opacity: 1; transform: none; transition-delay: calc(var(--i) * 70ms); }
.mx-in.mx-dim .mx-w, .mx-in .mx-w.on { transition-delay: 0s; }
.mx-out .mx-w { opacity: 0; transform: translateY(-6px); transition-delay: calc(var(--i) * 40ms); }

/* the whole sentence, as a sentence-level model sees it */
.mx-w::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -4px;
  height: 2px;
  border-radius: 2px;
  background: var(--text-softer);
  transform: scaleX(0);
  transform-origin: left;
  opacity: 0.55;
  transition: transform 0.35s ease;
}
.mx-sweep .mx-w::after { transform: scaleX(1); transition-delay: calc(var(--i) * 90ms); }

/* role tag (SOURCE / TARGET) under each word of the lit pair; arcs run above */
.mx-w::before {
  content: attr(data-role);
  position: absolute;
  left: 50%;
  top: 100%;
  transform: translate(-50%, 0.5rem);
  font-family: var(--sans);
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-soft);
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.4s ease;
}
.mx-w.on::before { opacity: 1; transition-delay: 0.35s; }

.mx-dim .mx-w:not(.on) { color: var(--text-softer); }
.mx-w.on.is-metaphor { background: var(--mx-metaphor-tint); box-shadow: inset 0 -2px 0 var(--mx-metaphor); }
.mx-w.on.is-literal  { background: var(--mx-literal-tint);  box-shadow: inset 0 -2px 0 var(--mx-literal); }

.mx-arc { fill: none; stroke-width: 2; stroke-linecap: round; opacity: 0; }
.mx-arc.is-metaphor { stroke: var(--mx-metaphor); }
.mx-arc.is-literal  { stroke: var(--mx-literal); }
.mx-arc.draw { opacity: 1; transition: stroke-dashoffset 0.9s cubic-bezier(.4,0,.2,1) 0.25s; }
.mx-arc.fade { opacity: 0; transition: opacity 0.4s ease; }

.mx-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 2.2rem;
  margin-top: 0.4rem;
}
.mx-verdict {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-family: var(--sans);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text);
  background: var(--bg-alt);
  border-radius: 999px;
  padding: 0.25rem 0.8rem;
  opacity: 0;
  transform: scale(0.92);
  transition: opacity 0.4s ease, transform 0.4s ease;
}
.mx-verdict.show { opacity: 1; transform: none; transition-delay: 0.7s; }
.mx-verdict i { width: 0.6rem; height: 0.6rem; border-radius: 50%; background: var(--mx-ref); }
.mx-verdict.is-metaphor i { background: var(--mx-metaphor); }
.mx-verdict.is-literal i  { background: var(--mx-literal); }

.mx-play {
  border: 0;
  background: none;
  cursor: pointer;
  padding: 0.4rem;
  border-radius: 999px;
  color: var(--text-softer);
  line-height: 0;
  opacity: 0.6;
  transition: opacity 0.2s ease;
}
.mx-play:hover, .mx-play:focus-visible { opacity: 1; }
.mx-play:focus-visible { outline: 2px solid var(--accent); }
.mx-play svg path { fill: currentColor; }
.mx-ico-play { display: none; }
.mx-demo.paused .mx-ico-play { display: inline; }
.mx-demo.paused .mx-ico-pause { display: none; }

/* --- Pipeline (ambient loop) --- */
/* Every animated piece shares one period; each starts at its own delay. */
.mx-pipe { --cyc: 6.4s; margin: 2.2rem 0; }
.mx-pipe-row {
  display: flex;
  align-items: flex-start;
  gap: 0;
  padding: 1.3rem 1rem 1.1rem;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.mx-node { display: flex; flex-direction: column; align-items: center; gap: 0.5rem; flex: 0 0 auto; }
.mx-node { height: 5rem; }
.mx-node > :last-child { margin-block: auto; }   /* center each body under its label */
.mx-node-label {
  font-family: var(--sans); font-size: 0.7rem; font-weight: 600;
  letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-softer);
}
.mx-chip {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.74rem;
  color: var(--text);
  background: var(--bg-alt);
  border-radius: 6px;
  padding: 0.45rem 0.6rem;
  white-space: nowrap;
  animation: mx-hold var(--cyc) ease infinite -0.3s both;
}
.mx-chip b { font-weight: 600; }
.mx-chip .m { color: var(--mx-metaphor); }
.mx-chip .l { color: var(--mx-literal); }
.mx-layers { display: flex; flex-direction: column-reverse; gap: 3px; }
.mx-layers i {
  display: block; width: 3.6rem; height: 6px; border-radius: 3px;
  background: var(--mx-grid);
  animation: mx-light var(--cyc) ease infinite both;
}
.mx-layers i:nth-child(1) { animation-delay: 0.7s; }
.mx-layers i:nth-child(2) { animation-delay: 0.82s; }
.mx-layers i:nth-child(3) { animation-delay: 0.94s; }
.mx-layers i:nth-child(4) { animation-delay: 1.06s; }
.mx-layers i:nth-child(5) { animation-delay: 1.18s; }
.mx-layers i:nth-child(6) { animation-delay: 1.3s; }
.mx-headbox {
  width: 1.6rem; height: 1.6rem; border-radius: 50%;
  border: 2px solid var(--mx-grid);
  animation: mx-ring var(--cyc) ease infinite 1.95s both;
}
.mx-link { flex: 1 1 1.5rem; min-width: 0.9rem; height: 2px; margin: 2.75rem 0.35rem 0; background: var(--border); position: relative; border-radius: 2px; }
.mx-link i {
  position: absolute; inset: 0; border-radius: 2px;
  background: var(--accent);
  animation: mx-flow var(--cyc) ease-in-out infinite both;
}
.mx-pipe .l1 i { animation-delay: 0.05s; }
.mx-pipe .l2 i { animation-delay: 1.45s; }
.mx-pipe .l3 i { animation-delay: 2.25s; }
.mx-pipe .mx-verdict { animation: mx-pop var(--cyc) ease infinite 2.75s both; transition: none; font-size: 0.8rem; padding: 0.22rem 0.7rem; }

@keyframes mx-flow {
  0%   { clip-path: inset(0 100% 0 0); opacity: 1; }
  9%   { clip-path: inset(0 0 0 0); opacity: 1; }
  42%  { opacity: 1; }
  52%, 100% { clip-path: inset(0 0 0 0); opacity: 0; }
}
@keyframes mx-flow-v {
  0%   { clip-path: inset(0 0 100% 0); opacity: 1; }
  9%   { clip-path: inset(0 0 0 0); opacity: 1; }
  42%  { opacity: 1; }
  52%, 100% { clip-path: inset(0 0 0 0); opacity: 0; }
}
@keyframes mx-light {
  0%   { background: var(--mx-grid); }
  5%   { background: var(--accent); }
  38%  { background: var(--accent); }
  50%, 100% { background: var(--mx-grid); }
}
@keyframes mx-ring {
  0%   { border-color: var(--mx-grid); transform: scale(1); }
  4%   { border-color: var(--accent); transform: scale(1.18); }
  9%   { transform: scale(1); }
  38%  { border-color: var(--accent); }
  50%, 100% { border-color: var(--mx-grid); }
}
@keyframes mx-hold {        /* input: visible nearly all cycle, a brief dip to swap examples */
  0%   { opacity: 0; }
  5%   { opacity: 1; }
  90%  { opacity: 1; }
  97%, 100% { opacity: 0; }
}
@keyframes mx-pop {
  0%   { opacity: 0; transform: scale(0.94); }
  6%   { opacity: 1; transform: none; }
  40%  { opacity: 1; transform: none; }
  50%, 100% { opacity: 0; transform: none; }
}
.mx-pipe figcaption {
  font-family: var(--sans); font-size: 0.85rem; color: var(--text-soft);
  margin-top: 0.6rem; line-height: 1.5;
}
@media (max-width: 620px) {
  .mx-pipe-row { flex-direction: column; padding: 1.2rem 1rem; }
  .mx-pipe-row { align-items: center; }
  .mx-node { height: auto; }
  .mx-node > :last-child { margin-block: 0; }
  .mx-link { flex: 0 0 1.6rem; width: 2px; height: 1.6rem; min-width: 0; margin: 0.45rem 0; }
  .mx-link i { animation-name: mx-flow-v; }
  .mx-chip { white-space: normal; text-align: center; }
}
@media (prefers-reduced-motion: reduce) {
  .mx-pipe * { animation: none !important; }
  .mx-pipe .mx-layers i { background: var(--accent); }
  .mx-pipe .mx-headbox { border-color: var(--accent); }
}

/* --- Paper-style (booktabs) tables --- */
/* Results tables: the same plain style as the charts' "Show as table". */
.mx-tbl { font-family: var(--sans); }
.post-body .mx-tbl table { border-collapse: collapse; margin-top: 0.5rem; width: 100%; font-size: 0.85rem; }
.post-body .mx-tbl th, .post-body .mx-tbl td {
  text-align: left; padding: 0.35rem 0.6rem 0.35rem 0; font-weight: 400; background: none;
  border: 0; border-bottom: 1px solid var(--border); white-space: nowrap;
}
.post-body .mx-tbl thead th { font-weight: 600; }
.post-body .mx-tbl th:last-child, .post-body .mx-tbl td:last-child { padding-right: 0; }
.post-body .mx-tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
.post-body .mx-tbl .mx-tbl-ref > * { color: var(--text-soft); }
.post-body .mx-tbl tr > th[scope=row] { white-space: normal; }
.post-body .mx-tbl .mx-note { font-size: 0.8rem; color: var(--text-soft); margin: 0.5rem 0 0; }
.post-body .mx-tbl .mx-note b { font-weight: 600; color: var(--text); }
.post-body .mx-tbl table { margin-top: 0; }
.ltx-sd { color: var(--text-soft); }
@media (max-width: 560px) {
  .post-body .mx-tbl table { font-size: 0.8rem; }
  .post-body .mx-tbl th, .post-body .mx-tbl td { padding-right: 0.5rem; }
  .post-body .mx-tbl thead th { white-space: normal; vertical-align: bottom; line-height: 1.25; }
  .post-body .mx-tbl tbody th { white-space: normal; }
  .ltx-sd { display: none; }   /* phones: means only */
}

/* --- Charts --- */
.mx-chart { margin: 2rem 0; }
.mx-chart-title {
  font-family: var(--sans);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 0.2rem;
}
.mx-chart-sub {
  font-family: var(--sans);
  font-size: 0.85rem;
  color: var(--text-soft);
  margin: 0 0 0.8rem;
}
.mx-legend {
  display: flex; gap: 1.1rem; flex-wrap: wrap;
  font-family: var(--sans); font-size: 0.8rem; color: var(--text-soft);
  margin: 0 0 0.4rem;
}
.mx-legend span { display: inline-flex; align-items: center; gap: 0.4rem; }
.mx-key { width: 0.7rem; height: 0.7rem; border-radius: 50%; display: inline-block; }
.mx-key.model { background: var(--mx-literal); }
.mx-key.human { border: 2px solid var(--mx-ref); width: 0.6rem; height: 0.6rem; }
.mx-key.ref { width: 2px; height: 0.8rem; border-radius: 0; background: var(--mx-ref); }
.mx-chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.mx-chart text { font-family: var(--sans); }
.mx-tip {
  position: absolute;
  pointer-events: none;
  background: var(--text);
  color: #fff;
  font-family: var(--sans);
  font-size: 0.8rem;
  line-height: 1.4;
  padding: 0.45rem 0.6rem;
  border-radius: 6px;
  max-width: 15rem;
  opacity: 0;
  transition: opacity 0.12s ease;
  z-index: 5;
}
.mx-tip.show { opacity: 1; }
.mx-plot { position: relative; }

.mx-table { margin-top: 0.6rem; font-family: var(--sans); font-size: 0.85rem; }
.mx-table summary { cursor: pointer; color: var(--text-soft); }
.mx-table table { border-collapse: collapse; margin-top: 0.6rem; width: 100%; }
.mx-table th, .mx-table td {
  text-align: left; padding: 0.35rem 0.6rem 0.35rem 0;
  border-bottom: 1px solid var(--border);
}
.mx-table td.num, .mx-table th.num { text-align: right; font-variant-numeric: tabular-nums; }

@media (max-width: 560px) {
  .mx-demo { padding: 1.8rem 1rem 0.8rem; }
  .mx-sentence { font-size: 1.2rem; }
  .mx-stage { min-height: 10.5rem; }
}
@media (prefers-reduced-motion: reduce) {
  .mx-w, .mx-w::before, .mx-w::after, .mx-verdict, .mx-arc.draw { transition: none !important; }
}
@media (max-width: 380px) {
  .post-body .mx-tbl table { font-size: 0.74rem; }
  .post-body .mx-tbl th, .post-body .mx-tbl td { padding-right: 0.35rem; }
}
@media (max-width: 340px) {
  #mx-metrics th:nth-child(6), #mx-metrics td:nth-child(6) { display: none; }
}

/* --- Static source/target examples (arcs drawn by metaphor.js) --- */
.mx-examples { margin: 1.6rem 0 2rem; font-family: var(--serif); }
.mx-ex { position: relative; margin: 0; font-size: 1.4rem; line-height: 2.9; color: var(--text); }
.mx-ex + .mx-ex { margin-top: 0.4rem; }
.mx-ex-label { font-family: var(--sans); font-size: 0.78rem; font-weight: 600; letter-spacing: 0.06em;
  text-transform: uppercase; margin-left: 0.5rem; white-space: nowrap; }
.mx-ex.is-metaphor .mx-ex-label { color: var(--mx-metaphor); }
.mx-ex.is-literal .mx-ex-label { color: var(--mx-literal); }
.mx-ex-w { position: relative; display: inline-block; line-height: 1.3; padding: 0 0.15em; border-radius: 2px; }
.mx-ex.is-metaphor .mx-ex-w { background: var(--mx-metaphor-tint); box-shadow: inset 0 -2px 0 var(--mx-metaphor); }
.mx-ex.is-literal .mx-ex-w { background: var(--mx-literal-tint); box-shadow: inset 0 -2px 0 var(--mx-literal); }
.mx-ex-w small { position: absolute; left: 50%; top: 100%; transform: translateX(-50%); margin-top: 0.2rem;
  font-family: var(--sans); font-size: 0.62rem; letter-spacing: 0.05em; text-transform: uppercase; color: var(--text-softer); line-height: 1; }
.mx-ex-keep { white-space: nowrap; }   /* the pair and its arrow stay on one line */
.mx-ex-arc { position: absolute; inset: 0; overflow: visible; pointer-events: none; }
.mx-ex-arc path.line { fill: none; stroke-width: 2; stroke-linecap: round; }
.mx-ex.is-metaphor .mx-ex-arc path.line { stroke: var(--mx-metaphor); }
.mx-ex.is-literal .mx-ex-arc path.line { stroke: var(--mx-literal); }
.mx-ex.is-metaphor .mx-ex-arc path.head { fill: var(--mx-metaphor); }
.mx-ex.is-literal .mx-ex-arc path.head { fill: var(--mx-literal); }
@media (max-width: 560px) {
  .mx-ex { font-size: 1.15rem; line-height: 2.8; }
}
