/* ====================================================================
 * THE PATH OF A PART THROUGH PRODUCTION  (/process-tools/, .cclp-flow)
 *
 * Six stations that used to sit in two unconnected rows and now form one
 * stroke that snakes: 1 2 3 to the right, down through a lane kept free at
 * the right edge, then 4 5 6 back to the left. The second row is read from
 * right to left, and that is the whole trick: it is what turns two strips
 * into one line. The printed brochure this page follows does it the same
 * way.
 *
 * WHAT LIVES WHERE
 *
 *   Everything the section looks like is in this file, including the two
 *   plain lines that stand in when the script does not run.
 *
 *   assets/ccx-lpflow.js measures the circles and draws one SVG path
 *   through them. It adds cclpf-wired to the section, which is what takes
 *   the plain lines away again, and cclpf-live while the section is on
 *   screen, which is what lets the light run.
 *
 * THE ONE MEASUREMENT EVERYTHING HANGS ON
 *
 *   --cclpf-lane is the distance from the top of a row down to the middle
 *   of its circles. It has to be a constant, because the piece that turns
 *   the corner is anchored to the top of the first row and to a point below
 *   its bottom edge, and neither may depend on how long a station's
 *   sentence happens to be. That is why the photograph band has a fixed
 *   height instead of an aspect ratio: a band that grew with the column
 *   would make the lane a moving target and the corner would miss.
 *
 * SPECIFICITY
 *
 *   The page builder writes its own container rules as
 *   .elementor-21301 .elementor-element-7c000068, which is two classes.
 *   Repeating the class once (.cclpf-row.cclpf-row) puts these rules above
 *   them without a single !important, and it keeps working when the post id
 *   differs, which it does between the live site and the staging clone.
 * ==================================================================== */

.cclp-flow {
  --cclpf-band: 168px;        /* height of the photograph band            */
  --cclpf-node: 52px;         /* diameter of a numbered circle            */
  --cclpf-gap: 14px;          /* upright gap inside one station           */
  --cclpf-col-gap: 24px;      /* gap between two stations of a row        */
  --cclpf-turn: 56px;         /* lane at the right edge, kept free        */
  --cclpf-rowgap: 56px;       /* between the two rows, the corner uses it */
  --cclpf-radius: 15px;       /* same corner as the idea cards            */
  --cclpf-edge: 0px;          /* gutter, see the note at the row          */

  /* derived, never written by hand */
  --cclpf-colw: calc((100% - 2 * var(--cclpf-edge) - var(--cclpf-turn)
                      - 2 * var(--cclpf-col-gap)) / 3);
  --cclpf-lane: calc(var(--cclpf-band) + var(--cclpf-gap) + var(--cclpf-node) / 2);

  position: relative;         /* the SVG hangs in here */
}


/* --------------------------------------------------------------------
 * THE TWO ROWS
 *
 * Three equal columns and a right hand lane that stays empty. The lane is
 * padding rather than a fourth grid column, so it does not pick up the
 * column gap and the corner sits exactly half a lane from the edge.
 *
 * In the lower row the three stations are put back to front by grid
 * placement, not by row-reverse. The document keeps the order 4, 5, 6,
 * which is the order they are read out in and the order they are numbered
 * in; only the eye walks them the other way, guided by the line.
 * -------------------------------------------------------------------- */
/* The gutter is on the row rather than on a station, which is the whole
 * point of it: the stations used to carry 16px of padding each, so their
 * text kept away from the edge of the window while the container itself sat
 * on it. A photograph fills its station to the last pixel, and it would
 * have sat on that edge with its rounded corner cut in half. Kept on the
 * row, the gutter takes the columns in with it and every station keeps the
 * same distance from the edge, picture and all.
 *
 * The right side carries the gutter plus the turning lane, so that the
 * drawing as a whole, the stations and the line that turns beside them, is
 * centred: it reaches exactly as far to the right as the pictures reach to
 * the left. */
