/* =========================================================
   CONNECT GROUPE — Motion Layer
   Additive styles : cursor, magnetic, tilt, reveals, scroll,
   gradient meshes, grain, page transitions.
   Respect prefers-reduced-motion.
   ========================================================= */

:root {
  --motion-ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --motion-ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --motion-ease-swift: cubic-bezier(0.22, 1, 0.36, 1);
  --motion-scroll-progress: 0;
  --motion-mouse-x: 50%;
  --motion-mouse-y: 50%;
}

/* ----- Custom cursor ----- */
.mx-cursor {
  position: fixed;
  top: 0;
  left: 0;
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--red);
  pointer-events: none;
  z-index: 9999;
  transform: translate3d(-100px, -100px, 0);
  mix-blend-mode: difference;
  transition: width 0.3s var(--motion-ease-out), height 0.3s var(--motion-ease-out),
              background 0.3s var(--motion-ease-out), opacity 0.3s;
}
.mx-cursor.is-ring {
  width: 48px;
  height: 48px;
  background: transparent;
  border: 1.5px solid var(--cream);
  mix-blend-mode: difference;
}
.mx-cursor.is-ring--lg {
  width: 88px;
  height: 88px;
}
.mx-cursor.is-drag::before {
  content: "DRAG";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-sans);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.15em;
  color: var(--cream);
}
.mx-cursor.is-hidden {
  opacity: 0;
}
@media (hover: none) {
  .mx-cursor { display: none; }
}
body.mx-cursor-active,
body.mx-cursor-active * { cursor: none !important; }
body.mx-cursor-active a,
body.mx-cursor-active button,
body.mx-cursor-active input,
body.mx-cursor-active select,
body.mx-cursor-active textarea { cursor: none !important; }

/* ----- Magnetic buttons ----- */
.mx-magnetic {
  display: inline-block;
  will-change: transform;
  transition: transform 0.6s var(--motion-ease-out);
}
.mx-magnetic > * {
  display: inline-block;
  will-change: transform;
  transition: transform 0.4s var(--motion-ease-out);
}

/* ----- Tilt cards ----- */
.mx-tilt {
  transform-style: preserve-3d;
  transform: perspective(900px);
  transition: transform 0.4s var(--motion-ease-out);
  will-change: transform;
}
.mx-tilt-inner {
  transform: translateZ(30px);
  transition: transform 0.4s var(--motion-ease-out);
}
.mx-tilt-shine {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(
    400px circle at var(--motion-mouse-x) var(--motion-mouse-y),
    rgba(255, 255, 255, 0.12),
    transparent 40%
  );
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s var(--motion-ease-out);
  z-index: 1;
}
.mx-tilt:hover .mx-tilt-shine { opacity: 1; }

/* ----- Text reveal — mask up ----- */
.mx-reveal-lines {
  display: block;
  overflow: hidden;
}
.mx-reveal-lines > .mx-line {
  display: block;
  transform: translateY(110%);
  transition: transform 0.9s var(--motion-ease-out);
  transition-delay: calc(var(--mx-line-i, 0) * 0.08s);
}
.mx-reveal-lines.is-in > .mx-line {
  transform: translateY(0);
}

.mx-reveal-chars {
  display: inline-block;
}
.mx-reveal-chars > .mx-char {
  display: inline-block;
  transform: translateY(0.6em);
  opacity: 0;
  transition: transform 0.7s var(--motion-ease-out), opacity 0.5s ease-out;
  transition-delay: calc(var(--mx-char-i, 0) * 0.02s);
}
.mx-reveal-chars.is-in > .mx-char {
  transform: translateY(0);
  opacity: 1;
}

/* ----- Fade/slide reveal variants ----- */
.mx-fade,
.mx-slide-up,
.mx-slide-left,
.mx-slide-right,
.mx-scale-in {
  opacity: 0;
  transition: opacity 0.9s var(--motion-ease-out), transform 0.9s var(--motion-ease-out);
  transition-delay: var(--mx-delay, 0s);
  will-change: opacity, transform;
}
.mx-slide-up { transform: translateY(40px); }
.mx-slide-left { transform: translateX(-40px); }
.mx-slide-right { transform: translateX(40px); }
.mx-scale-in { transform: scale(0.94); }
.mx-in {
  opacity: 1 !important;
  transform: translate(0, 0) scale(1) !important;
}

