/* Reuse: <a class="cn-beam-btn" href="/contact-us/">Get in Touch</a>
   Also works on <button>. Optional: --cn-beam-speed: 6s; --cn-beam-radius: 999px;
   --cn-beam-surface: #1e1e20; --cn-beam-hover-surface: #262629.
   CSS-only interpretation of the travelling glow at libraries.dev/beam.

   Performance: the beam is a conic gradient painted ONCE on ::before and spun with
   `transform`, so it animates on the compositor: no style recalc, no repaint and no
   blur per frame, however many buttons a page has. The button clips it to the pill
   (overflow: hidden). ::after is the button face; it covers everything except the
   edge, and its box-shadows fade into the edge to give the glow. ::after never
   changes (except on hover), so it is painted once too.

   The 1px border is drawn with an inset box-shadow (padding is 1px larger instead), so
   the beam can sit on the very edge. If you override padding, add 1px per side. */

.cn-beam-btn.cn-beam-btn {
  --cn-beam-face: var(--cn-beam-surface, #1e1e20);
  position: relative;
  isolation: isolate;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  box-sizing: border-box;
  min-height: 52px;
  padding: 17px 31px;
  border: 0;
  border-radius: var(--cn-beam-radius, 999px);
  background-color: var(--cn-beam-face);
  color: #f5f5f7;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.4;
  text-decoration: none;
  vertical-align: middle;
  cursor: pointer;
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.04);
  transition: background-color 200ms ease, transform 200ms ease;
}

/* The beam: a square big enough to cover the button at any angle, centred on it. */
.cn-beam-btn.cn-beam-btn::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: -2;
  width: calc(100% + 64px);
  aspect-ratio: 1;
  background: conic-gradient(
    transparent 0deg 225deg,
    var(--cn-pink, #58a4ff) 255deg 278deg,
    var(--cn-orange, #f29020) 300deg 322deg,
    transparent 350deg 360deg
  );
  opacity: 0.9;
  pointer-events: none;
  transform: translate(-50%, -50%) rotate(0deg);
  will-change: transform;
  animation: cn-beam-spin var(--cn-beam-speed, 6s) linear infinite;
}

/* The face: covers the beam everywhere except the outer 1px (the sharp line).
   Two shadows reach out to the edge: a hard-edged one that lets ~45% of the beam
   through just inside the line, and a soft one that fades that to nothing ~8px in.
   Together they read as the beam's glow, without any blur filter. */
.cn-beam-btn.cn-beam-btn::after {
  content: "";
  position: absolute;
  inset: 9px;
  z-index: -1;
  border-radius: max(0px, calc(var(--cn-beam-radius, 999px) - 9px));
  background-color: var(--cn-beam-face);
  box-shadow: 0 0 4px 4px var(--cn-beam-face); /* browsers without color-mix() */
  box-shadow:
    0 0 4px 4px var(--cn-beam-face),
    0 0 0 8px color-mix(in srgb, var(--cn-beam-face) 55%, transparent);
  pointer-events: none;
  transition: background-color 200ms ease, box-shadow 200ms ease;
}

.cn-beam-btn.cn-beam-btn:hover {
  --cn-beam-face: var(--cn-beam-hover-surface, #262629);
  color: #fff;
  transform: translateY(-2px);
  text-decoration: none;
}

.cn-beam-btn.cn-beam-btn:focus-visible {
  outline: 2px solid #a8d8ff;
  outline-offset: 5px;
}

.cn-beam-btn.cn-beam-btn:active {
  transform: translateY(0);
}

.cn-beam-btn .wwd-arrow {
  display: inline-block;
  transition: transform 200ms ease;
}

.cn-beam-btn:hover .wwd-arrow {
  transform: translateX(4px);
}

.cn-beam-btn.cn-beam-btn:disabled,
.cn-beam-btn.cn-beam-btn[aria-disabled="true"] {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

@keyframes cn-beam-spin {
  to { transform: translate(-50%, -50%) rotate(360deg); }
}

/* Nobody can see these: stop the animation (assets/js/core/beam-pause.js adds
   .cn-beam-paused to buttons that are off screen). */
.cn-beam-btn.cn-beam-btn:disabled::before,
.cn-beam-btn.cn-beam-btn[aria-disabled="true"]::before,
html:not(.cn-menu-open) .cn-menu .cn-beam-btn.cn-beam-btn::before,
.cn-beam-btn.cn-beam-btn.cn-beam-paused::before {
  animation-play-state: paused;
}

@media (prefers-reduced-motion: reduce) {
  .cn-beam-btn.cn-beam-btn,
  .cn-beam-btn.cn-beam-btn::after,
  .cn-beam-btn .wwd-arrow {
    transition: none;
  }
  .cn-beam-btn.cn-beam-btn::before {
    animation: none;
  }
  .cn-beam-btn.cn-beam-btn:hover,
  .cn-beam-btn:hover .wwd-arrow {
    transform: none;
  }
}

@media print {
  .cn-beam-btn.cn-beam-btn::before,
  .cn-beam-btn.cn-beam-btn::after { display: none; }
}
