/* 06 / How it works, automation 12 (competitor price monitor): overrides on top of flow.css.
   Gold key node, green team nodes, a 6 x 3 diagram grid (10 nodes), the weekly summary edges,
   the trace status line, the scroll hint, the legend loop key and the example architecture. */

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

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

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

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

#how .flow-caption {
  margin-top: 20px;
  text-wrap: pretty;
}

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

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

#how .pm-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). The 30px tracks are the gaps between the
   early nodes, the 104px track holds the "priced below market" label (two lines) and the 44px
   track is where the Monday summary's three edges meet. Every node has the same height, so each
   row's centres line up. */

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

/* 124px is the design height. A node whose text needs more room (the Monday summary, at the
   scaled 1280 width) grows; its row stays centred, so the edges still meet every node. */
#how .flow-dia > .flow-node {
  align-self: center;
  min-height: 124px;
}

/* Key: "How to read it" fills the empty top-left cell, above the first node */
#how .flow-key {
  grid-column: 1;
  grid-row: 1;
  align-self: center;
  padding-top: 0;
}

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

/* Nodes with a tag on their top edge get room above the title, so the tag never touches it */
#how .flow-node:has(> .flow-node-tag) {
  padding-top: 18px;
}

/* Key node: the alert that starts the response is gold */
#how .flow-node.pm-flow-node--key {
  border-color: rgb(255 255 255 / 0.5);
}

#how .flow-node.pm-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 .pm-flow-tag-key {
  border-color: rgb(255 255 255 / 0.6);
  color: var(--accent);
  font-size: 12px;
  letter-spacing: 0.04em;
  max-width: calc(100% - 12px);
  white-space: nowrap;
}

/* The Monday summary's tag is neutral: it is a schedule, not an alert */
#how .pm-flow-tag-week {
  border-color: hsl(34 10% 30%);
  color: var(--ash);
  font-size: 12px;
  letter-spacing: 0.04em;
  max-width: calc(100% - 12px);
  white-space: nowrap;
}

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

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

#how .flow-node.pm-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 .pm-flow-team {
  align-self: flex-start;
  max-width: 100%;
  margin-bottom: 2px;
  padding: 2px 7px;
  border: 1px solid hsl(152 60% 48% / 0.6);
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.3;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ok);
  white-space: normal;
}

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

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

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

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

#how .flow-legend-i,
#how .flow-legend-r {
  font-size: 12px;
}

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

/* The loop key is a drawn swatch in the same dash pattern as the weekly edges */
/* On a narrow legend the source line moves to its own row, pushed to the right */
#how .flow-legend-r {
  margin-left: auto;
}

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

/* ---------- Edge labels: ink pills on their own edge ---------- */

#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 ---------- */

@media (max-width: 640px) {
  /* Two columns; "Monday summary" takes the full last row. Every target is 44px tall. */
  #how .flow-seg {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 3px;
    width: 100%;
    border-radius: 22px;
  }

  #how .flow-seg-b {
    min-height: 44px;
    padding: 0 10px;
    text-align: center;
  }

  #how .flow-seg-b:last-child {
    grid-column: 1 / -1;
  }

  /* The architecture window keeps its title whole on phones: the prefix goes, the example stays */
  #how .flow-win-pm {
    display: none;
  }

  #how .flow-win-title {
    letter-spacing: 0.08em;
  }
}

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

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

#how .flow-cn {
  width: 200px;
}

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

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

/* ---------- Phone: the status reserves two lines (the longest status wraps there) ---------- */

@media (max-width: 640px) {
  /* Three lines on phones: the longest note wraps to three at 390 */
  #how .pm-flow-status {
    min-height: calc(3 * 1.5em);
  }
}
