/* Scrolling text band — views/sections/marquee.php. Full bleed: one line of texts with small dots between
   them, looping by sliding the track (the list twice, each copy at least a screen wide) by half its width.
   Background and text colour come from the section wrapper. The pointer over the texts, keyboard focus and
   the pause button (revealed by marquee.js, .is-ready) stop it; off-screen bands rest (.is-offscreen).
   Reduced motion: no animation and no button, the texts stand centred and wrap onto more lines. */

.rr-marquee {
  --rr-marquee-size: clamp(1.0625rem, 0.95rem + 0.55vw, 1.3125rem);
  --rr-marquee-height: 2.75rem;
  display: flex;
  align-items: center;
  min-height: var(--rr-marquee-height);
  font-size: var(--rr-marquee-size);
  font-weight: 700;
  line-height: 1.2;
}

.rr-marquee--md {
  --rr-marquee-size: clamp(0.9375rem, 0.9rem + 0.12vw, 1rem);
  --rr-marquee-height: 2.5rem;
  font-weight: 600;
}

@media (min-width: 768px) {
  .rr-marquee {
    --rr-marquee-height: 3.25rem;
  }

  .rr-marquee--md {
    --rr-marquee-height: 2.75rem;
  }
}

/* The clipping window: the page itself never scrolls sideways. */
.rr-marquee__viewport {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
}

.rr-marquee__track {
  display: flex;
  width: max-content;
  animation: rr-marquee-scroll var(--rr-marquee-duration, 30s) linear infinite;
}

.rr-marquee__list {
  display: flex;
  flex: none;
  align-items: center;
  min-width: 100vw;
  margin: 0;
  padding: 0;
  list-style: none;
}

/* Items share any spare width, so a short list still fills the screen and the loop has no gap. */
.rr-marquee__item {
  position: relative;
  display: flex;
  flex: 1 0 auto;
  align-items: center;
  justify-content: center;
  gap: 0.5em;
  padding: 0.35em 1.5em;
  white-space: nowrap;
}

/* The dot sits on the edge between two items, so it stays halfway between their texts. */
.rr-marquee__item::after {
  content: "";
  position: absolute;
  top: 50%;
  right: 0;
  width: 0.3em;
  height: 0.3em;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.55;
  transform: translate(50%, -50%);
}

.rr-section--bg-dark .rr-marquee__item::after {
  background: var(--color-accent);
  opacity: 1;
}

.rr-marquee__item .icon {
  width: 1.1em;
  height: 1.1em;
}

/* Pause / play (WCAG 2.2.2), at the end of the band. */
.rr-marquee__toggle {
  display: grid;
  flex: none;
  place-items: center;
  width: 2rem;
  height: 2rem;
  margin-inline: 0.25rem max(0.5rem, calc(var(--gutter) - 0.5rem));
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: inherit;
  font-size: 1rem;
  opacity: 0.8;
  transition: opacity var(--dur-1) var(--ease-out), background-color var(--dur-1) var(--ease-out);
}

.rr-marquee__toggle:hover {
  background: color-mix(in srgb, currentColor 14%, transparent);
  opacity: 1;
}

.rr-marquee__toggle:focus-visible {
  border-radius: 50%;
  outline: 2px solid currentColor;
  outline-offset: 2px;
  opacity: 1;
}

.rr-marquee__toggle .icon {
  width: 0.95rem;
  height: 0.95rem;
}

.rr-marquee__toggle .icon-play,
.rr-marquee.is-paused .rr-marquee__toggle .icon-pause {
  display: none;
}

.rr-marquee.is-paused .rr-marquee__toggle .icon-play {
  display: inline-block;
}

/* Keyboard focus holds the band until the visitor presses play on purpose (.is-playing); the pointer holds
   it over the texts, not over the button, so pressing play moves it at once. */
.rr-marquee.is-paused .rr-marquee__track,
.rr-marquee.is-offscreen .rr-marquee__track,
.rr-marquee:not(.is-playing):focus-within .rr-marquee__track {
  animation-play-state: paused;
}

@media (hover: hover) {
  .rr-marquee__viewport:hover .rr-marquee__track {
    animation-play-state: paused;
  }
}

@media (prefers-reduced-motion: no-preference) {
  /* Texts fade out just before the button instead of being cut off at it. */
  .rr-marquee.is-ready .rr-marquee__viewport {
    -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 2rem), transparent);
    mask-image: linear-gradient(90deg, #000 calc(100% - 2rem), transparent);
  }
}

@keyframes rr-marquee-scroll {
  to {
    transform: translate3d(-50%, 0, 0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .rr-marquee__track {
    width: auto;
    animation: none;
  }

  .rr-marquee__list {
    flex: 1 1 auto;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.3em 2.5em;
    min-width: 0;
    padding: 0.55em var(--gutter);
  }

  .rr-marquee__list--copy,
  .rr-marquee__toggle {
    display: none;
  }

  /* Standing still, space sets the texts apart: a dot could be left alone at the end of a line. */
  .rr-marquee__item {
    flex: 0 1 auto;
    padding: 0;
    white-space: normal;
    text-align: center;
  }

  .rr-marquee__item::after {
    content: none;
  }
}

/* Builder hint for a band without texts: dark text on the hint, whatever the band colour. */
.rr-marquee-empty {
  padding-block: 0.75rem;
}

.rr-marquee-empty .alert {
  color: var(--color-dark);
}
