/*
 * .seq-copy — the single-click copy control attached to any identifier, checksum, path or
 * digest. Confirms with a brief change of ground and the word
 * "copied", never a toast. A Stimulus controller adds .is-copied on success and removes it
 * after --duration-slow; the background transitions over the same token, so the wash fades.
 *
 *   <button class="seq-copy" type="button" aria-label="Copy NA12878" data-copy="NA12878">
 *     <span class="seq-copy__icon" aria-hidden="true"></span>
 *     <span class="seq-copy__status" role="status"></span>
 *   </button>
 *
 * With a visible label:  <button class="seq-copy"><span class="seq-copy__icon"></span><span class="seq-copy__label">copy</span><span class="seq-copy__status" role="status"></span></button>
 *
 * Announcement. aria-label overrides the button's content, so the visible "copied" drawn by
 * ::after is never spoken; the controller writes "copied" into .seq-copy__status, a live
 * region that 09-utilities/_utilities.css keeps screen-reader-only, and clears it with the
 * class. CSS alone cannot announce anything.
 *
 * Refusal. A clipboard that is absent (insecure origin) or denied is .is-copy-failed and
 * "copy failed" in the same region, for --duration-slow, so a refused copy is never silent.
 *
 * Target size: the icon-only control is padded to at least 24 by 24 px (WCAG 2.5.8), and its
 * hit area is 44 by 44 on a coarse pointer (WCAG 2.5.5; § Touch below).
 */

.seq-copy {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-4);
  min-inline-size: 24px;                    /* WCAG 2.5.8 minimum target; once-used */
  min-block-size: 24px;
  padding: var(--spacing-2) var(--spacing-4);
  border: 0;
  border-radius: var(--corner-radius-xxs);
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font-family-mono);
  font-size: var(--font-size-12);
  font-weight: var(--font-weight-400);
  line-height: 1;
  cursor: pointer;
  vertical-align: middle;
  transition: background-color var(--duration-slow) var(--ease-standard), color var(--duration-fast) var(--ease-standard);
}
.seq-copy:hover {
  color: var(--text-primary);
  background: var(--background-hover);
}

/* Two overlapping sheets, drawn with borders. The px values are the icon's own geometry:
   a 12px box (the --text-fine em), a back sheet of 7 by 8 at the top left and a front sheet
   of 8 by 9 at the bottom right, so the two overlap by a stroke. */
.seq-copy__icon {
  position: relative;
  display: inline-block;
  width: 12px;
  height: 12px;
  flex: none;
}
.seq-copy__icon::before,
.seq-copy__icon::after {
  content: "";
  position: absolute;
  box-sizing: border-box;
  width: 8px;
  height: 9px;
  border: var(--stroke-weight-1) solid currentColor;
  border-radius: var(--stroke-weight-1);
}
.seq-copy__icon::before {
  top: 0;
  left: 0;
  border-inline-end: 0;
  border-block-end: 0;
  width: 7px;
  height: 8px;
}
.seq-copy__icon::after {
  right: 0;
  bottom: 0;
  background: var(--background-surface-1);
}


/* ---------- Confirmation: the hover ground plus the word (no gold: the production mark alone is gold) ---------- */
.seq-copy.is-copied {
  background: var(--background-hover);
  color: var(--text-primary);
}
.seq-copy.is-copied::after {
  content: "copied";
  font-family: var(--font-family-mono);
  font-size: var(--font-size-12);
  font-weight: var(--font-weight-400);
}
/* ---------- Refusal: the clipboard was unavailable or denied ---------- */
/* An insecure origin has no navigator.clipboard and a denied permission rejects; neither is
   a silent no-op. Same shape as the confirmation, in --invalid, with the word in
   .seq-copy__status for the live region. */
.seq-copy.is-copy-failed {
  color: var(--invalid);
}
.seq-copy.is-copy-failed::after {
  content: "copy failed";
  font-family: var(--font-family-mono);
  font-size: var(--font-size-12);
  font-weight: var(--font-weight-400);
}
/* ---------- Touch: a 44px hit area on a coarse pointer ----------
   24px meets WCAG 2.5.8 for a mouse; a finger needs 44 (WCAG 2.5.5). A transparent ::before,
   inset by half the shortfall, extends the hit area to 44 by 44 without moving or repainting
   the control, so the wash of .is-copied stays the 24px box. ::after is the "copied" word. */
@media (pointer: coarse) {
  .seq-copy {
    position: relative;
  }
  .seq-copy::before {
    content: "";
    position: absolute;
    inset: min(0px, calc((100% - 44px) / 2));
  }
}

/* Copy controls are meaningless on paper. */
@media print {
  .seq-copy {
    display: none;
  }
}
