/* ==========================================================================
   FRAMER SCROLL TEXT EFFECTS SUITE
   Exact reproduction of https://scrolltexteffects.framer.website/#fx-fade
   
   Signature Effects Included:
   1. RISE (04 / 12)   : Letters lift into place from 28px below (SPLIT: LETTER · 28PX)
   2. MASK (05 / 12)   : Whole lines rise from behind an invisible edge (SPLIT: LINE)
   3. COLOR (02 / 12)  : Each word picks up its color as read (SPLIT: WORD)
   4. RANDOM           : Letters arrive in a shuffled order (ORDER: RANDOM · SPLIT: LETTER)
   5. FLIP (09 / 12)   : Letters swing up 90° from the baseline (SPLIT: LETTER · 90°)
   ========================================================================== */

/* Word wrapper: preserves whitespace and natural word grouping */
.fx-word {
  display: inline-block !important;
  white-space: nowrap !important;
  vertical-align: baseline;
}

/* Character & Word Base Item State */
.fx-char,
.fx-word-item {
  display: inline-block !important;
  vertical-align: baseline;
  will-change: transform, opacity;
}

/* ==========================================================================
   1. EFFECT: RISE (04 / 12)
   "Letters lift into place from below" — SPLIT: LETTER · 28PX
   ========================================================================== */
.fx-rise .fx-char,
[data-fx="rise"] .fx-char {
  opacity: 0;
  transform: translateY(28px);
  filter: blur(4px);
  -webkit-filter: blur(4px);
}

.is-revealed.fx-rise .fx-char,
.is-revealed .fx-rise .fx-char,
[data-fx="rise"].is-revealed .fx-char,
.is-revealed [data-fx="rise"] .fx-char {
  animation: framerRiseLetter 0.72s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  animation-delay: calc(var(--fx-idx, 0) * var(--fx-stagger, 0.016s) + var(--fx-delay, 0s));
}

