/**
 * Voucher tickets: the claimable row on the product page, cart and checkout
 * (inc/vouchers.php). Tokens only.
 *
 * A ticket is two parts split by a perforation: what the voucher gives on the
 * left, the one thing to do with it on the right. The notches are cut with a
 * mask, so the ticket sits on any surface (page, cart, the checkout summary
 * panel) without needing to know its colour.
 *
 * Contrast, measured 16 November 2026:
 *   --ink on --surface-note               15.3:1, on --brand-tint-lilac 13.8:1
 *   --brand-support-hover on note          6.6:1, on lilac               6.0:1
 *   white on --brand-accent                4.9:1, on --brand-primary    16.8:1
 */

.gq-vouchers {
  --gq-stub: 5.75rem;
  --gq-notch: 0.4375rem;

  display: flex;
  flex-direction: column;
  gap: var(--space-2xs);
  width: 100%;
  min-width: 0;
  text-align: start;
}

.gq-vouchers :where(h2, h3, p, ul, form) {
  margin: 0;
}

.gq-vouchers__title {
  font-family: var(--font-body);
  font-size: var(--text-small);
  font-weight: var(--weight-strong);
  line-height: var(--text-line-height);
  letter-spacing: 0;
  color: var(--ink);
}

/* One row that scrolls sideways when the tickets do not fit. Snap is
   proximity, not mandatory, so a short drag is never fought. */
.gq-vouchers__list {
  display: flex;
  gap: var(--space-2xs);
  padding: 0;
  /* Room between the tickets and a desktop scrollbar (Seth, 16 Nov 2026). */
  padding-block-end: var(--space-3xs);
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x proximity;
  scrollbar-width: thin;
  scrollbar-color: var(--hairline-strong) transparent;
  list-style: none;
}

.gq-voucher {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--gq-stub);
  min-width: 16.5rem;
  border-radius: var(--radius-md);
  background: var(--surface-note);
  color: var(--ink);
  list-style: none;
  scroll-snap-align: start;
  -webkit-mask-image:
    radial-gradient(circle at calc(100% - var(--gq-stub)) 0, transparent var(--gq-notch), black calc(var(--gq-notch) + 0.03rem)),
    radial-gradient(circle at calc(100% - var(--gq-stub)) 100%, transparent var(--gq-notch), black calc(var(--gq-notch) + 0.03rem));
  -webkit-mask-composite: source-in;
  mask-image:
    radial-gradient(circle at calc(100% - var(--gq-stub)) 0, transparent var(--gq-notch), black calc(var(--gq-notch) + 0.03rem)),
    radial-gradient(circle at calc(100% - var(--gq-stub)) 100%, transparent var(--gq-notch), black calc(var(--gq-notch) + 0.03rem));
  mask-composite: intersect;
}

/* Delivery is a different kind of saving, so it is a different paper. */
.gq-voucher--delivery {
  background: var(--brand-tint-lilac);
}

.gq-voucher__info {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
  padding: var(--space-2xs) var(--space-xs);
}

.gq-voucher__offer {
  font-family: var(--font-heading);
  font-size: var(--text-h4);
  font-weight: var(--heading-weight);
  line-height: 1.25;
  color: var(--brand-primary);
}

.gq-voucher__terms,
.gq-voucher__ends {
  font-size: var(--text-xs);
  line-height: 1.45;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.gq-voucher__action {
  display: grid;
  align-items: center;
  padding: var(--space-2xs);
  border-inline-start: thin dashed color-mix(in srgb, var(--brand-primary) 32%, transparent);
}

.gq-voucher__form {
  display: grid;
}

.gq-voucher__btn {
  min-height: var(--btn-min-height-sm);
  padding: 0 var(--space-2xs);
  border-radius: var(--radius-pill);
  background: var(--brand-accent);
  color: var(--white);
  font-family: var(--font-heading);
  font-size: var(--text-small);
  font-weight: var(--weight-strong);
  transition: background var(--duration-fast);
}

.gq-voucher__btn:hover {
  background: var(--brand-accent-hover);
}

.gq-voucher__btn--apply {
  background: var(--brand-primary);
}

.gq-voucher__btn--apply:hover {
  background: var(--brand-primary-hover);
}

/* The ring sits just outside the button, inside the ticket, so neither the
   ticket's mask nor the row's scroll clipping can cut it. */
.gq-voucher__btn:focus-visible {
  outline-offset: 0.125rem;
}

.gq-voucher__btn[aria-busy="true"] {
  opacity: 0.6;
  cursor: progress;
}

.gq-voucher__status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-3xs);
  font-size: var(--text-small);
  font-weight: var(--weight-strong);
  color: var(--brand-support-hover);
}

.gq-voucher__status:focus {
  outline: none;
}

.gq-voucher__status .icon {
  flex: none;
  width: 1.1em;
  height: 1.1em;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* The polite announcement for screen readers; nothing to see. */
.gq-vouchers__live {
  position: absolute;
  width: 0.0625rem;
  height: 0.0625rem;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* --- Where the row sits ---------------------------------------------------- */

/* Checkout: the row and the discount field are one group under the totals.
   The group's padding separates it from the Total; its gap separates the two. */
.gq-checkout-offers {
  display: flex;
  flex-direction: column;
  gap: var(--space-s);
  padding-top: var(--space-s);
}

.gq-checkout-offers form.checkout_coupon {
  margin-top: 0;
}

/* High-contrast modes drop backgrounds, and a mask would then cut holes in
   nothing: give the ticket an outline to be seen by instead. */
@media (forced-colors: active) {
  .gq-voucher {
    border: thin solid CanvasText;
    -webkit-mask-image: none;
    mask-image: none;
  }

  .gq-voucher__btn {
    border: thin solid ButtonText;
  }
}
