/*
 * Button component styles.
 *
 * The .btn class is a self-contained, reusable button skin. It works on both
 * <a>, <button>, and Rails-generated <form> wrappers (button_to). All variants
 * inherit shape, size and transitions from the base; only colors differ.
 *
 * Optimised for a light admin surface (white background, dark text).
 */
@layer components {
  .btn {
    align-items: center;
    background: transparent;
    border: 1px solid currentcolor;
    border-radius: var(--radius-sm);
    color: var(--color-dark-gray);
    cursor: pointer;
    display: inline-flex;
    font: inherit;
    font-size: var(--text-sm);
    font-weight: 500;
    gap: var(--space-2xs);
    justify-content: center;
    line-height: 1;
    padding: var(--space-2xs) var(--space-sm);
    text-decoration: none;
    transition:
      background-color 0.15s var(--ease-out),
      color 0.15s var(--ease-out),
      border-color 0.15s var(--ease-out);
    white-space: nowrap;
  }

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

  /* Rails' button_to wraps the button in a form. Strip its layout so a
     button_to lays out identically to a link_to inside .btn-group. */
  form.button_to {
    display: inline;
    margin: 0;
  }

  /* Variants ------------------------------------------------------------ */

  .btn--primary {
    background: #242424;
    border-color: #242424;
    color: var(--color-yellow);
  }

  .btn--primary:hover {
    background: #000;
    border-color: #000;
  }

  .btn--secondary {
    background: transparent;
    border-color: #ccc;
    color: var(--color-dark-gray);
  }

  .btn--secondary:hover {
    background: #f0f0f0;
    border-color: #808080;
  }

  .btn--danger {
    background: transparent;
    border-color: var(--color-error);
    color: var(--color-error);
  }

  .btn--danger:hover {
    background: var(--color-error);
    color: var(--color-white);
  }

  .btn--ghost {
    background: transparent;
    border-color: transparent;
    color: var(--color-text-secondary);
  }

  .btn--ghost:hover {
    color: var(--color-text);
    background: #f0f0f0;
  }

  /* Size modifier ------------------------------------------------------- */

  .btn--small {
    font-size: var(--text-xs);
    padding: var(--space-3xs) var(--space-xs);
  }

  /* Button group: row of related actions with consistent spacing -------- */

  .btn-group {
    display: inline-flex;
    flex-wrap: wrap;
    gap: var(--space-2xs);
    align-items: center;
  }
}