/* ----- Stagger containers ----- */
.mx-stagger > * { --mx-delay: 0s; }
.mx-stagger > *:nth-child(1) { --mx-delay: 0.05s; }
.mx-stagger > *:nth-child(2) { --mx-delay: 0.12s; }
.mx-stagger > *:nth-child(3) { --mx-delay: 0.19s; }
.mx-stagger > *:nth-child(4) { --mx-delay: 0.26s; }
.mx-stagger > *:nth-child(5) { --mx-delay: 0.33s; }
.mx-stagger > *:nth-child(6) { --mx-delay: 0.40s; }
.mx-stagger > *:nth-child(7) { --mx-delay: 0.47s; }
.mx-stagger > *:nth-child(8) { --mx-delay: 0.54s; }

/* ----- Noise / grain overlay ----- */
.mx-grain {
  position: fixed;
  inset: -50%;
  width: 200%;
  height: 200%;
  z-index: 9998;
  pointer-events: none;
  mix-blend-mode: overlay;
  opacity: 0.08;
  background-image: url("data:image/svg+xml;utf8,<svg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/></filter><rect width='200' height='200' filter='url(%23n)' opacity='0.9'/></svg>");
  animation: mx-grain-move 0.7s steps(6) infinite;
}
@keyframes mx-grain-move {
  0%, 100% { transform: translate(0, 0); }
  10% { transform: translate(-5%, -10%); }
  20% { transform: translate(-15%, 5%); }
  30% { transform: translate(7%, -25%); }
  40% { transform: translate(-5%, 25%); }
  50% { transform: translate(-15%, 10%); }
  60% { transform: translate(15%, 0%); }
  70% { transform: translate(0%, 15%); }
  80% { transform: translate(3%, 35%); }
  90% { transform: translate(-10%, 10%); }
}

/* ----- Gradient mesh background ----- */
.mx-mesh {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}
.mx-mesh::before,
.mx-mesh::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.55;
  will-change: transform;
  animation: mx-mesh-drift 18s ease-in-out infinite;
}
.mx-mesh::before {
  top: -20%;
  left: -10%;
  width: 60%;
  aspect-ratio: 1;
  background: radial-gradient(circle, rgba(238, 42, 36, 0.55), transparent 70%);
}
.mx-mesh::after {
  bottom: -20%;
  right: -10%;
  width: 55%;
  aspect-ratio: 1;
  background: radial-gradient(circle, rgba(238, 42, 36, 0.25), rgba(10,10,10,0) 70%);
  animation-delay: -9s;
}
@keyframes mx-mesh-drift {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(8%, -6%) scale(1.08); }
  66% { transform: translate(-6%, 6%) scale(0.94); }
}

/* ----- Scroll progress bar ----- */
.mx-scrollbar {
  position: fixed;
  top: 0;
  left: 0;
  height: 2px;
  width: 100%;
  transform-origin: left;
  transform: scaleX(var(--motion-scroll-progress, 0));
  background: linear-gradient(90deg, var(--red), var(--cream));
  z-index: 60;
  pointer-events: none;
  will-change: transform;
}

/* ----- Selection & scrollbar browser ----- */
::selection {
  background: var(--red);
  color: var(--cream);
}
html {
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  transition: background 0.2s;
}
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.4); }

/* ----- Focus states (a11y) ----- */
:focus-visible {
  outline: 2px solid var(--red);
  outline-offset: 4px;
  border-radius: 4px;
}
button:focus:not(:focus-visible),
a:focus:not(:focus-visible),
input:focus:not(:focus-visible),
select:focus:not(:focus-visible),
textarea:focus:not(:focus-visible) {
  outline: none;
}

/* ----- Page transition overlay ----- */
.mx-page-fade {
  position: fixed;
  inset: 0;
  background: var(--ink);
  z-index: 10000;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.4s var(--motion-ease-out);
}
.mx-page-fade.is-leaving {
  opacity: 1;
  pointer-events: auto;
}

/* ----- Pulsing dot (used on scroll indicator, CTAs) ----- */
.mx-pulse::after {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: inherit;
  border: 1.5px solid currentColor;
  opacity: 0;
  animation: mx-pulse-ring 2.2s var(--motion-ease-out) infinite;
}
@keyframes mx-pulse-ring {
  0% { transform: scale(0.9); opacity: 0.8; }
  100% { transform: scale(1.4); opacity: 0; }
}

/* ----- Hover underline for nav/footer links ----- */
.mx-link {
  position: relative;
  display: inline-block;
}
.mx-link::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -3px;
  width: 100%;
  height: 1.5px;
  background: currentColor;
  transform: scaleX(0);
  transform-origin: right;
  transition: transform 0.55s var(--motion-ease-out);
}
.mx-link:hover::after {
  transform: scaleX(1);
  transform-origin: left;
}

