/**
 * Falling hexagons background (nettl-hexfall- prefix).
 *
 * Each hexagon is a full-height, size-wide strip with the shape pinned to
 * its bottom. Translating the strip from -100% (shape just above the
 * section) to its own size (shape just below) makes the fall distance
 * track the section height with no measuring. The inner <svg> sways and
 * tilts on its own, slower timeline.
 */

.nettl-hexfall {
  position: relative;
  isolation: isolate; /* keeps the z-index:-1 layer above the section's own background */
}

.nettl-hexfall__layer {
  position: absolute;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}

.nettl-hexfall__hex {
  position: absolute;
  top: 0;
  left: var(--x);
  width: var(--size);
  height: 100%;
  opacity: var(--opacity);
  transform: translate3d(-50%, calc(-100% - var(--size) * 0.1), 0);
  animation: nettl-hexfall-fall var(--duration) linear var(--delay) infinite;
  will-change: transform;
}

.nettl-hexfall__hex svg {
  position: absolute;
  bottom: 0;
  left: 0;
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
  fill: var(--fill);
  stroke: var(--stroke);
  stroke-width: 5;
  animation: nettl-hexfall-sway var(--sway-duration) ease-in-out var(--delay)
    infinite alternate;
}

@keyframes nettl-hexfall-fall {
  from {
    transform: translate3d(-50%, calc(-100% - var(--size) * 0.1), 0);
  }
  to {
    transform: translate3d(-50%, calc(var(--size) * 1.2), 0);
  }
}

@keyframes nettl-hexfall-sway {
  from {
    transform: translateX(calc(var(--drift) * -1))
      rotate(calc(var(--spin) * -1));
  }
  to {
    transform: translateX(var(--drift)) rotate(var(--spin));
  }
}

/* Paused off-screen, and frozen mid-fall (a static scatter) for reduced motion. */
.nettl-hexfall__layer.is-paused .nettl-hexfall__hex,
.nettl-hexfall__layer.is-paused .nettl-hexfall__hex svg {
  animation-play-state: paused;
}

@media (prefers-reduced-motion: reduce) {
  .nettl-hexfall__hex,
  .nettl-hexfall__hex svg {
    animation-play-state: paused;
  }
}

/* On archive pages (and the blog posts page, which has .blog not .archive)
   with the nettl-hexfall class, switch the content margin to padding */
.archive .content-area.nettl-hexfall,
.blog .content-area.nettl-hexfall {
  margin-top: 0;
  margin-bottom: 0;
  padding-top: 5rem;
  padding-bottom: 5rem;
}
