/* Animation master - per-word-crossfade */

/*
  Usage:
    <div class="t-text-animation t-per-word-crossfade is-previewing">
      <span class="t-text-row"><span class="t-text-whole">China Ad</span></span>
      <span class="t-text-row"><span class="t-text-whole">Product Design</span></span>
    </div>

  Add `.t-per-word-crossfade` and `.is-previewing` to run this text animation.
*/

:root {
  --text-motion-ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --text-motion-ease-in: cubic-bezier(0.64, 0, 0.78, 0);
  --text-motion-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

.t-text-animation {
  display: inline-flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0;
  color: #171717;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 28px;
  font-weight: 760;
  line-height: 1.18;
  letter-spacing: 0;
  text-align: center;
  overflow-wrap: normal;
  word-break: normal;
}

.t-text-animation .t-char,
.t-text-animation .t-word,
.t-text-animation .t-line,
.t-text-animation .t-text-row,
.t-text-animation .t-text-whole {
  display: inline-block;
  opacity: 1;
  transform-origin: center;
  will-change: transform, opacity, filter, clip-path, background-position;
}

.t-text-animation .t-text-row {
  display: block;
  flex: 0 0 100%;
  width: 100%;
  max-width: 100%;
  line-height: inherit;
  white-space: nowrap;
  overflow-wrap: normal;
  word-break: normal;
}

.t-text-animation .t-line {
  flex-basis: 100%;
  max-width: 100%;
  white-space: nowrap;
  overflow-wrap: normal;
  word-break: normal;
}

.t-text-animation .t-text-whole {
  max-width: 100%;
  white-space: nowrap;
  overflow-wrap: normal;
  word-break: normal;
}

.t-text-animation .t-char-space {
  width: 0.32em;
}

/* Optional preview wrapper for Animation master demo pages. */
.text-preview {
  width: 272px;
  max-width: calc(100% - 24px);
  min-height: 120px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0;
  padding: 4px 0 6px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
  text-align: center;
  line-height: 1.18;
  overflow-wrap: normal;
  word-break: normal;
}

.text-preview .t-line {
  flex-basis: 100%;
  max-width: 100%;
  line-height: 1.18;
  white-space: nowrap;
  overflow-wrap: normal;
  word-break: normal;
}

.text-preview .t-text-row {
  display: block;
  flex: 0 0 100%;
  width: 100%;
  max-width: 100%;
  line-height: inherit;
  white-space: nowrap;
  overflow-wrap: normal;
  word-break: normal;
}

.text-preview .t-text-whole {
  max-width: 100%;
  white-space: nowrap;
  overflow-wrap: normal;
  word-break: normal;
}

.text-preview .t-char-space {
  width: 0.32em;
}

.text-preview:not(.is-previewing) .t-char,
.text-preview:not(.is-previewing) .t-word,
.text-preview:not(.is-previewing) .t-line,
.text-preview:not(.is-previewing) .t-text-whole {
  animation: none;
}

.t-per-word-crossfade.is-previewing .t-word {
  animation: t-per-word-crossfade 700ms var(--text-motion-ease-out) both;
  animation-delay: calc(var(--i) * 90ms);
}

@keyframes t-per-word-crossfade {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .t-per-word-crossfade,
  .t-per-word-crossfade * {
    animation: none !important;
    transition: none !important;
    filter: none !important;
  }
}
