/* ═══ Case study flowchart — REUSABLE component ═════════════════════
   A factual flowchart on a photo tile. Each stage (phase) is its own frosted glass tile; the
   heading sits straight on the photo. Inside a stage, steps are borderless white chips joined by
   fine connectors with small filled arrowheads. Flowchart conventions only: pill = start or
   end, box = step, diamond = choice, lighter chip on a dotted route = optional, rejoining the
   flow. No commentary or figures inside the chart.
   Stacked (default): stages run top to bottom, each tile with its name on the left and its
   steps on a single spine. With two periods (e.g. before and after a redesign), a toggle swaps
   the charts; each stage keeps the same height in every period (stages are matched by name, and
   a stage only one period has simply appears), so switching swaps the steps in place. The toggle and key sit in a sticky rail beside the chart; on
   narrow tiles the toggle becomes a sticky bar above it and the key moves below.
   Used on: wone.html (onboarding → Index Assessment → after, March and October 2026).

   To add to a case study:
     1. <link rel="stylesheet" href="components/cs-flow.css" /> in <head>
     2. Paste the markup below. Steps go in reading order; a choice is followed by its optional
        branch, then the step both routes lead to.
     3. <script src="components/cs-flow.js" defer></script> before </body>

   <figure class="cs-flow" data-cs-flow aria-labelledby="…">
     <img class="cs-flow-bg" src="…" alt="" loading="lazy" decoding="async" />
     <div class="cs-flow-card">
       <p class="cs-flow-eyebrow" id="…">…</p>
       <div class="cs-flow-body">
         <div class="cs-flow-rail">
           (optional, with two charts) <div class="cs-flow-toggle" role="group" aria-label="…">
             <button type="button" data-flow-show="before" aria-pressed="false">… <span>note</span></button>
             <button type="button" data-flow-show="after" aria-pressed="true">… <span>note</span></button>
           </div>
           <p class="cs-flow-key">…</p>
         </div>
         <div class="cs-flow-charts">
           <div class="cs-flow-chart" data-flow-period="after">
             <div class="cs-flow-stage">
               <div class="cs-flow-label"><p class="cs-flow-kicker">01</p><p class="cs-flow-name">…</p></div>
               <p class="cs-flow-node cs-flow-node--term">Start</p>
               <p class="cs-flow-node">Step<span>Detail line</span></p>
               <p class="cs-flow-node cs-flow-node--choice" data-no="Skip">Choice?</p>
               <p class="cs-flow-node cs-flow-node--optional">Optional step</p>
               <p class="cs-flow-node">Next step</p>
             </div>
           </div>
           (more charts with hidden and their own data-flow-period)
         </div>
       </div>
       <p class="cs-flow-key cs-flow-key--foot" aria-hidden="true">…</p>
     </div>
   </figure>

   A chart can run across instead: add cs-flow--across to the figure and, on wide tiles, the
   stage tiles sit side by side and the flow runs left to right, with the toggle beside the
   heading and the key underneath (stacked on narrower tiles and phones, or when the steps don't
   fit).

   To pick out one stage as the focus, add cs-flow-stage--focus to it: its tile is a touch
   brighter and lifts slightly.

   Settings on .cs-flow: --flow-stick (how far below the top the rail sticks; clears the site
   nav), --flow-line (connector colour).
   ═══════════════════════════════════════════════════════════════════ */

