/* =========================================================================
   Solace Technologies - shared motion layer (pairs with motion.js)
   Micro-interactions + IO-based reveal fallbacks for pages without GSAP.
   Safe to load on any page; all selectors are opt-in.
   ========================================================================= */

/* ----- Scroll progress bar (injected by motion.js) ----- */
.solace-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 2px;
  width: 100%;
  z-index: 300;
  pointer-events: none;
  transform-origin: 0 50%;
  transform: scaleX(0);
  background: linear-gradient(90deg, #34d399 0%, #38bdf8 60%, #a78bfa 100%);
  opacity: 0.9;
}

/* ----- Cursor-tracking glow on cards (motion.js sets --mx / --my) ----- */
.glow-card {
  position: relative;
}
.glow-card::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  opacity: 0;
  transition: opacity 320ms ease;
  background: radial-gradient(
    320px 220px at var(--mx, 50%) var(--my, 50%),
    rgba(56, 189, 248, 0.12) 0%,
    rgba(52, 211, 153, 0.08) 35%,
    transparent 70%
  );
  z-index: 1;
}
.glow-card:hover::after { opacity: 1; }

/* ----- Magnetic buttons (transform driven by motion.js) ----- */
.is-magnetic {
  will-change: transform;
  transition: transform 360ms cubic-bezier(0.16, 1, 0.3, 1);
}

/* ----- IO reveal fallback (pages without GSAP: about, contact, legal) ----- */
body.motion-io [data-anim-show],
body.motion-io [data-anim-card] {
  opacity: 0;
  transform: translateY(26px);
  transition: opacity 800ms cubic-bezier(0.16, 1, 0.3, 1),
    transform 800ms cubic-bezier(0.16, 1, 0.3, 1);
}
body.motion-io [data-anim-show].is-in,
body.motion-io [data-anim-card].is-in {
  opacity: 1;
  transform: none;
}

/* ----- Infinite logo / proof marquee ----- */
.logo-marquee {
  overflow: hidden;
  position: relative;
  -webkit-mask-image: linear-gradient(90deg, transparent 0%, #000 8%, #000 92%, transparent 100%);
  mask-image: linear-gradient(90deg, transparent 0%, #000 8%, #000 92%, transparent 100%);
}
.logo-marquee-track {
  display: flex;
  width: max-content;
  gap: 18px;
  animation: logoMarqueeScroll 36s linear infinite;
}
.logo-marquee:hover .logo-marquee-track { animation-play-state: paused; }
@keyframes logoMarqueeScroll {
  from { transform: translateX(0); }
  to { transform: translateX(-50%); }
}

/* ----- Slow-drifting aurora layer (CSS only, GPU friendly) ----- */
.aurora {
  position: absolute;
  inset: -20%;
  pointer-events: none;
  z-index: 0;
  opacity: 0.5;
  background:
    radial-gradient(38% 42% at 24% 30%, rgba(52, 211, 153, 0.16) 0%, transparent 70%),
    radial-gradient(40% 44% at 76% 24%, rgba(56, 189, 248, 0.16) 0%, transparent 70%),
    radial-gradient(36% 40% at 56% 78%, rgba(167, 139, 250, 0.14) 0%, transparent 70%);
  filter: blur(60px);
  animation: auroraDrift 26s ease-in-out infinite alternate;
  will-change: transform;
}
@keyframes auroraDrift {
  from { transform: translate3d(-2.5%, -2%, 0) rotate(-1.5deg) scale(1); }
  to { transform: translate3d(2.5%, 2.5%, 0) rotate(1.5deg) scale(1.06); }
}

/* ----- 3D perspective tilt + specular highlight (motion.js sets vars) ----- */
.is-tilt {
  transform-style: preserve-3d;
  transition: transform 320ms cubic-bezier(0.16, 1, 0.3, 1);
  transform: perspective(900px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg));
  will-change: transform;
}
.is-tilt::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  opacity: 0;
  transition: opacity 320ms ease;
  background: radial-gradient(
    260px 200px at var(--sx, 50%) var(--sy, 50%),
    rgba(255, 255, 255, 0.22) 0%,
    rgba(255, 255, 255, 0) 60%
  );
  mix-blend-mode: screen;
  z-index: 2;
}
.is-tilt:hover::after { opacity: 1; }

