/* Shared by the Astro, React and Vanilla Button variants. */

.exo-button {
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--exo-space-2, 6px);
  margin: 0;
  font-family: var(--exo-font-family-sans, system-ui, sans-serif);
  font-weight: var(--exo-font-weight-medium, 500);
  line-height: var(--exo-font-line-height-snug, 1.25);
  white-space: nowrap;
  text-decoration: none;
  color: var(--exo-color-text, #333333);
  background: transparent;
  border: var(--exo-border-width-1, 1px) solid transparent;
  border-radius: var(--exo-radius-3, 6px);
  /* Gradient fills run under the (transparent) border instead of tiling into it. */
  background-origin: border-box;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

/* Sizes */
.exo-button--md {
  padding: var(--exo-space-2, 6px) var(--exo-space-4, 12px);
  font-size: var(--exo-font-size-sm, 14px);
}

.exo-button--sm {
  padding: var(--exo-space-1, 4px) var(--exo-space-3, 8px);
  font-size: var(--exo-font-size-xs, 12px);
}

.exo-button--icon.exo-button--md {
  padding: var(--exo-space-2, 6px);
}

.exo-button--icon.exo-button--sm {
  padding: var(--exo-space-1, 4px);
}

/* Variants. Primary and secondary are vertical gradients with a hairline
   ring; hover changes their brightness. */
.exo-button--primary {
  color: var(--exo-button-primary-text, #ffffff);
  background-image: linear-gradient(
    to top,
    var(--exo-button-primary-bg-bottom, #000000) 0%,
    var(--exo-button-primary-bg-top, #2e2e2e) 50%
  );
  box-shadow: 0 0 1px 1px var(--exo-button-primary-ring, rgb(0 0 0 / 0.06));
}

.exo-button--secondary,
.exo-button--icon {
  color: var(--exo-button-secondary-text, #333333);
  background-image: linear-gradient(
    to bottom,
    var(--exo-button-secondary-bg-top, rgb(255 255 255 / 0.42)) 0%,
    var(--exo-button-secondary-bg-bottom, rgb(196 196 196 / 0.46)) 100%
  );
  /* Inset, so the ring sits where a border would and joined buttons share one line. */
  box-shadow: inset 0 0 0 var(--exo-border-width-1, 1px) var(--exo-button-secondary-ring, rgb(0 0 0 / 0.23));
}

.exo-button--primary,
.exo-button--secondary,
.exo-button--icon {
  transition: filter var(--exo-duration-hover, 150ms) ease;
}

/* States */
.exo-button--primary:hover:not(:disabled, [aria-disabled="true"]) {
  filter: brightness(var(--exo-button-primary-hover-brightness, 1.12));
}

.exo-button--secondary:hover:not(:disabled, [aria-disabled="true"]),
.exo-button--icon:hover:not(:disabled, [aria-disabled="true"]) {
  filter: brightness(var(--exo-button-secondary-hover-brightness, 0.97));
}

.exo-button--ghost:hover:not(:disabled, [aria-disabled="true"]) {
  background-color: var(--exo-color-bg-hover, rgb(0 0 0 / 0.1));
}

@media (prefers-reduced-motion: reduce) {
  .exo-button {
    transition: none;
  }
}

.exo-button:focus-visible {
  outline: var(--exo-border-width-2, 2px) solid var(--exo-color-accent, #2f5fdb);
  outline-offset: var(--exo-border-width-2, 2px);
}

.exo-button:disabled,
.exo-button[aria-disabled="true"] {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Buttons joined side by side, such as a split button: a main action and a
   Menu with more. Put them in an element with this class. Also joins a
   Button inside a wrapper, such as a Menu's trigger. */
.exo-button-group {
  display: inline-flex;
  vertical-align: middle;
}

.exo-button-group > .exo-button:not(:last-child),
.exo-button-group > :not(:last-child) > .exo-button {
  border-start-end-radius: 0;
  border-end-end-radius: 0;
}

.exo-button-group > .exo-button:not(:first-child),
.exo-button-group > :not(:first-child) > .exo-button {
  margin-inline-start: calc(-1 * var(--exo-border-width-1, 1px));
  border-start-start-radius: 0;
  border-end-start-radius: 0;
}

/* Filled buttons get a line in the page color between them. */
.exo-button-group > .exo-button--primary:not(:first-child),
.exo-button-group > :not(:first-child) > .exo-button--primary {
  border-inline-start-color: var(--exo-color-bg, #ffffff);
}

/* Keep the focus ring above the neighbouring button. */
.exo-button-group .exo-button:focus-visible {
  position: relative;
  z-index: 1;
}
