/* Hero system diagram.
   Static default = every node lit, "Booked" amber (what no-JS and reduced-motion users get).
   html.motion (set in <head> unless prefers-reduced-motion) switches to the animated state:
   nodes start dim and light up as the amber lead reaches them. Wires are pure CSS. */

.flow { margin: 0; }
.flow-panel {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-panel);
  padding: clamp(var(--space-5), 3vw, var(--space-6));
}

.flow-nodes {
  --gap-x: 2.25rem;
  --gap-y: 1.75rem;
  --node-h: 3.5rem;
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  row-gap: var(--gap-y);
}
.flow-step {
  position: relative;
  display: flex;
  justify-content: center;
  height: var(--node-h);
}

/* ----- wires (mobile first: vertical, centre to centre) ----- */
.flow-step::after {
  content: "";
  position: absolute;
  z-index: 0;
  left: calc(50% - 0.5px);
  top: 50%;
  width: 1px;
  height: calc(100% + var(--gap-y));
  background: var(--edge);
  transition: background-color 0.3s ease;
}
.flow-step:last-child::after { display: none; }
.motion .flow-step.wire-on::after { background: var(--accent); }

/* ----- node ----- */
.node {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  width: min(100%, 14rem);
  height: var(--node-h);
  padding: 0 var(--space-4);
  background: var(--lit);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.7);
  box-shadow: 0 0 24px -8px rgba(255, 255, 255, 0.5);
  border-radius: var(--radius-node);
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 500;
  letter-spacing: -0.01em;
  line-height: 1.1;
  cursor: pointer;
  transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease, box-shadow 0.3s ease;
}
.node svg {
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
  color: var(--link);
  transition: color 0.3s ease;
}
.node:hover { border-color: var(--text); }

/* booked state: the only other place amber appears */
.node--final { background: var(--lead); border-color: var(--lead); color: var(--lead-ink); box-shadow: 0 0 26px -6px rgba(var(--ember), 0.7); }
.node--final svg { color: var(--lead-ink); }
.node--final:hover { border-color: #fff; }

/* animated mode: dim until lit */
.motion .node:not(.is-lit) { background: var(--surface); border-color: var(--line-strong); color: var(--text-muted); box-shadow: none; }
.motion .node:not(.is-lit) svg { color: var(--text-muted); }

/* ----- the lead ----- */
.lead-dot {
  display: none;
  position: absolute;
  left: 0;
  top: 0;
  z-index: 0; /* passes behind nodes: the node lights as the lead arrives */
  width: 18px;
  height: 18px;
  margin: -9px 0 0 -9px;
  border-radius: 50%;
  background: var(--lead);
  border: 2px solid var(--lead-ink);
  box-shadow: 0 0 0 6px rgba(var(--ember), 0.3), 0 0 22px rgba(var(--ember), 0.7);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  will-change: transform;
}
.motion .lead-dot { display: block; }
.lead-dot.is-on { opacity: 1; }

/* ----- readout ----- */
.flow-readout {
  margin: var(--space-5) 0 0;
  padding-top: var(--space-4);
  border-top: 1px dashed var(--line-strong);
  min-height: 4.5em;
  color: var(--text-muted);
  font-size: var(--step--1);
  line-height: 1.5;
}
.flow-readout strong { color: var(--text); }
html:not(.js) .flow-readout { display: none; }

.flow-caption {
  margin-top: var(--space-3);
  max-width: 46ch;
  color: var(--text-muted);
  font-size: var(--step--1);
}

/* ----- wide: serpentine 3 x 2 patch-panel layout ----- */
@media (min-width: 40rem) {
  .flow-nodes {
    --gap-x: 2.5rem;
    --gap-y: 2.5rem;
    --node-h: 5.5rem;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    column-gap: var(--gap-x);
  }
  .flow-step:nth-child(4) { grid-column: 3; grid-row: 2; }
  .flow-step:nth-child(5) { grid-column: 2; grid-row: 2; }
  .flow-step:nth-child(6) { grid-column: 1; grid-row: 2; }

  .flow-step[data-wire="right"]::after {
    left: 50%;
    top: calc(50% - 1px);
    width: calc(100% + var(--gap-x));
    height: 1px;
  }
  .flow-step[data-wire="left"]::after {
    left: auto;
    right: 50%;
    top: calc(50% - 0.5px);
    width: calc(100% + var(--gap-x));
    height: 1px;
  }
  /* data-wire="down" keeps the vertical default */

  .node {
    flex-direction: column;
    gap: var(--space-2);
    width: min(100%, 8.5rem);
    padding: 0 var(--space-2);
  }
}
