/* ============================================================
   IASTA 2026 — Flash-In & Dissolve Into Title Animation
   Incoming conference highlights drift in around the masthead,
   pause briefly so visitors can read them, then converge and
   dissolve directly into the "IASTA 2026" heading.
   ============================================================ */

.masthead {
  overflow: hidden;
}

.masthead .masthead-inner {
  position: relative;
}

/* Stage wrapper around the H1 title so incoming phrases have an exact anchor */
.title-dissolve-stage {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 5.8rem;
  margin: 0 0 6px;
  perspective: 900px;
}

.title-dissolve-stage h1 {
  position: relative;
  z-index: 2;
  margin: 0 !important;
}

/* Layer holding floating / dissolving stat pills */
.flashin-dissolve-layer {
  position: absolute;
  inset: -45px -160px;
  pointer-events: none;
  z-index: 4;
  overflow: visible;
}

/* Individual incoming stat item */
.flashin-item {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate3d(-50%, -50%, 0);
  display: inline-flex;
  align-items: baseline;
  gap: 0.42rem;
  padding: 0.34rem 0.85rem;
  border-radius: 999px;
  background: radial-gradient(
    ellipse at center,
    rgba(12, 28, 44, 0.86) 0%,
    rgba(18, 43, 64, 0.72) 70%,
    rgba(18, 43, 64, 0) 100%
  );
  border: 1px solid rgba(255, 224, 106, 0.55);
  box-shadow:
    0 0 18px rgba(245, 189, 36, 0.38),
    0 6px 20px rgba(5, 14, 24, 0.45);
  backdrop-filter: blur(4px);
  white-space: nowrap;
  opacity: 0;
  will-change: transform, opacity, filter;
  animation: flashin-to-title var(--flash-duration, 4.4s) cubic-bezier(0.2, 0.78, 0.24, 1) forwards;
  animation-delay: var(--flash-delay, 0s);
}

.flashin-item .flashin-num {
  font-family: var(--font-display, "Fraunces", Georgia, serif);
  font-weight: 700;
  font-size: clamp(1.1rem, 2.1vw, 1.55rem);
  line-height: 1;
  color: #ffe06a;
  text-shadow:
    0 0 12px rgba(255, 224, 106, 0.85),
    0 1px 2px rgba(0, 0, 0, 0.8);
}

.flashin-item .flashin-label {
  font-family: var(--font-mono, "IBM Plex Mono", monospace);
  font-weight: 600;
  font-size: clamp(0.72rem, 1.25vw, 0.92rem);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #eef9ff;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.85);
}

/* Keyframes:
   0%   -> Spawn outside with blur
   18%  -> Arrive at reading position around the title (sharp & glowing)
   56%  -> Hold/drift gently so user can read the writing
   88%  -> Pulled into the center ("IASTA 2026") while dispersing into golden aerosol mist
   100% -> Completely dissolved into the title
*/
@keyframes flashin-to-title {
  0% {
    opacity: 0;
    filter: blur(12px) brightness(1.4);
    transform: translate3d(
        calc(-50% + var(--start-x, 0px)),
        calc(-50% + var(--start-y, -90px)),
        0
      )
      scale(0.72)
      rotate(var(--start-rot, 0deg));
  }
  18% {
    opacity: 1;
    filter: blur(0px) brightness(1.08);
    transform: translate3d(
        calc(-50% + var(--hold-x, 0px)),
        calc(-50% + var(--hold-y, -40px)),
        0
      )
      scale(1)
      rotate(0deg);
  }
  56% {
    opacity: 1;
    filter: blur(0px) brightness(1.15);
    transform: translate3d(
        calc(-50% + calc(var(--hold-x, 0px) * 0.72)),
        calc(-50% + calc(var(--hold-y, -40px) * 0.72)),
        0
      )
      scale(0.96)
      rotate(0deg);
  }
  84% {
    opacity: 0.78;
    filter: blur(6px) brightness(1.9);
    transform: translate3d(
        calc(-50% + var(--target-x, 0px)),
        calc(-50% + var(--target-y, 0px)),
        0
      )
      scale(0.48);
  }
  100% {
    opacity: 0;
    filter: blur(18px) brightness(2.4);
    transform: translate3d(
        calc(-50% + var(--target-x, 0px)),
        calc(-50% + var(--target-y, 0px)),
        0
      )
      scale(0.12);
  }
}

/* Golden absorción pulse on the IASTA 2026 title as writings dissolve into it */
.title-dissolve-stage h1.is-absorbing {
  animation:
    gold-title-shine 7s ease-in-out infinite alternate,
    title-absorb-pulse 1.15s cubic-bezier(0.22, 0.8, 0.24, 1);
}

@keyframes title-absorb-pulse {
  0% {
    transform: scale(1);
    filter: brightness(1) drop-shadow(0 0 0 rgba(255, 224, 106, 0));
  }
  45% {
    transform: scale(1.045);
    filter: brightness(1.32) drop-shadow(0 0 26px rgba(255, 224, 106, 0.88));
  }
  100% {
    transform: scale(1);
    filter: brightness(1) drop-shadow(0 0 0 rgba(255, 224, 106, 0));
  }
}

/* Dissolve burst particles that scatter into the letters when a phrase merges */
.flashin-spark {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: radial-gradient(circle, #fff8c4 0%, #f5bd24 65%, rgba(245, 189, 36, 0) 100%);
  box-shadow: 0 0 10px rgba(255, 224, 106, 0.95);
  pointer-events: none;
  opacity: 0;
  animation: spark-coalesce 0.85s ease-out forwards;
}

@keyframes spark-coalesce {
  0% {
    opacity: 0.95;
    transform: translate3d(
        calc(-50% + var(--spark-from-x, 0px)),
        calc(-50% + var(--spark-from-y, 0px)),
        0
      )
      scale(1.2);
  }
  100% {
    opacity: 0;
    transform: translate3d(
        calc(-50% + var(--spark-to-x, 0px)),
        calc(-50% + var(--spark-to-y, 0px)),
        0
      )
      scale(0.15);
  }
}

@media (max-width: 760px) {
  .title-dissolve-stage {
    min-height: 3.6rem;
  }
  .flashin-dissolve-layer {
    inset: -28px -20px;
  }
  .flashin-item {
    padding: 0.24rem 0.62rem;
    gap: 0.3rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .flashin-dissolve-layer {
    display: none;
  }
}
