/**
 * Logo Marquee styles.
 *
 * Naming convention: BEM-ish, all prefixed with `itm-logo-marquee` to avoid
 * collisions with Elementor, themes and other plugins.
 *
 * The animation distance is driven by the `--itm-lm-distance` custom property,
 * which JavaScript sets to the width of exactly one original sequence. The
 * track is translated by that distance and then the animation restarts, which
 * is seamless because the clones that follow are identical to the originals.
 */

.itm-logo-marquee {
  --itm-lm-gap: 80px;
  --itm-lm-logo-height: 60px;
  --itm-lm-distance: 0px;
  --itm-lm-duration: 20s;

  position: relative;
  width: 100%;
  overflow: hidden;
}

.itm-logo-marquee__viewport {
  position: relative;
  width: 100%;
  overflow: hidden;
}

.itm-logo-marquee__track {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  width: max-content;
  margin: 0;
  padding: 0;
  list-style: none;

  /* The animation is applied by JS once the distance is known. */
  will-change: transform;
}

/* Applied by JS when the marquee is ready to animate. */
.itm-logo-marquee__track.is-ready {
  animation-name: itm-logo-marquee-scroll;
  animation-duration: var(--itm-lm-duration, 20s);
  animation-timing-function: linear;
  animation-iteration-count: infinite;
}

/* Pause on hover/focus, only when the instance opts in. */
.itm-logo-marquee--pause-on-hover:hover .itm-logo-marquee__track,
.itm-logo-marquee--pause-on-hover:focus-within .itm-logo-marquee__track {
  animation-play-state: paused;
}

.itm-logo-marquee__item {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;

  /* The gap is applied as a right margin so the sequence width measured by
	   JS includes the spacing between items (and after the last item). This is
	   what makes the loop distance exact. */
  margin: 0 var(--itm-lm-gap) 0 0;
  padding: 0;
  list-style: none;
}

.itm-logo-marquee__link {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  color: inherit;
  outline-offset: 4px;
}

.itm-logo-marquee__inner {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.itm-logo-marquee__logo {
  display: block;
  max-height: var(--itm-lm-logo-height);
  width: auto;
  max-width: 100%;
  height: auto;
  object-fit: contain;
  /* Keep logos from being distorted and avoid layout shift. */
  transition: opacity 0.2s ease;
}

/* -------------------------------------------------------------------------
 * Name reveal
 * -------------------------------------------------------------------------
 * The name is absolutely positioned so revealing it never changes the size of
 * the item (no layout instability). It fades in on hover and on keyboard focus.
 */
.itm-logo-marquee__name {
  position: absolute;
  left: 50%;
  bottom: 100%;
  transform: translate(-50%, 4px);
  margin-bottom: 8px;
  padding: 4px 10px;
  white-space: nowrap;
  font-size: 13px;
  line-height: 1.4;
  color: #fff;
  background: rgba(17, 17, 17, 0.92);
  border-radius: 4px;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition:
    opacity 0.18s ease,
    transform 0.18s ease,
    visibility 0.18s ease;
  z-index: 2;
}

/* Small caret under the tooltip. */
.itm-logo-marquee__name::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: rgba(17, 17, 17, 0.92);
}

.itm-logo-marquee__link:hover .itm-logo-marquee__name,
.itm-logo-marquee__link:focus .itm-logo-marquee__name,
.itm-logo-marquee__link:focus-visible .itm-logo-marquee__name {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, 0);
}

/* Visible focus ring for keyboard users. */
.itm-logo-marquee__link:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 4px;
  border-radius: 2px;
}

/* Non-link items are focusable but should not look like links. */
.itm-logo-marquee__link--static {
  cursor: default;
}

/* -------------------------------------------------------------------------
 * Keyframes
 * -------------------------------------------------------------------------
 * Translate by exactly one sequence width. Because the track contains the
 * original sequence followed by identical clones, translating by one sequence
 * width lands on a pixel-identical state, so the restart is invisible.
 */
@keyframes itm-logo-marquee-scroll {
  from {
    transform: translate3d(0, 0, 0);
  }
  to {
    transform: translate3d(calc(-1 * var(--itm-lm-distance)), 0, 0);
  }
}

/* -------------------------------------------------------------------------
 * Reduced motion
 * -------------------------------------------------------------------------
 * Users who request reduced motion get a static, horizontally scrollable row
 * of logos. All logos remain visible and accessible; nothing is hidden.
 */
@media (prefers-reduced-motion: reduce) {
  .itm-logo-marquee__track,
  .itm-logo-marquee__track.is-ready {
    animation: none !important;
    transform: none !important;
  }

  .itm-logo-marquee__viewport {
    overflow-x: auto;
  }

  .itm-logo-marquee__logo {
    transition: none;
  }

  .itm-logo-marquee__name {
    transition: none;
  }
}
