.process {
  padding-block: var(--space-2xl);
  background: var(--color-bg-soft);
}

.process__head {
  max-width: 60ch;
}

.process__head h2 {
  margin-top: var(--space-sm);
}

/* Always a single row of 5 — --process-gap drives both the grid gap and
   the connector-line math below, so they can never drift out of sync as
   it shrinks at narrower widths. */
.process__steps {
  --process-gap: var(--space-md);
  margin-top: var(--space-2xl);
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: var(--process-gap);
}

.process-step {
  position: relative;
  text-align: center;
  min-width: 0;
}

/* ---- Connector: runs from this step's circle CENTER to the next
   step's circle center. Because .process-step is itself one grid
   column, "100%" inside these calc()s is that column's own width, so
   "100% + gap" is exactly the center-to-center distance regardless of
   how wide the column ends up being — stays accurate at any viewport. */
.process-step:not(:last-child)::after {
  content: "";
  position: absolute;
  top: 27px;
  left: 50%;
  width: calc(100% + var(--process-gap));
  height: 1px;
  background: var(--color-line);
  z-index: 0;
}

/* ---- Traveling icon: each segment carries something thematically tied
   to what's happening between those two steps, instead of a plain dot —
   blood/DNA is drawn, then it becomes a sample in a tube, the tube's
   results travel as a report, and the report becomes a healthy person. */
.process-step:not(:last-child)::before {
  content: "";
  position: absolute;
  top: 27px;
  left: 50%;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
  box-shadow: 0 4px 10px -3px rgba(20, 25, 27, 0.4);
  transform: translate(-50%, -50%);
  z-index: 1;
  animation: processFlowTravel 3.6s ease-in-out infinite;
  animation-delay: calc(var(--step-delay, 0) * 1.2s);
}

/* 1 -> 2: blood / DNA drawn from the patient */
.process-step:nth-child(1)::before {
  --step-delay: 0;
  background-image: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%20viewBox%3D%220%200%2024%2024%22%3E%3Ccircle%20cx%3D%2212%22%20cy%3D%2212%22%20r%3D%2212%22%20fill%3D%22%23287f8f%22/%3E%3Cpath%20d%3D%22M12%205.2s5.2%206.2%205.2%209.8a5.2%205.2%200%2001-10.4%200c0-3.6%205.2-9.8%205.2-9.8z%22%20fill%3D%22%23fff%22/%3E%3C/svg%3E");
}

/* 2 -> 3: the sample travels to the lab in a tube */
.process-step:nth-child(2)::before {
  --step-delay: 1;
  background-image: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%20viewBox%3D%220%200%2024%2024%22%3E%3Ccircle%20cx%3D%2212%22%20cy%3D%2212%22%20r%3D%2212%22%20fill%3D%22%23287f8f%22/%3E%3Cpath%20d%3D%22M9.5%204.5h5M10.3%204.5v6.3l-3.4%205.4a1.8%201.8%200%20001.5%202.8h6.9a1.8%201.8%200%20001.5-2.8l-3.4-5.4V4.5%22%20fill%3D%22none%22%20stroke%3D%22%23fff%22%20stroke-width%3D%221.5%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22/%3E%3Cpath%20d%3D%22M8.3%2014.3h7.3%22%20stroke%3D%22%23fff%22%20stroke-width%3D%221.5%22%20stroke-linecap%3D%22round%22/%3E%3C/svg%3E");
}

/* 3 -> 4: the lab's findings arrive as a report */
.process-step:nth-child(3)::before {
  --step-delay: 2;
  background-image: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%20viewBox%3D%220%200%2024%2024%22%3E%3Ccircle%20cx%3D%2212%22%20cy%3D%2212%22%20r%3D%2212%22%20fill%3D%22%23287f8f%22/%3E%3Crect%20x%3D%225.3%22%20y%3D%227.3%22%20width%3D%2213.4%22%20height%3D%229.6%22%20rx%3D%221.4%22%20fill%3D%22none%22%20stroke%3D%22%23fff%22%20stroke-width%3D%221.5%22/%3E%3Cpath%20d%3D%22M5.8%208.1L12%2012.6l6.2-4.5%22%20fill%3D%22none%22%20stroke%3D%22%23fff%22%20stroke-width%3D%221.5%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22/%3E%3C/svg%3E");
}

