/* 06 / How it works, automation 05 (AI voice receptionist): overrides on top of flow.css.
   Gold key node, green team node, red urgent path for the emergency call, a 6 x 4 diagram grid,
   the trace status line, the scroll hint, the legend, and the example architecture lanes. */

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

/* The status keeps one reserved line, so the diagram never moves during a trace */
#how .vr-flow-status {
  display: none;
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
  letter-spacing: 0.04em;
  color: var(--ash);
  min-height: 1.5em;
}

#how .vr-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 .vr-flow-swipe {
  display: none;
  margin: 0 0 10px;
  padding: 12px 16px 0;
  color: var(--ash);
}

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

/* ---------- Diagram grid: 6 node columns, 4 rows ----------
   Node columns are the odd tracks (1, 3, 5, 7, 9, 11); the even tracks are 34px gaps. The gap
   between "understand" and "info" is wider (100px) so the "has a question" label fits on its
   own edge. The gap between "booked" and "summary" (track 10) is where the elbow runs down. */

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

#how .flow-dia > .flow-node {
  align-self: center;
  height: 116px;
  padding: 12px 12px;
}

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

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

/* Key node: the booked job is the gold answer */
#how .flow-node.vr-flow-node--key {
  border-color: rgb(255 255 255 / 0.5);
}

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

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

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

#how .flow-node.vr-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 .vr-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: 11.5px;
  line-height: 1.3;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ok);
  white-space: normal;
}

/* Urgent path: the emergency node and its edges run red. Set after the team rules so an
   urgent team node (the transfer) reads red. The state sticks until the trace resets. */
#how .flow-dia > .flow-node.is-urgent,
#how .flow-dia > .flow-node.vr-flow-node--team.is-urgent {
  border-color: var(--danger);
  background: hsl(0 70% 56% / 0.07);
  box-shadow: 0 0 0 4px hsl(0 70% 56% / 0.14);
}

#how .flow-dia > .flow-node.is-urgent.is-on {
  animation: vr-flow-pulse 0.9s var(--ease-out) 2;
}

@keyframes vr-flow-pulse {
  0% { box-shadow: 0 0 0 4px hsl(0 70% 56% / 0.14); }
  50% { box-shadow: 0 0 0 12px hsl(0 70% 56% / 0.22); }
  100% { box-shadow: 0 0 0 4px hsl(0 70% 56% / 0.14); }
}

#how .flow-run.vr-run-urgent {
  stroke: var(--danger);
}

/* ---------- 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-elabel.vr-elabel-urgent {
  fill: hsl(0 70% 66% / 0.8);
}

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

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

#how .flow-legend-r {
  margin-left: auto;
}

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

#how .vr-flow-redline {
  display: block;
  flex: none;
  width: 14px;
  height: 2px;
  border-radius: 2px;
  background: var(--danger);
}

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

#how .flow-canvas {
  width: 1300px;
  height: 440px;
}

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

@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 .flow-dia {
    padding: 36px 20px 30px;
    min-width: 1080px;
    column-gap: 0;
  }

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

  #how .flow-trace-text {
    min-height: 6.1em;
    -webkit-line-clamp: 6;
  }
}

/* ---------- Static and reduced motion: the finished trace shows no pulse ---------- */

#how .vr-flow-final .flow-node.is-urgent.is-on,
#how.is-static .flow-node.is-urgent.is-on {
  animation: none;
}

@media (prefers-reduced-motion: reduce) {
  #how .flow-node.is-urgent.is-on {
    animation: none;
  }
}

/* ---------- Phones: the scenario control is a 2 x 2 grid of 44px buttons ---------- */

@media (max-width: 640px) {
  #how .flow-seg-b {
    min-height: 44px;
  }
}

@media (max-width: 480px) {
  #how .flow-seg {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
    gap: 2px;
    border-radius: 18px;
  }
}

/* ---------- Phones: the architecture stacks into one column, lane by lane, in reading order.
   The connector lines are drawn for the wide canvas, so they are hidden here. ---------- */

@media (max-width: 640px) {
  #how .flow-canvas {
    width: auto;
    height: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 8px 16px 20px;
    background-image: none;
  }

  #how .flow-canvas-edges {
    display: none;
  }

  #how .flow-sticky {
    position: relative;
    left: auto;
    top: auto;
    width: auto;
    height: auto;
    margin-top: 10px;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: none;
  }

  #how .flow-sticky-t {
    position: static;
    display: block;
    padding: 0 0 4px;
    font-size: 12px;
    color: var(--bone-70);
  }

  #how .flow-cn {
    position: relative;
    left: auto;
    top: auto;
    width: 100%;
    height: auto;
    min-height: 52px;
  }

  #how .flow-cn--sub {
    width: calc(100% - 16px);
    margin-left: 16px;
    border-radius: 12px;
  }

  #how .flow-canvas > :nth-child(2) { order: 1; }
  #how .flow-canvas > :nth-child(6) { order: 2; }
  #how .flow-canvas > :nth-child(3) { order: 3; }
  #how .flow-canvas > :nth-child(7) { order: 4; }
  #how .flow-canvas > :nth-child(8) { order: 5; }
  #how .flow-canvas > :nth-child(9) { order: 6; }
  #how .flow-canvas > :nth-child(10) { order: 7; }
  #how .flow-canvas > :nth-child(4) { order: 8; }
  #how .flow-canvas > :nth-child(11) { order: 9; }
  #how .flow-canvas > :nth-child(5) { order: 10; }
  #how .flow-canvas > :nth-child(12) { order: 11; }
  #how .flow-canvas > :nth-child(13) { order: 12; }
  #how .flow-canvas > :nth-child(14) { order: 13; }
  #how .flow-canvas > :nth-child(15) { order: 14; }
}