.cclp-flow .cclpf-row.cclpf-row {
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  column-gap: var(--cclpf-col-gap);
  row-gap: 0;
  padding: 0 calc(var(--cclpf-edge) + var(--cclpf-turn)) 0 var(--cclpf-edge);
  width: 100%;
  margin: 40px 0 0 0;
}

/* Under 1440 the section is no longer narrower than the window, so nothing
 * keeps it off the edge any more and the gutter has to. */
@media (max-width: 1439px) {
  .cclp-flow { --cclpf-edge: 20px; }
}

.cclp-flow .cclpf-row-b.cclpf-row-b {
  margin-top: var(--cclpf-rowgap);
}

/* The row has to be named as well as the column. Placing the first station
 * in column 3 and the next one in column 2 sends the grid looking for a
 * free cell from left to right, finds column 2 already behind it, and opens
 * a second row for it: without grid-row the lower three stations end up
 * underneath one another instead of beside one another. */
.cclp-flow .cclpf-row-b .cclpf-s4.cclpf-s4 { grid-column: 3; grid-row: 1; }
.cclp-flow .cclpf-row-b .cclpf-s5.cclpf-s5 { grid-column: 2; grid-row: 1; }
.cclp-flow .cclpf-row-b .cclpf-s6.cclpf-s6 { grid-column: 1; grid-row: 1; }


/* --------------------------------------------------------------------
 * ONE STATION
 *
 * Photograph, circle, title, sentence, in that order and flush left. The
 * brochure sets them left as well, and it is the only alignment that works
 * once a picture sits above the text: centred lines under a full width
 * photograph leave two ragged margins and no edge for the eye to hold.
 * -------------------------------------------------------------------- */
.cclp-flow .cclpf-step.cclpf-step {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--cclpf-gap);
  width: 100%;
  padding: 0;
  overflow: visible;
}

/* Headings and paragraphs of a station: full width, flush left. The custom
 * width of 340px on the sentence and the centred alignment both come from
 * the widget settings and are answered here rather than in the page data,
 * so the page keeps working if this stylesheet is ever switched off. */
.cclp-flow .cclpf-step .cclpf-title.cclpf-title,
.cclp-flow .cclpf-step .cclpf-text.cclpf-text {
  --width: 100%;
  width: 100%;
  max-width: 100%;
  margin: 0;
}

.cclp-flow .cclpf-step .cclpf-title .elementor-heading-title,
.cclp-flow .cclpf-step .cclpf-text .elementor-heading-title {
  text-align: left;
}

/* The sentence keeps the silver gradient fill it is given in the widget,
 * so only the box is touched here. */
.cclp-flow .cclpf-step .cclpf-text.cclpf-text {
  margin-top: -2px;
}


/* --------------------------------------------------------------------
 * THE PHOTOGRAPH
 *
 * A band of fixed height with the picture cut to fill it. The files are cut
 * to 12:5 beforehand, so on a wide screen the band shows very nearly the
 * whole frame and only the narrow windows crop into it.
 * -------------------------------------------------------------------- */
.cclp-flow .cclpf-shot.cclpf-shot {
  width: 100%;
  height: var(--cclpf-band);
  margin: 0;
  border-radius: var(--cclpf-radius);
  overflow: hidden;
  position: relative;
  background: rgba(255, 255, 255, 0.03);
}

.cclp-flow .cclpf-shot .elementor-widget-container,
.cclp-flow .cclpf-shot figure,
.cclp-flow .cclpf-shot a {
  display: block;
  width: 100%;
  height: 100%;
  margin: 0;
  border-radius: inherit;
}

.cclp-flow .cclpf-shot img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
}

/* A hairline inside the corner, the same one the idea cards carry, so the
 * photographs sit in the page instead of on it. */
.cclp-flow .cclpf-shot.cclpf-shot::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.10);
  pointer-events: none;
}