/* ----- Button shine sweep (opt-in via data-shine) ----- */
[data-shine] {
  position: relative;
  overflow: hidden;
}
[data-shine]::before {
  content: "";
  position: absolute;
  top: 0;
  left: -120%;
  width: 60%;
  height: 100%;
  pointer-events: none;
  background: linear-gradient(
    100deg,
    transparent 0%,
    rgba(255, 255, 255, 0.35) 50%,
    transparent 100%
  );
  transform: skewX(-18deg);
  transition: left 720ms cubic-bezier(0.16, 1, 0.3, 1);
}
[data-shine]:hover::before { left: 140%; }

/* ----- Animated gradient border on featured cards (opt-in via data-gradient-border) ----- */
[data-gradient-border] {
  position: relative;
  isolation: isolate;
}
[data-gradient-border]::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(130deg, #34d399, #38bdf8, #a78bfa, #34d399);
  background-size: 300% 300%;
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  animation: gradientBorderShift 8s linear infinite;
  pointer-events: none;
  z-index: -1;
}
@keyframes gradientBorderShift {
  0% { background-position: 0% 50%; }
  100% { background-position: 300% 50%; }
}

/* ----- Clip-path / fade section reveals (opt-in via data-reveal-clip) ----- */
[data-reveal-clip] {
  opacity: 0;
  transform: translateY(34px);
  clip-path: inset(0 0 14% 0 round 18px);
  transition: opacity 900ms cubic-bezier(0.16, 1, 0.3, 1),
    transform 900ms cubic-bezier(0.16, 1, 0.3, 1),
    clip-path 900ms cubic-bezier(0.16, 1, 0.3, 1);
  will-change: opacity, transform, clip-path;
}
[data-reveal-clip].is-in {
  opacity: 1;
  transform: none;
  clip-path: inset(0 0 0 0 round 18px);
}

/* ----- Parallax layers ----- */
[data-parallax] { will-change: transform; }

/* ----- Floating ambient 3D layers (slow drift) ----- */
.float-layer {
  animation: floatDrift 12s ease-in-out infinite alternate;
  will-change: transform;
}
.float-layer.float-slow { animation-duration: 18s; }
@keyframes floatDrift {
  from { transform: translateY(-10px) rotate(-1deg); }
  to { transform: translateY(10px) rotate(1.5deg); }
}

/* ----- Sticky in-page subnav + scrollspy ----- */
.subnav {
  position: sticky;
  top: 64px;
  z-index: 40;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
  padding: 8px;
  margin: 0 auto;
  border-radius: 999px;
  background: var(--glass-bg-strong, rgba(10, 20, 35, 0.78));
  -webkit-backdrop-filter: blur(18px) saturate(160%);
  backdrop-filter: blur(18px) saturate(160%);
  border: 1px solid var(--glass-border, rgba(255, 255, 255, 0.12));
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.4);
}
.subnav a {
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--text-soft, #b8c4d4);
  white-space: nowrap;
  transition: color 200ms ease, background 200ms ease;
}
.subnav a:hover { color: #fff; }
.subnav a.is-active {
  color: #06111e;
  background: linear-gradient(120deg, #34d399, #38bdf8);
}

/* ----- Reduced motion: switch everything off ----- */
@media (prefers-reduced-motion: reduce) {
  .is-tilt { transform: none !important; transition: none; }
  .is-tilt::after { display: none; }
  [data-shine]::before { display: none; }
  [data-gradient-border]::before { animation: none; }
  [data-parallax] { transform: none !important; }
  .float-layer { animation: none; }
  [data-reveal-clip] {
    opacity: 1;
    transform: none;
    clip-path: none;
    transition: none;
  }
  .glass-grain { display: none; }
  .solace-progress { display: none; }
  .glow-card::after { display: none; }
  .is-magnetic { transition: none; transform: none !important; }
  .logo-marquee-track { animation: none; flex-wrap: wrap; }
  .aurora { animation: none; }
  body.motion-io [data-anim-show],
  body.motion-io [data-anim-card] {
    opacity: 1;
    transform: none;
    transition: none;
  }
}