.cs-flow {
  --flow-stick: 80px;
  --flow-line: color-mix(in srgb, var(--ink) 38%, transparent);
  --flow-chip: rgba(255, 255, 255, 0.94);
  --flow-chip-shadow: 0 1px 1px rgba(14, 13, 11, 0.04), 0 8px 18px -12px rgba(14, 13, 11, 0.32);
  --flow-glass: rgba(255, 255, 255, 0.48);
  --flow-glass-edge: rgba(255, 255, 255, 0.6);
  position: relative;
  isolation: isolate;
  /* clip, not hidden: hidden makes the tile a scroll container, which would pin the sticky
     rail to the tile instead of the page. */
  overflow: clip;
  container-type: inline-size;
  margin: 0;
  padding: clamp(16px, 3.2vw, 44px);
  border-radius: 28px;
  background: #C8CFBF;
  color: var(--ink);
}
@media (max-width: 767px) { .cs-flow { --flow-stick: 70px; } }
/* Leading an Impact section: the stat cards follow at the same gap as under a hero. */
.cs-flow + .cs-impact-cards { margin-top: 12px; }
.cs-flow-bg {
  position: absolute;
  inset: 0;
  z-index: -1;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
}

/* The card is only a wrapper now: the stages carry the glass. */
.cs-flow-card { position: relative; }

/* The heading sits straight on the photo, so it's set in full ink with a soft light halo. */
.cs-flow-eyebrow {
  margin: 0 0 clamp(16px, 2.2cqi, 24px);
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink);
  text-shadow: 0 0 18px rgba(255, 255, 255, 0.55);
}

/* Charts on the left, the rail on the right. The rail shares the charts' grid row, so it can
   stick for the chart's whole height. */
.cs-flow-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 156px;
  column-gap: clamp(20px, 3cqi, 36px);
  align-items: start;
}
.cs-flow-charts { grid-column: 1; grid-row: 1; }
.cs-flow-rail {
  grid-column: 2;
  grid-row: 1;
  position: sticky;
  top: var(--flow-stick);
  z-index: 3;
  display: grid;
  gap: 12px;
}

/* Glass, shared by the stage tiles, the toggle and the key. */
.cs-flow-stage,
.cs-flow-toggle,
.cs-flow-key {
  border: 1px solid var(--flow-glass-edge);
  background: var(--flow-glass);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.55);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
          backdrop-filter: blur(20px) saturate(140%);
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .cs-flow-stage, .cs-flow-toggle, .cs-flow-key { background: rgba(255, 255, 255, 0.82); }
}

/* Period toggle: stacked on wide tiles, a pill bar on narrow ones. */
.cs-flow-toggle {
  display: grid;
  gap: 4px;
  padding: 4px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.66);
  box-shadow: 0 10px 30px -18px rgba(14, 13, 11, 0.35);
}
.cs-flow-toggle button {
  border: 0;
  background: transparent;
  padding: 10px 14px;
  border-radius: 14px;
  text-align: left;
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--ink-mid);
  cursor: pointer;
  transition: background 0.25s ease, color 0.25s ease;
}
/* A short note after the month (<span>Before updates</span>): its own smaller line in the rail
   and the narrow bar, and on the same line after a dash when the toggle sits by the heading. */
