/* Shared button components (REQ-129, contract: specs/coordination/design-system.md section 5).
   Tokens only: every colour, radius and duration comes from design-system.css. The configurator carries a
   byte-identical copy of this file (WEB-BUILD-012); edit styles/components.css and copy it
   (scripts/check-design-tokens.mjs fails when the copies differ).

   Classes: .bc-btn (+ --primary, --secondary, --tool, --compact, --large), .bc-link, .bc-toggle, .bc-chip, .bc-tab. */

.bc-icon { flex: none; display: block; }

.bc-btn,
.bc-toggle,
.bc-chip,
.bc-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-sizing: border-box;
  margin: 0;
  border: 1px solid var(--bc-line);
  background: var(--bc-surface);
  color: var(--bc-ink);
  font: 600 13px/1.2 var(--bc-font);
  text-decoration: none;
  cursor: pointer;
  transition:
    background-color var(--bc-motion-fast) var(--bc-ease-out),
    border-color var(--bc-motion-fast) var(--bc-ease-out),
    color var(--bc-motion-fast) var(--bc-ease-out);
}

/* Sizes: default 36 px, compact 28 px (32 px on touch), large 48 px. */
.bc-btn { min-height: 36px; padding: 0 var(--bc-space-2); border-radius: var(--bc-radius); }
.bc-btn--compact { min-height: 28px; padding: 0 12px; font-weight: 500; font-size: 12px; }
.bc-btn--large { min-height: 48px; padding: 0 20px; font-size: 15px; }

.bc-btn--primary { border-color: var(--bc-blue); background: var(--bc-blue); color: var(--bc-on-accent); }
.bc-btn--secondary { background: transparent; }

/* Tool: 40 px round button holding one icon, named by aria-label (and a tooltip drawn by the host). */
.bc-btn--tool { width: 40px; min-height: 40px; padding: 0; border-radius: 50%; border-color: transparent; }

.bc-link {
  border: 0;
  padding: 0;
  background: none;
  color: var(--bc-blue);
  font: inherit;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

/* Toggle: one button of a group (role="group", aria-label) that carries aria-pressed. */
.bc-toggle { min-height: 32px; padding: 0 12px; font-weight: 500; font-size: 12px; border-radius: var(--bc-radius); }

/* Chip: a small selectable or removable value; the pill shape is allowed for chips only. */
.bc-chip { min-height: 28px; padding: 0 12px; border-radius: 999px; font-weight: 500; font-size: 12px; }

/* Tab: role="tab" with aria-selected. */
.bc-tab { min-height: 36px; padding: 0 var(--bc-space-2); border-radius: var(--bc-radius) var(--bc-radius) 0 0; }

/* States. Hover only on devices that hover. */
@media (hover: hover) {
  .bc-btn--primary:hover:not(:disabled, [aria-disabled='true']) {
    border-color: var(--bc-blue-dark);
    background: var(--bc-blue-dark);
  }
  .bc-btn--secondary:hover:not(:disabled, [aria-disabled='true']) {
    border-color: var(--bc-ink);
    background: var(--bc-surface);
  }
  .bc-btn--tool:hover:not(:disabled, [aria-disabled='true']),
  .bc-toggle:hover:not(:disabled, [aria-disabled='true']),
  .bc-chip:hover:not(:disabled, [aria-disabled='true']),
  .bc-tab:hover:not(:disabled, [aria-disabled='true']) {
    background: var(--bc-soft);
  }
  .bc-link:hover { color: var(--bc-blue-dark); }
}

/* Pressed and current: selected surface and dark action colour; the host adds text or an icon change too. */
.bc-btn[aria-pressed='true'],
.bc-toggle[aria-pressed='true'],
.bc-chip[aria-pressed='true'],
.bc-tab[aria-selected='true'],
.bc-btn[aria-current],
.bc-tab[aria-current] {
  border-color: var(--bc-blue-dark);
  background: var(--bc-selected);
  color: var(--bc-blue-dark);
}

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

/* Loading: the label changes to the action in progress; the button keeps its width. */
.bc-btn[aria-busy='true'] { cursor: progress; }

/* Touch targets: 44 px (WCAG 2.5.8 asks at least 24 px; the contract asks 44 px on touch). */
@media (pointer: coarse) {
  .bc-btn,
  .bc-toggle,
  .bc-tab { min-height: 44px; }
  .bc-btn--tool { width: 44px; min-height: 44px; }
  .bc-btn--compact,
  .bc-chip { min-height: 32px; }
}
