/*
 * Coupon code copy button (#1052, from the approved Mockup R2).
 * The icon-only button sits right after a coupon code inside a Shop Feed benefit line.
 * Two overlapping squares = copy; it turns into a check mark for 2 seconds after copying.
 * The code and its button never break across lines (the group is nowrap).
 */

.coupon-code-group {
  white-space: nowrap;
}

/* A code longer than the line may break inside itself (up to 40 characters are accepted). */
.coupon-code {
  white-space: normal;
  overflow-wrap: anywhere;
}

.coupon-code-copy {
  display: none; /* Shown by coupon-code-copy.js once copying is possible (no dead button without JS). */
  align-items: center;
  justify-content: center;
  inline-size: max(1.75em, 24px);
  block-size: max(1.75em, 24px);
  margin: -0.4em 0 -0.4em 0.1em;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--color-accent-strong, #0a6a99);
  font: inherit;
  line-height: 1;
  vertical-align: middle;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.wsg-coupon-copy-ready .coupon-code-copy {
  display: inline-flex;
}

.coupon-code-copy svg {
  inline-size: 1.05em;
  block-size: 1.05em;
  flex: none;
}

.coupon-code-copy .coupon-code-copy__done {
  display: none;
}

.coupon-code-copy[data-state="copied"] .coupon-code-copy__idle {
  display: none;
}

.coupon-code-copy[data-state="copied"] .coupon-code-copy__done {
  display: block;
}

.coupon-code-copy:hover {
  background: var(--color-accent-a10, #20a2dc1a);
}

/* After copying: a white check on the deep blue, so it is not read as the benefit's own check mark. */
.coupon-code-copy[data-state="copied"],
.coupon-code-copy[data-state="copied"]:hover {
  background: var(--color-accent-strong, #0a6a99);
  color: #fff;
}

.coupon-code-copy:focus-visible {
  outline: 2px solid var(--color-accent-strong, #0a6a99);
  outline-offset: 1px;
}

/* Touch screens: a larger target (at least 28px). */
@media (pointer: coarse) {
  .coupon-code-copy {
    inline-size: max(2em, 28px);
    block-size: max(2em, 28px);
    margin-block: -0.55em;
  }
}

/* BFCM LP card (#936): the benefit line is red; the button uses the LP's ink. */
[data-campaign-root][data-variant="bfcm"] .coupon-code-copy {
  color: var(--ink, #0d0d0e);
}

[data-campaign-root][data-variant="bfcm"] .coupon-code-copy:hover {
  background: rgba(13, 13, 14, 0.08);
}

[data-campaign-root][data-variant="bfcm"] .coupon-code-copy[data-state="copied"] {
  background: var(--ink, #0d0d0e);
  color: #fff;
}

[data-campaign-root][data-variant="bfcm"] .coupon-code-copy:focus-visible {
  outline-color: var(--ink, #0d0d0e);
}

/*
 * "Code copied" bubble (R2, YU 2026-11-21 12:11): one element at the end of the page, placed
 * above the clicked button for 2 seconds (below it when there is no room above). It sits outside
 * the cards so the collapsed caption cannot clip it. Screen readers get the same text from a
 * separate status element; the bubble itself is aria-hidden.
 */
.coupon-code-copied {
  position: absolute;
  z-index: 1000;
  top: 0;
  left: 0;
  padding: 5px 10px;
  border-radius: 6px;
  background: var(--color-text-heading, #192a3d);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.4;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transform: translateY(2px);
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.coupon-code-copied[hidden] {
  display: none;
}

.coupon-code-copied.is-visible {
  opacity: 1;
  transform: none;
}

.coupon-code-copied::after {
  position: absolute;
  top: 100%;
  left: var(--arrow-x, 50%);
  border: 5px solid transparent;
  border-top-color: var(--color-text-heading, #192a3d);
  content: '';
  transform: translateX(-50%);
}

.coupon-code-copied.is-below::after {
  top: auto;
  bottom: 100%;
  border-top-color: transparent;
  border-bottom-color: var(--color-text-heading, #192a3d);
}

@media (prefers-reduced-motion: reduce) {
  .coupon-code-copied {
    transition: none;
    transform: none;
  }
}
