/* SECTION: diagnosis */
.step {
  margin-top: var(--space-8);
}

.step__head {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}

.step__head .sub-title {
  margin: 0;
}

.step__figure {
  margin-top: var(--space-5);
}

.step__row {
  margin-top: var(--space-6);
}

.step__small {
  max-width: 680px;
}

.step__more {
  margin-top: var(--space-4);
}

/* ---------- pipe: the direction signal followed through a Video-LLM ----------
   Same look as the pipeline scene of the hero reel. diagnosis.js builds the
   stages from data/diagnosis.json. Sizes inside the stage are in cqw. */
.pipe {
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* what the two kinds of number mean, in plain words */
.pipe__legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-6);
  margin-bottom: var(--space-4);
  font-size: var(--fs-label);
  font-weight: 600;
}

.pipe__legend li {
  display: inline-flex;
  align-items: center;
  gap: 0.6em;
}

.pipe__key {
  flex: none;
  width: 2em;
  height: 1.05em;
  border: 3px solid var(--blue);
  border-radius: 999px;
  background: #fff;
}

.pipe__key--qa {
  border-color: var(--red);
}

.pipe__stage {
  position: relative;
  aspect-ratio: 1280 / 370;
  overflow: hidden;
  border-radius: 24px;
  background: var(--stage);
  container-type: inline-size;
}

/* the LLM holds two measuring points */
.pipe__llm {
  position: absolute;
  top: 6.4cqw;
  left: 47cqw;
  width: 32cqw;
  height: 11.6cqw;
  padding: 0.7cqw 1.4cqw;
  border-radius: 1.6cqw;
  background: #e9eef6;
  font-size: 1.7cqw;
  font-weight: 800;
}

.pipe__wire {
  position: absolute;
  top: 13.75cqw;
  margin-top: -0.12cqw;
  border-top: 0.24cqw solid var(--ink);
}

.pipe__wire--1 { left: 11cqw; width: 3cqw; }
.pipe__wire--2 { left: 28cqw; width: 3.5cqw; }
.pipe__wire--3 { left: 43.5cqw; width: 5cqw; }
.pipe__wire--4 { left: 61.5cqw; width: 3cqw; }

.pipe__wire--gap {
  left: 77.5cqw;
  width: 7.5cqw;
  border-top: 0.3cqw dashed var(--red);
}

/* the signal passes behind each module and comes out on the other side */
.pipe__sig {
  position: absolute;
  z-index: 1;
  top: 13.75cqw;
  left: 6.5cqw;
  width: 2.4cqw;
  height: 2.4cqw;
  margin: -1.2cqw 0 0 -1.2cqw;
  border: 0.24cqw solid var(--ink);
  border-radius: 50%;
  background: var(--yellow);
  opacity: 0;
}

.pipe__video {
  position: absolute;
  z-index: 2;
  top: 9.25cqw;
  left: 2cqw;
  width: 9cqw;
  height: 9cqw;
  border: 0.24cqw solid var(--ink);
  border-radius: 1.2cqw;
  background: #fffdf5;
}

.pipe__video i {
  position: absolute;
  top: 46%;
  width: 6%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--yellow);
  opacity: 0.5;
  transform: translate(-50%, -50%);
}

.pipe__video i:last-child {
  width: 20%;
  opacity: 1;
}

.pipe__video-label {
  position: absolute;
  top: 19.2cqw;
  left: 6.5cqw;
  font-size: 1.6cqw;
  font-weight: 700;
  white-space: nowrap;
  transform: translateX(-50%);
}

.pipe__item {
  position: absolute;
  z-index: 2;
  top: 13.75cqw;
  left: var(--x);
  width: var(--w);
  margin-left: calc(var(--w) / -2);
}

.pipe__item:nth-child(1) { --x: 21cqw; --w: 14cqw; }
.pipe__item:nth-child(2) { --x: 37.5cqw; --w: 12cqw; }
.pipe__item:nth-child(3) { --x: 55cqw; --w: 13cqw; }
.pipe__item:nth-child(4) { --x: 71cqw; --w: 13cqw; }
.pipe__item:nth-child(6) { --x: 91cqw; --w: 12cqw; }

.pipe__node {
  display: grid;
  place-items: center;
  height: 6.4cqw;
  margin-top: -3.2cqw;
  border: 0.24cqw solid var(--ink);
  border-radius: 1.3cqw;
  background: #fff;
  font-size: 1.75cqw;
  font-weight: 700;
  white-space: nowrap;
}

.pipe__item[data-where] .pipe__node {
  height: 5cqw;
  margin-top: -2.5cqw;
  font-size: 1.55cqw;
}

