/* 05 / How it works — workflow diagram traced along the sample chat, and the n8n canvas */

#how .flow-stage {
  margin-top: 8px;
}

#how .flow-inner {
  display: flex;
  flex-direction: column;
}

/* ---------- Now-playing bar ---------- */

#how .flow-trace {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
}

#how .flow-trace-main {
  display: grid;
  gap: 6px;
  min-width: 0;
  flex: 1;
}

#how .flow-trace-kicker {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin: 0;
}

#how .flow-trace-line {
  display: flex;
  align-items: baseline;
  gap: 14px;
  margin: 0;
}

#how .flow-trace-who {
  display: inline-flex;
  align-items: baseline;
  gap: 10px;
  color: var(--accent);
}

#how .flow-trace-note {
  color: var(--ash);
}

#how .flow-trace-note::before {
  content: "·";
  margin-right: 10px;
}

#how .flow-trace-count {
  padding-left: 14px;
  border-left: 1px solid var(--line);
  color: var(--ash);
}

#how .flow-trace-text {
  margin: 0;
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 500;
  letter-spacing: -0.015em;
  line-height: 1.35;
  color: var(--bone);
  max-width: 62ch;
  min-height: 2.7em;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  transition: opacity 0.25s var(--ease-std);
}

#how .flow-trace-text.is-swapping {
  opacity: 0;
}

#how .flow-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
}

#how .flow-ctl {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 500;
  color: var(--bone);
  transition: border-color 0.2s, color 0.2s;
}

#how .flow-ctl[data-flow-act="toggle"] {
  min-width: 96px;
}

#how .flow-ctl:hover {
  border-color: var(--accent);
  color: var(--accent);
}

#how .flow-ctl svg {
  width: 14px;
  height: 14px;
}

#how .flow-i-play {
  display: none;
}

#how .flow-ctl[data-paused="true"] .flow-i-pause {
  display: none;
}

#how .flow-ctl[data-paused="true"] .flow-i-play {
  display: block;
}

#how .flow-seg {
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 999px;
}

#how .flow-seg-b {
  min-height: 32px;
  padding: 0 14px;
  border-radius: 999px;
  font-family: var(--font-display);
  font-size: 15px;
  color: var(--ash);
  transition: color 0.2s, background-color 0.2s;
}

#how .flow-seg-b:hover {
  color: var(--bone);
}

#how .flow-seg-b[aria-pressed="true"] {
  background: var(--bone);
  color: var(--ink);
}

/* ---------- Scroll containers (diagram and canvas) ---------- */

#how .flow-scrollwrap {
  position: relative;
}

#how .flow-dia-scroll,
#how .flow-canvas-scroll {
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
  -webkit-overflow-scrolling: touch;
}

#how .flow-scrollwrap.is-scrollable::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 48px;
  pointer-events: none;
  background: linear-gradient(to right, transparent, var(--ink));
  transition: opacity 0.3s;
}

#how .flow-scrollwrap--elev.is-scrollable::after {
  background: linear-gradient(to right, transparent, var(--surface));
}

#how .flow-scrollwrap.is-scrollable.is-end::after {
  opacity: 0;
}

/* ---------- Diagram ---------- */

#how .flow-dia {
  position: relative;
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  grid-template-rows: repeat(4, auto);
  column-gap: 34px;
  row-gap: 34px;
  padding: 40px 30px 36px;
  min-width: 1120px;
}

#how .flow-edges {
  position: absolute;
  left: 0;
  top: 0;
  overflow: visible;
  pointer-events: none;
}

#how .flow-node {
  position: relative;
  z-index: 1;
  min-width: 0;
  grid-column: var(--c);
  grid-row: var(--r);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  min-height: 74px;
  padding: 12px 13px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  transition: border-color 0.35s var(--ease-std), background-color 0.35s var(--ease-std), box-shadow 0.45s var(--ease-out), transform 0.45s var(--ease-out);
}

#how .flow-node-l {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 500;
  letter-spacing: -0.015em;
  line-height: 1.2;
  /* Long step names (appointment, availability) break with a hyphen rather than spill out of a
     narrow box; words under 10 letters never break. */
  hyphens: auto;
  hyphenate-limit-chars: 10 4 4;
  color: var(--bone-80);
  transition: color 0.35s;
}

#how .flow-node-s {
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.4;
  letter-spacing: 0;
  text-transform: uppercase;
  color: var(--ash);
}

#how .flow-node-tag {
  position: absolute;
  left: 12px;
  top: 0;
  transform: translateY(-50%);
  padding: 2px 7px;
  border: 1px solid hsl(0 70% 56% / 0.55);
  border-radius: 999px;
  background: var(--ink);
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--danger);
  white-space: nowrap;
}

