/**
 * Text Shimmer — AI(ChatGPT/Claude) 스타일 은은한 gradient sweep
 *
 * 사용 (HTML):
 *   <button class="btn btn-primary">
 *     <span class="text-shimmer">바로 구매하기</span>
 *   </button>
 *
 * 사용 (React):
 *   import { TextShimmer } from "../components/TextShimmer";
 *   <button><TextShimmer>Continue</TextShimmer></button>
 */

:root {
  --text-shimmer-base: var(--mall-ink, #2a2f36);
  --text-shimmer-band: color-mix(in srgb, var(--text-shimmer-base) 18%, #ffffff);
  --text-shimmer-peak: color-mix(in srgb, var(--text-shimmer-base) 8%, #ffffff);
  --text-shimmer-duration: 2s;
  --text-shimmer-delay: 0s;
  --text-shimmer-bg-size: 260%;
}

@media (prefers-color-scheme: dark) {
  :root {
    --text-shimmer-band: color-mix(in srgb, var(--text-shimmer-base) 35%, #ffffff);
    --text-shimmer-peak: color-mix(in srgb, var(--text-shimmer-base) 22%, #ffffff);
  }
}

/* 어두운 버튼/배경 위 */
.text-shimmer--on-dark {
  --text-shimmer-base: #f3f4f6;
  --text-shimmer-band: color-mix(in srgb, var(--text-shimmer-base) 40%, #ffffff);
  --text-shimmer-peak: #ffffff;
}

@keyframes text-shimmer-sweep {
  0% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0% 50%;
  }
}

.text-shimmer {
  display: inline-block;
  max-width: 100%;
  color: var(--text-shimmer-base);
  background-image: linear-gradient(
    90deg,
    var(--text-shimmer-base) 0%,
    var(--text-shimmer-base) 40%,
    color-mix(in srgb, var(--text-shimmer-base) 82%, var(--text-shimmer-band)) 44%,
    var(--text-shimmer-band) 47%,
    var(--text-shimmer-peak) 50%,
    var(--text-shimmer-band) 53%,
    color-mix(in srgb, var(--text-shimmer-base) 82%, var(--text-shimmer-band)) 56%,
    var(--text-shimmer-base) 60%,
    var(--text-shimmer-base) 100%
  );
  background-size: var(--text-shimmer-bg-size) 100%;
  background-repeat: no-repeat;
  background-position: 100% 50%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: text-shimmer-sweep var(--text-shimmer-duration) ease-in-out infinite;
  animation-delay: var(--text-shimmer-delay);
  will-change: background-position;
  transform: translateZ(0);
  backface-visibility: hidden;
}

@media (prefers-reduced-motion: reduce) {
  .text-shimmer {
    animation: none;
    background-image: none;
    -webkit-text-fill-color: currentColor;
    color: var(--text-shimmer-base);
    will-change: auto;
    transform: none;
  }
}
