/**
 * blog-haunting.css - Ghost effect animations and classes
 * Project Meridian Syn
 *
 * CRITICAL: NO filter/transform on body - use .app-layout instead
 */

/* ========== Word Replace Effect ========== */
@keyframes ghost-word-pulse {
  0%, 100% { text-shadow: 0 0 4px rgba(232, 168, 62, 0.4); }
  50% { text-shadow: 0 0 12px rgba(232, 168, 62, 0.8), 0 0 24px rgba(232, 168, 62, 0.3); }
}

.ghost-word {
  color: #E8A83E;
  font-weight: 700;
  text-shadow: 0 0 8px rgba(232, 168, 62, 0.6);
  animation: ghost-word-pulse 2s ease-in-out 3;
  transition: color 0.4s ease;
}

.ghost-word-subtle {
  font-weight: 600;
  color: #D4963A;
  text-shadow: 0 0 4px rgba(232, 168, 62, 0.3);
  transition: color 1.5s ease;
}

/* ========== Letter Fall Effect ========== */
@keyframes letter-fall {
  0% {
    transform: translateY(0) rotate(0deg);
    opacity: 1;
    color: #E8A83E;
    text-shadow: 0 0 8px rgba(232, 168, 62, 0.8);
  }
  30% {
    transform: translateY(20px) rotate(-5deg);
    opacity: 0.9;
  }
  70% {
    opacity: 0.5;
    text-shadow: 0 0 16px rgba(232, 168, 62, 0.4);
  }
  100% {
    transform: translateY(100vh) rotate(15deg);
    opacity: 0;
  }
}

.ghost-letter-fall {
  display: inline-block;
  position: relative;
  color: #E8A83E;
  font-weight: 700;
  text-shadow: 0 0 10px rgba(232, 168, 62, 0.8);
  animation: letter-fall 2.5s ease-in forwards;
}

/* ========== Sentence Replace Effect ========== */
@keyframes ghost-sentence-out {
  0% {
    opacity: 1;
    filter: blur(0);
  }
  60% {
    opacity: 0.3;
    filter: blur(2px);
    color: #E8A83E;
  }
  100% {
    opacity: 0;
    filter: blur(6px);
  }
}

@keyframes ghost-sentence-in {
  0% {
    opacity: 0;
    filter: blur(6px);
    letter-spacing: 0.3em;
  }
  50% {
    letter-spacing: 0.05em;
  }
  100% {
    opacity: 1;
    filter: blur(0);
    letter-spacing: normal;
  }
}

@keyframes ghost-sentence-glow {
  0%, 100% { text-shadow: 0 0 6px rgba(232, 168, 62, 0.4); }
  50% { text-shadow: 0 0 18px rgba(232, 168, 62, 0.7), 0 0 30px rgba(232, 168, 62, 0.2); }
}

.ghost-sentence-out {
  animation: ghost-sentence-out 0.8s ease forwards;
}

.ghost-sentence-in {
  color: #E8A83E;
  font-style: italic;
  font-weight: 600;
  text-shadow: 0 0 10px rgba(232, 168, 62, 0.6);
  animation: ghost-sentence-in 1.2s ease forwards, ghost-sentence-glow 3s ease-in-out 1.2s infinite;
  background: linear-gradient(90deg, transparent, rgba(232, 168, 62, 0.06), transparent);
  padding: 2px 4px;
  border-radius: 2px;
}

/* ========== Amber Shift Effect ========== */
@keyframes amber-shift-flicker {
  0% { opacity: 1; }
  10% { opacity: 0.6; }
  20% { opacity: 1; }
  30% { opacity: 0.8; }
  50% { opacity: 1; }
  100% { opacity: 1; }
}

.ghost-amber-shift {
  color: #E8A83E;
  font-weight: 600;
  text-shadow: 0 0 6px rgba(232, 168, 62, 0.5);
  animation: amber-shift-flicker 0.6s ease 1;
  transition: color 1s ease, text-shadow 1s ease;
}

/* ========== Interstitial Text Effect ========== */
@keyframes interstitial-glow {
  0%, 100% { text-shadow: 0 0 4px rgba(232, 168, 62, 0.3); }
  50% { text-shadow: 0 0 14px rgba(232, 168, 62, 0.6); }
}