/* --------------------------------------------------------------------
 * STATION 6 HAS NO PHOTOGRAPH
 *
 * In the brochure the last station carries a small note pointing at the
 * board printed underneath it instead of a picture. The note takes the
 * place the picture would have had, which is what keeps the circle of
 * station 6 on the same line as those of 4 and 5. A hole there would have
 * dropped it below the others and broken the very line this round is about.
 *
 * The script turns the note into something that can be clicked and gives it
 * a keyboard role; without the script it stays exactly what it reads as, a
 * printed hint.
 * -------------------------------------------------------------------- */
.cclp-flow .cclpf-chip.cclpf-chip {
  /* Last in the page, first on the screen. Read aloud the note belongs
   * behind the station it closes; seen, it belongs where the other five
   * stations have their photograph, because that is what keeps the circle
   * of station 6 on the same line as the circles of 4 and 5. */
  order: -1;
  width: 100%;
  height: var(--cclpf-band);
  margin: 0;
  border-radius: var(--cclpf-radius);
  border: 1px dashed rgba(255, 255, 255, 0.16);
  background:
    radial-gradient(120% 100% at 50% 0%,
      rgba(255, 142, 43, 0.07) 0%, rgba(255, 142, 43, 0) 62%),
    rgba(255, 255, 255, 0.022);
  display: flex;
  align-items: center;
  justify-content: center;
}

.cclp-flow .cclpf-chip .elementor-widget-container {
  display: flex;
  align-items: center;
  justify-content: center;
}

.cclp-flow .cclpf-chip .elementor-heading-title {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 9px 16px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.05);
  font-family: "Plus Jakarta Sans", sans-serif;
  font-size: 13px;
  font-weight: 600;
  line-height: 17px;
  letter-spacing: 0.01em;
  color: #C9D0E0;
  text-align: center;
  transition: color 0.25s ease, border-color 0.25s ease,
              background-color 0.25s ease;
}

/* The chevron is drawn rather than typed, so no glyph and no icon font has
 * to be loaded for it. It nods once when the note is hovered. */
.cclp-flow .cclpf-chip .elementor-heading-title::after {
  content: "";
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-right: 2px solid #ff8e2b;
  border-bottom: 2px solid #ff8e2b;
  transform: translateY(-2px) rotate(45deg);
  transition: transform 0.25s ease;
}

.cclp-flow .cclpf-chip.cclpf-chip-live { cursor: pointer; }

.cclp-flow .cclpf-chip-live:hover .elementor-heading-title,
.cclp-flow .cclpf-chip-live:focus-visible .elementor-heading-title {
  color: #fff;
  border-color: rgba(255, 162, 77, 0.55);
  background: rgba(255, 142, 43, 0.10);
}

.cclp-flow .cclpf-chip-live:hover .elementor-heading-title::after,
.cclp-flow .cclpf-chip-live:focus-visible .elementor-heading-title::after {
  transform: translateY(1px) rotate(45deg);
}

.cclp-flow .cclpf-chip-live:focus-visible {
  outline: 2px solid rgba(255, 162, 77, 0.7);
  outline-offset: 3px;
}


/* --------------------------------------------------------------------
 * THE NUMBERED CIRCLE
 *
 * Same circle the section had before, lifted out of the page settings into
 * this file so that it can be given something to do: it flares when the
 * light reaches it. The resting state below and the first and last frame of
 * the flare are deliberately the same values, so a circle looks identical
 * whether the light has been past or not.
 * -------------------------------------------------------------------- */
.cclp-flow .cclpf-node.cclpf-node {
  width: var(--cclpf-node);
  height: var(--cclpf-node);
  margin: 0;
  flex: 0 0 auto;
  position: relative;
  z-index: 2;
}

.cclp-flow .cclpf-node .elementor-widget-container {
  width: 100%;
  height: 100%;
}