/* ----- Marquee section hover ----- */
.clients__marquee { transition: filter 0.3s var(--motion-ease-out); }
.clients__item { transition: transform 0.35s var(--motion-ease-out), filter 0.35s var(--motion-ease-out); }
.clients__item:hover { transform: translateY(-4px); filter: grayscale(0); }
.clients__marquee:has(.clients__item:hover) .clients__item:not(:hover) { filter: grayscale(1) opacity(0.4); }

/* ----- Location cards enhancement ----- */
.loc { transition: transform 0.5s var(--motion-ease-out), box-shadow 0.5s var(--motion-ease-out); }
.loc:hover { transform: translateY(-6px); }
.loc__cta svg { transition: transform 0.35s var(--motion-ease-out); }
.loc__cta:hover svg { transform: translateX(6px); }

/* ----- Stats animation boost ----- */
.stat__n {
  font-variant-numeric: tabular-nums;
  transition: transform 0.35s var(--motion-ease-out), color 0.35s var(--motion-ease-out);
}
.stat:hover .stat__n {
  transform: translateY(-4px);
  color: var(--red);
}

/* ----- Lab card tilt prep ----- */
.lab__card {
  transform-style: preserve-3d;
  transition: transform 0.5s var(--motion-ease-out);
}
.lab__thumb {
  transition: transform 0.5s var(--motion-ease-out), box-shadow 0.5s var(--motion-ease-out);
}
.lab__card:hover .lab__thumb {
  transform: scale(1.035);
  box-shadow: 0 24px 60px rgba(238, 42, 36, 0.25);
}

/* ----- Form field focus glow ----- */
.field input:focus,
.field select:focus,
.field textarea:focus,
.hero__form-input:focus {
  box-shadow: 0 0 0 3px rgba(238, 42, 36, 0.18);
  transition: box-shadow 0.25s var(--motion-ease-out), border-color 0.25s;
}

/* ----- Submit button shine sweep ----- */
.pro-contact__submit,
.hero__form-submit,
.hero__cta-btn,
.hero__store-cta {
  position: relative;
  overflow: hidden;
  isolation: isolate;
}
.pro-contact__submit::before,
.hero__form-submit::before,
.hero__cta-btn::before,
.hero__store-cta::before {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.35), transparent);
  transition: left 0.7s var(--motion-ease-out);
  z-index: 1;
}
.pro-contact__submit:hover::before,
.hero__form-submit:hover::before,
.hero__cta-btn:hover::before,
.hero__store-cta:hover::before {
  left: 100%;
}
.pro-contact__submit > *,
.hero__form-submit > *,
.hero__cta-btn > *,
.hero__store-cta > * { position: relative; z-index: 2; }

/* ----- Footer link polish ----- */
.footer__col a {
  display: inline-block;
  transition: transform 0.35s var(--motion-ease-out), color 0.25s;
}
.footer__col a:hover {
  transform: translateX(4px);
  color: var(--cream);
}
.footer__social {
  transition: transform 0.4s var(--motion-ease-spring), color 0.25s;
}
.footer__social:hover { transform: translateY(-3px) scale(1.1); color: var(--red); }

/* ----- Section scroll fade-in helper ----- */
.section.mx-fade-section > * {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 1s var(--motion-ease-out), transform 1s var(--motion-ease-out);
}
.section.mx-fade-section.mx-in > * { opacity: 1; transform: translateY(0); }

/* ----- Respect user motion preferences ----- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .mx-grain,
  .mx-mesh::before,
  .mx-mesh::after { animation: none !important; }
  .mx-cursor { display: none; }
  body.mx-cursor-active,
  body.mx-cursor-active * { cursor: auto !important; }
  .mx-reveal-lines > .mx-line,
  .mx-reveal-chars > .mx-char,
  .mx-fade, .mx-slide-up, .mx-slide-left, .mx-slide-right, .mx-scale-in {
    transform: none !important;
    opacity: 1 !important;
  }
}

/* ----- Smooth scroll activation (Lenis) ----- */
html.lenis, html.lenis body { height: auto; }
.lenis.lenis-smooth { scroll-behavior: auto !important; }
.lenis.lenis-smooth [data-lenis-prevent] { overscroll-behavior: contain; }
.lenis.lenis-stopped { overflow: hidden; }