@keyframes framerRiseLetter {
  0% {
    opacity: 0;
    transform: translateY(28px);
    filter: blur(4px);
    -webkit-filter: blur(4px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
    filter: blur(0);
    -webkit-filter: blur(0);
  }
}

/* ==========================================================================
   2. EFFECT: MASK (05 / 12)
   "Whole lines rise from behind an edge, the way the best editorial sites do it."
   "Lines slide up from behind an invisible edge." — SPLIT: LINE
   ========================================================================== */
.fx-line-mask {
  display: block !important;
  overflow: hidden !important;
  position: relative !important;
  padding-bottom: 0.14em;
  margin-bottom: -0.14em;
  vertical-align: top;
  line-height: inherit;
}

.fx-line {
  display: block !important;
  transform: translateY(118%);
  opacity: 0;
  will-change: transform, opacity;
  color: inherit !important;
  -webkit-text-fill-color: inherit !important;
}

.is-revealed .fx-line,
.is-revealed.fx-line,
.fx-line-mask.is-revealed .fx-line,
.is-revealed.fx-mask .fx-line,
[data-fx="mask"].is-revealed .fx-line {
  animation: framerEditorialMaskRise 0.85s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  animation-delay: calc(var(--line-idx, 0) * var(--line-stagger, 0.085s) + var(--line-delay, 0s));
}

@keyframes framerEditorialMaskRise {
  0% {
    opacity: 0;
    transform: translateY(118%);
  }
  20% {
    opacity: 1;
  }
  100% {
    opacity: 1;
    transform: translateY(0%);
  }
}

/* ==========================================================================
   3. EFFECT: COLOR (02 / 12)
   "The classic. Each word picks up its color as it's read" — SPLIT: WORD
   ========================================================================== */
.fx-color .fx-word-item,
[data-fx="color"] .fx-word-item {
  opacity: 0.28;
  color: inherit !important;
  -webkit-text-fill-color: inherit !important;
  transition: opacity 0.4s ease;
}

.is-revealed.fx-color .fx-word-item,
.is-revealed .fx-color .fx-word-item,
[data-fx="color"].is-revealed .fx-word-item,
.is-revealed [data-fx="color"] .fx-word-item {
  animation: framerColorWord 0.65s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  animation-delay: calc(var(--fx-idx, 0) * var(--fx-stagger, 0.038s) + var(--fx-delay, 0s));
}

@keyframes framerColorWord {
  0% {
    opacity: 0.28;
  }
  45% {
    opacity: 1;
    text-shadow: 0 0 12px rgba(255, 255, 255, 0.5);
  }
  100% {
    opacity: 1;
    text-shadow: none;
  }
}

/* ==========================================================================
   4. EFFECT: RANDOM (ORDER: RANDOM)
   "Letters arrive in a shuffled order, the same on every visit" — SPLIT: LETTER
   ========================================================================== */
.fx-random .fx-char,
[data-fx="random"] .fx-char {
  opacity: 0;
  filter: blur(8px);
  -webkit-filter: blur(8px);
  transform: scale(0.92);
}

.is-revealed.fx-random .fx-char,
.is-revealed .fx-random .fx-char,
[data-fx="random"].is-revealed .fx-char,
.is-revealed [data-fx="random"] .fx-char {
  animation: framerRandomLetter 0.78s cubic-bezier(0.22, 1, 0.36, 1) forwards;
  animation-delay: calc(var(--fx-random-idx, 0) * var(--fx-stagger, 0.022s) + var(--fx-delay, 0s));
}

@keyframes framerRandomLetter {
  0% {
    opacity: 0;
    filter: blur(8px);
    -webkit-filter: blur(8px);
    transform: scale(0.92);
  }
  100% {
    opacity: 1;
    filter: blur(0);
    -webkit-filter: blur(0);
    transform: scale(1);
  }
}

/* ==========================================================================
   5. EFFECT: FLIP (09 / 12)
   "Letters swing up from the baseline like cards turn" — SPLIT: LETTER · 90°
   ========================================================================== */
.fx-flip,
[data-fx="flip"],
.fx-flip .fx-word,
[data-fx="flip"] .fx-word {
  perspective: 900px;
  -webkit-perspective: 900px;
}

.fx-flip .fx-char,
[data-fx="flip"] .fx-char {
  opacity: 0;
  transform: perspective(600px) rotateX(-90deg);
  -webkit-transform: perspective(600px) rotateX(-90deg);
  transform-origin: 50% 100%;
  -webkit-transform-origin: 50% 100%;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.is-revealed.fx-flip .fx-char,
.is-revealed .fx-flip .fx-char,
[data-fx="flip"].is-revealed .fx-char,
.is-revealed [data-fx="flip"] .fx-char {
  animation: framerFlipLetter 0.68s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
  animation-delay: calc(var(--fx-idx, 0) * var(--fx-stagger, 0.022s) + var(--fx-delay, 0s));
}

@keyframes framerFlipLetter {
  0% {
    opacity: 0;
    transform: perspective(600px) rotateX(-90deg);
    -webkit-transform: perspective(600px) rotateX(-90deg);
  }
  50% {
    opacity: 1;
  }
  100% {
    opacity: 1;
    transform: perspective(600px) rotateX(0deg);
    -webkit-transform: perspective(600px) rotateX(0deg);
  }
}

/* ==========================================================================
   CRITICAL: SETTLED STATE (ONCE LOADED, REMAINS LOADED)
   After animation completes:
   - Removes overflow: hidden from masks so descenders ('g', 'y', 'p') aren't clipped.
   - Clears GPU transforms and filters for buttery smooth 60 FPS scrolling.
   - NEVER resets or re-triggers when scrolling up!
   ========================================================================== */
.fx-settled .fx-line-mask,
.fx-line-mask.fx-settled {
  overflow: visible !important;
}

.fx-settled,
.fx-settled .fx-char,
.fx-settled .fx-word,
.fx-settled .fx-word-item,
.fx-settled .fx-line,
.fx-line.fx-settled {
  opacity: 1 !important;
  filter: none !important;
  -webkit-filter: none !important;
  transform: none !important;
  -webkit-transform: none !important;
  animation: none !important;
  will-change: auto !important;
  color: inherit !important;
  -webkit-text-fill-color: inherit !important;
}

/* Backward compatibility fallbacks */
.bloom-char,
.bloom-word-item {
  opacity: 1 !important;
  filter: none !important;
  transform: none !important;
}

/* Respect user preference for reduced motion */
@media (prefers-reduced-motion: reduce) {
  .fx-line-mask {
    overflow: visible !important;
  }
  .fx-char,
  .fx-word-item,
  .fx-line {
    opacity: 1 !important;
    filter: none !important;
    transform: none !important;
    animation: none !important;
    transition: none !important;
  }
}
