/* =============================================================================
   Loop and river shapes (October 2026): cycleLoop and riverPath
   Markup: src/_includes/rd/shapes.njk   Behaviour: /js/rd-shapes.js   Colours: --rd-* in redesign.css
   The base styles are the narrow layout, a list, which is also what shows without JavaScript.
   The round loop and the flowing river switch on with container queries once there is room.
   ============================================================================= */

/* ---------- Shared: the open and closed details ---------- */
.rd-js .rd .rd-loop__step:not(.is-open) > .rd-loop__detail,
.rd-js .rd .rd-river__stop:not(.is-open) > .rd-river__card,
.rd-js .rd .rd-river__waste:not(.is-open) > .rd-river__card,
.rd-js .rd .rd-river__back:not(.is-open) > .rd-river__card { display: none; }


/* =============================================================================
   cycleLoop
   ============================================================================= */
.rd.rd-loop { container: rdloop / inline-size; }
.rd .rd-loop__fig { margin: 0; }

/* Narrow layout: a vertical list. A dashed line runs down through the numbers and a looped arrow
   carries step 4 back round to step 1. */
.rd .rd-loop__stage { --rd-shape-mode: list; display: flex; flex-direction: column; gap: 26px; max-width: 34rem; margin: 0 auto; }
.rd .rd-loop__ring { display: none; }
.rd .rd-loop__steps { order: 1; position: relative; display: grid; gap: 20px; padding-left: 30px; }
.rd .rd-loop__step { position: relative; }
.rd .rd-loop__step:not(:last-child)::after { content: ""; position: absolute; left: 23px; top: 48px; bottom: -20px; border-left: 2px dashed var(--rd-green); pointer-events: none; }
.rd .rd-loop__step::before { content: ""; position: absolute; left: -26px; width: 18px; border-left: 2px dashed var(--rd-green); pointer-events: none; }
.rd .rd-loop__step:first-child::before { top: 23px; bottom: -20px; border-top: 2px dashed var(--rd-green); border-top-left-radius: 16px; }
.rd .rd-loop__step:not(:first-child):not(:last-child)::before { top: 0; bottom: -20px; }
.rd .rd-loop__step:last-child::before { top: 0; width: 26px; height: 25px; border-bottom: 2px dashed var(--rd-green); border-bottom-left-radius: 16px; }
.rd .rd-loop__step:first-child > .rd-loop__pill::before { content: ""; position: absolute; left: -12px; top: 50%; margin-top: -5px; border-left: 8px solid var(--rd-green); border-top: 5px solid transparent; border-bottom: 5px solid transparent; }

