/* Decorative swim: thumb art faces left — path is right→left, flip, left→right (round trip). */
.species-swim-layer {
  position: fixed;
  left: 0;
  bottom: max(10vh, 5rem);
  z-index: 50;
  pointer-events: none;
  opacity: 0;
  transform: translate3d(100vw, 0, 0);
  transform-origin: center center;
  will-change: transform, opacity;
}

.species-swim-layer.is-swimming {
  opacity: 1;
  animation: species-swim-roundtrip 18s cubic-bezier(0.42, 0, 0.58, 1) forwards;
}

.species-swim-school {
  display: flex;
  flex-direction: row;
  align-items: flex-end;
  gap: clamp(0.12rem, 1.2vw, 0.45rem);
  transform-origin: center center;
}

.species-swim-school[data-swim-count="1"] {
  gap: 0;
}

/* Slightly shrink each fish when the school is large so the group stays readable. */
.species-swim-school[data-swim-count="7"] .species-swim-fish,
.species-swim-school[data-swim-count="8"] .species-swim-fish,
.species-swim-school[data-swim-count="9"] .species-swim-fish,
.species-swim-school[data-swim-count="10"] .species-swim-fish,
.species-swim-school[data-swim-count="11"] .species-swim-fish,
.species-swim-school[data-swim-count="12"] .species-swim-fish {
  width: min(104px, 22vw);
}

.species-swim-fish {
  flex: 0 0 auto;
  width: min(128px, 28vw);
  animation: species-swim-wobble 2.1s ease-in-out infinite;
}

.species-swim-fish img {
  display: block;
  width: 100%;
  height: auto;
  filter: drop-shadow(0 6px 14px rgba(15, 23, 42, 0.22));
}

@keyframes species-swim-roundtrip {
  0% {
    transform: translate3d(100vw, 0, 0) scaleX(1);
  }
  44% {
    transform: translate3d(calc(-100% - 40px), 0, 0) scaleX(1);
  }
  45% {
    transform: translate3d(calc(-100% - 40px), 0, 0) scaleX(-1);
  }
  100% {
    transform: translate3d(calc(100vw + 40px), 0, 0) scaleX(-1);
  }
}

@keyframes species-swim-wobble {
  0%,
  100% {
    transform: translateY(0) rotate(-5deg);
  }
  50% {
    transform: translateY(-10px) rotate(6deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .species-swim-layer,
  .species-swim-fish {
    animation: none !important;
  }

  .species-swim-layer {
    display: none !important;
  }
}
