/* BE Solutions homepage effects (fx.js): particle field, cursor spotlight on the blueprint grid,
   scroll progress, card glow + tilt, magnetic buttons, word-by-word headings.
   Everything here is decoration: with JS off or reduced motion the page looks and works the same, minus the motion. */

/* ---------- background layers (behind all content) ---------- */
.fx-canvas, .fx-grid { position: fixed; inset: 0; z-index: -1; pointer-events: none; }
.fx-canvas { width: 100%; height: 100%; opacity: 0; transition: opacity 1.2s var(--ease-out); }
.fx-canvas.on { opacity: 1; }

/* A brighter copy of the body grid, shown only in a soft circle around the cursor. Its position tracks the
   page scroll (--sy) so its lines sit exactly on the body grid's lines. */
.fx-grid {
  --mx: -999px; --my: -999px; --sy: 0px; --r: 260px;
  background-image:
    linear-gradient(rgba(140, 200, 255, 0.22) 1px, transparent 1px),
    linear-gradient(90deg, rgba(140, 200, 255, 0.22) 1px, transparent 1px),
    linear-gradient(rgba(140, 200, 255, 0.1) 1px, transparent 1px),
    linear-gradient(90deg, rgba(140, 200, 255, 0.1) 1px, transparent 1px);
  background-size: 120px 120px, 120px 120px, 24px 24px, 24px 24px;
  background-position: 0 calc(var(--sy) * -1);
  -webkit-mask-image: radial-gradient(var(--r) circle at var(--mx) var(--my), #000 0%, rgba(0, 0, 0, 0.35) 45%, transparent 100%);
  mask-image: radial-gradient(var(--r) circle at var(--mx) var(--my), #000 0%, rgba(0, 0, 0, 0.35) 45%, transparent 100%);
  opacity: 0; transition: opacity 0.4s;
}
.fx-grid.on { opacity: 1; }
/* A faint warm glow under the cursor, so the spotlight reads as light, not just lines. */
.fx-grid::after {
  content: ''; position: absolute; inset: 0;
  background: radial-gradient(420px circle at var(--mx) var(--my), rgba(255, 198, 41, 0.06), transparent 60%);
}

/* ---------- scroll progress ---------- */
.fx-progress {
  position: fixed; top: 0; left: 0; right: 0; z-index: 40; height: 2px; pointer-events: none;
  background: linear-gradient(90deg, var(--accent), var(--orange));
  transform: scaleX(var(--p, 0)); transform-origin: left;
  box-shadow: 0 0 12px rgba(255, 198, 41, 0.6);
}

/* ---------- card glow (follows the pointer) + tilt ---------- */
.fx-glow { position: relative; isolation: isolate; }
.fx-glow::after {
  content: ''; position: absolute; inset: -1px; z-index: -1; border-radius: inherit; pointer-events: none;
  padding: 1px;
  background: radial-gradient(240px circle at var(--gx, 50%) var(--gy, 50%), rgba(255, 198, 41, 0.75), rgba(255, 198, 41, 0.12) 40%, transparent 70%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
  opacity: 0; transition: opacity 0.3s;
}
.fx-glow::before {
  content: ''; position: absolute; inset: 0; z-index: -1; border-radius: inherit; pointer-events: none;
  background: radial-gradient(320px circle at var(--gx, 50%) var(--gy, 50%), rgba(255, 198, 41, 0.07), transparent 65%);
  opacity: 0; transition: opacity 0.3s;
}
.fx-glow.fx-hot::after, .fx-glow.fx-hot::before { opacity: 1; }
/* fx.js adds .fx-tilt on the first hover, after the card's reveal has played; the selector outranks .js .reveal.in. */
.js .reveal.in.fx-tilt, .fx-tilt:not(.reveal) {
  transform: perspective(900px) rotateX(var(--tx, 0deg)) rotateY(var(--ty, 0deg));
  transition: transform 0.5s var(--ease-out), opacity 0.7s var(--ease-out); transition-delay: 0s;
}
.js .reveal.in.fx-tilt.fx-hot, .fx-tilt.fx-hot:not(.reveal) { transition-duration: 0.12s, 0.7s; }
/* The talk card already clips its children; keep its glow inside the rounded box. */
.talk__card.fx-glow::after { inset: 0; }

/* ---------- magnetic buttons: `translate` composes with the buttons' own hover transform ---------- */
.fx-mag { transition: transform 0.16s var(--ease-out), translate 0.4s var(--ease-out), background-color 0.2s var(--ease-out), border-color 0.2s var(--ease-out); }
.fx-mag.fx-hot { transition: transform 0.16s var(--ease-out), translate 0.1s linear, background-color 0.2s var(--ease-out), border-color 0.2s var(--ease-out); }

/* ---------- headings that rise in word by word ---------- */
.fx-words .fx-w { display: inline-block; opacity: 0; transform: translateY(0.45em) rotate(2deg); filter: blur(6px);
  transition: opacity 0.6s var(--ease-out), transform 0.7s var(--ease-out), filter 0.6s var(--ease-out); transition-delay: calc(var(--i) * 45ms); }
.fx-words.in .fx-w, .reveal.in .fx-words .fx-w { opacity: 1; transform: none; filter: none; }
/* fx.js puts the heading's own reveal on its words instead. */
.js .fx-words.reveal, .js .home-hero .fx-words, .js .hero .fx-words { opacity: 1; transform: none; animation: none; }

/* ---------- hero: drifts back as you scroll past it ---------- */
.home-hero .wrap, .hero .hero__copy { will-change: transform, opacity; transform-origin: 50% 0; }

/* ---------- click ripple on the page background ---------- */
.fx-ring { position: fixed; z-index: 45; width: 12px; height: 12px; margin: -6px 0 0 -6px; border-radius: 50%; pointer-events: none;
  border: 1.5px solid var(--accent); animation: fx-ring 0.7s var(--ease-out) forwards; }
@keyframes fx-ring { from { transform: scale(0.4); opacity: 0.9; } to { transform: scale(9); opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  .fx-canvas { transition: none; }
  .fx-words .fx-w { opacity: 1; transform: none; filter: none; transition: none; }
  .fx-tilt { transform: none; }
}
