:root {
  --height-loco: 120px;
  --height-carriage: 105px;
}
.train-container {
  width: max-content;
  display: flex;
  align-items: flex-end;  /* the locomotive and carriages are aligned at the same level on the tracks */
  gap: 0;  /* no margin between the images */
  opacity: 0;  /* unset by JS to avoid FOUC */
  animation: moveImage 30s linear infinite;
  will-change: transform;  /* to limmit 'saccades' */
}
.train-alert {  /* small margin in the container around the train */
  padding-top: 2px !important;
  padding-bottom: 2px !important;
  min-height: unset;
  align-items: flex-end;
}
.wagon {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}
.wagon img {
  height: var(--height-carriage);
  width: auto;
  display: block;
}
.wagon span {
  position: absolute;
  top: 25%;  /* text position, increase value to put the text down */
  color: black;
  font-weight: bold;
  font-size: 0.9rem;  /* text size */
}
/* animation underline */
.wagon span::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 100%;
  height: 2px;
  background: currentColor;
  transform: scaleX(0);
  transition: transform .25s ease;
  transform-origin: center;
}
.wagon:hover span::after {
  transform: scaleX(1);
}
.locomotive {
  height: var(--height-loco);
  width: auto;
}
@keyframes moveImage {
  0% {
    transform: translateX(calc(var(--train-width) - 30px));  /* 30px if for margin 'anti-pop' */
  }
  100% {
    transform: translateX(100vw);
  }
}