/* =========================================================================
   Component — buttons
   A button is a <button>; a link that looks like a button is an <a class="btn">.
   ========================================================================= */

/* **Paired with `[hidden]`, because the line below defeats it otherwise.**
   `[hidden] { display: none }` in `base.css` and `.btn` have the same
   specificity, and this sheet loads later — so a `<button class="btn" hidden>`
   stayed on screen and in the tab order. `base.css` names the rule and the
   classes it applies to; `U-796` is the first to hide a button this way and
   the second factor's reveal on the account page is the button. */
.btn[hidden] {
  display: none;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  /* The SIDES button (ADR-0167): 42px, 16px padding, 4px gap, a 1.6px frame
     every variant can colour, label 13/20 semibold. */
  gap: var(--space-xs);
  height: var(--control-h);
  padding: 0 var(--space-md);
  border: var(--border-w-strong) solid transparent;
  border-radius: var(--radius);
  /* A button without a variant is the administration's grey (U-1881, the
     owner's decision of 2026-11-06): a surface from the tokens, so a <button>
     and an <a class="btn"> look alike in both themes. Without it a <button>
     showed the browser's own face and a link showed none. Every variant below
     sets its own surface and ink. */
  background: var(--sd-surface-alt);
  color: var(--doc-ink);
  font: inherit;
  font-size: var(--text-body);
  font-weight: 600;
  line-height: var(--text-body-lh);
  letter-spacing: 0;
  /* A label longer than a 320px screen wraps rather than widening the page
     (guards-narrow-render, U-2265: a 16px-padded link button on blog-post ran
     11px past the edge when it could not wrap). */
  max-width: 100%;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s, border-color .15s, color .15s, transform .05s;
}

.btn:hover {
  background: var(--sd-surface-alt2);
  color: var(--doc-ink);
  text-decoration: none;
}

.btn:active {
  transform: translateY(1px);
}

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

.btn-primary {
  background: var(--sd-primary);
  color: var(--sd-on-primary);
}

.btn-primary:hover {
  background: var(--sd-primary-hover);
  color: var(--sd-on-primary);
}

/* SIDES outline: the surface, its frame and the text colour. */
.btn-outline {
  background: var(--doc-panel);
  color: var(--doc-ink);
  border-color: var(--sd-border);
}

.btn-outline:hover {
  background: var(--sd-surface-alt);
  color: var(--doc-ink);
}

/* SIDES secondary: the surface with the link colour as frame and label. */
.btn-secondary {
  background: var(--doc-panel);
  color: var(--sd-secondary);
  border-color: var(--sd-secondary);
}

.btn-secondary:hover {
  background: var(--sd-surface-alt);
  color: var(--sd-secondary);
}

/* SIDES ghost (link button): no surface until hovered. */
.btn-quiet {
  background: transparent;
  color: var(--sd-secondary);
  padding: 0 var(--space-sm);
}

.btn-quiet:hover {
  background: var(--sd-surface-alt);
  /* `.btn:hover` sets the plain ink; the quiet variant keeps its own. */
  color: var(--sd-secondary);
}

.btn-block {
  width: 100%;
}

/* --- On the theme-invariant brand surfaces (hero, footer, sidebar) ------- *
 * These are dark teal in BOTH themes, so the themed --sd-primary would turn
 * teal-on-teal in dark mode. Pin the mint.
 * ------------------------------------------------------------------------ */

.on-brand .btn-primary {
  background: var(--brand-mint);
  color: var(--brand-mint-ink);
}

.on-brand .btn-primary:hover {
  background: var(--brand-mint-hover);
  color: var(--brand-mint-ink);
}

/* The ghost on a dark band: white at 40 % for the edge, 8 % for the hover
   (DESIGN_TOKENS.md §8.2, U-2277). */
.on-brand .btn-ghost {
  background: transparent;
  color: var(--brand-on-dark);
  border-color: var(--on-dark-line);
}

.on-brand .btn-ghost:hover {
  background: var(--on-dark-hover);
  color: var(--brand-on-dark);
}

