/**
 * Elviss Mivon FX — marquee, loader, floating shapes.
 * Scoped under .emfx-* / body.emfx-* so the Elviss theme stays untouched.
 */

/* -------------------------------------------------------------------------- */
/* Hide the theme ripple preloader (replaced by .emfx-loader)                   */
/* -------------------------------------------------------------------------- */
body .preloader {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

/* -------------------------------------------------------------------------- */
/* Loader — Mivon rubber-band wordmark + wipe                                  */
/* -------------------------------------------------------------------------- */
.emfx-loader {
  position: fixed;
  inset: 0;
  z-index: 2147483000;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: transparent;
  pointer-events: none;
  transition: transform 0.9s cubic-bezier(0.77, 0, 0.18, 1), opacity 0.4s ease 0.2s;
}

.emfx-loader__wipe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100vw;
  height: 110vh;
  fill: #f8fafb; /* match live base-1 page bg */
}

.emfx-loader__heading {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

.emfx-loader__text {
  font-family: inherit;
  font-size: clamp(2.5rem, 6vw, 3.25rem);
  font-weight: 500;
  line-height: 1;
  letter-spacing: -0.02em;
  color: #131313;
  display: inline-flex;
  position: relative;
  z-index: 2;
}

.emfx-loader__text span {
  display: inline-block;
  transform-origin: 50% 100%;
  animation: emfx-rubber 1s infinite alternate;
  will-change: transform, opacity;
}

.emfx-loader__text span:nth-child(1) { animation-delay: 0s; }
.emfx-loader__text span:nth-child(2) { animation-delay: 0.08s; }
.emfx-loader__text span:nth-child(3) { animation-delay: 0.16s; }
.emfx-loader__text span:nth-child(4) { animation-delay: 0.24s; }
.emfx-loader__text span:nth-child(5) { animation-delay: 0.32s; }
.emfx-loader__text span:nth-child(6) { animation-delay: 0.4s; }
.emfx-loader__text span:nth-child(7) { animation-delay: 0.48s; }
.emfx-loader__text span:nth-child(8) { animation-delay: 0.56s; }

@keyframes emfx-rubber {
  0% {
    opacity: 1;
    transform: scaleY(1) translateY(0);
  }
  100% {
    opacity: 0.35;
    transform: scaleY(1.45) translateY(-6px);
  }
}

/* Logo SVG is the same wordmark — hide it; rubber-band text is the Mivon effect */
.emfx-loader__logo {
  display: none !important;
}

.emfx-loader.is-leaving {
  transform: translateY(-110%);
}

.emfx-loader.is-done {
  display: none !important;
}

html.emfx-loaded,
body.emfx-loaded {
  overflow: auto;
}

/* -------------------------------------------------------------------------- */
/* Marquee — restyle .wp-block-marquee-text to Mivon grey ticker               */
/* -------------------------------------------------------------------------- */
.wp-block-marquee-text,
.wp-block-marquee-text.emfx-marquee-ready {
  background: transparent !important;
  background-color: transparent !important;
  color: #9a9a9a !important;
  /* Kill the blue primary bar */
  --marquee-text-background: transparent !important;
  --marquee-text-color: #9a9a9a !important;
  position: relative;
  overflow: hidden;
  padding: 0.35rem 0;
  font-size: clamp(2.5rem, 8vw, 10vw) !important;
  line-height: 1.15;
  font-weight: 500;
}

.wp-block-marquee-text::after {
  content: "";
  position: absolute;
  inset: -8px -4px;
  pointer-events: none;
  z-index: 2;
  /* Soft edge fade into page background (base-1 ≈ #f8fafb) */
  background: linear-gradient(
    to left,
    #f8fafb,
    rgba(248, 250, 251, 0) 180px,
    rgba(248, 250, 251, 0) calc(100% - 180px),
    #f8fafb
  );
}

.wp-block-marquee-text .marquee-text {
  overflow: hidden;
  width: 100%;
  position: relative;
}

.wp-block-marquee-text .marquee-text-track {
  /* Keep existing animation; ensure smooth GPU path */
  transform: translateZ(0);
  will-change: transform;
  align-items: center;
}

.wp-block-marquee-text .marquee-text-content {
  align-items: center !important;
  gap: 0 !important;
}

.wp-block-marquee-text .marquee-text-content p,
.wp-block-marquee-text .marquee-text-content .wp-block-paragraph {
  font-size: inherit !important;
  font-weight: 500 !important;
  font-style: normal !important;
  text-transform: uppercase !important;
  color: #9a9a9a !important;
  -webkit-text-stroke: 0 !important;
  margin: 0 !important;
  white-space: nowrap;
  padding: 0 1.25rem;
  opacity: 0.85;
}

/* Alternate stroke look like Mivon even items */
.wp-block-marquee-text .marquee-text-content > *:nth-child(4n + 1) p,
.wp-block-marquee-text .marquee-text-content > *:nth-child(4n + 1).wp-block-paragraph {
  color: transparent !important;
  -webkit-text-stroke: 1px #b0b0b0 !important;
  opacity: 0.7;
}

/* Replace icon-block stars with Mivon 4-point sparkle */
.wp-block-marquee-text .wp-block-outermost-icon-block,
.wp-block-marquee-text .icon-container {
  width: clamp(28px, 4vw, 56px) !important;
  height: clamp(28px, 4vw, 56px) !important;
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  color: #b0b0b0 !important;
  flex: 0 0 auto;
}

.wp-block-marquee-text .wp-block-outermost-icon-block svg {
  display: none !important;
}

.wp-block-marquee-text .wp-block-outermost-icon-block .icon-container::before,
.wp-block-marquee-text .emfx-star {
  content: "";
  display: block;
  width: 70%;
  height: 70%;
  background: currentColor;
  /* 4-point sparkle via mask; JS also injects <img> fallback */
  -webkit-mask: url("../img/star.svg") center / contain no-repeat;
  mask: url("../img/star.svg") center / contain no-repeat;
  background-color: #b0b0b0;
}

.wp-block-marquee-text .emfx-star-img {
  width: clamp(28px, 4vw, 56px);
  height: clamp(28px, 4vw, 56px);
  opacity: 0.55;
  display: block;
  flex: 0 0 auto;
  margin: 0 0.25rem;
}

/* When JS rebuilds the track as Mivon main-marq structure */
.emfx-main-marq {
  position: relative;
  overflow: hidden;
  width: 100%;
  padding: 0.5rem 0;
  background: transparent !important;
}

.emfx-main-marq::after {
  content: "";
  position: absolute;
  inset: -12px -4px;
  pointer-events: none;
  z-index: 2;
  background: linear-gradient(
    to left,
    #f8fafb,
    rgba(248, 250, 251, 0) 200px,
    rgba(248, 250, 251, 0) calc(100% - 200px),
    #f8fafb
  );
}

.emfx-main-marq .emfx-slide {
  display: flex;
  width: max-content;
  animation: emfx-slide-har 80s linear infinite;
  will-change: transform;
}

.emfx-main-marq .emfx-box {
  display: flex;
  align-items: center;
}

.emfx-main-marq .emfx-item {
  display: flex;
  align-items: center;
  padding: 0 clamp(12px, 2vw, 30px);
  white-space: nowrap;
}

.emfx-main-marq .emfx-item__text {
  font-size: clamp(2.5rem, 10vw, 10vw);
  font-weight: 500;
  line-height: 1.15;
  text-transform: uppercase;
  color: #9a9a9a;
  margin: 0;
  opacity: 0.8;
  letter-spacing: -0.02em;
}

.emfx-main-marq .emfx-item:nth-child(odd) .emfx-item__text {
  color: transparent;
  -webkit-text-stroke: 1px #b0b0b0;
  opacity: 0.65;
}

.emfx-main-marq .emfx-item__star {
  width: clamp(28px, 4.5vw, 64px);
  height: clamp(28px, 4.5vw, 64px);
  opacity: 0.5;
  margin: 0 clamp(4px, 1vw, 12px);
  flex: 0 0 auto;
}

@keyframes emfx-slide-har {
  0% { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}

/* -------------------------------------------------------------------------- */
/* Floating decorative shapes — document-absolute, behind content              */
/* -------------------------------------------------------------------------- */
.emfx-floats {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 0; /* children are absolutely placed down the page */
  pointer-events: none;
  z-index: 0;
  overflow: visible;
}

/* Positioning context for document-absolute floats */
body.emfx-has-floats {
  position: relative;
}

/* Keep site chrome / content above the float layer */
body.emfx-has-floats .site,
body.emfx-has-floats .wp-site-blocks,
body.emfx-has-floats header,
body.emfx-has-floats footer,
body.emfx-has-floats main,
body.emfx-has-floats nav {
  position: relative;
  z-index: 1;
}

.emfx-float {
  position: absolute;
  pointer-events: none;
  z-index: 0;
  opacity: 0.55;
  will-change: transform;
  /* Rotate/drift outward from the screen edge so AABB doesn't swing into content */
  transform-origin: var(--emfx-origin, 50% 50%);
  animation: emfx-float-drift var(--emfx-dur, 14s) ease-in-out infinite alternate;
  animation-delay: var(--emfx-delay, 0s);
  filter: drop-shadow(0 10px 24px rgba(10, 57, 129, 0.06));
}

.emfx-float.is-hidden {
  display: none !important;
}

.emfx-float img {
  display: block;
  width: 100%;
  height: auto;
  max-width: 100%;
  user-select: none;
  -webkit-user-drag: none;
}

@keyframes emfx-float-drift {
  0% { transform: translate3d(0, 0, 0) rotate(var(--emfx-rot, 0deg)); }
  100% { transform: translate3d(var(--emfx-tx, 12px), var(--emfx-ty, -16px), 0) rotate(calc(var(--emfx-rot, 0deg) + 6deg)); }
}

.emfx-float.is-parallax {
  transform: translate3d(0, var(--emfx-py, 0px), 0) rotate(var(--emfx-rot, 0deg));
  animation: none;
}

@media (max-width: 767px) {
  .emfx-float {
    opacity: 0.4;
    max-width: 120px !important;
  }
  .wp-block-marquee-text::after,
  .emfx-main-marq::after {
    background: linear-gradient(
      to left,
      #f8fafb,
      rgba(248, 250, 251, 0) 72px,
      rgba(248, 250, 251, 0) calc(100% - 72px),
      #f8fafb
    );
  }
}

/* -------------------------------------------------------------------------- */
/* Reduced motion                                                              */
/* -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  .emfx-loader__text span {
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
  }
  .emfx-loader {
    transition: opacity 0.3s ease;
  }
  .emfx-loader.is-leaving {
    transform: none;
    opacity: 0;
  }
  .wp-block-marquee-text .marquee-text-track,
  .emfx-main-marq .emfx-slide {
    animation: none !important;
    transform: none !important;
  }
  .emfx-float {
    animation: none !important;
  }
}
