/* Scale — "From data to result" (home): the steps between data and a result, and who does each.
   A sibling of the product's case-file spine: 24px nodes on a 2px rail, ink once done, dashed while still to
   come, one blue ring for "needs you". Shape tells who: agents are ink rounded squares, the person is a circle.
   The markup is the finished state. flow.js adds .is-armed for the state before (today) and plays from one to
   the other; everything that moves is a transform, an opacity or a colour, so the two states share their boxes. */

.flow {
  --flow-gap: 36px;    /* rail between two nodes */
  --flow-air: 4px;     /* between a node and the rail, as in the product's spine (flow.js reads it) */
  --flow-lane: 30px;   /* the side label and its bracket */
  --flow-name: 136px;  /* the step names' column */
  --flow-who: 236px;   /* below this the "who" wraps under the name */
  --flow-dash: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 2 8' preserveAspectRatio='none'%3E%3Crect y='2' width='2' height='4' rx='1'/%3E%3C/svg%3E");
  container: flow / inline-size;
  width: 100%;
  max-width: 572px;
  min-width: 0;
}

.flow [hidden] { display: none; }

.flow-track { position: relative; isolation: isolate; }

/* ---------- A step: node, name, who ---------- */
.flow-step {
  position: relative;
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  column-gap: 14px;
  align-items: start;
  padding-bottom: var(--flow-gap);
}
.flow-end { padding-bottom: 0; }

/* The rail to the next node: dashed while the step is still to come, ink once it is done */
.flow-step::before,
.flow-step::after {
  content: "";
  position: absolute;
  left: 11px;
  top: calc(24px + var(--flow-air));
  bottom: var(--flow-air);
  width: 2px;
}
.flow-step::before {
  background: var(--faint);
  -webkit-mask: var(--flow-dash) 0 0 / 2px 8px no-repeat round;
  mask: var(--flow-dash) 0 0 / 2px 8px no-repeat round;
  opacity: 0;
}
.flow-step::after {
  border-radius: 2px;
  background: var(--ink);
  transform-origin: 50% 0;
  transform: scaleY(var(--fill, 1));
}
.flow-end::before,
.flow-end::after { content: none; }

.flow-node {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border: 1.5px dashed var(--ink);   /* the dashes show only while the node is hollow */
  border-radius: 50%;
  background: var(--ink);
  color: var(--sheet);
}
.flow-node .i { width: 13px; height: 13px; stroke-width: 2.2; }
.flow-end .flow-node { border: 2px solid var(--ink); }

/* "Needs you": the blue ring with its centre dot, shown while the approval waits */
.flow-you .flow-node::before,
.flow-you .flow-node::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  opacity: var(--needs, 0);
}
.flow-you .flow-node::before {
  inset: -1.5px;
  border: 2px solid var(--accent);
  background: var(--sheet);
}
.flow-you .flow-node::after {
  left: 50%;
  top: 50%;
  width: 8px;
  height: 8px;
  margin: -4px 0 0 -4px;
  background: var(--accent);
}

.flow-what {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 16px;
  min-width: 0;
}
.flow-name {
  flex: 0 0 var(--flow-name);
  font-size: 17px;
  font-weight: 600;
  line-height: 24px;
  letter-spacing: -0.01em;
  color: var(--ink);
}
.flow-who {
  flex: 1 1 var(--flow-who);
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  min-height: 24px;
  font-size: 14.5px;
  line-height: 20px;
  color: var(--muted);
}
.flow-who b { font-weight: 550; color: var(--ink); }
.flow-start .flow-who,
.flow-end .flow-who { flex-basis: calc(var(--flow-who) + var(--flow-lane)); }
.flow-end .flow-who { color: var(--ink-2); }

.flow .agent-mark { width: 24px; height: 24px; border-radius: 6px; flex: none; }
.flow .agent-mark .i { width: 14px; height: 14px; stroke-width: 1.8; }
.flow .person { width: 24px; height: 24px; flex: none; box-shadow: none; }
.flow .person .i { width: 14px; height: 14px; stroke-width: 1.8; }