/* --- Icon button --------------------------------------------------------- */

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--doc-line);
  border-radius: var(--radius);
  background: var(--doc-panel);
  color: var(--doc-ink);
  cursor: pointer;
  transition: background .15s;
}

.icon-btn:hover {
  background: var(--sd-surface-alt);
}

.icon-btn svg {
  width: 20px;
  height: 20px;
}

.on-brand .icon-btn {
  background: color-mix(in srgb, var(--brand-on-dark) 8%, transparent);
  border-color: color-mix(in srgb, var(--brand-on-dark) 30%, transparent);
  color: var(--brand-on-dark);
}

.on-brand .icon-btn:hover {
  background: color-mix(in srgb, var(--brand-on-dark) 18%, transparent);
}

/* --- The retire control (U-907, U-1713) ------------------------------------ */
/* The padlock with its verb beside it, the size and outline of the edit link it
   stands next to in a row's actions. */

.retire-toggle svg {
  flex: none;
  width: 16px;
  height: 16px;
}

/* --- The copy control (U-859) ------------------------------------------- */
/* An icon button the height of .btn-small, so it sits in a table row and still
   clears the 24 px pointer target; its result wraps beside it, in the body
   font even inside a .table-mono cell. */

.icon-btn-small {
  width: 32px;
  height: 32px;
}

.icon-btn-small svg,
.copy-value .btn svg {
  width: 16px;
  height: 16px;
}

/* The first press of a delete as an icon (U-2199): the amber of .btn-caution. */
.icon-btn-caution {
  color: var(--sd-warning);
  border-color: var(--sd-warning);
}

/* A busy icon button looks it, as .btn[disabled] does (U-2199). */
.icon-btn[disabled] {
  cursor: not-allowed;
  opacity: .6;
}

.copy-value {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
  vertical-align: middle;
}

.copy-value-status {
  font-family: var(--font);
  font-size: 12.5px;
  color: var(--doc-ink-soft);
}

/* --- A button inside a table row ----------------------------------------- */
/* Shorter than --control-h, which is sized for a form. Still 32 px tall and
   with real padding, so it clears the 24 px minimum a pointer target needs and
   does not shrink the row's hit area to the glyph. */

.btn-small {
  height: 32px;
  min-width: 32px;
  padding: 0 12px;
  font-size: var(--text-caption);
  line-height: var(--text-caption-lh);
}

/* --- The destructive confirmation ----------------------------------------- */
/* Reached only as the SECOND press of a two-step control: the first press asks,
   this one acts. The colour is not the warning — the label is ("Confirm
   removal"), because colour never carries meaning alone (audit rule E-4).
   --sd-on-primary is the ink for a filled semantic surface; --sd-error is a
   background here rather than text, so the contrast pair to check is
   on-primary against error, not error against panel. */

.btn-danger {
  background: var(--sd-error);
  color: var(--sd-on-primary);
}

.btn-danger:hover {
  background: var(--sd-error);
  color: var(--sd-on-primary);
  filter: brightness(.92);
}

/* The FIRST press of that control, where it starts something that cannot be
   undone (U-1740): in the error colour, so it does not read as one more link,
   and outlined rather than filled, because this press only asks. The label
   still says what it does. The error colour is text here, as in a field's
   error message (`form.css`). */
.btn-danger-outline {
  background: transparent;
  color: var(--sd-error);
  border-color: var(--sd-error);
}

.btn-danger-outline:hover {
  background: var(--sd-surface-alt);
  color: var(--sd-error);
}

/* The FIRST press of decommissioning, revoking, deactivating or removing in the
   administration (U-1881): a restrained signal and not grey, the owner's words
   of 2026-11-04, in the warning colour from the tokens — the owner's choice of
   2026-11-06. Outlined, because this press only asks or only starts; where a
   second press confirms, that one stays `.btn-danger`. The label says what it
   does. */
.btn-caution {
  background: transparent;
  color: var(--sd-warning);
  border-color: var(--sd-warning);
}

.btn-caution:hover {
  background: var(--sd-surface-alt);
  color: var(--sd-warning);
}
