/* Process flowchart block (templates/blocks/process_flowchart.html.j2).
   A vertical spine on the left carries the numbered phases (rows) from the
   start terminal to the end terminal. Columns are swimlanes (one per client
   side, plus an optional conditional lane). A phase with `shared` renders one
   node across every lane. On mobile the spine stays and the lanes stack, the
   lane name moves into each node. */
.process-flowchart {
  --pf-rail: 32px;            /* spine column, the numbers sit on it */
  --pf-phase-col: 236px;      /* rail + phase title on desktop */
  --pf-spine: var(--color-cobalt, #0857b0);
  --pf-ink: var(--color-ink, #0f172a);
  --pf-muted: rgba(15, 23, 42, 0.68);
  --pf-rule: var(--color-rule, rgba(15, 23, 42, 0.12));
  --pf-node-bg: var(--color-cream, #faf8f3);
  --pf-node-border: rgba(15, 23, 42, 0.09);
  --pf-cond: #c2410c;
  --pf-cond-tint: #fff7ed;
  --pf-cond-border: #f0c4a8;
  padding: 80px 0;
  background: #ffffff;
}

/* The lead advisor card follows on the homepage: same white surface, so it
   reads as the coda of the chart ("the same expert handles your case"). */
.process-flowchart + .lead-advisor-card-section { padding-top: 0; }

.pf-head { text-align: center; margin: 0 auto 2.75rem; max-width: 62rem; }
.pf-head h2 {
  margin: 0;
  color: var(--pf-ink);
  font-family: var(--font-display, Georgia, serif);
  font-weight: 600;
  font-size: clamp(1.85rem, 3.5vw, 2.6rem);
  line-height: 1.1;
  letter-spacing: -0.015em;
  text-wrap: balance;
}
.pf-head p { margin: 0.9rem auto 0; max-width: 60ch; color: var(--pf-muted); font-size: 1.05rem; line-height: 1.6; text-wrap: balance; }

.pf-chart { max-width: 1120px; margin: 0 auto; }

/* ---- Start and end terminals: a node on the spine plus one line of text ---- */
.pf-bar {
  position: relative;
  display: grid; grid-template-columns: var(--pf-rail) 1fr; column-gap: 0.75rem; align-items: start;
}
.pf-bar--start { padding-bottom: 1.5rem; }
/* Align the end terminal text with the card columns above on desktop while
   keeping its hollow dot centered on the left spine. */
.pf-bar--end {
  padding-top: 1.5rem;
  grid-template-columns: var(--pf-phase-col) minmax(0, 1fr);
  column-gap: 1rem;
}
.pf-bar-node {
  position: relative; z-index: 1;
  justify-self: center; margin-top: 0.4rem;
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--pf-spine); border: 2px solid var(--pf-spine);
}
.pf-bar--end .pf-bar-node {
  background: #fff;
  justify-self: start;
  margin-left: calc(var(--pf-rail) / 2 - 7px);
}
/* Spine segment from the start node down into the grid. */
.pf-bar--start::after {
  content: ""; position: absolute; left: calc(var(--pf-rail) / 2 - 1px); top: 0.9rem; bottom: 0;
  border-left: 2px solid var(--pf-spine);
}
/* The end terminal is conditional (only if there is a dispute): dashed segment. */
.pf-bar--end::before {
  content: ""; position: absolute; left: calc(var(--pf-rail) / 2 - 1px); top: 0; height: 2rem;
  border-left: 2px dashed var(--pf-spine);
}
.pf-bar-text { margin: 0; line-height: 1.5; color: var(--pf-muted); font-size: 0.95rem; }
.pf-bar-k { display: block; font-size: 0.8rem; font-weight: 600; color: var(--pf-spine); margin-bottom: 0.1rem; }
.pf-bar-t { font-family: var(--font-display, Georgia, serif); font-size: 1.15rem; font-weight: 600; color: var(--pf-ink); margin-right: 0.35rem; }

/* ---- The grid: spine drawn as the grid's own background, so it runs unbroken ---- */
.pf-grid {
  display: grid;
  grid-template-columns: var(--pf-phase-col) repeat(var(--pf-lanes, 2), minmax(0, 1fr));
  column-gap: 1rem;
  background: linear-gradient(var(--pf-spine), var(--pf-spine)) calc(var(--pf-rail) / 2 - 1px) 0 / 2px 100% no-repeat;
}

.pf-lanehead {
  align-self: end;
  padding: 0 1rem 0.6rem;
  border-bottom: 2px solid var(--pf-spine);
  margin-bottom: 0.6rem;
  font-family: var(--font-display, Georgia, serif); font-size: 1.1rem; font-weight: 600; line-height: 1.25;
  color: var(--pf-ink);
}
.pf-lanehead.pf-cond { border-bottom-style: dashed; border-bottom-color: var(--pf-cond); }
.pf-lanehead.pf-blank { border: 0; }
.pf-lanehead small { display: block; margin-top: 0.1rem; font-family: var(--font-body, sans-serif); font-size: 0.85rem; font-weight: 400; color: var(--pf-muted); }

.pf-phase {
  display: grid; grid-template-columns: var(--pf-rail) 1fr; column-gap: 0.75rem; align-items: start;
  padding: 0.9rem 0 0.4rem;
}
.pf-num {
  position: relative; z-index: 1;
  display: grid; place-items: center;
  width: var(--pf-rail); height: var(--pf-rail); border-radius: 50%;
  background: #fff; border: 2px solid var(--pf-spine);
  font-family: var(--font-mono, monospace); font-size: 0.74rem; font-weight: 600; color: var(--color-cobalt-deep, #06458c);
}
.pf-phase b {
  padding-top: 0.3rem;
  font-family: var(--font-display, Georgia, serif); font-size: 1.05rem; font-weight: 600; line-height: 1.3;
  color: var(--pf-ink); hyphens: manual; text-wrap: balance;
}

.pf-cell, .pf-empty { padding: 0.4rem 0; }
/* Nodes fill the grid row, so the lanes' nodes in one phase share a height. */
.pf-cell { display: flex; flex-direction: column; }
.pf-cell--shared { grid-column: 2 / -1; }

.pf-node {
  flex: 1 1 auto; display: flex; flex-direction: column;
  background: var(--pf-node-bg); border: 1px solid var(--pf-node-border); border-radius: 6px;
  padding: 0.85rem 1rem 0.9rem;
}
.pf-node h3,
.pf-node .pf-title {
  margin: 0 0 0.3rem;
  font-family: var(--font-display, Georgia, serif); font-size: 1.05rem; font-weight: 600; line-height: 1.3;
  color: var(--pf-ink);
}
.pf-node p { margin: 0; font-size: 0.92rem; line-height: 1.55; color: var(--pf-muted); }
.pf-node .pf-trigger { font-size: 0.82rem; font-weight: 600; color: var(--pf-cond); margin: 0 0 0.4rem; }
.pf-svc {
  margin-top: auto; padding-top: 0.65rem; align-self: flex-start;
  font-size: 0.88rem; font-weight: 600; line-height: 1.35; color: var(--pf-spine);
  text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px;
  text-decoration-color: rgba(8, 87, 176, 0.35);
}
.pf-svc--bar { display: inline-block; padding-top: 0.3rem; }
a.pf-svc:hover { text-decoration-color: currentColor; }
a.pf-svc:focus-visible { outline: 2px solid var(--pf-spine); outline-offset: 2px; border-radius: 2px; }
.pf-node--cond { border-color: var(--pf-cond-border); background: var(--pf-cond-tint); }
.pf-node--cond .pf-svc { color: var(--pf-cond); }
.pf-node--loop { border-style: dashed; }
.pf-node--loop h3::after,
.pf-node--loop .pf-title::after { content: " \21BB"; color: var(--pf-spine); }

.pf-legend { display: flex; flex-wrap: wrap; gap: 1.25rem; margin-top: 1.5rem; padding-left: calc(var(--pf-rail) + 0.75rem); font-size: 0.85rem; color: var(--pf-muted); }
.pf-legend span::before { content: ""; display: inline-block; width: 12px; height: 12px; margin-right: 0.45rem; vertical-align: -1px; border: 1px solid var(--pf-node-border); background: var(--pf-node-bg); }
.pf-legend .pf-legend--cond::before { background: var(--pf-cond-tint); border-color: var(--pf-cond-border); }
.pf-legend .pf-legend--loop::before { border-style: dashed; }

/* Collapsed variant (block `collapse`): the phase names as one line, the chart
   behind a <details> toggle. Node titles are text there, not H3s. */
.pf-inline {
  list-style: none; margin: 0 auto 1.5rem; padding: 0;
  display: flex; flex-wrap: wrap; justify-content: center; gap: .5rem 1.5rem;
  font-family: var(--font-display, Georgia, serif); font-size: 1.05rem; font-weight: 600; color: var(--pf-ink);
}
.pf-inline span { font-family: var(--font-mono, monospace); font-size: .72rem; font-weight: 500; color: var(--pf-spine); margin-right: .2rem; }
.pf-collapse { border-top: 1px solid var(--pf-rule); border-bottom: 1px solid var(--pf-rule); }
.pf-collapse__summary {
  display: flex; align-items: center; justify-content: center; gap: .6rem;
  min-height: 48px; padding: .75rem 1rem; cursor: pointer; list-style: none;
  font-family: var(--font-body, sans-serif); font-size: .95rem; font-weight: 600; color: var(--pf-spine);
}
.pf-collapse__summary::-webkit-details-marker { display: none; }
.pf-collapse__summary::after { content: "+"; font-size: 1.25rem; font-weight: 400; line-height: 1; }
.pf-collapse[open] > .pf-collapse__summary::after { content: "\2212"; }
.pf-collapse__summary:hover { text-decoration: underline; text-underline-offset: 3px; }
.pf-collapse__summary:focus-visible { outline: 2px solid var(--pf-spine); outline-offset: 2px; }
.pf-collapse[open] { padding-bottom: 1.5rem; }
.pf-collapse[open] > .pf-collapse__summary { margin-bottom: 1rem; }

@media (max-width: 860px) {
  .process-flowchart { padding: 56px 0; --pf-rail: 28px; }
  .pf-head { margin-bottom: 2rem; }
  .pf-head p { font-size: 1rem; }
  .pf-inline { justify-content: flex-start; gap: .4rem 1.1rem; font-size: .98rem; }
  /* Rail + one content column: phases span both, nodes sit in the content column. */
  .pf-grid { grid-template-columns: var(--pf-rail) minmax(0, 1fr); column-gap: 0.75rem; }
  .pf-lanehead { display: none; }
  .pf-phase { grid-column: 1 / -1; column-gap: 0.75rem; padding: 1.1rem 0 0.35rem; }
  .pf-lanehead + .pf-phase { padding-top: 0.25rem; }
  .pf-num { font-size: 0.7rem; }
  .pf-phase b { padding-top: 0.2rem; }
  .pf-cell { grid-column: 2; }
  .pf-cell--shared { grid-column: 2; }
  .pf-empty { display: none; }
  /* No card chrome on phones: the spine and the lane label carry the structure. */
  .pf-node { background: transparent; border: 0; border-left: 2px solid var(--pf-node-border); border-radius: 0; padding: 0.1rem 0 0.15rem 0.85rem; }
  .pf-node--cond { background: transparent; border-left-color: var(--pf-cond-border); }
  .pf-cell { padding: 0.45rem 0; }
  /* The lane name moves into the node (shared nodes have none: both sides). */
  .pf-node[data-lane]::before {
    content: attr(data-lane); display: block; margin-bottom: 0.2rem;
    font-size: 0.78rem; font-weight: 600; line-height: 1.3; color: var(--pf-spine);
  }
  .pf-node--cond[data-lane]::before { color: var(--pf-cond); }
  .pf-node p { font-size: 0.9rem; }
  .pf-bar-t { font-size: 1.08rem; }
  .pf-bar-text { font-size: 0.92rem; }
  .pf-bar--start { padding-bottom: 1.1rem; }
  .pf-bar--end { padding-top: 1.1rem; grid-template-columns: var(--pf-rail) minmax(0, 1fr); column-gap: 0.75rem; }
  .pf-bar--end .pf-bar-node { justify-self: center; margin-left: 0; }
  .pf-legend { padding-left: 0; }
}
