/**
 * Buttons — sharp corners, gold primary, shine sweep + magnetic.
 *
 * IMPORTANT: every modifier sets `color` in its `:hover`/`:focus` state
 * so the global `a:hover { color: var(--bes-gold-600) }` rule in
 * typography.css can never paint the label invisible.
 */

/* =========================================================================
 * Base
 * ====================================================================== */

.bes-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 48px;
  padding: 14px 26px;
  font-family: var(--bes-font-body);
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-align: center;
  border: 2px solid transparent;
  border-radius: 0;
  cursor: pointer;
  overflow: hidden;
  isolation: isolate;
  transition:
    background var(--bes-dur-fast) var(--bes-ease),
    color var(--bes-dur-fast) var(--bes-ease),
    border-color var(--bes-dur-fast) var(--bes-ease),
    box-shadow var(--bes-dur) var(--bes-ease),
    transform var(--bes-dur) var(--bes-ease);
  text-decoration: none;
  line-height: 1;
}

/* Text node is what has to stay visible — keep it above the shine layer. */
.bes-btn,
.bes-btn:link,
.bes-btn:visited,
.bes-btn:focus,
.bes-btn:hover,
.bes-btn:active {
  text-decoration: none;
}

/* Shine sweep layer */
.bes-btn::before {
  content: "";
  position: absolute;
  top: 0;
  left: -120%;
  width: 60%;
  height: 100%;
  background: linear-gradient(
    100deg,
    transparent 0%,
    rgba(255, 255, 255, 0.3) 50%,
    transparent 100%
  );
  transform: skewX(-18deg);
  transition: left 700ms var(--bes-ease-out);
  pointer-events: none;
  z-index: 1;
}

.bes-btn:hover::before {
  left: 130%;
}

/* Move the *text content* above the shine layer. */
.bes-btn > *,
.bes-btn > svg {
  position: relative;
  z-index: 2;
}

.bes-btn svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  transition: transform var(--bes-dur) var(--bes-ease);
}

.bes-btn:hover svg {
  transform: translateX(4px);
}

/* =========================================================================
 * Primary — gold fill, black text
 * ====================================================================== */

.bes-btn--primary,
.bes-btn--primary:link,
.bes-btn--primary:visited {
  background: var(--bes-gold);
  color: var(--bes-black);
  border-color: var(--bes-gold);
}

/* Re-assert colour on hover/focus — this is the fix. */
a.bes-btn--primary:hover,
a.bes-btn--primary:focus,
button.bes-btn--primary:hover,
button.bes-btn--primary:focus,
.bes-btn--primary:hover,
.bes-btn--primary:focus {
  background: var(--bes-gold-600);
  border-color: var(--bes-gold-600);
  color: var(--bes-black); /* ← previously missing */
  box-shadow: var(--bes-glow-md);
  transform: translateY(-2px);
}

.bes-btn--primary:active {
  transform: translateY(0);
  color: var(--bes-black);
}

/* =========================================================================
 * Secondary — outline
 * ====================================================================== */

.bes-btn--secondary,
.bes-btn--secondary:link,
.bes-btn--secondary:visited {
  background: transparent;
  color: var(--bes-black);
  border-color: var(--bes-black);
}

.bes-btn--secondary:hover,
.bes-btn--secondary:focus {
  background: var(--bes-black);
  border-color: var(--bes-black);
  color: var(--bes-white); /* ← explicit */
  box-shadow: var(--bes-shadow-lg);
  transform: translateY(-2px);
}

.bes-btn--secondary:active {
  transform: translateY(0);
}

/* Secondary on dark surfaces */
.bes-on-dark .bes-btn--secondary,
.bes-btn--secondary.bes-btn--on-dark,
.bes-on-dark .bes-btn--secondary:link,
.bes-btn--secondary.bes-btn--on-dark:link,
.bes-on-dark .bes-btn--secondary:visited,
.bes-btn--secondary.bes-btn--on-dark:visited {
  color: var(--bes-white);
  border-color: var(--bes-white);
  background: transparent;
}

.bes-on-dark .bes-btn--secondary:hover,
.bes-btn--secondary.bes-btn--on-dark:hover,
.bes-on-dark .bes-btn--secondary:focus,
.bes-btn--secondary.bes-btn--on-dark:focus {
  background: var(--bes-white);
  border-color: var(--bes-white);
  color: var(--bes-black); /* ← explicit */
  box-shadow: var(--bes-glow-sm);
  transform: translateY(-2px);
}

/* =========================================================================
 * Ghost — text link with animated underline
 * ====================================================================== */

.bes-btn--ghost,
.bes-btn--ghost:link,
.bes-btn--ghost:visited {
  background: transparent;
  color: var(--bes-black);
  border-color: transparent;
  padding: 12px 0;
  overflow: visible;
  min-height: auto;
}

.bes-btn--ghost::before {
  display: none;
}

.bes-btn--ghost::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 6px;
  width: 0;
  height: 2px;
  background: var(--bes-gold);
  transition: width var(--bes-dur) var(--bes-ease);
}

.bes-btn--ghost:hover,
.bes-btn--ghost:focus {
  color: var(--bes-gold-600); /* ← explicit */
}

.bes-btn--ghost:hover::after,
.bes-btn--ghost:focus::after {
  width: calc(100% - 26px);
}

.bes-on-dark .bes-btn--ghost,
.bes-btn--ghost.bes-btn--on-dark,
.bes-on-dark .bes-btn--ghost:link,
.bes-btn--ghost.bes-btn--on-dark:link {
  color: var(--bes-white);
}

.bes-on-dark .bes-btn--ghost:hover,
.bes-btn--ghost.bes-btn--on-dark:hover,
.bes-on-dark .bes-btn--ghost:focus,
.bes-btn--ghost.bes-btn--on-dark:focus {
  color: var(--bes-gold);
}

/* =========================================================================
 * Sizes & helpers
 * ====================================================================== */

.bes-btn--small {
  min-height: 40px;
  padding: 10px 18px;
  font-size: 0.8125rem;
}
.bes-btn--large {
  min-height: 56px;
  padding: 18px 34px;
  font-size: 0.9375rem;
}
.bes-btn--block {
  width: 100%;
}

.bes-btn-group {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

/* Disabled */
.bes-btn[disabled],
.bes-btn.is-disabled {
  opacity: 0.55;
  cursor: not-allowed;
  pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
  .bes-btn {
    transition: none;
  }
  .bes-btn::before {
    display: none;
  }
}
