/* 06 / How it works, automation 09 (invoice pipeline): overrides on top of flow.css.
   A gold key node, a red review branch (held for review), a green team node, a dashed month-end
   edge, the trace status line, the scroll hint, the legend, the example architecture lanes. */

/* ---------- Trace ---------- */

/* Red text on the dark ground: a lighter red than the fill, for 4.5:1 or better (fills keep --danger) */
#how {
  --ip-danger-text: #f26b6b;
}

/* The text and the status keep the room of the longest trace step (three lines of text, one line
   of status on wide screens, two on phones), so the diagram below never moves during a trace. */
#how .ip-flow-status {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
  letter-spacing: 0.04em;
  color: var(--ash);
  min-height: 1.5em;
}

#how .ip-flow-status.is-empty {
  visibility: hidden;
}

#how .flow-trace-text {
  max-width: 72ch;
  min-height: 4.05em;
  -webkit-line-clamp: 3;
}

#how .flow-caption {
  text-wrap: pretty;
}

/* ---------- Scroll hint: shown only where a region scrolls sideways ---------- */

#how .ip-flow-swipe {
  display: none;
  margin: 0 0 10px;
  padding: 12px 16px 0;
  color: var(--ash);
}

#how .ip-flow-swipe:has(+ .flow-scrollwrap.is-scrollable) {
  display: block;
}

/* ---------- Diagram grid: 6 node columns, 3 rows ----------
   Node columns are the odd tracks (1, 3, 5, 7, 9, 11) and the even tracks are 34px gaps. The node
   column in the markup is --c (1 to 6); the track is 2 * --c - 1. */

#how .flow-dia {
  grid-template-columns: minmax(0, 1fr) 34px minmax(0, 1fr) 34px minmax(0, 1fr) 34px minmax(0, 1fr) 34px minmax(0, 1fr) 34px minmax(0, 1fr);
  grid-template-rows: repeat(3, auto);
  column-gap: 0;
  row-gap: 34px;
  min-width: 1120px;
}

#how .flow-dia > .flow-node {
  grid-column: calc(var(--c) * 2 - 1);
  align-self: center;
  min-height: 112px;
}

/* The key is the legend in the footer strip; the diagram does not repeat it */
#how .flow-key {
  display: none;
}

/* Node captions: 10px minimum (the mono captions were 9px) */
#how .flow-node-s {
  font-size: 12px;
  line-height: 1.4;
}

/* A node already passed on the trace: a gold mark in its corner and a brighter border, so the
   path taken reads as a trace in the static and reduced-motion views too */
#how .flow-node.is-done {
  border-color: hsl(42 30% 94% / 0.42);
}

#how .flow-node.is-done::after {
  content: "";
  position: absolute;
  top: 12px;
  right: 12px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
}

#how .flow-node.ip-flow-node--key.is-done::after {
  box-shadow: 0 0 0 3px rgb(255 255 255 / 0.18);
}

#how .ip-flow-key-sw--team {
  border-color: var(--ok);
  background: hsl(152 60% 48% / 0.14);
}

/* Key node: the answer that closes the invoice is gold */
#how .flow-node.ip-flow-node--key {
  border-color: rgb(255 255 255 / 0.5);
}

#how .flow-node.ip-flow-node--key.is-done {
  border-color: rgb(255 255 255 / 0.7);
}

/* Tags sit on the card's top edge and are never wider than the card (9.5px minimum) */
#how .flow-node .ip-flow-tag-key {
  left: 6px;
  max-width: calc(100% - 12px);
  padding: 2px 6px;
  border-color: rgb(255 255 255 / 0.6);
  color: var(--accent);
  font-size: 10px;
  letter-spacing: 0;
  white-space: nowrap;
}

/* Review node: the card's review tag is always visible; lit, the card turns red */
#how .ip-flow-review {
  align-self: flex-start;
  max-width: 100%;
  margin-bottom: 2px;
  padding: 2px 6px;
  border: 1px solid hsl(0 70% 56% / 0.5);
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  line-height: 1.3;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ip-danger-text);
  white-space: nowrap;
}

#how .flow-node.ip-flow-node--review.is-on {
  border-color: var(--danger);
  background: hsl(0 70% 52% / 0.07);
  box-shadow: 0 0 0 4px hsl(0 70% 52% / 0.12), 0 18px 40px -24px hsl(0 70% 52% / 0.6);
}

#how .flow-node.ip-flow-node--review.is-done {
  border-color: hsl(0 70% 52% / 0.6);
  background: hsl(0 70% 52% / 0.07);
}