.cclp-flow .cclpf-node .elementor-heading-title {
  width: var(--cclpf-node);
  height: var(--cclpf-node);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #FFA24D 0%, #E2680D 100%);
  box-shadow: 0 6px 18px rgba(206, 89, 4, 0.35);
  color: #12182b;
  font-family: "Plus Jakarta Sans", sans-serif;
  font-weight: 700;
  font-size: 18px;
  line-height: 1;
  letter-spacing: 0.01em;
  -webkit-user-select: none;
  user-select: none;
}


/* --------------------------------------------------------------------
 * THE LINE WITHOUT THE SCRIPT
 *
 * One line per row, from the middle of the first circle to the middle of
 * the third, in the same faint orange the section had before. It is what a
 * visitor without JavaScript sees, and it is also what stands there for the
 * few milliseconds before the script has measured anything, so the section
 * never appears with its stations floating unconnected.
 *
 * The width is read off the grid rather than guessed: half a column in from
 * the left, half a column plus the turning lane in from the right.
 * -------------------------------------------------------------------- */
.cclp-flow .cclpf-row.cclpf-row::before {
  content: "";
  position: absolute;
  left: calc(var(--cclpf-edge) + var(--cclpf-colw) / 2);
  right: calc(var(--cclpf-edge) + var(--cclpf-turn) + var(--cclpf-colw) / 2);
  top: calc(var(--cclpf-lane) - 1px);
  height: 2px;
  border-radius: 2px;
  z-index: 0;
  pointer-events: none;
  background: linear-gradient(90deg,
    rgba(255, 142, 43, 0.10) 0%,
    rgba(255, 142, 43, 0.42) 50%,
    rgba(255, 142, 43, 0.10) 100%);
}

/* The script has drawn the real one. */
.cclp-flow.cclpf-wired .cclpf-row.cclpf-row::before {
  content: none;
}


/* --------------------------------------------------------------------
 * THE STROKE AND THE LIGHT ON IT
 *
 * Three paths on top of one another, all with the same shape:
 *
 *   cclpf-rail   the resting line, always there
 *   cclpf-halo   a wide soft dash, the glow around the light
 *   cclpf-beam   a narrow bright dash, the light itself
 *
 * The two dashes are one dash each, moved along the path by their offset.
 * A blur filter would have been the obvious way to get the glow, but a
 * filter is recomputed on every frame over the whole box; a second, wider
 * stroke at low alpha costs a fraction of that and is indistinguishable at
 * this size.
 *
 * The dash pattern is "beam, length": the gap is as long as the whole path,
 * so there is never a second dash on the line. --cclpf-o0 and --cclpf-o1
 * are set by the script from the measured length; at o0 the dash sits just
 * before the start, at o1 just past the end.
 *
 * The light is only allowed to run while the section is on screen
 * (cclpf-live), so a page left open somewhere below keeps nothing busy.
 * -------------------------------------------------------------------- */
.cclp-flow .cclpf-wire {
  position: absolute;
  z-index: 0;
  pointer-events: none;
  overflow: visible;
}