#how .flow-node--danger {
  border-color: hsl(0 70% 56% / 0.45);
}

#how .flow-node.is-done {
  background: var(--elev);
  border-color: hsl(34 10% 24%);
}

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

#how .flow-node.is-on {
  border-color: var(--accent);
  background: rgb(255 255 255 / 0.07);
  box-shadow: 0 0 0 4px rgb(255 255 255 / 0.1), 0 18px 40px -24px rgb(255 255 255 / 0.6);
  transform: translateY(-2px);
}

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

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

#how .flow-node--danger.is-done {
  border-color: hsl(0 70% 56% / 0.6);
}

/* Edges (drawn by flow.js) */

#how .flow-e {
  fill: none;
  stroke: hsl(34 10% 25%);
  stroke-width: 1.25;
  transition: stroke 0.4s;
}

#how .flow-e.is-dashed {
  stroke-dasharray: 3 4;
}

#how .flow-e.is-done {
  stroke: hsl(42 30% 94% / 0.32);
}

#how .flow-e--danger {
  stroke: hsl(0 70% 56% / 0.35);
}

#how .flow-e--danger.is-done {
  stroke: hsl(0 70% 56% / 0.7);
}

#how .flow-run {
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.75;
  stroke-linecap: round;
  opacity: 0;
  transition: stroke-dashoffset 0.42s cubic-bezier(0.45, 0, 0.25, 1), opacity 0.5s var(--ease-std);
}

#how .flow-run.is-run {
  opacity: 1;
}

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

#how .flow-elabel {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  fill: var(--ash);
}

#how .flow-elabel--danger {
  fill: hsl(0 70% 66%);
}

#how .flow-arrow {
  fill: none;
  stroke-width: 1.25;
  stroke-linecap: round;
  stroke-linejoin: round;
}

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

#how .flow-legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 24px;
  padding: 14px 22px;
  border-top: 1px solid var(--line);
}

#how .flow-legend-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 24px;
}

#how .flow-legend-i {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

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

#how .flow-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

#how .flow-dot--gold {
  background: var(--accent);
}

#how .flow-dot--danger {
  background: var(--danger);
}

/* ---------- n8n window ---------- */

#how .flow-fig {
  margin-top: 28px;
}

#how .flow-win-inner {
  background: var(--surface);
}

#how .flow-win-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 11px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--ink);
}

#how .flow-win-dots {
  display: inline-flex;
  gap: 6px;
}

#how .flow-win-dots i {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  border: 1px solid var(--line);
}

#how .flow-win-title {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#how .flow-win-active {
  color: var(--ok);
}

#how .flow-win-active::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  margin: 0 6px 1px 2px;
  border-radius: 50%;
  background: var(--ok);
}

#how .flow-canvas {
  position: relative;
  width: 1320px;
  height: 556px;
  margin: 0 auto;
  background-image: radial-gradient(hsl(42 30% 94% / 0.09) 1px, transparent 1.3px);
  background-size: 20px 20px;
  background-position: 6px 6px;
}

#how .flow-canvas-edges {
  position: absolute;
  left: 0;
  top: 0;
  overflow: visible;
  pointer-events: none;
}

#how .flow-sticky {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: var(--w);
  height: var(--h);
  border: 1px dashed hsl(42 30% 94% / 0.12);
  border-radius: 10px;
  background: hsl(42 30% 94% / 0.015);
}

#how .flow-sticky-t {
  position: absolute;
  left: 14px;
  top: 10px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ash);
}

#how .flow-cn {
  position: absolute;
  left: var(--x);
  top: var(--y);
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 176px;
  height: 52px;
  padding: 0 12px 0 8px;
  border: 1px solid hsl(34 10% 25%);
  border-radius: 8px;
  background: var(--elev-2);
  transition: border-color 0.35s var(--ease-std), box-shadow 0.45s var(--ease-out), background-color 0.35s;
}

#how .flow-cn[data-cn^="wa-trigger"],
#how .flow-cn[data-cn="schedule"] {
  border-radius: 26px 8px 8px 26px;
  padding-left: 10px;
}

#how .flow-cn-ico {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  flex: none;
  border-radius: 6px;
  background: var(--elev);
  color: var(--bone-70);
}

#how .flow-cn-ico svg {
  width: 17px;
  height: 17px;
}

#how .flow-cn-t {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

#how .flow-cn-t b {
  font-family: var(--font-sans);
  font-size: 14.5px;
  font-weight: 600;
  letter-spacing: -0.005em;
  color: var(--bone);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#how .flow-cn-t small {
  font-size: 12.5px;
  line-height: 1.25;
  color: var(--ash);
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