.cs-flow-toggle button span { display: block; margin-top: 1px; font-size: 12px; font-weight: 400; opacity: 0.75; }
.cs-flow-toggle button:hover { color: var(--ink); }
.cs-flow-toggle button[aria-pressed="true"] { background: var(--ink); color: #fff; }
.cs-flow-toggle button:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

/* Key to the shapes, on its own small glass panel. */
.cs-flow-key {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 14px 16px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.72);
  font-family: var(--sans);
  font-size: 12.5px;
  line-height: 1.3;
  color: var(--ink-mid);
}
.cs-flow-key span { display: flex; align-items: center; gap: 10px; }
.cs-flow-key i { flex: none; display: inline-block; }
.cs-flow-key-term { width: 22px; height: 12px; border-radius: 999px; background: #fff; box-shadow: var(--flow-chip-shadow); }
.cs-flow-key-step { width: 20px; height: 13px; border-radius: 3px; background: #fff; box-shadow: var(--flow-chip-shadow); }
.cs-flow-key-choice { width: 10px; height: 10px; margin: 0 6px; border-radius: 2px; background: #fff; box-shadow: var(--flow-chip-shadow); transform: rotate(45deg); }
/* Optional: a dotted route, as on the chart. */
.cs-flow-key-optional {
  width: 22px;
  height: 2px;
  background: radial-gradient(circle, var(--flow-line) 0 0.9px, transparent 1.3px) 0 50% / 5px 2px repeat-x;
}
.cs-flow-key--foot { display: none; }

/* ── The chart ── */
.cs-flow-chart { position: relative; display: grid; gap: 22px; }
.cs-flow-chart[hidden] { display: none; }
/* Connectors run above the glass (whose blur would otherwise wash them out) and end at the
   chips' edges, so they never cross a label. */
.cs-flow-wires {
  position: absolute;
  inset: 0;
  z-index: 2;
  overflow: visible;
  pointer-events: none;
  color: var(--flow-line);
}
.cs-flow-wire { fill: none; stroke: currentColor; stroke-width: 1.15; stroke-linecap: round; stroke-linejoin: round; }
/* Optional routes are dotted: round caps on near-zero dashes. */
.cs-flow-wire--dash { stroke-width: 1.7; stroke-dasharray: 0.01 4.6; }
.cs-flow-arrow { fill: currentColor; stroke: currentColor; stroke-width: 0.6; stroke-linejoin: round; }
.cs-flow-wire-label { font-family: var(--sans); font-size: 11px; font-weight: 500; letter-spacing: 0.02em; fill: var(--ink-mid); }

/* One glass tile per stage: name | spine | branches. Steps place themselves: each step takes
   the next row on the spine, and an optional step sits beside the choice before it. */
.cs-flow-stage {
  position: relative;
  display: grid;
  grid-template-columns: 124px minmax(0, 200px) minmax(0, 160px);
  align-content: start;
  column-gap: 26px;
  row-gap: 18px;
  padding: clamp(18px, 2.4cqi, 26px);
  border-radius: 22px;
}
.cs-flow-stage--focus {
  --flow-glass: rgba(255, 255, 255, 0.7);
  --flow-glass-edge: rgba(255, 255, 255, 0.9);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7), 0 26px 50px -32px rgba(14, 13, 11, 0.4);
}
.cs-flow-label { grid-column: 1; grid-row: 1; padding: 2px 0 0; }
.cs-flow-kicker {
  margin: 0;
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.06em;
  color: var(--ink-mid);
}
.cs-flow-name {
  margin: 5px 0 0;
  font-family: var(--serif);
  font-weight: 400;
  font-size: 17px;
  line-height: 1.15;
  letter-spacing: -0.015em;
}

/* Steps: borderless white chips with a soft lift. */
.cs-flow-node {
  position: relative;
  grid-column: 2;
  justify-self: center;
  align-self: center;
  display: inline-flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 2px;
  min-height: 38px;
  max-width: 100%;
  margin: 0;
  padding: 8px 14px;
  border: 0;
  border-radius: 10px;
  background: var(--flow-chip);
  box-shadow: var(--flow-chip-shadow);
  font-family: var(--sans);
  font-size: 13px;
  line-height: 1.25;
  text-align: center;
  text-wrap: balance;
  color: var(--ink);
}
.cs-flow-node span { display: block; font-size: 11.5px; color: var(--ink-mid); }
.cs-flow-node--term { padding: 8px 18px; border-radius: 999px; background: #fff; font-weight: 500; white-space: nowrap; }
/* Optional: a lighter chip, reached by a dotted route. */
.cs-flow-node--optional { grid-column: 3; background: rgba(255, 255, 255, 0.55); box-shadow: none; color: var(--ink-mid); }
/* A choice: the box is a diamond drawn behind the label, its tips on the box edges. */
.cs-flow-node--choice {
  width: 80px;
  height: 80px;
  min-height: 0;
  padding: 0 12px;
  background: none;
  box-shadow: none;
  font-size: 11.5px;
}
.cs-flow-node--choice::before {
  content: "";
  position: absolute;
  inset: 12px;
  z-index: -1;
  border-radius: 6px;
  background: var(--flow-chip);
  box-shadow: var(--flow-chip-shadow);
  transform: rotate(45deg);
}

/* Narrow tiles: the toggle becomes a sticky bar above the chart and the key moves below it.
   Block layout (not grid), so the bar can stick for the whole chart. Each stage's name sits top
   right, beside its first step. */
@container (max-width: 640px) {
  .cs-flow-body { display: block; }
  .cs-flow-rail { display: flex; justify-content: center; margin-bottom: 16px; }
  .cs-flow-rail .cs-flow-key { display: none; }
  .cs-flow-rail:not(:has(.cs-flow-toggle)) { display: none; }
  .cs-flow-toggle { display: inline-flex; border-radius: 999px; }
  .cs-flow-toggle button { padding: 9px 16px; border-radius: 999px; text-align: center; }
  .cs-flow-key--foot { display: flex; flex-wrap: wrap; gap: 10px 18px; margin-top: 16px; }
  .cs-flow-chart { gap: 14px; }
  .cs-flow-stage { grid-template-columns: minmax(0, 1fr) minmax(0, 112px); column-gap: 12px; padding: 18px 16px; }
  .cs-flow-label { grid-column: 2; grid-row: 1; padding: 0; text-align: right; }
  .cs-flow-node { grid-column: 1; }
  .cs-flow-node--optional { grid-column: 2; }
}

/* ── Across (.cs-flow--across). On wide tiles the stage tiles sit side by side and the whole
   flow runs on one row, left to right; an optional step sits under its choice. cs-flow.js
   sizes the stage columns by their step counts (--stage-cols, the most steps a stage of that
   name has in any period, so tiles stay put when the toggle swaps periods), gives each stage its step
   count (--n) and each step its column (--c). Stage tiles share their rows (subgrid), so
   headings and steps line up across the row. The toggle, if there is one, sits beside the
   heading and the key under the chart.
   Narrower tiles, and tiles too narrow for the steps even at the slimmer is-dense sizes
   (cs-flow.js adds is-tight), fall back to the stacked layout above. ── */
.cs-flow--across { padding: clamp(14px, 2.2vw, 40px); }
/* With no toggle there's no rail: the key sits under the chart at every width. */
.cs-flow--across:not(:has(.cs-flow-toggle)) .cs-flow-body { display: block; }
.cs-flow--across:not(:has(.cs-flow-toggle)) .cs-flow-rail { display: none; }
.cs-flow--across:not(:has(.cs-flow-toggle)) .cs-flow-key--foot { display: inline-flex; flex-wrap: wrap; gap: 10px 20px; margin-top: 16px; }
@container (min-width: 820px) {
  /* Heading and toggle share the top line; the chart and key span the tile below. */
  .cs-flow--across:not(.is-tight) .cs-flow-card {
    --flow-layout: across;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    column-gap: 20px;
  }
  .cs-flow--across:not(.is-tight) .cs-flow-body { display: contents; }
  .cs-flow--across:not(.is-tight) .cs-flow-eyebrow { grid-column: 1; grid-row: 1; margin: 0; }
  .cs-flow--across:not(.is-tight) .cs-flow-rail { grid-column: 2; grid-row: 1; position: static; }
  .cs-flow--across:not(.is-tight) .cs-flow-rail .cs-flow-key { display: none; }
  .cs-flow--across:not(.is-tight) .cs-flow-toggle { display: inline-flex; border-radius: 999px; }
  .cs-flow--across:not(.is-tight) .cs-flow-toggle button { padding: 9px 16px; border-radius: 999px; text-align: center; }
  .cs-flow--across:not(.is-tight) .cs-flow-toggle button span { display: inline; margin: 0; font-size: inherit; }
  .cs-flow--across:not(.is-tight) .cs-flow-toggle button span::before { content: "\2013\00a0"; }
  .cs-flow--across:not(.is-tight) .cs-flow-charts { grid-column: 1 / -1; grid-row: 2; margin-top: clamp(16px, 2.2cqi, 24px); }
  .cs-flow--across:not(.is-tight) .cs-flow-key--foot { grid-column: 1 / -1; grid-row: 3; justify-self: start; display: inline-flex; flex-wrap: wrap; gap: 10px 20px; margin-top: 16px; }
  .cs-flow--across:not(.is-tight) .cs-flow-chart {
    grid-template-columns: var(--stage-cols, repeat(3, auto));
    grid-template-rows: auto auto auto;
    column-gap: 14px;
    row-gap: 0;
  }
  .cs-flow--across:not(.is-tight) .cs-flow-stage {
    grid-row: 1 / 4;
    grid-template-rows: subgrid;
    grid-template-columns: repeat(var(--n, 4), auto);
    justify-content: space-between;
    align-items: center;
    column-gap: 14px;
    row-gap: 0;
    padding: 18px 16px 20px;
  }
  .cs-flow--across:not(.is-tight) .cs-flow-label { grid-column: 1 / -1; grid-row: 1; align-self: start; margin-bottom: 20px; }
  .cs-flow--across:not(.is-tight) .cs-flow-node { grid-row: 2; grid-column: var(--c); padding: 7px 10px; font-size: 12.5px; }
  /* A stage's only step lines up under its name, like every stage's first step. */
  .cs-flow--across:not(.is-tight) .cs-flow-stage > p.cs-flow-node:only-of-type { justify-self: start; }
  .cs-flow--across:not(.is-tight) .cs-flow-node span { white-space: nowrap; }
  .cs-flow--across:not(.is-tight) .cs-flow-node--term { padding: 7px 14px; }
  .cs-flow--across:not(.is-tight) .cs-flow-node--choice { width: 72px; height: 72px; padding: 0 10px; font-size: 11px; }
  .cs-flow--across:not(.is-tight) .cs-flow-node--choice::before { inset: 11px; }
  .cs-flow--across:not(.is-tight) .cs-flow-node--optional { grid-row: 3; margin-top: 18px; }
  /* Long flows: when the steps would wrap, cs-flow.js adds is-dense for slimmer tiles, chips
     and diamonds before falling back to the stacked layout. */
  .cs-flow--across.is-dense:not(.is-tight) .cs-flow-chart { column-gap: 10px; }
  .cs-flow--across.is-dense:not(.is-tight) .cs-flow-stage { padding-inline: 12px; }
  .cs-flow--across.is-dense:not(.is-tight) .cs-flow-node { padding-inline: 8px; font-size: 12px; }
  .cs-flow--across.is-dense:not(.is-tight) .cs-flow-node--term { padding-inline: 12px; }
  .cs-flow--across.is-dense:not(.is-tight) .cs-flow-node--choice { width: 64px; height: 64px; padding: 0 8px; font-size: 11px; }
  .cs-flow--across.is-dense:not(.is-tight) .cs-flow-node--choice::before { inset: 10px; }
}
/* The tile itself can't be styled from its own container query, so its slimmer padding sits
   here (cs-flow.js only adds is-dense when the chart runs across). */
.cs-flow--across.is-dense { padding: clamp(14px, 1.6vw, 40px); }
/* Across, steps and stage names stay on one line whenever they fit that way (cs-flow.js adds
   is-one-line), so the stage tiles are sized to their one-line widths. An optional step can
   be wider than the choice above it: it overhangs its column (negative side margins keep it
   centred) instead of widening it, as the row under the steps is otherwise empty. */
.cs-flow.is-one-line .cs-flow-node,
.cs-flow.is-one-line .cs-flow-name { white-space: nowrap; }
.cs-flow.is-one-line .cs-flow-node--optional { max-width: none; margin-inline: -48px; }

@media (prefers-reduced-motion: reduce) {
  .cs-flow-toggle button { transition: none; }
}
