/* Magnetic button.
   script.js only writes --mx / --my (the pull, in px). CSS decides how it moves:
   quick while following the pointer, a spring when it lets go. */

.magnetic {
  --mx: 0px;
  --my: 0px;
  position: relative;
  display: inline-grid;
  place-items: center;
  min-height: 64px;
  padding: 0 32px;
  border: 1px solid #463f37;
  border-radius: 999px;
  background: transparent;
  color: var(--text, #f0ebe2);
  font: 600 17px var(--font-ui, system-ui, sans-serif);
  text-decoration: none;
  cursor: pointer;
  isolation: isolate;
  overflow: hidden;
  transform: translate(var(--mx), var(--my));
  /* letting go: the bouncy spring from motion-tokens */
  transition: transform var(--spring-bouncy-duration) var(--spring-bouncy);
}

.magnetic--round {
  width: 96px;
  height: 96px;
  padding: 0;
}

/* the label travels a little further than the button: a hint of depth */
.magnetic__label {
  display: inline-flex;
  transform: translate(calc(var(--mx) * 0.4), calc(var(--my) * 0.4));
  transition: inherit;
}

/* following the pointer: short and smooth, so it never feels laggy */
.magnetic.is-pulled,
.magnetic.is-pulled .magnetic__label {
  transition: transform var(--duration-quick) var(--ease-standard);
}

/* hover fill, rising from the bottom (transform only) */
.magnetic::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  background: var(--accent, #ff6a3d);
  transform: translateY(101%);
  transition: transform var(--duration-slow) var(--ease-enter);
}
.magnetic:hover,
.magnetic:focus-visible { color: var(--accent-ink, #160d08); border-color: var(--accent, #ff6a3d); }
.magnetic:hover::before,
.magnetic:focus-visible::before { transform: translateY(0); }

/* Reduced motion: no pull and no rising fill; the fill simply fades in. */
@media (prefers-reduced-motion: reduce) {
  .magnetic { transform: none; }
  .magnetic__label { transform: none; }
  .magnetic::before {
    transform: none;
    opacity: 0;
    transition: opacity var(--duration-fast) var(--ease-standard);
  }
  .magnetic:hover::before,
  .magnetic:focus-visible::before { opacity: 1; }
}

/* demo layout */
.mg-stage {
  min-height: 100svh;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 48px;
  padding: 24px;
}
.mg-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 56px; }