#how .flow-node.ip-flow-node--review.is-on .flow-node-l,
#how .flow-node.ip-flow-node--review.is-done .flow-node-l {
  color: var(--bone);
}

#how .flow-node.ip-flow-node--review.is-on .ip-flow-review,
#how .flow-node.ip-flow-node--review.is-done .ip-flow-review {
  border-color: var(--danger);
}

/* Team node: a person steps in. The tag sits inside the card, under the top edge. */
#how .flow-node.ip-flow-node--team {
  border-color: hsl(152 60% 48% / 0.45);
}

#how .flow-node.ip-flow-node--team.is-done {
  border-color: hsl(152 60% 48% / 0.6);
}

#how .flow-node.ip-flow-node--team.is-on {
  border-color: var(--ok);
  background: hsl(152 60% 48% / 0.07);
  box-shadow: 0 0 0 4px hsl(152 60% 48% / 0.12), 0 18px 40px -24px hsl(152 60% 48% / 0.6);
}

#how .ip-flow-team {
  align-self: flex-start;
  max-width: 100%;
  margin-bottom: 2px;
  padding: 2px 6px;
  border: 1px solid hsl(152 60% 48% / 0.6);
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 10px;
  line-height: 1.3;
  letter-spacing: 0;
  text-transform: uppercase;
  color: var(--ok);
  white-space: nowrap;
}

/* Team edges: green when idle-but-reached, brighter once run */
#how .flow-e.ip-e-team {
  stroke: hsl(152 60% 48% / 0.35);
}

#how .flow-e.ip-e-team.is-done {
  stroke: hsl(152 60% 48% / 0.75);
}

#how .flow-run.ip-run-team {
  stroke: var(--ok);
}

/* Review edge: the base stays neutral; its run is red, and its arrowhead turns red once done */
#how .flow-arrow.ip-e-review.is-done {
  stroke: var(--danger);
}

#how .flow-run.ip-run-review {
  stroke: var(--danger);
}

/* ---------- Legend ---------- */

#how .ip-flow-dot--team {
  background: var(--ok);
}

/* The loop key is a drawn swatch in the same dash pattern as the month-end edge */
#how .flow-legend-r {
  margin-left: auto;
}

#how .ip-flow-loopkey {
  display: block;
  flex: none;
  width: 22px;
  height: 8px;
  color: var(--bone-70);
  overflow: visible;
}

/* ---------- Edge labels: ink pills on their own edge, or set beside the run ---------- */

#how .flow-elabel {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  fill: var(--bone-70);
}

#how .flow-elab-bg {
  fill: var(--ink);
}

/* ---------- Diagram, phone sizes ---------- */

/* Touch: the scenario buttons are 44px tall on tablets and phones */
@media (max-width: 834px) {
  #how .flow-seg-b {
    min-height: 44px;
  }
}

@media (max-width: 640px) {
  #how .flow-seg {
    display: flex;
    flex-wrap: wrap;
    width: 100%;
    border-radius: 18px;
  }

  #how .flow-seg-b {
    flex: 1 1 auto;
    text-align: center;
  }

  #how .ip-flow-status {
    min-height: 3em;
  }
}

/* ---------- Example architecture ---------- */

#how .ip-flow-badge {
  flex: none;
  margin-left: auto;
  padding: 3px 9px;
  border: 1px solid rgb(255 255 255 / 0.4);
  border-radius: 999px;
  font-size: 11.5px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent);
  white-space: nowrap;
}

#how .flow-win-bar .flow-win-title {
  min-width: 0;
}

/* Phones: the badge carries the label; the window title would only be cut to "INVOIC…" */
@media (max-width: 480px) {
  #how .flow-win-bar .flow-win-title {
    display: none;
  }
}

#how .ip-flow-canvas {
  width: 1200px;
  height: 420px;
}

#how .ip-flow-canvas .flow-cn {
  width: 200px;
  min-height: 56px;
  height: auto;
  padding: 10px 12px 10px 8px;
}

#how .ip-flow-canvas .flow-cn-t b {
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  line-height: 1.25;
}

/* Sub-nodes grow with their text, keeping 10px of air above and below it */
#how .ip-flow-canvas .flow-cn--sub {
  width: 172px;
  height: auto;
  min-height: 48px;
  padding: 10px 14px 10px 8px;
  border-radius: 24px;
}

#how .ip-flow-canvas .flow-cn--sub .flow-cn-t small {
  font-size: 12px;
  line-height: 1.3;
  text-wrap: balance;
}

/* ---------- Static / reduced motion ---------- */

#how.is-static .flow-node,
#how.is-static .flow-e,
#how.is-static .flow-run {
  transition: none !important;
}