.cclp-flow .cclpf-wire path {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.cclp-flow .cclpf-rail {
  stroke: rgba(255, 142, 43, 0.26);
  stroke-width: 2;
}

/* The light is two dashes that share a leading edge: a short bright one and
 * a longer, wider, much fainter one behind it. Together they read as a head
 * with a tail, which says which way the part is travelling; a single dash of
 * even brightness is a bar and says nothing.
 *
 * Sharing the edge is the whole reason the two have their own pair of
 * offsets. A dash pattern is measured from its own start, so a tail that is
 * three times longer would begin three times earlier if both were given the
 * same offset. The script shifts the tail by the difference in length, which
 * puts the two front ends on the same point of the path at every moment. */
.cclp-flow .cclpf-halo,
.cclp-flow .cclpf-beam {
  opacity: 0;
}

.cclp-flow .cclpf-halo {
  stroke: rgba(255, 168, 84, 0.22);
  stroke-width: 10;
  stroke-dasharray: var(--cclpf-trail, 240) var(--cclpf-len, 4000);
  stroke-dashoffset: var(--cclpf-h0, 240);
}

.cclp-flow .cclpf-beam {
  stroke: #ffe0bd;
  stroke-width: 2.5;
  stroke-dasharray: var(--cclpf-beam, 80) var(--cclpf-len, 4000);
  stroke-dashoffset: var(--cclpf-o0, 80);
}

.cclp-flow.cclpf-live .cclpf-halo {
  animation: cclpf-run-halo var(--cclpf-cycle, 9.2s) linear infinite;
}

.cclp-flow.cclpf-live .cclpf-beam {
  animation: cclpf-run var(--cclpf-cycle, 9.2s) linear infinite;
}

/* Half the cycle carries the light from station 1 to station 6, the other
 * half is the pause that keeps the section from becoming a tic. The script
 * derives the delay of every circle from the same half, so the two can not
 * drift apart. */
@keyframes cclpf-run {
  0%   { stroke-dashoffset: var(--cclpf-o0, 80); opacity: 0; }
  3%   { opacity: 1; }
  47%  { opacity: 1; }
  50%  { stroke-dashoffset: var(--cclpf-o1, -4000); opacity: 0; }
  100% { stroke-dashoffset: var(--cclpf-o1, -4000); opacity: 0; }
}

@keyframes cclpf-run-halo {
  0%   { stroke-dashoffset: var(--cclpf-h0, 240); opacity: 0; }
  3%   { opacity: 1; }
  47%  { opacity: 1; }
  50%  { stroke-dashoffset: var(--cclpf-h1, -4000); opacity: 0; }
  100% { stroke-dashoffset: var(--cclpf-h1, -4000); opacity: 0; }
}


/* --------------------------------------------------------------------
 * A CIRCLE CATCHING THE LIGHT
 *
 * --cclpf-at is written on each circle by the script: the moment the head
 * of the light stands on it, counted from the start of the run. Because
 * every circle shares the cycle length and differs only in its delay, the
 * six flares stay locked to the light for as long as the page is open.
 *
 * The flare is short and low: a swell of the shadow it already casts, a
 * thin ring that opens and fades, and a seventh of a step in size. The
 * section is about a part being tracked, not about fairy lights.
 * -------------------------------------------------------------------- */
.cclp-flow.cclpf-live .cclpf-node .elementor-heading-title {
  animation: cclpf-flare var(--cclpf-cycle, 9.2s) linear infinite;
  animation-delay: var(--cclpf-at, 0s);
}

@keyframes cclpf-flare {
  0% {
    transform: scale(1);
    box-shadow: 0 6px 18px rgba(206, 89, 4, 0.35),
                0 0 0 0 rgba(255, 200, 140, 0);
  }
  1.7% {
    transform: scale(1.07);
    box-shadow: 0 6px 26px rgba(255, 142, 43, 0.60),
                0 0 0 5px rgba(255, 200, 140, 0.26);
  }
  8% {
    transform: scale(1);
    box-shadow: 0 6px 18px rgba(206, 89, 4, 0.35),
                0 0 0 14px rgba(255, 200, 140, 0);
  }
  100% {
    transform: scale(1);
    box-shadow: 0 6px 18px rgba(206, 89, 4, 0.35),
                0 0 0 0 rgba(255, 200, 140, 0);
  }
}


/* --------------------------------------------------------------------
 * BETWEEN 768 AND 1024
 *
 * Same arrangement, one size down. The turning lane shrinks with the rest,
 * which keeps the corner in proportion to the circles.
 * -------------------------------------------------------------------- */
@media (max-width: 1024px) {
  .cclp-flow {
    --cclpf-band: 148px;
    --cclpf-node: 48px;
    --cclpf-col-gap: 20px;
    --cclpf-turn: 44px;
    --cclpf-rowgap: 46px;
  }

  .cclp-flow .cclpf-node .elementor-heading-title { font-size: 17px; }
  .cclp-flow .cclpf-chip .elementor-heading-title { font-size: 12px; padding: 8px 13px; }
}


/* --------------------------------------------------------------------
 * BELOW 768: THE LINE STANDS UP
 *
 * The six stations become one column and the circles move to a lane of
 * their own on the left, with picture, title and sentence to the right of
 * them. The line then runs straight down from station 1 to station 6, and
 * the script needs to be told nothing about it: it looks at where the
 * circles ended up, sees them standing above one another and leaves out the
 * detour to the right.
 *
 * The gap between the two rows is closed to the gap between two stations,
 * so the column reads as six equal steps rather than as two rows that
 * happen to sit under one another.
 * -------------------------------------------------------------------- */
@media (max-width: 767px) {
  .cclp-flow {
    --cclpf-band: 132px;
    --cclpf-node: 44px;
    --cclpf-turn: 0px;
    --cclpf-col-gap: 0px;
    --cclpf-rowgap: 28px;
    --cclpf-lane-w: 18px;      /* between circle and content */
    --cclpf-step-gap: 28px;    /* between two stations       */
    /* the section itself is given 16px of padding here by the page
     * builder, so a gutter of our own would only double it */
    --cclpf-edge: 0px;
  }

  .cclp-flow .cclpf-row.cclpf-row {
    grid-template-columns: 1fr;
    row-gap: var(--cclpf-step-gap);
    padding: 0;
    margin-top: 28px;
  }

  .cclp-flow .cclpf-row-b.cclpf-row-b {
    margin-top: var(--cclpf-rowgap);
  }

  /* placement is only for the wide layout */
  .cclp-flow .cclpf-row-b .cclpf-s4.cclpf-s4,
  .cclp-flow .cclpf-row-b .cclpf-s5.cclpf-s5,
  .cclp-flow .cclpf-row-b .cclpf-s6.cclpf-s6 {
    grid-column: auto;
    grid-row: auto;
  }

  .cclp-flow .cclpf-step.cclpf-step {
    padding-left: calc(var(--cclpf-node) + var(--cclpf-lane-w));
    min-height: var(--cclpf-node);
  }

  /* The circle leaves the flow and sits in its lane, level with the middle
   * of the picture band it stands beside. */
  .cclp-flow .cclpf-node.cclpf-node {
    position: absolute;
    left: 0;
    top: calc(var(--cclpf-band) / 2 - var(--cclpf-node) / 2);
  }

  .cclp-flow .cclpf-node .elementor-heading-title { font-size: 16px; }

  /* The two plain lines of the no-script fallback are horizontal by nature
   * and have nothing to sit on here. The upright one is the script's. */
  .cclp-flow .cclpf-row.cclpf-row::before { content: none; }

  .cclp-flow .cclpf-chip .elementor-heading-title { font-size: 12px; padding: 8px 13px; }
}


/* --------------------------------------------------------------------
 * LESS MOTION
 *
 * The line is drawn in full and stays that way, the circles keep the look
 * they have when the light has been past. Nothing moves, and nothing is
 * missing either: someone who asked for less motion still sees the whole
 * connection from station 1 to station 6, which is the point of the
 * section.
 * -------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  .cclp-flow.cclpf-live .cclpf-halo,
  .cclp-flow.cclpf-live .cclpf-beam,
  .cclp-flow.cclpf-live .cclpf-node .elementor-heading-title {
    animation: none;
  }

  .cclp-flow .cclpf-rail {
    stroke: rgba(255, 142, 43, 0.42);
  }

  .cclp-flow .cclpf-halo,
  .cclp-flow .cclpf-beam {
    opacity: 0;
  }
}