/* the number measured at this stage */
.pipe__chip {
  position: absolute;
  top: 7.3cqw;
  left: 50%;
  padding: 0.25cqw 1.4cqw;
  border: 0.26cqw solid var(--blue);
  border-radius: 999px;
  background: #fff;
  font-size: 2.3cqw;
  font-weight: 800;
  line-height: 1.2;
  transform: translateX(-50%);
}

.pipe__item[data-kind="qa"] .pipe__chip {
  border-color: var(--red);
}

.pipe__gap {
  position: absolute;
  z-index: 2;
  top: 2.6cqw;
  left: 84cqw;
  padding: 0.3cqw 1.3cqw;
  border-radius: 999px;
  background: var(--red);
  color: #fff;
  font-size: 1.65cqw;
  font-weight: 700;
  white-space: nowrap;
  transform: translateX(-50%);
}

.pipe__replay {
  margin-top: var(--space-3);
}

/* waiting to play: numbers and the gap label are hidden */
.pipe__stage.is-armed .pipe__chip,
.pipe__stage.is-armed .pipe__gap {
  opacity: 0;
}

.pipe__stage.is-playing .pipe__sig {
  animation: pipe-sig 5s linear both;
}

.pipe__stage.is-playing .pipe__chip {
  animation: pipe-chip 0.4s var(--ease) both;
}

.pipe__stage.is-playing .pipe__item:nth-child(1) .pipe__chip { animation-delay: 1s; }
.pipe__stage.is-playing .pipe__item:nth-child(2) .pipe__chip { animation-delay: 1.8s; }
.pipe__stage.is-playing .pipe__item:nth-child(3) .pipe__chip { animation-delay: 2.6s; }
.pipe__stage.is-playing .pipe__item:nth-child(4) .pipe__chip { animation-delay: 3.4s; }
.pipe__stage.is-playing .pipe__item:nth-child(6) .pipe__chip { animation-delay: 4.5s; }

.pipe__stage.is-playing .pipe__gap {
  animation: pipe-gap 0.4s var(--ease) 4.1s both;
}

/* out of the video, through each module, and lost in the gap before the answer */
@keyframes pipe-sig {
  0% { left: 6.5cqw; opacity: 1; }
  6%, 10% { left: 12.5cqw; opacity: 1; }
  20%, 26% { left: 29.75cqw; opacity: 1; }
  36%, 42% { left: 46cqw; opacity: 1; }
  52%, 58% { left: 63cqw; opacity: 1; }
  68%, 76% { left: 80.5cqw; opacity: 1; }
  86%, 100% { left: 82.5cqw; opacity: 0; }
}

@keyframes pipe-chip {
  from { opacity: 0; transform: translateX(-50%) scale(0.7); }
  to { opacity: 1; transform: translateX(-50%) scale(1); }
}

@keyframes pipe-gap {
  from { opacity: 0; transform: translateX(-50%) scale(0.7); }
  to { opacity: 1; transform: translateX(-50%) scale(1); }
}

@media (max-width: 599px) {
  .step {
    margin-top: var(--space-7);
  }
}

/* small screens: a plain list, every number shown */
@media (max-width: 759px) {
  .pipe__stage {
    aspect-ratio: auto;
    padding: var(--space-4);
    container-type: normal;
  }

  .pipe__llm,
  .pipe__wire,
  .pipe__sig,
  .pipe__video,
  .pipe__video-label,
  .pipe__replay {
    display: none;
  }

  .pipe__items {
    display: grid;
    gap: var(--space-2);
  }

  .pipe__item {
    position: static;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    width: auto;
    margin: 0;
  }

  .pipe__node,
  .pipe__item[data-where] .pipe__node {
    display: block;
    height: auto;
    margin: 0;
    padding: 0;
    border: 0;
    background: none;
    font-size: 1.05rem;
    white-space: normal;
  }

  .pipe__item[data-where] .pipe__node::before {
    content: attr(data-where) ": ";
  }

  .pipe__chip {
    position: static;
    padding: 1px 14px;
    border-width: 3px;
    font-size: 1.15rem;
    transform: none;
  }

  .pipe__gap {
    position: static;
    justify-self: start;
    padding: 2px 14px;
    font-size: 0.95rem;
    transform: none;
  }

  .pipe__stage.is-armed .pipe__chip,
  .pipe__stage.is-armed .pipe__gap {
    opacity: 1;
  }

  .pipe__stage.is-playing .pipe__chip,
  .pipe__stage.is-playing .pipe__gap {
    animation: none;
  }
}
