/* An optional accent for short headings or phrases. Typography stays inherited. */
@media screen {
  @supports ((background-clip: text) or (-webkit-background-clip: text)) {
    .bf-spectral-text {
      --bf-spectral-rose: #ac325d;
      --bf-spectral-amber: #955217;
      --bf-spectral-teal: #087766;
      --bf-spectral-blue: #315fba;
      --bf-spectral-violet: #7936a0;
      --bf-spectral-rest: #343434;
      --bf-spectral-motion-shade: var(--color-blue-title, #303f4f);
      --bf-spectral-motion-steel: var(--color-brand-600, #3c618d);
      --bf-spectral-motion-highlight: #386fa8;
      --bf-spectral-motion-mist: var(--color-grey-blue-600, #4a637f);

      /* The image contains two matching spectra. One sweep covers exactly one. */
      --bf-spectral-gradient: repeating-linear-gradient(
        90deg,
        var(--bf-spectral-rose) 0%,
        var(--bf-spectral-amber) 9%,
        var(--bf-spectral-teal) 19%,
        var(--bf-spectral-blue) 29%,
        var(--bf-spectral-violet) 40%,
        var(--bf-spectral-rose) 50%
      );
      background-image: var(--bf-spectral-gradient);
      background-size: 200% 100%;
      background-position: 0% 50%;
      background-repeat: no-repeat;
      -webkit-background-clip: text;
      background-clip: text;
      color: transparent;
      -webkit-text-fill-color: transparent;
    }

    html[data-theme="dark"] .bf-spectral-text {
      --bf-spectral-rose: #ff8cad;
      --bf-spectral-amber: #ffc27e;
      --bf-spectral-teal: #69ddc8;
      --bf-spectral-blue: #8dbbff;
      --bf-spectral-violet: #c8a2ff;
      --bf-spectral-rest: #f1f1f1;
      --bf-spectral-motion-shade: var(--color-blue-close, #6aa4d8);
      --bf-spectral-motion-steel: var(--color-brand-300, #a2bcd7);
      --bf-spectral-motion-highlight: var(--color-brand-100, #e9eef5);
      --bf-spectral-motion-mist: var(--color-blue-muted, #c6d3e6);
    }

    @media (prefers-color-scheme: dark) {
      html[data-theme="system"] .bf-spectral-text {
        --bf-spectral-rose: #ff8cad;
        --bf-spectral-amber: #ffc27e;
        --bf-spectral-teal: #69ddc8;
        --bf-spectral-blue: #8dbbff;
        --bf-spectral-violet: #c8a2ff;
        --bf-spectral-rest: #f1f1f1;
        --bf-spectral-motion-shade: var(--color-blue-close, #6aa4d8);
        --bf-spectral-motion-steel: var(--color-brand-300, #a2bcd7);
        --bf-spectral-motion-highlight: var(--color-brand-100, #e9eef5);
        --bf-spectral-motion-mist: var(--color-blue-muted, #c6d3e6);
      }
    }

    .bf-spectral-text::selection {
      color: HighlightText;
      -webkit-text-fill-color: HighlightText;
      background-color: Highlight;
    }

    .bf-spectral-text:where(.bf-spectral-text--animated) {
      background-image: none;
      color: var(--bf-spectral-rest);
      -webkit-text-fill-color: currentColor;
    }

    @media (prefers-reduced-motion: no-preference) {
      .bf-spectral-text:where(.bf-spectral-text--animated) {
        /* A soft-edged neutral layer covers the spectrum after both passes. */
        background-image:
          linear-gradient(90deg, var(--bf-spectral-rest) calc(100% - 1.5rem), transparent),
          repeating-linear-gradient(
            90deg,
            var(--bf-spectral-motion-shade) 0%,
            var(--bf-spectral-motion-steel) 11%,
            var(--bf-spectral-motion-highlight) 21%,
            var(--bf-spectral-motion-mist) 33%,
            var(--bf-spectral-motion-shade) 50%
          );
        background-size: calc(100% + 1.5rem) 100%, 200% 100%;
        background-position: left center, left center;
        color: transparent;
        -webkit-text-fill-color: transparent;
        animation:
          bf-spectral-sweep 2s ease-in-out 2,
          bf-spectral-settle 1s linear 4s backwards;
      }
    }
  }
}

@keyframes bf-spectral-sweep {
  from { background-position: 0% 50%, 100% 50%; }
  to { background-position: 0% 50%, 0% 50%; }
}

@keyframes bf-spectral-settle {
  from { background-size: 0% 100%, 200% 100%; }
  to { background-size: calc(100% + 1.5rem) 100%, 200% 100%; }
}

@media (forced-colors: active) {
  .bf-spectral-text {
    background-image: none;
    color: CanvasText;
    -webkit-text-fill-color: currentColor;
    animation: none;
  }
}

@media print {
  .bf-spectral-text {
    color: #000;
    -webkit-text-fill-color: currentColor;
  }
}