/* 4 -> 5: the report becomes a healthy person */
.process-step:nth-child(4)::before {
  --step-delay: 3;
  background-image: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%20viewBox%3D%220%200%2024%2024%22%3E%3Ccircle%20cx%3D%2212%22%20cy%3D%2212%22%20r%3D%2212%22%20fill%3D%22%23287f8f%22/%3E%3Ccircle%20cx%3D%2212%22%20cy%3D%229.3%22%20r%3D%222.6%22%20fill%3D%22%23fff%22/%3E%3Cpath%20d%3D%22M6.3%2018c0-3.2%202.7-4.8%205.7-4.8s5.7%201.6%205.7%204.8%22%20fill%3D%22none%22%20stroke%3D%22%23fff%22%20stroke-width%3D%221.5%22%20stroke-linecap%3D%22round%22/%3E%3C/svg%3E");
}

@keyframes processFlowTravel {
  0% { left: 50%; opacity: 0; }
  12% { opacity: 1; }
  88% { opacity: 1; }
  100% { left: calc(150% + var(--process-gap)); opacity: 0; }
}

.process-step__num {
  position: relative;
  z-index: 2;
  width: 56px;
  height: 56px;
  margin-inline: auto;
  border-radius: 50%;
  background: var(--color-bg);
  border: 1px solid var(--color-brand-tint);
  box-shadow: 0 10px 24px -14px rgba(40, 127, 143, 0.45),
    inset 0 1px 2px rgba(255, 255, 255, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--color-brand);
  transition: transform var(--dur-med) var(--ease-silk),
    box-shadow var(--dur-med) var(--ease-silk);
}

.process-step:hover .process-step__num {
  transform: translateY(-3px);
  box-shadow: 0 16px 30px -14px rgba(40, 127, 143, 0.55),
    inset 0 1px 2px rgba(255, 255, 255, 0.9);
}

.process-step__title {
  margin-top: var(--space-md);
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 600;
}

.process-step__desc {
  margin-top: 0.4rem;
  margin-inline: auto;
  font-size: var(--fs-small);
  max-width: 30ch;
}

/* ---- Progressive shrink so all 5 stay in one row down to phone widths
   instead of falling back to a stacked list. ---- */
@media (max-width: 900px) {
  .process__steps {
    --process-gap: var(--space-sm);
  }
  .process-step__num {
    width: 46px;
    height: 46px;
    font-size: 1.1rem;
  }
  .process-step:not(:last-child)::before {
    width: 18px;
    height: 18px;
  }
  .process-step__title {
    margin-top: var(--space-sm);
    font-size: 0.95rem;
  }
  .process-step__desc {
    font-size: 0.8rem;
    max-width: 18ch;
  }
}

/* ---- Phone: a vertical stepper instead of a cramped single row — each
   step reads left-to-right (numbered circle, then title + description),
   stacked top to bottom. The connector line and traveling icon now run
   down the left edge (through the circles' shared center column) instead
   of across, using the same "100% + gap" trick as the horizontal version,
   just on the height axis instead of width. Sizes are a touch larger than
   the old horizontal-shrink values since nothing needs to be squeezed to
   fit 5 across anymore. ---- */
@media (max-width: 640px) {
  .process__steps {
    grid-template-columns: 1fr;
    --process-gap: var(--space-xl);
  }

  .process-step {
    display: flex;
    align-items: flex-start;
    gap: var(--space-md);
    text-align: left;
  }

  .process-step__body {
    flex: 1;
    min-width: 0;
  }

  .process-step__num {
    flex-shrink: 0;
    margin-inline: 0;
    width: 52px;
    height: 52px;
    font-size: 1.2rem;
  }

  .process-step__title {
    margin-top: 0.35rem;
    font-size: 1rem;
  }

  .process-step__desc {
    display: block;
    margin-top: 0.3rem;
    margin-inline: 0;
    font-size: 0.88rem;
    max-width: none;
  }

  .process-step:not(:last-child)::after {
    top: 26px;
    left: 26px;
    width: 1px;
    height: calc(100% + var(--process-gap));
  }

  .process-step:not(:last-child)::before {
    top: 26px;
    left: 26px;
    width: 18px;
    height: 18px;
    animation-name: processFlowTravelVertical;
  }
}

@keyframes processFlowTravelVertical {
  0% { top: 26px; opacity: 0; }
  12% { opacity: 1; }
  88% { opacity: 1; }
  100% { top: calc(100% + var(--process-gap) + 26px); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .process-step:not(:last-child)::before {
    animation: none;
    opacity: 0;
  }
}
