@layer components {
  /* The main button: deep green with warm white text, the one thing to press on a screen.
   * Every other button is .btn--outline, which fills with charcoal under the mouse. */
  .btn {
    align-items: center;
    background: var(--btn-background, var(--color-main-action));
    border: var(--btn-border, 0);
    border-radius: var(--rounded-md);
    color: var(--btn-color, var(--color-on-main-action));
    cursor: pointer;
    display: inline-flex;
    font: var(--text-button);
    gap: 10px;
    justify-content: center;
    min-block-size: 50px;
    padding: 0 22px;
    position: relative;
    text-decoration: none;
    white-space: nowrap;

    /* On the narrowest phones a long label wraps instead of spilling out of its card. */
    @media (max-width: 360px) {
      text-align: center;
      white-space: normal;
    }

    &:hover {
      background: var(--btn-hover-background, var(--btn-background, var(--color-main-action)));
      color: var(--btn-hover-color, var(--btn-color, var(--color-on-main-action)));
      filter: var(--btn-hover-filter, brightness(0.92));
    }

    &:disabled {
      cursor: default;
      filter: none;
      opacity: 0.5;
    }

    /* A file input inside the button: the label opens the picker, the input takes the focus. */
    &:has(input:focus-visible) {
      outline: var(--focus-ring-size) solid var(--focus-ring-color);
      outline-offset: var(--focus-ring-offset);
    }

    input[type=file] {
      block-size: 1px;
      clip-path: inset(50%);
      inline-size: 1px;
      overflow: hidden;
      position: absolute;
      white-space: nowrap;
    }

    @media (prefers-reduced-motion: no-preference) {
      transition: background-color 150ms ease, color 150ms ease, filter 150ms ease;
    }
  }

  /* The nav's size: 37 px tall, 14 px. */
  .btn--small {
    font-size: 14px;
    min-block-size: 37px;
    padding: 0 15px;
  }

  .btn--outline {
    --btn-background: transparent;
    --btn-border: 1px solid var(--color-ink);
    --btn-color: var(--color-ink);
    --btn-hover-background: var(--color-ink);
    --btn-hover-color: var(--color-on-main-action);
    --btn-hover-filter: none;
  }
}
