/*
 * Node graph — .seq-graph (docs/design-system/component-inventory.md).
 *
 * A read-only rendering of a workflow version's DAG as inline SVG: one column per depth,
 * an edge per binding. An edge carries no drawn label (labels drawn between the columns ran
 * under and across nodes and over each other, the review of 2026-09-24): what it carries, the
 * artifact type and on a run the artifact, is the edge's SVG <title>, shown on hover; the
 * artifacts of a run are listed and linked in the run page's Artifacts table. The SVG is
 * authored at natural size and the
 * container scrolls horizontally when the measure is narrower than the graph. The geometry
 * (node 164 by 60, column pitch 240, row pitch 94) is the constants of ApplicationHelper,
 * which draws every graph; this file declares no size.
 *
 * Markup:
 *   <div class="seq-graph seq-graph--run" tabindex="0" aria-labelledby="…"><svg ...>
 *     <path class="seq-graph__edge" d="..."><title>cram, artifacts #101</title></path>
 *     <g class="seq-graph__node" data-state="succeeded">
 *       <rect class="seq-graph__box"/>
 *       <text class="seq-graph__name">align-bwa-mem2</text>
 *       <text class="seq-graph__word" data-state="succeeded">Succeeded</text>
 *     </g>
 *   </svg></div>
 *
 * A node is drawn to the composition rules (docs/plans/seq-redesign.md § State has one mark):
 * a rounded rectangle on the gem's surface ground with a hairline, the step name in the body
 * face, and the state as a sentence-cased word in the body face with the state colour on that
 * word only, as .seq-state colours its word. No bar, no glow, no mono. Variants:
 *   --run    nodes carry data-state and the word is the job's state
 *   --plain  no state; the word is omitted
 *
 * The graph is not redrawn for a narrow viewport (docs/plans/seq-narrow-viewports.md); it stays
 * a horizontal scroll box and says that it scrolls, in two ways. An edge fade masks the side
 * that has more: where scroll-driven animations are supported the two fade widths follow the
 * box's own scroll position (none when the graph fits, so there is no scroll timeline); elsewhere
 * a static fade on the right edge. And below 768px a line of small prose follows a graph of more
 * than one column:
 *   <p class="seq-graph__hint">Scroll sideways to see the whole workflow.</p>
 * rendered by the same helper as the graph, hidden at 768px and up and omitted for a one-column
 * graph, which fits every supported viewport.
 */

.seq-graph {
  --_fade: var(--spacing-32);
  overflow-x: auto;
  max-width: 100%;
  padding-block: var(--spacing-8);
  mask-image: linear-gradient(to right, black calc(100% - var(--_fade)), transparent);
}

/* ---------- The edge fade that tracks scroll ----------
   --_fade-start and --_fade-end are the widths of the left and right fades. Registered, so the
   keyframes interpolate them; the timeline is the box's own horizontal scroll, which is
   inactive when nothing overflows, leaving both at their initial 0px. The mask is dropped
   under :focus-visible, where it would fade the ring drawn inside the box's edges. */
@property --_fade-start {
  syntax: "<length>";
  inherits: false;
  initial-value: 0px;
}
@property --_fade-end {
  syntax: "<length>";
  inherits: false;
  initial-value: 0px;
}

@supports (animation-timeline: scroll()) {
  .seq-graph {
    mask-image: linear-gradient(to right, transparent, black var(--_fade-start), black calc(100% - var(--_fade-end)), transparent);
    animation: seq-graph-fade linear both;
    animation-timeline: scroll(self inline);
  }
}

@keyframes seq-graph-fade {
  0%   { --_fade-start: 0px;          --_fade-end: var(--_fade); }
  10%  { --_fade-start: var(--_fade); }
  90%  { --_fade-end: var(--_fade); }
  100% { --_fade-start: var(--_fade); --_fade-end: 0px; }
}

.seq-graph:focus-visible {
  mask-image: none;
}

/* The hint under the graph: a phone reader is told the box scrolls; at 768px and up it is hidden. */
.seq-graph__hint {
  font-family: var(--font-family-body);
  font-size: var(--font-size-14);
  font-weight: var(--font-weight-400);
  color: var(--text-secondary);
}
@media (min-width: 768px) {
  .seq-graph__hint {
    display: none;
  }
}

/* A scroll container is reachable by keyboard only when focusable: the markup carries
   tabindex="0" and aria-labelledby on the graph, and the page ring is restated here, drawn
   inside, as 05-objects/_scroll.css does. */
.seq-graph:focus-visible {
  outline: var(--stroke-weight-2) solid var(--focus-ring);
  outline-offset: calc(-1 * var(--stroke-weight-2));
}

/* The drawing is set in the body face: a step name and a state word are read as words. */
.seq-graph svg {
  display: block;
  font-family: var(--font-family-body);
  font-size: var(--font-size-14);
  font-weight: var(--font-weight-400);
  font-variant-numeric: var(--numerals);
}

/* ---------- Edges ---------- */
.seq-graph__edge {
  fill: none;
  stroke: var(--border-strong);
  stroke-width: var(--stroke-weight-1);
}

.seq-graph__arrow {
  fill: var(--border-strong);
}

/* ---------- Nodes ---------- */
.seq-graph__box {
  fill: var(--background-surface-1);
  stroke: var(--border-default);
  stroke-width: var(--stroke-weight-1);
  rx: var(--corner-radius-xs);
}

.seq-graph__name {
  fill: var(--text-primary);
}

/* The state word: grey for pending and cancelled, the state colour otherwise, exactly as
   .seq-state (06-components/_state.css) colours its word's dot. */
.seq-graph__word {
  fill: var(--text-secondary);
}
.seq-graph__word[data-state="succeeded"] {
  fill: var(--state-succeeded);
}
.seq-graph__word[data-state="queued"],
.seq-graph__word[data-state="running"] {
  fill: var(--state-working);
}
.seq-graph__word[data-state="failed"],
.seq-graph__word[data-state="blocked"] {
  fill: var(--state-failed);
}
.seq-graph__word[data-state="cancelled"] {
  text-decoration: line-through;
}

/* ---------- The --plain variant: no state, no word ---------- */
.seq-graph--plain .seq-graph__word {
  display: none;
}
