/* ==========================================================================
   ANIMATIONS.CSS — Scroll Reveals, Keyframes, Parallax, Particles
   Primordial Stone — Cave-Themed Stone Craftsmanship
   ========================================================================== */

/* ==========================================================================
   SCROLL REVEAL
   ========================================================================== */

.reveal {
  opacity: 0;
  transform: translateY(30px) scale(0.98);
  transition:
    opacity var(--transition-slow),
    transform var(--transition-slow);
}

.reveal.revealed {
  opacity: 1;
  transform: translateY(0) scale(1);
}

/* Directional variants */
.reveal--left {
  opacity: 0;
  transform: translateX(-40px);
  transition:
    opacity var(--transition-slow),
    transform var(--transition-slow);
}

.reveal--left.revealed {
  opacity: 1;
  transform: translateX(0);
}

.reveal--right {
  opacity: 0;
  transform: translateX(40px);
  transition:
    opacity var(--transition-slow),
    transform var(--transition-slow);
}

.reveal--right.revealed {
  opacity: 1;
  transform: translateX(0);
}

.reveal--scale {
  opacity: 0;
  transform: scale(0.9);
  transition:
    opacity var(--transition-slow),
    transform var(--transition-slow);
}

.reveal--scale.revealed {
  opacity: 1;
  transform: scale(1);
}

/* Stagger children */
.reveal-stagger > .reveal:nth-child(1) { transition-delay: 0ms; }
.reveal-stagger > .reveal:nth-child(2) { transition-delay: 100ms; }
.reveal-stagger > .reveal:nth-child(3) { transition-delay: 200ms; }
.reveal-stagger > .reveal:nth-child(4) { transition-delay: 300ms; }
.reveal-stagger > .reveal:nth-child(5) { transition-delay: 400ms; }
.reveal-stagger > .reveal:nth-child(6) { transition-delay: 500ms; }
.reveal-stagger > .reveal:nth-child(7) { transition-delay: 600ms; }
.reveal-stagger > .reveal:nth-child(8) { transition-delay: 700ms; }

/* ==========================================================================
   GLOW PULSE
   ========================================================================== */

@keyframes glow-pulse {
  0% {
    opacity: 0.6;
    transform: translate(-50%, -50%) scale(1);
  }
  100% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.1);
  }
}

/* Standalone glow-pulse for elements not using translate centering */
@keyframes glow-pulse-simple {
  0% {
    opacity: 0.6;
    transform: scale(1);
  }
  100% {
    opacity: 1;
    transform: scale(1.1);
  }
}

/* ==========================================================================
   FLICKER (Subtle firelight)
   ========================================================================== */

@keyframes flicker {
  0%, 100% { opacity: 1; }
  25% { opacity: 0.92; }
  50% { opacity: 0.97; }
  75% { opacity: 0.88; }
}

.flicker {
  animation: flicker 3s ease-in-out infinite;
}

/* Slower flicker variant */
@keyframes flicker-slow {
  0%, 100% { opacity: 1; }
  20% { opacity: 0.95; }
  40% { opacity: 0.98; }
  60% { opacity: 0.9; }
  80% { opacity: 0.96; }
}

.flicker--slow {
  animation: flicker-slow 5s ease-in-out infinite;
}

/* ==========================================================================
   EMBER FLOAT PARTICLES
   ========================================================================== */

.ember-particles {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  pointer-events: none;
  z-index: 1;
}

@keyframes ember-rise-1 {
  0% {
    transform: translateY(100%) translateX(0);
    opacity: 0;
  }
  10% {
    opacity: 0.8;
  }
  50% {
    transform: translateY(40%) translateX(20px);
    opacity: 0.5;
  }
  100% {
    transform: translateY(-10%) translateX(-10px);
    opacity: 0;
  }
}

@keyframes ember-rise-2 {
  0% {
    transform: translateY(100%) translateX(0);
    opacity: 0;
  }
  15% {
    opacity: 0.7;
  }
  50% {
    transform: translateY(50%) translateX(-15px);
    opacity: 0.4;
  }
  100% {
    transform: translateY(-5%) translateX(25px);
    opacity: 0;
  }
}

@keyframes ember-rise-3 {
  0% {
    transform: translateY(100%) translateX(0);
    opacity: 0;
  }
  12% {
    opacity: 0.6;
  }
  60% {
    transform: translateY(30%) translateX(18px);
    opacity: 0.3;
  }
  100% {
    transform: translateY(-15%) translateX(-8px);
    opacity: 0;
  }
}

@keyframes ember-sway {
  0%, 100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(8px);
  }
  75% {
    transform: translateX(-8px);
  }
}

.ember-particles::before,
.ember-particles::after {
  content: '';
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
}

.ember-particles::before {
  width: 3px;
  height: 3px;
  background: var(--ember);
  bottom: 10%;
  left: 20%;
  animation: ember-rise-1 8s ease-in infinite;
  box-shadow: 0 0 6px 2px rgba(196, 105, 42, 0.4);
}

.ember-particles::after {
  width: 2px;
  height: 2px;
  background: var(--flame);
  bottom: 15%;
  left: 60%;
  animation: ember-rise-2 10s ease-in infinite 2s;
  box-shadow: 0 0 4px 1px rgba(232, 176, 74, 0.3);
}

/* Additional particles via child spans */
.ember-particle {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
}

.ember-particle:nth-child(1) {
  width: 2px;
  height: 2px;
  background: var(--ember);
  bottom: 5%;
  left: 35%;
  animation: ember-rise-1 12s ease-in infinite 1s;
  box-shadow: 0 0 4px 1px rgba(196, 105, 42, 0.3);
}

