/*
 * The single public button component. Every clickable control on the campaign page, the checkout and the
 * backer view is a `.crowtg-btn` plus modifiers — there is no per-surface button class. All three
 * interaction states come from the branding tokens, so an org that edits its accent/hover/press colours
 * restyles every button on every surface at once.
 *
 *   .crowtg-btn--primary   filled, the main action        .crowtg-btn--block   full width
 *   .crowtg-btn--ghost     outlined, the companion action .crowtg-btn--small   compact
 *   .crowtg-btn--quiet     text only, back / inline links .crowtg-btn--icon    square, icon only
 *
 * Every selector is prefixed with `:root` on purpose. A block theme's theme.json emits
 * `:root :where(button, input[type="submit"], …)` for element styles — specificity (0,1,0), the same as
 * a bare `.crowtg-btn--ghost`, so whichever stylesheet loads last wins. That made a <button> render with
 * the theme's fill while the identical <a> next to it rendered as ours. The prefix lifts the whole
 * component above element styling without resorting to !important, and keeps our own cascade intact.
 */
:root .crowtg-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  box-sizing: border-box;
  /* Themes and page builders like to give bare <button>s a margin, which knocks them out of line with
     the <a>s beside them. Surface stylesheets load after this one, so their margins still apply. */
  margin: 0;
  padding: 0.8rem 1.25rem;
  appearance: none;
  border: 1px solid transparent;
  border-radius: 10px;
  background: none;
  font: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition:
    background-color 0.15s ease,
    border-color 0.15s ease,
    color 0.15s ease,
    box-shadow 0.15s ease,
    transform 0.06s ease;
}

/* `display` above would otherwise beat the browser's `[hidden] { display: none }`. */
:root .crowtg-btn[hidden] {
  display: none;
}

:root .crowtg-btn:focus-visible {
  outline: 2px solid var(--crowtg-accent);
  outline-offset: 2px;
}

:root .crowtg-btn:disabled,
:root .crowtg-btn[aria-disabled='true'] {
  opacity: 0.55;
  cursor: not-allowed;
}

:root .crowtg-btn--primary {
  background: var(--crowtg-accent);
  color: var(--crowtg-accent-contrast);
}
:root .crowtg-btn--primary:not(:disabled):hover {
  background: var(--crowtg-accent-hover);
  color: var(--crowtg-accent-hover-contrast);
  box-shadow: 0 6px 16px rgb(0 0 0 / 0.22);
}
:root .crowtg-btn--primary:not(:disabled):active {
  background: var(--crowtg-accent-press);
  color: var(--crowtg-accent-press-contrast);
  transform: translateY(1px);
  box-shadow: 0 2px 6px rgb(0 0 0 / 0.2);
}

:root .crowtg-btn--ghost {
  border-color: var(--crowtg-border);
  color: var(--crowtg-accent);
}
:root .crowtg-btn--ghost:not(:disabled):hover {
  border-color: var(--crowtg-accent-hover);
  background: color-mix(in srgb, var(--crowtg-accent-hover) 10%, transparent);
  color: var(--crowtg-ink);
}
:root .crowtg-btn--ghost:not(:disabled):active {
  border-color: var(--crowtg-accent-press);
  background: color-mix(in srgb, var(--crowtg-accent-press) 18%, transparent);
  color: var(--crowtg-ink);
  transform: translateY(1px);
}

:root .crowtg-btn--quiet {
  padding: 0.35rem 0.6rem;
  color: var(--crowtg-muted);
}
:root .crowtg-btn--quiet:not(:disabled):hover {
  background: color-mix(in srgb, var(--crowtg-accent-hover) 10%, transparent);
  color: var(--crowtg-ink);
}
:root .crowtg-btn--quiet:not(:disabled):active {
  background: color-mix(in srgb, var(--crowtg-accent-press) 18%, transparent);
  color: var(--crowtg-ink);
  transform: translateY(1px);
}

:root .crowtg-btn--block {
  display: flex;
  width: 100%;
}

:root .crowtg-btn--small {
  padding: 0.55rem 1rem;
  font-size: 0.875rem;
}

:root .crowtg-btn--icon {
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 999px;
}
:root .crowtg-btn--icon svg {
  width: 17px;
  height: 17px;
  fill: currentColor;
}

@media (prefers-reduced-motion: reduce) {
  :root .crowtg-btn {
    transition: none;
  }
  :root .crowtg-btn:not(:disabled):active {
    transform: none;
  }
}