.rd .rd-loop__pill {
  position: relative; display: inline-flex; align-items: center; gap: 10px; height: 48px; padding: 0 22px 0 8px;
  border: 2px solid var(--rd-navy); border-radius: 999px; background: #fff; color: var(--rd-navy);
  font-size: 17px; font-weight: 700; line-height: 1; white-space: nowrap;
  transition: background-color .2s, color .2s, box-shadow .25s, transform .25s var(--rd-ease);
}
.rd .rd-loop__num { display: grid; place-items: center; flex: none; width: 28px; height: 28px; border-radius: 50%; background: var(--rd-navy); color: #fff; font-size: 14px; font-weight: 700; transition: background-color .2s, color .2s; }
.rd .rd-loop__pill:hover { box-shadow: 0 0 0 4px var(--rd-mint-soft), 0 8px 20px rgba(3, 23, 79, .12); }
.rd .rd-loop__pill:focus-visible { outline-offset: 4px; }
.rd .rd-loop__step.is-open > .rd-loop__pill { background: var(--rd-navy); color: #fff; box-shadow: 0 0 0 6px var(--rd-mint), 0 10px 24px rgba(3, 23, 79, .16); }
.rd .rd-loop__step.is-open > .rd-loop__pill .rd-loop__num { background: var(--rd-mint); color: var(--rd-navy); }

.rd .rd-loop__detail { margin: 14px 0 4px 52px; }
.rd .rd-loop__title { font-size: 19px; font-weight: 700; line-height: 1.25; color: var(--rd-navy); text-wrap: balance; }
.rd .rd-loop__lead { margin-top: 6px; font-size: 16px; font-weight: 500; line-height: 1.45; color: var(--rd-navy); text-wrap: pretty; }
.rd .rd-loop__points { display: grid; gap: 5px; margin-top: 12px; }
.rd .rd-loop__points li { display: flex; align-items: flex-start; gap: 7px; color: var(--rd-body); font-size: 14.5px; font-weight: 500; line-height: 1.4; }
.rd .rd-loop__points .rd-icon { flex: none; margin-top: 2px; color: var(--rd-green); }
.rd .rd-loop__text { margin-top: 12px; font-size: 15.5px; line-height: 1.6; color: var(--rd-body); }
.rd .rd-loop__text p { text-wrap: pretty; }
.rd .rd-loop__text p + p { margin-top: 8px; }

.rd .rd-loop__centre { order: 2; padding-left: 30px; font-size: 20px; font-weight: 700; line-height: 1.3; letter-spacing: -.2px; color: var(--rd-navy); text-wrap: balance; }

.rd .rd-loop__cap { display: flex; align-items: flex-start; gap: 12px; max-width: 46rem; margin: 30px auto 0; padding: 16px 20px; border-radius: var(--rd-radius); background: var(--rd-mint-soft); border: 1px solid var(--rd-mint-line); font-size: 15px; line-height: 1.6; color: var(--rd-body); text-wrap: pretty; }
.rd .rd-loop__cap .rd-icon { margin-top: 2px; color: var(--rd-green); }
.rd .rd-loop__cap b { color: var(--rd-navy); }
.rd .rd-loop__cap a { color: var(--rd-navy); font-weight: 700; text-decoration: underline; text-underline-offset: 3px; white-space: nowrap; }
.rd .rd-loop__cap a:hover { color: var(--rd-green); }

/* The round loop: pills sit on a soft mint ring, a dashed line with small arrowheads runs round it,
   and the middle holds the centre line until a step opens its detail there. */
@container rdloop (min-width: 700px) {
  .rd-js .rd .rd-loop__stage { --rd-shape-mode: ring; --R: 256px; position: relative; display: block; width: calc(2 * var(--R) + 172px); max-width: 100%; height: calc(2 * var(--R) + 64px); margin: 0 auto; }
  .rd-js .rd .rd-loop__ring { display: block; position: absolute; left: 50%; top: 50%; width: calc(var(--R) * 2.24); height: calc(var(--R) * 2.24); transform: translate(-50%, -50%); overflow: visible; pointer-events: none; }
  .rd-js .rd .rd-loop__steps { position: static; display: block; padding: 0; }
  .rd-js .rd .rd-loop__step { position: static; }
  .rd-js .rd .rd-loop__step::before,
  .rd-js .rd .rd-loop__step::after,
  .rd-js .rd .rd-loop__step:first-child > .rd-loop__pill::before { display: none; }
  .rd-js .rd .rd-loop__pill { position: absolute; z-index: 2; left: calc(50% + var(--R) * cos(var(--a))); top: calc(50% + var(--R) * sin(var(--a))); transform: translate(-50%, -50%); box-shadow: 0 6px 16px rgba(3, 23, 79, .09); }
  .rd-js .rd .rd-loop__pill:hover { transform: translate(-50%, calc(-50% - 2px)); box-shadow: 0 0 0 4px var(--rd-mint-soft), 0 10px 22px rgba(3, 23, 79, .14); }
  .rd-js .rd .rd-loop__step.is-open > .rd-loop__pill { box-shadow: 0 0 0 6px var(--rd-mint), 0 12px 26px rgba(3, 23, 79, .18); }
  .rd-js .rd .rd-loop__centre { position: absolute; z-index: 1; left: 50%; top: 50%; width: calc(var(--R) * 1.06); margin: 0; padding: 0; transform: translate(-50%, -50%); text-align: center; font-size: 30px; line-height: 1.2; letter-spacing: -.4px; transition: opacity .3s ease, visibility 0s; }
  .rd-js .rd.rd-loop.has-open .rd-loop__centre { visibility: hidden; opacity: 0; transition: none; }
  .rd-js .rd .rd-loop__step:not(.is-open) > .rd-loop__detail { display: block; visibility: hidden; opacity: 0; }
  .rd-js .rd .rd-loop__detail { position: absolute; z-index: 1; left: 50%; top: 50%; width: calc(var(--R) * 1.34); margin: 0; transform: translate(-50%, -50%); text-align: center; }
  .rd-js .rd .rd-loop__step.is-open > .rd-loop__detail { visibility: visible; opacity: 1; transition: opacity .3s ease; }
  .rd-js .rd .rd-loop__title { font-size: 21px; }
  .rd-js .rd .rd-loop__lead { margin-top: 6px; }
  .rd-js .rd .rd-loop__points { width: fit-content; max-width: 100%; margin: 12px auto 0; text-align: left; }
  .rd-js .rd .rd-loop__text { margin-top: 12px; font-size: 15px; line-height: 1.58; }
}
@container rdloop (min-width: 1000px) {
  .rd-js .rd .rd-loop__stage { --R: 266px; }
}

/* The ring: a mint band, a dashed green line and an arrowhead between each pair of steps */
.rd .rd-loop__band { fill: none; stroke: var(--rd-mint); stroke-width: 8.8; opacity: .8; }
.rd .rd-loop__line { fill: none; stroke: var(--rd-green); stroke-width: 1.1; stroke-dasharray: 3.4 3.4; stroke-linecap: round; }
.rd .rd-loop__chev { fill: none; stroke: var(--rd-green); stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
/* Drawn once on arrival: a mask circle uncovers the ring clockwise from the top (its length is 628) */
.rd .rd-loop__draw { fill: none; stroke: #fff; stroke-width: 30; stroke-dasharray: 640 640; stroke-dashoffset: 0; }
.rd.rd-loop.is-armed:not(.is-drawn) .rd-loop__draw { stroke-dashoffset: 640; }
.rd.rd-loop.is-drawn .rd-loop__draw { transition: stroke-dashoffset 1.8s cubic-bezier(.45, .05, .25, 1); }


/* =============================================================================
   riverPath
   ============================================================================= */
.rd.rd-river { container: rdriver / inline-size; }
.rd .rd-river__fig { margin: 0; }

/* Narrow layout: the river runs top to bottom down the left, with each stop's words beside its stone.
   Each stop draws the stretch of river from its stone to the next one, so an open card simply makes
   that stretch longer. */
.rd .rd-river__stage { --rd-shape-mode: list; position: relative; max-width: 34rem; margin: 0 auto; }
.rd .rd-river__art, .rd .rd-river__arrow { display: none; }
.rd .rd-river__stops { position: relative; }
.rd .rd-river__stop { position: relative; padding-bottom: 24px; }
.rd .rd-river__stop:last-child { padding-bottom: 0; }
.rd .rd-river__seg { position: absolute; z-index: 0; left: 14px; top: 20px; width: 60px; height: 100%; overflow: visible; pointer-events: none; }
.rd .rd-river__seg-band { fill: none; stroke: #BFDBFE; stroke-width: 34px; vector-effect: non-scaling-stroke; }
.rd .rd-river__seg-current { fill: none; stroke: #7FB6F7; stroke-width: 2px; stroke-dasharray: 8 9; stroke-linecap: round; vector-effect: non-scaling-stroke; }

.rd .rd-river__btn { position: relative; z-index: 1; display: flex; align-items: center; gap: 16px; width: 100%; min-height: 40px; padding: 0 0 0 24px; text-align: left; border-radius: 12px; }
.rd .rd-river__btn:focus-visible { outline-offset: 4px; }
.rd .rd-river__stone {
  display: grid; place-items: center; flex: none; align-self: flex-start; width: 40px; height: 40px; border-radius: 50%;
  background: var(--rd-mint); border: 2px solid var(--rd-green); color: var(--rd-navy); font-size: 15px; font-weight: 700; line-height: 1;
  box-shadow: 0 4px 10px rgba(3, 23, 79, .12); transition: background-color .2s, color .2s, box-shadow .25s, transform .25s var(--rd-ease);
}
.rd .rd-river__stop--start .rd-river__stone { background: #fff; border-color: #93C5FD; color: #2563EB; }
.rd .rd-river__stop--end .rd-river__stone { width: 44px; height: 44px; margin-left: -2px; margin-top: -2px; background: var(--rd-navy); border-color: var(--rd-navy); color: var(--rd-mint); }
.rd .rd-river__words { display: flex; flex-direction: column; gap: 2px; }
.rd .rd-river__label { font-size: 16.5px; font-weight: 700; line-height: 1.2; color: var(--rd-navy); }
.rd .rd-river__meta { font-size: 14px; font-style: italic; line-height: 1.25; color: var(--rd-muted); }
.rd .rd-river__btn:hover .rd-river__stone { transform: translateY(-2px); box-shadow: 0 0 0 4px rgba(21, 128, 61, .14), 0 8px 16px rgba(3, 23, 79, .14); }
.rd .rd-river__stop.is-open > .rd-river__btn .rd-river__stone { background: var(--rd-green); border-color: var(--rd-green); color: #fff; box-shadow: 0 0 0 5px rgba(21, 128, 61, .2), 0 8px 16px rgba(3, 23, 79, .14); }
.rd .rd-river__stop--start.is-open > .rd-river__btn .rd-river__stone { background: #2563EB; border-color: #2563EB; box-shadow: 0 0 0 5px rgba(37, 99, 235, .18), 0 8px 16px rgba(3, 23, 79, .14); }
.rd .rd-river__stop--end.is-open > .rd-river__btn .rd-river__stone { background: var(--rd-navy); border-color: var(--rd-navy); color: var(--rd-mint); box-shadow: 0 0 0 5px var(--rd-mint), 0 8px 16px rgba(3, 23, 79, .16); }

/* The cards */
.rd .rd-river__card { margin: 12px 0 2px 80px; padding: 14px 16px 15px; border: 1px solid var(--rd-line); border-radius: var(--rd-radius-lg); background: #fff; box-shadow: var(--rd-shadow); text-align: left; }
.rd .rd-river__title { font-size: 16.5px; font-weight: 700; line-height: 1.3; color: var(--rd-navy); }
.rd .rd-river__lead { margin-top: 6px; font-size: 15px; line-height: 1.5; color: var(--rd-body); text-wrap: pretty; }
.rd .rd-river__points { display: grid; gap: 6px; margin-top: 10px; }
.rd .rd-river__points li { display: flex; align-items: flex-start; gap: 8px; font-size: 14px; font-weight: 500; line-height: 1.4; color: var(--rd-navy); }
.rd .rd-river__points .rd-icon { margin-top: 1px; color: var(--rd-green); }
.rd .rd-river__text { margin-top: 8px; font-size: 14.5px; line-height: 1.55; color: var(--rd-body); }

/* The Waste Stream: a thin grey stream leaves the river's bank */
.rd .rd-river__waste { position: relative; margin: 16px 0 0 80px; }
.rd .rd-river__waste::before { content: ""; position: absolute; left: -23px; top: -24px; width: 28px; height: 40px; border-left: 7px solid #D5DDE8; border-bottom: 7px solid #D5DDE8; border-bottom-left-radius: 22px; pointer-events: none; }
.rd .rd-river__waste > .rd-river__card { margin-left: 0; }
.rd .rd-river__wbtn { display: flex; flex-direction: column; gap: 2px; padding: 2px 6px 2px 10px; text-align: left; border-radius: 8px; }
.rd .rd-river__wlabel { font-size: 15px; font-weight: 700; line-height: 1.25; color: #475569; }
.rd .rd-river__wcap { font-size: 14px; font-style: italic; line-height: 1.3; color: var(--rd-muted); }
.rd .rd-river__wbtn:hover .rd-river__wlabel, .rd .rd-river__waste.is-open .rd-river__wlabel { color: var(--rd-navy); text-decoration: underline; text-decoration-color: #CBD5E1; text-underline-offset: 4px; }

/* The river's name, in italics like a label on a map */
.rd .rd-river__fig { position: relative; }
.rd .rd-river__cap { max-width: 34rem; margin: 22px auto 0; padding-left: 24px; font-size: 14px; font-style: italic; line-height: 1.4; color: #2563EB; }

/* The 3 R's: a pill on the arc that carries customers back upstream */
.rd .rd-river__back { position: relative; margin: 16px 0 0 80px; }
.rd .rd-river__back > .rd-river__card { margin-left: 0; }
.rd .rd-river__bbtn { display: inline-flex; align-items: center; gap: 7px; padding: 7px 13px 7px 10px; border-radius: 999px; background: var(--rd-mint); border: 1.5px solid var(--rd-green); color: var(--rd-green-dark); font-size: 13.5px; font-weight: 700; line-height: 1.25; text-align: left; transition: background-color .2s, color .2s; }
.rd .rd-river__bbtn:hover, .rd .rd-river__back.is-open > .rd-river__bbtn { background: var(--rd-green); color: #fff; }

/* The return line on phones: from the customer's stone, up the left bank, into the stop it returns to */
.rd .rd-river__stop--back-to::after, .rd .rd-river__stop--back-mid::after, .rd .rd-river__stop--back-from::after { content: ""; position: absolute; left: 3px; width: 21px; border-left: 2px solid var(--rd-green); pointer-events: none; }
.rd .rd-river__stop--back-to::after { top: 19px; bottom: 0; border-top: 2px solid var(--rd-green); border-top-left-radius: 12px; }
.rd .rd-river__stop--back-mid::after { top: 0; bottom: 0; }
.rd .rd-river__stop--back-from::after { top: 0; height: 23px; width: 23px; border-bottom: 2px solid var(--rd-green); border-bottom-left-radius: 12px; }
.rd .rd-river__stop--back-to::before { content: ""; position: absolute; z-index: 1; left: 16px; top: 15px; border-left: 8px solid var(--rd-green); border-top: 5px solid transparent; border-bottom: 5px solid transparent; pointer-events: none; }
.rd .rd-river__stop--back-to > .rd-river__card, .rd .rd-river__stop--back-mid > .rd-river__card { margin-right: 0; }

/* Flowing in on arrival (phones): each stretch of river fills from the top, one after another */
.rd.rd-river.is-armed:not(.is-drawn) .rd-river__seg { clip-path: inset(0 0 100% 0); }
.rd.rd-river.is-drawn .rd-river__seg { transition: clip-path .42s linear; transition-delay: calc(var(--i, 0) * .36s); }

/* The flowing river: wide screens. Everything is placed on a 1000 by 400 grid that stretches to the
   frame, and the lines keep their thickness whatever the stretch. */
@container rdriver (min-width: 620px) {
  .rd-js .rd .rd-river__stage { --rd-shape-mode: river; max-width: none; height: clamp(360px, 38cqw, 440px); margin: 0; }
  .rd-js .rd .rd-river__cap { position: absolute; left: 0; bottom: 2px; max-width: 46%; margin: 0; padding: 0; pointer-events: none; }
  .rd-js .rd .rd-river__art { display: block; position: absolute; inset: 0; width: 100%; height: 100%; overflow: hidden; pointer-events: none; }
  .rd-js .rd .rd-river__seg { display: none; }
  .rd-js .rd .rd-river__stops { position: static; }
  .rd-js .rd .rd-river__stop { position: static; padding: 0; }
  .rd-js .rd .rd-river__stop::before, .rd-js .rd .rd-river__stop::after { display: none; }

  .rd-js .rd .rd-river__btn { position: absolute; z-index: 2; left: calc(var(--x) * .1%); top: calc(var(--y) * .25%); width: max-content; min-height: 0; padding: 4px 6px; flex-direction: column; align-items: center; gap: 7px; text-align: center; transform: translate(-50%, -24px); }
  .rd-js .rd .rd-river__stop--above > .rd-river__btn { flex-direction: column-reverse; transform: translate(-50%, calc(-100% + 24px)); }
  .rd-js .rd .rd-river__stop--end > .rd-river__btn { transform: translate(-50%, -26px); }
  .rd-js .rd .rd-river__stop--end.rd-river__stop--above > .rd-river__btn { transform: translate(-50%, calc(-100% + 26px)); }
  .rd-js .rd .rd-river__stone { align-self: center; }
  .rd-js .rd .rd-river__stop--end .rd-river__stone { margin: 0; }
  .rd-js .rd .rd-river__words { align-items: center; }

  /* A card opens on the side of the river away from its label, points at its stone, and lets the
     pointer through to any stone it covers */
  .rd-js .rd .rd-river__card { --w: 260px; --ax: calc(var(--x) * .1cqw); --cl: clamp(0px, calc(var(--ax) - var(--w) / 2), calc(100cqw - var(--w)));
    position: absolute; z-index: 6; width: var(--w); margin: 0; left: var(--cl); top: calc(var(--y) * .25% + 32px); pointer-events: none;
    box-shadow: 0 18px 40px rgba(3, 23, 79, .16), 0 2px 6px rgba(3, 23, 79, .06); }
  .rd-js .rd .rd-river__card::before { content: ""; position: absolute; top: -8px; left: clamp(14px, calc(var(--ax) - var(--cl) - 7px), calc(var(--w) - 28px)); width: 14px; height: 14px; background: #fff; border-left: 1px solid var(--rd-line); border-top: 1px solid var(--rd-line); transform: rotate(45deg); }
  .rd-js .rd .rd-river__stop--below > .rd-river__card, .rd-js .rd .rd-river__card--waste { top: auto; bottom: calc(100% - var(--y) * .25% + 32px); }
  .rd-js .rd .rd-river__stop--below > .rd-river__card::before, .rd-js .rd .rd-river__card--waste::before { top: auto; bottom: -8px; border: 0; border-right: 1px solid var(--rd-line); border-bottom: 1px solid var(--rd-line); }

  .rd-js .rd .rd-river__waste { position: static; margin: 0; }
  .rd-js .rd .rd-river__waste::before { display: none; }
  .rd-js .rd .rd-river__wbtn { position: absolute; z-index: 2; left: calc(var(--x) * .1% + 12px); top: calc(var(--y) * .25%); transform: translateY(-50%); }
  .rd-js .rd .rd-river__card--waste { --ax: calc(var(--x) * .1cqw + 44px); bottom: calc(100% - var(--y) * .25% + 26px); }

  .rd-js .rd .rd-river__back { position: static; margin: 0; }
  .rd-js .rd .rd-river__bbtn { position: absolute; z-index: 3; left: calc(var(--x) * .1%); top: calc(var(--y) * .25%); transform: translate(-50%, -50%); white-space: nowrap; box-shadow: 0 0 0 4px #fff; }
  .rd-js .rd .rd-river__card--back { top: calc(var(--y) * .25% + 26px); bottom: auto; }

  .rd-js .rd .rd-river__arrow { display: block; position: absolute; z-index: 1; left: calc(var(--x) * .1%); top: calc(var(--y) * .25% - 34px); margin-left: -6px; border-top: 9px solid var(--rd-green); border-left: 6px solid transparent; border-right: 6px solid transparent; pointer-events: none; }
}
@container rdriver (min-width: 620px) and (max-width: 899px) {
  .rd-js .rd .rd-river__band { stroke-width: 38px; }
  .rd-js .rd .rd-river__label { font-size: 15.5px; }
  .rd-js .rd .rd-river__meta { font-size: 13px; }
  .rd-js .rd .rd-river__card { --w: 250px; }
}

/* The river art */
.rd .rd-river__band { fill: none; stroke-width: 46px; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.rd .rd-river__current { fill: none; stroke-width: 2.5px; stroke-dasharray: 12 11; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.rd .rd-river__waste-line { fill: none; stroke: #DCE3EC; stroke-width: 11px; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.rd .rd-river__back-line { fill: none; stroke: var(--rd-green); stroke-width: 2px; stroke-linecap: round; vector-effect: non-scaling-stroke; }
/* Flowing in on arrival (wide screens): the river runs in from the left */
.rd.rd-river.is-armed:not(.is-drawn) .rd-river__art { clip-path: inset(0 100% 0 0); }
.rd.rd-river.is-armed:not(.is-drawn) .rd-river__arrow { opacity: 0; }
.rd.rd-river.is-drawn .rd-river__art { transition: clip-path 2.2s cubic-bezier(.45, .05, .3, 1); }
.rd.rd-river.is-drawn .rd-river__arrow { transition: opacity .4s ease 1.7s; }


/* ---------- Reduced motion: everything is drawn and opens without movement ---------- */
@media (prefers-reduced-motion: reduce) {
  .rd.rd-loop *, .rd.rd-river * { transition: none !important; }
  .rd .rd-river__btn:hover .rd-river__stone { transform: none; }
  @container rdloop (min-width: 700px) {
    .rd-js .rd .rd-loop__pill:hover { transform: translate(-50%, -50%); }
  }
}
