/* Button scale — the single source of truth.
 *
 * Loaded the same two ways as nav.css: @imported by src/index.css for the app,
 * linked by the static wiki pages. Every rule is scoped to .btn, so the sheet
 * is inert on anything that has not opted in.
 *
 * There are four sizes and nothing between them. Before adding a fifth, check
 * that an existing one will not do — the reason this file exists is that the
 * same secondary chip had drifted to 26px on Fiber, 28px on Calculator and
 * Lens (at two different font sizes) and 40px on the planner, each defined in
 * its own shell block.
 *
 *   .btn.btn--mini      20px   inline chips inside a table row
 *   .btn.btn--chip      28px   presets, secondary actions next to a control
 *   .btn.btn--control   32px   standalone secondary actions
 *   .btn.btn--primary   40px   toolbar actions and the main action of a view
 *
 * Modifiers, combinable with any size:
 *   .btn--icon      square, no text padding
 *   .btn--strong    heavier label, for the one primary action in a view
 *   .btn--quiet     no border until hovered
 *   .is-active      the selected member of a group (also matches
 *                   [aria-pressed="true"] so toggles need no extra class)
 */

.btn {
  --btn-rule: #cbd1d3;
  --btn-rule-strong: #20262a;
  --btn-fill: transparent;
  --btn-fill-active: #f1f2f0;
  --btn-ink: #58636a;
  --btn-ink-strong: #20262a;

  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  height: var(--btn-h);
  min-height: var(--btn-h);
  padding: 0 var(--btn-pad-x);
  border: 1px solid var(--btn-rule);
  border-radius: 2px;
  background: var(--btn-fill);
  color: var(--btn-ink);
  font-family: inherit;
  font-size: var(--btn-font);
  font-weight: 500;
  line-height: 1;
  letter-spacing: 0;
  text-align: center;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition:
    border-color 120ms ease,
    color 120ms ease,
    background-color 120ms ease;
}

/* ------------------------------------------------------------------ sizes */

.btn--mini {
  --btn-h: 1.25rem;
  --btn-pad-x: 0.3rem;
  --btn-font: 0.62rem;
}

.btn--chip {
  --btn-h: 1.75rem;
  --btn-pad-x: 0.5rem;
  --btn-font: 0.72rem;
}

.btn--control {
  --btn-h: 2rem;
  --btn-pad-x: 0.625rem;
  --btn-font: 0.75rem;
}

.btn--primary {
  --btn-h: 2.5rem;
  --btn-pad-x: 1rem;
  --btn-font: 0.75rem;
}

/* -------------------------------------------------------------- modifiers */

/* Square: the horizontal padding goes, and the width matches the height so a
   row of icon buttons lines up with the text buttons beside it. */
.btn--icon {
  --btn-pad-x: 0;
  width: var(--btn-h);
  min-width: var(--btn-h);
  gap: 0;
}

.btn--strong {
  color: var(--btn-ink-strong);
  font-weight: 600;
}

.btn--quiet {
  border-color: transparent;
}

.btn--block {
  width: 100%;
}

/* ------------------------------------------------------------------ state */

.btn:hover:not(:disabled) {
  border-color: color-mix(in srgb, var(--btn-rule-strong) 45%, var(--btn-rule));
  color: var(--btn-ink-strong);
}

.btn.is-active,
.btn[aria-pressed='true'] {
  border-color: var(--btn-rule-strong);
  background: var(--btn-fill-active);
  color: var(--btn-ink-strong);
}

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

.btn:focus-visible {
  outline: 1px solid rgba(31, 35, 40, 0.32);
  outline-offset: 2px;
}

/* A group of buttons that reads as one control: the members share edges and
   only the outer corners are rounded. */
.btn-group {
  display: inline-flex;
  align-items: center;
}

.btn-group > .btn {
  border-radius: 0;
}

.btn-group > .btn:not(:first-child) {
  margin-left: -1px;
}

.btn-group > .btn:first-child {
  border-start-start-radius: 2px;
  border-end-start-radius: 2px;
}

.btn-group > .btn:last-child {
  border-start-end-radius: 2px;
  border-end-end-radius: 2px;
}

/* The active member has the dark edge, so it has to sit above its neighbours
   or their lighter border paints over its own. */
.btn-group > .btn.is-active,
.btn-group > .btn[aria-pressed='true'] {
  position: relative;
  z-index: 1;
}
