/* ==========================================================================
   my-design-kit: Flux Loader
   Plain-CSS port of 21st.dev "Progressive Flux Loader".
   Needs: kit-tokens.css, flux-loader.js
   ========================================================================== */

.flux {
  /* Recolour per instance by overriding these */
  --flux-from: var(--kit-red);
  --flux-to: var(--kit-cream);
  --flux-depth: rgba(22, 11, 5, 0.35);            /* inner bottom shade (original: rgba(0,40,120,.35)) */
  --flux-track: var(--kit-iron-10);
  --flux-track-shadow: inset 0 2px 3px rgba(0, 0, 0, 0.09), inset 0 -1px 2px rgba(255, 255, 255, 0.7);
  --flux-label-color: var(--kit-iron-60);
  --flux-mid: color-mix(in oklab, var(--flux-from), var(--flux-to));

  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2rem;
  width: 100%;
  max-width: 28rem;          /* 448px */
  margin-inline: auto;
  font-family: var(--kit-font);
}

/* Dark background version (use on Cast Iron) */
.flux--on-dark {
  --flux-track: var(--kit-cream-10);
  --flux-track-shadow: inset 0 2px 3px rgba(0, 0, 0, 0.45), inset 0 -1px 2px rgba(255, 255, 255, 0.05);
  --flux-label-color: var(--kit-cream-70);
}

/* ---- Phase label ---- */
.flux__stage {
  position: relative;
  width: 100%;
  height: 4rem;
  perspective: 1000px;
  user-select: none;
}

.flux__label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 1.875rem;        /* 30px */
  line-height: 2.25rem;
  font-weight: var(--kit-weight-semibold);
  letter-spacing: var(--kit-tracking-tight);
  color: var(--flux-label-color);
  transform-style: preserve-3d;
}

@media (min-width: 640px) {
  .flux__label { font-size: 2.25rem; line-height: 2.5rem; }  /* 36px */
}

.flux__word { display: inline-flex; }
.flux__char { display: inline-block; white-space: pre; }

/* Enter: flies in from deep behind the screen, overshoots, settles */
.flux__label.is-entering {
  animation: flux-label-in var(--kit-dur-hero) var(--kit-ease-settle) both;
}
.flux__label.is-entering .flux__char {
  animation: flux-char-in var(--kit-dur-quick) var(--kit-ease-settle) both;
  animation-delay: calc(0.18s + var(--i, 0) * 0.035s);
}
/* Leave: accelerates toward the viewer and blurs out */
.flux__label.is-leaving {
  animation: flux-label-out var(--kit-dur-quick) var(--kit-ease-launch) forwards;
}

@keyframes flux-label-in {
  0%      { opacity: 0; transform: translateZ(-380px) scale(0.65);  filter: blur(14px); }
  33.333% { opacity: 1; transform: translateZ(60px)   scale(1.08);  filter: blur(0); }
  66.666% { opacity: 1; transform: translateZ(-8px)   scale(0.985); filter: blur(0); }
  100%    { opacity: 1; transform: translateZ(0)      scale(1);     filter: blur(0); }
}
@keyframes flux-char-in {
  from { opacity: 0; transform: translateY(12px); filter: blur(8px); }
  to   { opacity: 1; transform: translateY(0);    filter: blur(0); }
}
@keyframes flux-label-out {
  to { opacity: 0; transform: translateZ(220px) scale(1.35); filter: blur(10px); }
}

/* ---- Bar ---- */
.flux__track {
  position: relative;
  width: 100%;
  height: 1.25rem;            /* 20px */
  overflow: hidden;
  border-radius: var(--kit-radius-pill);
  background: var(--flux-track);
  box-shadow: var(--flux-track-shadow);
}

.flux__fill {
  position: relative;
  height: 100%;
  width: 0%;
  border-radius: var(--kit-radius-pill);
  background: linear-gradient(90deg,
    var(--flux-from) 0%,
    var(--flux-mid) 35%,
    var(--flux-to) 55%,
    var(--flux-mid) 78%,
    var(--flux-from) 100%);
  box-shadow:
    0 0 18px color-mix(in oklab, var(--flux-from) 55%, transparent),
    0 0 32px color-mix(in oklab, var(--flux-to) 40%, transparent),
    inset 0 1.5px 0 rgba(255, 255, 255, 0.5),
    inset 0 -2px 3px var(--flux-depth);
  transition: width var(--kit-dur-base) var(--kit-ease-settle);
}

/* White glint that glides across the fill forever */
.flux__sheen {
  position: absolute;
  inset-block: 0;
  left: 0;
  width: 50%;
  border-radius: var(--kit-radius-pill);
  background: linear-gradient(90deg, transparent 0%, rgba(255, 255, 255, 0.55) 50%, transparent 100%);
  mix-blend-mode: screen;
  pointer-events: none;
  animation: flux-sheen 1.6s linear infinite;
}
@keyframes flux-sheen {
  from { transform: translateX(-110%); }
  to   { transform: translateX(210%); }
}

/* ---- Reduced motion: static label, no glint, bar jumps ---- */
@media (prefers-reduced-motion: reduce) {
  .flux__sheen { display: none; }
  .flux__fill { transition: none; }
  .flux__stage { perspective: none; }
  .flux__label,
  .flux__label .flux__char { animation: none !important; }
}