.flow-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 26px;
  margin: -1px 0;
  padding: 0 12px 0 10px;
  border-radius: 999px;
  background: var(--tint-2);
  color: var(--accent-ink);
  font-size: 13.5px;
  font-weight: 550;
  white-space: nowrap;
}
.flow-pill i { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); flex: none; }

.flow-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--positive); flex: none; }

/* ---------- The steps in between, and the label that runs along them ---------- */
.flow-between {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--flow-lane);
}
.flow-inner { grid-area: 1 / 1; }
.flow-era {
  grid-area: 1 / 2;
  display: grid;
  grid-template-columns: 6px minmax(0, 1fr);
  column-gap: 6px;
  margin-bottom: var(--flow-gap);
}
.flow-era::before {
  content: "";
  grid-area: 1 / 1;
  border: 1px solid var(--rule-2);
  border-left: 0;
}
.flow-era span {
  grid-area: 1 / 2;
  place-self: center;
  writing-mode: vertical-rl;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 500;
  line-height: 18px;
  color: var(--ink-2);
}
.flow-era .flow-era-then { color: var(--muted); opacity: 0; }

/* ---------- The mark that travels (added by flow.js) ---------- */
.flow-tile {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 2;
  width: 24px;
  height: 24px;
  opacity: 0;
  pointer-events: none;
}
.flow-tile svg { width: 100%; height: 100%; }

/* ---------- Summary and replay ---------- */
.flow-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px 16px;
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--rule);
}
.flow-sum {
  flex: 1 1 280px;
  font-family: var(--display);
  font-weight: 650;
  font-size: 1.125rem;
  line-height: 1.3;
  letter-spacing: -0.012em;
}
.flow-sum span { display: inline-block; }

.flow-replay {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: -4px 0 -4px auto;
  padding: 8px 0;
  border: 0;
  background: none;
  color: var(--muted);
  font: 500 13px/1 var(--font);
  cursor: pointer;
  visibility: hidden;
  opacity: 0;
  transition: opacity 320ms var(--ease), color 140ms var(--ease);
}
.flow-replay .i { width: 14px; height: 14px; }
.flow-replay:hover { color: var(--ink); }
.flow.can-replay .flow-replay { visibility: visible; opacity: 1; }
/* The button carries the hidden attribute until flow.js can replay; from then on it keeps its place in both states. */

/* ---------- The state before: today ----------
   Still to come is dashed and hollow, as in the spine. The dashes are Slate Faint (the mini spine's hollow node)
   rather than Hairline Strong: on the canvas they are the whole picture of "today" and have to be seen. */
.flow.is-armed .flow-step { --fill: 0; }
.flow.is-armed .flow-step::before { opacity: 1; }
.flow.is-armed .flow-between .flow-node { border-color: var(--faint); background-color: var(--canvas); }
.flow.is-armed .flow-end .flow-node { background-color: var(--canvas); }
.flow.is-armed .flow-you .flow-node { --needs: 0; }
.flow.is-armed .flow-node .i { stroke-dasharray: 23; stroke-dashoffset: -23; }
.flow.is-armed .flow-between .flow-name { color: var(--muted); }
.flow.is-armed .flow-between .flow-who,
.flow.is-armed .flow-end .flow-who { opacity: 0; transform: translateX(10px); }
.flow.is-armed .flow-era-now { opacity: 0; }
.flow.is-armed .flow-era-then { opacity: 1; }
.flow.is-armed .flow-sum { opacity: 0; transform: translateY(8px); }

/* ---------- Width of the figure, not of the window ---------- */
@container flow (min-width: 540px) {
  .flow-track { --flow-gap: 40px; }
}
@container flow (max-width: 455px) {
  /* the "who" has wrapped under the name, so the rows are taller and need less rail */
  .flow-track { --flow-gap: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  .flow-replay { display: none; }
}
@media print {
  .flow-replay, .flow-tile { display: none; }
}