#how .flow-cn--sub {
  width: auto;
  height: 36px;
  padding: 0 14px 0 6px;
  border-radius: 999px;
  border-style: dashed;
  background: var(--elev);
}

#how .flow-cn--sub .flow-cn-ico {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--elev-2);
}

#how .flow-cn--sub .flow-cn-ico svg {
  width: 14px;
  height: 14px;
}

#how .flow-cn--sub .flow-cn-t b {
  font-size: 13.5px;
  font-weight: 500;
}

#how .flow-cn.is-on {
  border-color: var(--accent);
  border-style: solid;
  box-shadow: 0 0 0 3px rgb(255 255 255 / 0.16);
}

#how .flow-cn.is-on .flow-cn-ico {
  color: var(--accent);
}

#how .flow-cn.is-on-danger {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px hsl(0 70% 56% / 0.16);
}

#how .flow-cn.is-on-danger .flow-cn-ico {
  color: var(--danger);
}

#how .flow-ce {
  fill: none;
  stroke: hsl(36 8% 60% / 0.5);
  stroke-width: 1.5;
}

#how .flow-ce--sub {
  stroke: hsl(36 8% 60% / 0.4);
  stroke-dasharray: 4 4;
}

#how .flow-ch-in {
  fill: hsl(36 8% 60% / 0.7);
}

#how .flow-ch-out {
  fill: var(--elev-2);
  stroke: hsl(36 8% 60% / 0.7);
  stroke-width: 1.25;
}

#how .flow-ch-sub {
  fill: var(--elev-2);
  stroke: hsl(36 8% 60% / 0.6);
  stroke-width: 1.25;
}

#how .flow-clabel {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  fill: var(--ash);
}

#how .flow-caption {
  margin-top: 16px;
  max-width: 62ch;
  font-size: 1.0625rem;
  line-height: 1.6;
  color: var(--ash);
}

#how .flow-foot {
  margin-top: 28px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

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

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

@media (prefers-reduced-motion: reduce) {
  #how .flow-node,
  #how .flow-e,
  #how .flow-run,
  #how .flow-trace-text,
  #how .flow-cn {
    transition: none !important;
  }

  #how .flow-node.is-on {
    transform: none;
  }
}

/* ---------- Responsive ---------- */

@media (max-width: 1100px) {
  #how .flow-trace {
    flex-direction: column;
    align-items: stretch;
    gap: 16px;
  }

  #how .flow-controls {
    flex-wrap: wrap;
  }
}

@media (max-width: 640px) {
  #how .flow-trace {
    padding: 16px;
  }

  #how .flow-trace-text {
    font-size: 16.5px;
    min-height: 4em;
    -webkit-line-clamp: 3;
  }

  #how .flow-trace-line {
    flex-wrap: wrap;
    gap: 6px 14px;
  }

  #how .flow-ctl {
    min-height: 44px;
  }

  #how .flow-seg-b {
    min-height: 38px;
  }

  #how .flow-legend {
    padding: 14px 16px;
  }

  #how .flow-dia {
    padding: 36px 20px 30px;
    min-width: 1020px;
    column-gap: 28px;
  }
}

/* ---------- Review fixes ---------- */

#how .flow-node-s {
  font-size: 12px;
  letter-spacing: 0.1em;
}

#how .flow-win-example {
  color: var(--bone-70);
}

/* Key in the empty lower-left of the diagram */
#how .flow-key {
  grid-column: 1;
  grid-row: 3 / span 2;
  align-self: start;
  display: grid;
  gap: 12px;
  padding-top: 8px;
}

#how .flow-key-t {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--bone-70);
}

#how .flow-key ul {
  display: grid;
  gap: 9px;
}

#how .flow-key li {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 14px;
  line-height: 1.3;
  color: var(--ash);
}

#how .flow-key-sw {
  flex: none;
  width: 16px;
  height: 11px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--surface);
}

#how .flow-key-sw--on {
  border-color: var(--accent);
  background: rgb(255 255 255 / 0.14);
}

#how .flow-key-sw--done {
  border-color: hsl(34 10% 24%);
  background: var(--elev);
}

#how .flow-key-sw--danger {
  border-color: var(--danger);
}

@media (pointer: coarse) {
  #how .flow-ctl {
    min-height: 44px;
  }

  #how .flow-seg-b {
    min-height: 40px;
  }
}

/* ---------- Round 2 ---------- */

#how .flow-trace-kicker {
  align-items: flex-start;
}

#how .flow-trace-kicker .live-dot {
  flex: none;
  margin-top: 5px;
}

@media (max-width: 640px) {
  #how .flow-trace-count {
    padding-left: 0;
    border-left: 0;
  }
}