.ember-particle:nth-child(2) {
  width: 3px;
  height: 3px;
  background: var(--amber);
  bottom: 8%;
  left: 75%;
  animation: ember-rise-3 9s ease-in infinite 3s;
  box-shadow: 0 0 6px 2px rgba(212, 148, 58, 0.4);
}

.ember-particle:nth-child(3) {
  width: 2px;
  height: 2px;
  background: var(--flame);
  bottom: 12%;
  left: 45%;
  animation: ember-rise-2 11s ease-in infinite 5s;
  box-shadow: 0 0 4px 1px rgba(232, 176, 74, 0.3);
}

.ember-particle:nth-child(4) {
  width: 1px;
  height: 1px;
  background: var(--ember);
  bottom: 3%;
  left: 15%;
  animation: ember-rise-1 14s ease-in infinite 7s;
  box-shadow: 0 0 3px 1px rgba(196, 105, 42, 0.25);
}

.ember-particle:nth-child(5) {
  width: 2px;
  height: 2px;
  background: var(--amber);
  bottom: 6%;
  left: 85%;
  animation: ember-rise-3 10s ease-in infinite 4s;
  box-shadow: 0 0 5px 2px rgba(212, 148, 58, 0.35);
}

.ember-particle:nth-child(6) {
  width: 3px;
  height: 3px;
  background: var(--flame);
  bottom: 10%;
  left: 55%;
  animation: ember-rise-2 13s ease-in infinite 6s;
  box-shadow: 0 0 6px 2px rgba(232, 176, 74, 0.3);
}

.ember-particle:nth-child(7) {
  width: 1px;
  height: 1px;
  background: var(--ember);
  bottom: 7%;
  left: 30%;
  animation: ember-rise-1 15s ease-in infinite 8s;
  box-shadow: 0 0 3px 1px rgba(196, 105, 42, 0.2);
}

.ember-particle:nth-child(8) {
  width: 2px;
  height: 2px;
  background: var(--amber);
  bottom: 4%;
  left: 90%;
  animation: ember-rise-3 11s ease-in infinite 2.5s;
  box-shadow: 0 0 5px 2px rgba(212, 148, 58, 0.3);
}

.ember-particle:nth-child(9) {
  width: 2px;
  height: 2px;
  background: var(--ember);
  bottom: 9%;
  left: 10%;
  animation: ember-rise-2 12s ease-in infinite 9s;
  box-shadow: 0 0 4px 1px rgba(196, 105, 42, 0.3);
}

.ember-particle:nth-child(10) {
  width: 1px;
  height: 1px;
  background: var(--flame);
  bottom: 11%;
  left: 68%;
  animation: ember-rise-1 16s ease-in infinite 4.5s;
  box-shadow: 0 0 3px 1px rgba(232, 176, 74, 0.25);
}

/* ==========================================================================
   PARALLAX HELPER
   ========================================================================== */

.parallax {
  background-attachment: fixed;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

@media (max-width: 768px) {
  .parallax {
    background-attachment: scroll;
  }
}

/* ==========================================================================
   SMOOTH SECTION TRANSITIONS
   Gradient blending at top/bottom of sections
   ========================================================================== */

.section-fade-top::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 80px;
  background: linear-gradient(to bottom, var(--void), transparent);
  pointer-events: none;
  z-index: 1;
}

.section-fade-bottom::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 80px;
  background: linear-gradient(to top, var(--void), transparent);
  pointer-events: none;
  z-index: 1;
}

.section-fade-top--cave::before {
  background: linear-gradient(to bottom, var(--cave), transparent);
}

.section-fade-bottom--cave::after {
  background: linear-gradient(to top, var(--cave), transparent);
}

.section-fade-top--bedrock::before {
  background: linear-gradient(to bottom, var(--bedrock), transparent);
}

.section-fade-bottom--bedrock::after {
  background: linear-gradient(to top, var(--bedrock), transparent);
}

/* ==========================================================================
   TEXT SHIMMER (decorative heading effect)
   ========================================================================== */

@keyframes text-shimmer {
  0% {
    background-position: -200% center;
  }
  100% {
    background-position: 200% center;
  }
}

.text-shimmer {
  background: linear-gradient(
    90deg,
    var(--chalk) 0%,
    var(--flame) 25%,
    var(--chalk) 50%,
    var(--flame) 75%,
    var(--chalk) 100%
  );
  background-size: 200% auto;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: text-shimmer 6s linear infinite;
}

/* ==========================================================================
   FADE IN/UP for page load
   ========================================================================== */

@keyframes fade-in-up {
  0% {
    opacity: 0;
    transform: translateY(20px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

.animate-fade-in-up {
  animation: fade-in-up 0.8s ease forwards;
}

.animate-fade-in-up--delay-1 {
  animation-delay: 200ms;
  opacity: 0;
}

.animate-fade-in-up--delay-2 {
  animation-delay: 400ms;
  opacity: 0;
}

.animate-fade-in-up--delay-3 {
  animation-delay: 600ms;
  opacity: 0;
}

.animate-fade-in-up--delay-4 {
  animation-delay: 800ms;
  opacity: 0;
}

/* ==========================================================================
   REDUCED MOTION
   Respect user preferences
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .reveal {
    opacity: 1;
    transform: none;
  }

  .reveal--left,
  .reveal--right,
  .reveal--scale {
    opacity: 1;
    transform: none;
  }

  .parallax {
    background-attachment: scroll;
  }
}
