/* Mirrors src/components/button.rs with the tokens from Theme::dark() in src/theme.rs.
   Pages load the Inter font themselves. */

:root {
  --font-family: "Inter", sans-serif;
  --background: #18171d;

  --focus-ring: #4493f8;
  --focus-ring-width: 2px;

  --button-primary-bg: #e5e5e5;
  --button-primary-hover: #fafafa;
  --button-primary-active: #c9c9cc;
  --button-primary-text: #28272d;

  --button-secondary-bg: #3a393f;
  --button-secondary-hover: #56555b;
  --button-secondary-active: #28272c;
  --button-secondary-text: #e8e8ea;

  --button-padding-x: 15px;
  --button-padding-y: 4px;
  /* Taller padding used by full-width buttons. */
  --button-full-width-padding-y: 5px;
  --button-radius: 7px;
  --button-text-size: 14px;
  --button-line-height: 17px;
  --button-font-weight: 400;
  /* Hover fade durations. */
  --button-hover-in: 0.1s;
  --button-hover-out: 0.15s;
}

body {
  margin: 0;
  background: var(--background);
}

.button {
  --bg: var(--button-primary-bg);
  --hover: var(--button-primary-hover);
  --active: var(--button-primary-active);
  --text: var(--button-primary-text);

  display: inline-block;
  box-sizing: border-box;
  margin: 0;
  padding: var(--button-padding-y) var(--button-padding-x);
  border: 1px solid var(--bg);
  border-radius: var(--button-radius);
  background: var(--bg);
  color: var(--text);
  text-decoration: none;
  font-family: var(--font-family);
  font-size: var(--button-text-size);
  line-height: var(--button-line-height);
  font-weight: var(--button-font-weight);
  cursor: pointer;
  outline: none;
  /* Fade out on leaving hover. Linear, like Fade in fade.rs. */
  transition:
    background-color var(--button-hover-out) linear,
    border-color var(--button-hover-out) linear;
}

.button--secondary {
  --bg: var(--button-secondary-bg);
  --hover: var(--button-secondary-hover);
  --active: var(--button-secondary-active);
  --text: var(--button-secondary-text);
}

/* Stretch to the parent's width with the label centered, e.g. a form's submit button. */
.button--full-width {
  display: flex;
  justify-content: center;
  width: 100%;
  padding-top: var(--button-full-width-padding-y);
  padding-bottom: var(--button-full-width-padding-y);
}

.button:hover {
  background: var(--hover);
  border-color: var(--hover);
  transition-duration: var(--button-hover-in);
}

/* Pressed stays instant so clicks feel immediate. */
.button:active {
  background: var(--active);
  border-color: var(--active);
  transition: none;
}

/* Focus ring only shows for keyboard navigation, not after mouse clicks. */
.button:focus-visible {
  box-shadow: 0 0 0 var(--focus-ring-width) var(--focus-ring);
}