.ghost-interstitial {
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: max-height 1.5s ease, opacity 2s ease, padding 1.5s ease;
  font-size: 0.95rem;
  font-style: italic;
  color: #E8A83E;
  font-weight: 500;
  padding: 0 0;
  line-height: 1.8;
  letter-spacing: 0.02em;
  border-left: 2px solid transparent;
  margin-left: -1rem;
  padding-left: 1rem;
}

.ghost-interstitial.visible {
  max-height: 5rem;
  opacity: 1;
  padding: 1rem 0 1rem 1rem;
  border-left-color: rgba(232, 168, 62, 0.5);
  text-shadow: 0 0 8px rgba(232, 168, 62, 0.4);
  animation: interstitial-glow 3s ease-in-out infinite;
}

/* ========== Character Corruption Effect ========== */
@keyframes char-corrupt {
  0% {
    opacity: 1;
    transform: translateY(0);
    color: inherit;
  }
  15% {
    opacity: 0.3;
    transform: translateY(-3px);
    color: #E8A83E;
  }
  30% {
    opacity: 0.9;
    transform: translateY(2px) scaleY(1.3);
    color: #E8A83E;
    text-shadow: 0 0 8px rgba(232, 168, 62, 0.8);
  }
  60% {
    opacity: 0.5;
    transform: translateX(2px) scaleX(0.9);
  }
  100% {
    opacity: 1;
    transform: translate(0) scale(1);
    color: inherit;
    text-shadow: none;
  }
}

.ghost-char-corrupt {
  display: inline;
  animation: char-corrupt 0.5s ease;
  color: #E8A83E;
  text-shadow: 0 0 6px rgba(232, 168, 62, 0.6);
}

/* ========== Word Scatter Effect ========== */

/* During scramble: monospace font so character cycling looks like decoding */
.ghost-scatter-word {
  display: inline;
  color: #E8A83E;
  font-weight: 700;
  font-family: 'Courier New', monospace;
  text-shadow: 0 0 8px rgba(232, 168, 62, 0.6);
  letter-spacing: 0.05em;
}

/* After scramble completes: return to body font, pulse gently */
@keyframes scatter-settle-pulse {
  0%, 100% { text-shadow: 0 0 6px rgba(232, 168, 62, 0.4); }
  50% { text-shadow: 0 0 14px rgba(232, 168, 62, 0.7); }
}

.ghost-scatter-word.ghost-scatter-settled {
  font-family: inherit;
  letter-spacing: normal;
  animation: scatter-settle-pulse 3s ease-in-out infinite;
}

/* ========== Word Stream Effect ========== */

/* Active word in the stream - the "head" of the wave */
@keyframes stream-word-appear {
  0% {
    opacity: 0;
    transform: translateY(4px) scale(0.8);
  }
  40% {
    opacity: 1;
    transform: translateY(-2px) scale(1.1);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.ghost-stream-word {
  display: inline-block;
  color: #E8A83E;
  font-weight: 700;
  text-shadow: 0 0 10px rgba(232, 168, 62, 0.7), 0 0 20px rgba(232, 168, 62, 0.3);
  animation: stream-word-appear 0.3s ease forwards;
}

/* Fading out at end of stream */
@keyframes stream-word-fade {
  0% {
    opacity: 1;
    color: #E8A83E;
    text-shadow: 0 0 10px rgba(232, 168, 62, 0.7);
  }
  100% {
    opacity: 0.3;
    color: #D4963A;
    text-shadow: 0 0 4px rgba(232, 168, 62, 0.2);
  }
}

.ghost-stream-word.ghost-stream-fade {
  animation: stream-word-fade 1.5s ease forwards;
}

/* ========== Reduced Motion ========== */
@media (prefers-reduced-motion: reduce) {
  .ghost-letter-fall {
    animation: none;
    opacity: 0;
  }

  .ghost-sentence-out,
  .ghost-sentence-in {
    animation: none;
  }

  .ghost-sentence-out {
    opacity: 0;
  }

  .ghost-sentence-in {
    opacity: 1;
  }

  .ghost-interstitial {
    transition: none;
  }

  .ghost-interstitial.visible {
    animation: none;
  }

  .ghost-char-corrupt {
    animation: none;
  }

  .ghost-word,
  .ghost-word-subtle {
    animation: none;
  }

  .ghost-amber-shift {
    animation: none;
    transition: none;
  }

  .ghost-scatter-word {
    animation: none;
  }

  .ghost-stream-word {
    animation: none;
  }

  .ghost-stream-word.ghost-stream-fade {
    animation: none;
  }
}
