/*
 * Diff panel — .seq-diff (docs/design-system/component-inventory.md).
 *
 * A unified (default, .seq-diff--unified) or side-by-side (.seq-diff--side-by-side)
 * difference of two workflow versions or two run configurations: nodes, edges, parameters,
 * step versions, reference artifact ids. Embeds .seq-graph--diff for the node and edge part.
 * The --inline variant is the compact form used inside the confirmations that change the
 * science, where it sits under a sentence saying what will change.
 *
 * Markup (the sentence naming the two sides, "Run 17 compared with run 19", is prose above
 * the panel in the page's own type, not part of it):
 *   <div class="seq-diff seq-diff--unified">
 *     <div class="seq-diff__row" data-diff="added"><span class="seq-diff__kind">node</span>
 *       <span class="seq-diff__name">happy-compare</span>
 *       <span class="seq-diff__before"></span><span class="seq-diff__after">happy.compare@0.3.15</span></div>
 *   </div>
 * Rows carry data-diff="added|removed|changed"; the mark column prints + − ~ from CSS with
 * the word (added, removed, changed) as the mark's alternative text, so a screen reader hears
 * the word and not "plus"; the row takes the matching wash, so the difference is never colour
 * alone.
 */

.seq-diff {
  --diff-mark: "";
  --diff-word: "";
  --diff-mark-ink: var(--text-tertiary);   /* a rule color for an unchanged row, drawn transparent below; not text */
  --diff-wash: transparent;
  display: flex;
  flex-direction: column;
  gap: var(--spacing-8);
  font-family: var(--font-family-mono);
  font-size: var(--font-size-14);
  font-weight: var(--font-weight-400);
  font-variant-numeric: var(--numerals);
}


/* ---------- Rows ---------- */
.seq-diff__row {
  display: grid;
  grid-template-columns: var(--spacing-24) max-content minmax(0, 3fr) minmax(0, 2fr) minmax(0, 2fr);   /* the kind column takes its word: at 5em "parameter" ran into the name (2026-09-24) */
  gap: var(--spacing-8);
  align-items: baseline;
  padding-block: var(--spacing-4);
  padding-inline: var(--spacing-8);
  border-inline-start: var(--stroke-weight-2) solid var(--diff-mark-ink);
  background: var(--diff-wash);
}

/* A row with no difference has no rule and no wash; the mark column stays blank */
.seq-diff__row[data-diff="unchanged"],
.seq-diff__row:not([data-diff]) {
  border-inline-start-color: transparent;
}

.seq-diff__row::before {
  content: var(--diff-mark) / var(--diff-word);
  color: var(--diff-mark-ink);
  text-align: center;
}

.seq-diff__kind {
  color: var(--text-secondary);
}

.seq-diff__name {
  color: var(--text-primary);
  overflow-wrap: anywhere;
}

.seq-diff__before,
.seq-diff__after {
  color: var(--text-secondary);
  overflow-wrap: anywhere;
}

.seq-diff__before:empty::before,
.seq-diff__after:empty::before {
  content: "—";
  color: var(--text-tertiary);
}

.seq-diff__row[data-diff="added"] {
  --diff-mark: "+";
  --diff-word: "added ";
  --diff-mark-ink: var(--diff-added-ink);
  --diff-wash: var(--diff-added-wash);
}
.seq-diff__row[data-diff="added"] .seq-diff__after {
  color: var(--diff-added-ink);
}

.seq-diff__row[data-diff="removed"] {
  --diff-mark: "−";
  --diff-word: "removed ";
  --diff-mark-ink: var(--diff-removed-ink);
  --diff-wash: var(--diff-removed-wash);
}
.seq-diff__row[data-diff="removed"] .seq-diff__name,
.seq-diff__row[data-diff="removed"] .seq-diff__before {
  text-decoration: line-through;
  color: var(--diff-removed-ink);
}

.seq-diff__row[data-diff="changed"] {
  --diff-mark: "~";
  --diff-word: "changed ";
  --diff-mark-ink: var(--diff-changed-ink);
  --diff-wash: var(--diff-changed-wash);
}
.seq-diff__row[data-diff="changed"] .seq-diff__before {
  text-decoration: line-through;
}
.seq-diff__row[data-diff="changed"] .seq-diff__after {
  color: var(--diff-changed-ink);
}

.seq-diff__row[data-diff="unchanged"] {
  color: var(--text-secondary);
}

/* ---------- Side by side ---------- */
/* Below 768px a row is the mark, the kind and the name on one line, and each value on a line of
   its own under the name: in five columns at 390 the name and values stood five or six
   characters a line ("deepva/riant./run_de"). An after value is marked with an arrow, so
   the two lines stay before and after. */
@media (max-width: 767px) {
  .seq-diff__row {
    grid-template-columns: var(--spacing-24) max-content minmax(0, 1fr);
    row-gap: var(--spacing-2);
  }
  .seq-diff__before,
  .seq-diff__after {
    grid-column: 3;
  }
  .seq-diff__row > .seq-diff__after:not(:empty)::before {
    content: "→ ";
  }
}

/* ---------- Inline, inside a confirmation ---------- */
.seq-diff--inline {
  font-size: var(--font-size-12);
  gap: var(--spacing-4);
  padding: var(--spacing-12);
  border: var(--stroke-weight-1) solid var(--border-subtle);
  border-radius: var(--corner-radius-xs);
  background: var(--background-surface-1);
}


.seq-diff--inline .seq-diff__row {
  padding-block: var(--spacing-2);
}

/* A sentence, in the prose face, above an inline diff: what the confirmation will change. */
.seq-diff__sentence {
  font-family: var(--font-family-body);
  font-size: var(--font-size-16);
  font-weight: var(--font-weight-400);
  color: var(--text-primary);
  max-width: var(--width-740);
}
