/* Magnetic Button — original. A primary CTA whose label and a soft accent halo
   are magnetically pulled toward the cursor inside a generous hit area, easing
   back on leave. Set in a considered editorial composition.
   Pure CSS + a little pointer JS. Every selector is scoped to
   .byq-gem--magnetic-button-01 so it never leaks into the host page. */

.byq-gem--magnetic-button-01 {
  font-family: var(--byq-font-sans);
  color: var(--byq-fg);
  display: grid;
  place-items: center;
  width: 100%;
  padding: 3rem 1.5rem;
  box-sizing: border-box;
}

.byq-gem--magnetic-button-01 *,
.byq-gem--magnetic-button-01 *::before,
.byq-gem--magnetic-button-01 *::after {
  box-sizing: border-box;
}

/* — Actions row — centres the magnetic button in the demo canvas — */
.byq-gem--magnetic-button-01__actions {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* — The magnetic button —
   The <a> is the enlarged hit area. JS writes --mx / --my (the pull offset in
   px) onto it; the halo and label translate by those amounts. When not being
   pulled, the transition springs everything home. */
.byq-gem--magnetic-button-01__magnet {
  --mx: 0px;
  --my: 0px;
  --pull-label: 0.35; /* label follows the cursor a touch less than the halo */
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 1.35rem 1.15rem; /* generous invisible hit padding */
  margin: -0.6rem; /* absorb padding so layout stays tight */
  border: 0;
  background: none;
  text-decoration: none;
  color: var(--byq-on-accent);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  outline: none;
}

/* Soft accent halo — the glow that gets pulled toward the cursor. */
.byq-gem--magnetic-button-01__halo {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 10.5rem;
  height: 4.6rem;
  border-radius: 999px;
  background: radial-gradient(
    60% 75% at 50% 50%,
    color-mix(in srgb, var(--byq-accent-lime) 85%, transparent),
    color-mix(in srgb, var(--byq-accent-lime) 0%, transparent) 72%
  );
  filter: blur(14px);
  opacity: 0;
  transform: translate(-50%, -50%)
    translate(calc(var(--mx) * 1.35), calc(var(--my) * 1.35));
  transition: transform 0.55s cubic-bezier(0.16, 1, 0.3, 1),
    opacity 0.45s ease;
  pointer-events: none;
  z-index: 0;
}

/* The visible pill — its inner label follows the cursor slightly. */
.byq-gem--magnetic-button-01__label {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.95rem 1.75rem;
  font-family: var(--byq-font-sans);
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--byq-fg);
  background: var(--byq-card);
  border: 1px solid var(--byq-depth);
  border-radius: 999px;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.08) inset,
    0 18px 36px -22px rgba(0, 0, 0, 0.8);
  transform: translate(
    calc(var(--mx) * var(--pull-label)),
    calc(var(--my) * var(--pull-label))
  );
  transition: transform 0.55s cubic-bezier(0.16, 1, 0.3, 1),
    background 0.4s ease, border-color 0.4s ease, box-shadow 0.4s ease,
    color 0.4s ease;
}

.byq-gem--magnetic-button-01__label-text {
  transform: translateZ(0);
}

.byq-gem--magnetic-button-01__arrow {
  width: 1.05rem;
  height: 1.05rem;
  flex: none;
  transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

/* While being pulled (JS adds .is-pulling), react instantly — no lag on the
   pointer, but keep the springy ease for the return. */
.byq-gem--magnetic-button-01__magnet.is-pulling .byq-gem--magnetic-button-01__halo,
.byq-gem--magnetic-button-01__magnet.is-pulling .byq-gem--magnetic-button-01__label {
  transition-duration: 0.12s;
}

/* Hover / focus: the pill fills with the lime accent and the halo glows. */
.byq-gem--magnetic-button-01__magnet:hover .byq-gem--magnetic-button-01__halo,
.byq-gem--magnetic-button-01__magnet:focus-visible .byq-gem--magnetic-button-01__halo {
  opacity: 1;
}
.byq-gem--magnetic-button-01__magnet:hover .byq-gem--magnetic-button-01__label,
.byq-gem--magnetic-button-01__magnet:focus-visible .byq-gem--magnetic-button-01__label {
  background: var(--byq-accent-lime);
  border-color: var(--byq-accent-lime);
  color: var(--byq-on-accent);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.35) inset,
    0 18px 38px -18px color-mix(in srgb, var(--byq-accent-lime) 70%, transparent);
}
.byq-gem--magnetic-button-01__magnet:hover .byq-gem--magnetic-button-01__arrow,
.byq-gem--magnetic-button-01__magnet:focus-visible .byq-gem--magnetic-button-01__arrow {
  transform: translateX(3px);
}

/* Clear focus ring for keyboard users. */
.byq-gem--magnetic-button-01__magnet:focus-visible .byq-gem--magnetic-button-01__label {
  outline: 2px solid var(--byq-fg);
  outline-offset: 3px;
}

.byq-gem--magnetic-button-01__magnet:active .byq-gem--magnetic-button-01__label {
  transform: translate(
      calc(var(--mx) * var(--pull-label)),
      calc(var(--my) * var(--pull-label))
    )
    scale(0.97);
}

/* — Reduced motion: no magnetic pull, instant states — */
@media (prefers-reduced-motion: reduce) {
  .byq-gem--magnetic-button-01__halo,
  .byq-gem--magnetic-button-01__label,
  .byq-gem--magnetic-button-01__arrow {
    transition-duration: 0.001ms;
    transform: translate(-50%, -50%);
  }
  .byq-gem--magnetic-button-01__label {
    transform: none;
  }
}
