/*
 * The points card (includes/Engine/Storefront/templates/redeem-card.php). Hand-written and shipped as-is:
 * no build step, and nothing from the launcher's stylesheet or the Design tab, which styles the launcher only.
 *
 * - Every rule is nested under the root, so it is at least 0,2,0 and a theme's plain `button {}` or
 *   `input {}` rules cannot beat it. The resets below undo what themes commonly set on those elements.
 * - Sizes are px: rem follows the theme's html font-size (62.5% is common).
 * - The colours are storefront-tokens.css's, shared with the other cards, so a theme or custom CSS can re-point
 *   them in one place.
 */
@import url("storefront-tokens.css");

.yayloyalty-redeem {
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--yayloyalty-redeem-border);
  border-radius: calc(var(--yayloyalty-redeem-radius) + 2px);
  background: var(--yayloyalty-redeem-field);
  font-size: 13px;
  font-weight: 400;
  line-height: 1.45;
  text-align: left;
  color: var(--yayloyalty-redeem-text);
}

.yayloyalty-redeem *,
.yayloyalty-redeem *::before,
.yayloyalty-redeem *::after {
  box-sizing: border-box;
}

.yayloyalty-redeem :is(h3, p, span, a, button, input, label) {
  margin: 0;
  font-family: inherit;
  letter-spacing: normal;
  text-transform: none;
  text-shadow: none;
}

.yayloyalty-redeem[data-busy] {
  opacity: 0.6;
}

/* Header: icon, title, then the balance and its worth pushed right, above the list with a line between. */

.yayloyalty-redeem .yayloyalty-redeem__header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--yayloyalty-redeem-border);
}

.yayloyalty-redeem .yayloyalty-redeem__icon {
  display: block;
  flex-shrink: 0;
  width: 18px;
  height: 18px;
}

.yayloyalty-redeem .yayloyalty-redeem__heading {
  display: flex;
  flex: 1;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 8px;
  min-width: 0;
  padding: 0;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.45;
  color: var(--yayloyalty-redeem-text);
}

.yayloyalty-redeem .yayloyalty-redeem__balance {
  margin-left: auto;
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  color: var(--yayloyalty-redeem-text);
}

.yayloyalty-redeem .yayloyalty-redeem__unit {
  font-size: 11px;
  font-weight: 400;
  color: var(--yayloyalty-redeem-muted);
}

.yayloyalty-redeem .yayloyalty-redeem__worth {
  font-size: 12px;
  font-weight: 400;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  color: var(--yayloyalty-redeem-muted);
}

@media (max-width: 360px) {
  .yayloyalty-redeem .yayloyalty-redeem__heading > span:first-child {
    flex-basis: 100%;
  }

  .yayloyalty-redeem .yayloyalty-redeem__balance {
    margin-left: 0;
  }
}

/* Guest: one row, a black badge, the title over the sign-in line, and a small Sign in button. */

.yayloyalty-redeem[data-state="guest"] {
  background: var(--yayloyalty-redeem-surface);
}

.yayloyalty-redeem .yayloyalty-redeem__guest {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
}

.yayloyalty-redeem .yayloyalty-redeem__guest-text {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.yayloyalty-redeem .yayloyalty-redeem__badge {
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--yayloyalty-redeem-badge);
  color: #ffffff;
}

.yayloyalty-redeem .yayloyalty-redeem__text {
  font-size: 12px;
  color: var(--yayloyalty-redeem-muted);
}

.yayloyalty-redeem .yayloyalty-redeem__signin {
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  width: auto;
  min-width: 0;
  height: 30px;
  min-height: 0;
  padding: 0 12px;
  border: 1px solid var(--yayloyalty-redeem-border);
  border-radius: calc(var(--yayloyalty-redeem-radius) - 2px);
  background: var(--yayloyalty-redeem-field) none;
  box-shadow: none;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.2;
  text-decoration: none;
  color: var(--yayloyalty-redeem-text);
  cursor: pointer;
  transition: background-color 0.15s;
}

.yayloyalty-redeem .yayloyalty-redeem__signin:hover {
  background: var(--yayloyalty-redeem-selected) none;
  color: var(--yayloyalty-redeem-text);
}

/* The list: rows with no dividers, 8px apart; a ticked row gets a rounded grey highlight. */

.yayloyalty-redeem .yayloyalty-redeem__list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
}

.yayloyalty-redeem .yayloyalty-redeem__option {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--yayloyalty-redeem-radius);
  font-size: 13px;
  font-weight: 400;
  cursor: pointer;
}

.yayloyalty-redeem .yayloyalty-redeem__item {
  border-radius: var(--yayloyalty-redeem-radius);
}

/*
 * The list's gap is its only spacing. Checkout themes give `label` a margin-bottom through selectors stronger
 * than any nesting here (`.wc-block-checkout … label`), so this one reset is !important, and only on the rows.
 */
.yayloyalty-redeem .yayloyalty-redeem__list :is(.yayloyalty-redeem__item, .yayloyalty-redeem__option) {
  margin: 0 !important;
}

.yayloyalty-redeem .yayloyalty-redeem__item:has(.yayloyalty-redeem__check:checked) {
  background: var(--yayloyalty-redeem-selected);
}

.yayloyalty-redeem .yayloyalty-redeem__option:has(.yayloyalty-redeem__check:disabled) {
  opacity: 0.5;
  cursor: not-allowed;
}

/*
 * Drawn, not the browser's: a rounded square, filled with the accent and a white tick when checked. Themes style
 * every checkbox too (Brandy: `input[type=checkbox]:not(…)` at 0,2,1 with a tick in `:checked:after` at 0,3,2), so
 * these selectors name the element and its type to outrank them: 0,3,1 for the box, 0,4,2 for its pseudo-elements.
 */
.yayloyalty-redeem input.yayloyalty-redeem__check[type="checkbox"] {
  -webkit-appearance: none;
  appearance: none;
  display: inline-block;
  flex-shrink: 0;
  position: relative;
  width: 16px;
  min-width: 16px;
  height: 16px;
  min-height: 16px;
  margin: 0;
  padding: 0;
  border: 1px solid var(--yayloyalty-redeem-check-border);
  border-radius: 4px;
  background: var(--yayloyalty-redeem-field) center / 12px 12px no-repeat;
  box-shadow: none;
  vertical-align: middle;
  cursor: inherit;
  transition: background-color 0.15s, border-color 0.15s;
}

.yayloyalty-redeem input.yayloyalty-redeem__check[type="checkbox"]:checked {
  border-color: var(--yayloyalty-redeem-accent);
  background-color: var(--yayloyalty-redeem-accent);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' fill='none' stroke='%23fff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M2.5 6.2l2.3 2.3 4.7-4.9'/%3E%3C/svg%3E");
}

.yayloyalty-redeem input.yayloyalty-redeem__check[type="checkbox"]:is(:checked, :not(:checked))::before,
.yayloyalty-redeem input.yayloyalty-redeem__check[type="checkbox"]:is(:checked, :not(:checked))::after {
  content: none;
  display: none;
}

.yayloyalty-redeem .yayloyalty-redeem__option-body {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
  min-width: 0;
}

.yayloyalty-redeem .yayloyalty-redeem__name {
  font-weight: 500;
  color: var(--yayloyalty-redeem-text);
}

/* Every row that can't be ticked, refused or unaffordable; not while a request has every control disabled. */
.yayloyalty-redeem:not([data-busy]) .yayloyalty-redeem__option:has(.yayloyalty-redeem__check:disabled) .yayloyalty-redeem__name {
  text-decoration: line-through;
  text-decoration-thickness: 0.5px;
}

.yayloyalty-redeem .yayloyalty-redeem__chip {
  padding: 0 8px;
  border-radius: 999px;
  background: var(--yayloyalty-redeem-chip);
  font-size: 11px;
  font-weight: 400;
  line-height: 18px;
  white-space: nowrap;
  color: var(--yayloyalty-redeem-muted);
}

/* The Points discount row's body: limits at both ends, then the field and the preview; or, in auto max, one line. */

.yayloyalty-redeem .yayloyalty-redeem__body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 0 12px 12px;
}

.yayloyalty-redeem .yayloyalty-redeem__body[hidden] {
  display: none;
}

.yayloyalty-redeem .yayloyalty-redeem__limits {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  font-size: 11px;
  color: var(--yayloyalty-redeem-muted);
}

.yayloyalty-redeem .yayloyalty-redeem__controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

/*
 * The field draws its own stepper, as the admin's NumberInput does: the browser's spin buttons are hidden, and a
 * 24px column of chevrons fades in at the right edge on hover or focus.
 */

.yayloyalty-redeem .yayloyalty-redeem__stepper {
  position: relative;
  display: flex;
  flex: 1;
  min-width: 0;
}

.yayloyalty-redeem .yayloyalty-redeem__points {
  flex: 1;
  width: auto;
  min-width: 0;
  height: 34px;
  min-height: 0;
  padding: 0 30px 0 10px;
  -moz-appearance: textfield;
  appearance: textfield;
  border: 1px solid var(--yayloyalty-redeem-border);
  border-radius: calc(var(--yayloyalty-redeem-radius) - 2px);
  background: var(--yayloyalty-redeem-field);
  box-shadow: none;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
  color: var(--yayloyalty-redeem-text);
}

.yayloyalty-redeem .yayloyalty-redeem__points::-webkit-inner-spin-button,
.yayloyalty-redeem .yayloyalty-redeem__points::-webkit-outer-spin-button {
  -webkit-appearance: none;
  appearance: none;
  margin: 0;
}

.yayloyalty-redeem .yayloyalty-redeem__chevrons {
  position: absolute;
  top: 1px;
  right: 1px;
  bottom: 1px;
  display: flex;
  flex-direction: column;
  width: 24px;
  border-left: 1px solid var(--yayloyalty-redeem-border);
  border-radius: 0 calc(var(--yayloyalty-redeem-radius) - 3px) calc(var(--yayloyalty-redeem-radius) - 3px) 0;
  background: var(--yayloyalty-redeem-field);
  opacity: 0;
  transition: opacity 0.5s;
}

.yayloyalty-redeem .yayloyalty-redeem__stepper:hover .yayloyalty-redeem__chevrons,
.yayloyalty-redeem .yayloyalty-redeem__points:focus ~ .yayloyalty-redeem__chevrons {
  opacity: 1;
}

.yayloyalty-redeem .yayloyalty-redeem__chevron {
  display: inline-flex;
  flex: 1;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-width: 0;
  height: auto;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent none;
  box-shadow: none;
  line-height: 0;
  color: var(--yayloyalty-redeem-muted);
  cursor: pointer;
  user-select: none;
  transition: background-color 0.15s, color 0.15s;
}

.yayloyalty-redeem .yayloyalty-redeem__chevron:first-child {
  border-top-right-radius: inherit;
}

.yayloyalty-redeem .yayloyalty-redeem__chevron + .yayloyalty-redeem__chevron {
  border-top: 1px solid var(--yayloyalty-redeem-border);
  border-bottom-right-radius: inherit;
}

.yayloyalty-redeem .yayloyalty-redeem__chevron:hover {
  background: var(--yayloyalty-redeem-surface) none;
  color: var(--yayloyalty-redeem-text);
}

.yayloyalty-redeem .yayloyalty-redeem__chevron svg {
  display: block;
  flex-shrink: 0;
}

.yayloyalty-redeem .yayloyalty-redeem__auto {
  margin: 0;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--yayloyalty-redeem-muted);
}

.yayloyalty-redeem .yayloyalty-redeem__off {
  flex-shrink: 0;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  color: var(--yayloyalty-redeem-muted);
}

/*
 * The points row's notes take the amber notice's box (below): neutral for rounding to the step, amber for a limit
 * that lowered the amount, red below the minimum, where nothing is sent until it is fixed.
 */
.yayloyalty-redeem .yayloyalty-redeem__note {
  margin: 0;
  padding: 8px 12px;
  border: 0;
  border-left: 1.5px solid var(--yayloyalty-redeem-muted);
  border-radius: var(--yayloyalty-redeem-radius);
  /* The chip's fill: the ticked row behind it is already the surface colour. */
  background: var(--yayloyalty-redeem-chip);
  font-size: 12px;
  line-height: 1.5;
  color: var(--yayloyalty-redeem-text);
}

.yayloyalty-redeem .yayloyalty-redeem__note--warning {
  border-left-color: currentColor;
  background: var(--yayloyalty-warning-bg);
  color: var(--yayloyalty-warning);
}

.yayloyalty-redeem .yayloyalty-redeem__note--error {
  border-left-color: currentColor;
  background: var(--yayloyalty-redeem-error-bg);
  color: var(--yayloyalty-redeem-error);
}

.yayloyalty-redeem .yayloyalty-redeem__note[hidden] {
  display: none;
}

/*
 * The amber notice: picked rewards the store took away, under the header. Same colours and left edge as the
 * My Points tab's notice (account/points-card.css).
 */

.yayloyalty-redeem .yayloyalty-redeem__alert {
  margin: 12px 12px 0;
  padding: 8px 12px;
  /* Left edge only: the radius curves it into the corners. */
  border: 0;
  border-left: 1.5px solid currentColor;
  border-radius: var(--yayloyalty-redeem-radius);
  background: var(--yayloyalty-warning-bg);
  font-size: 12px;
  line-height: 1.5;
  color: var(--yayloyalty-warning);
}

.yayloyalty-redeem .yayloyalty-redeem__alert p {
  color: inherit;
}

/*
 * Checkout mode (data-mode, set by redeem.js), per the "checkout_applied" and "Points selected _ edit" frames:
 * a grey header with the black badge, "Points & rewards", "✓ N rewards selected" and Change while something is
 * applied (data-applied) and the list is closed; Update in Change's place while it is open. With nothing applied
 * the list is open and the balance sits under the title. Outside checkout none of this shows.
 */

.yayloyalty-redeem:not([data-mode="checkout"])
  :is(
    .yayloyalty-redeem__title-checkout,
    .yayloyalty-redeem__summary,
    .yayloyalty-redeem__change,
    .yayloyalty-redeem__update
  ) {
  display: none;
}

.yayloyalty-redeem[data-mode="checkout"] .yayloyalty-redeem__header .yayloyalty-redeem__title {
  display: none;
}

.yayloyalty-redeem[data-mode="checkout"] .yayloyalty-redeem__header {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) auto;
  align-items: center;
  gap: 2px 12px;
  padding: 14px 16px;
  background: var(--yayloyalty-redeem-surface);
}

.yayloyalty-redeem[data-mode="checkout"] .yayloyalty-redeem__icon {
  grid-row: 1 / span 2;
  width: 40px;
  height: 40px;
  padding: 11px;
  border-radius: 50%;
  background: var(--yayloyalty-redeem-badge);
  color: #ffffff;
}

.yayloyalty-redeem[data-mode="checkout"] .yayloyalty-redeem__heading {
  grid-column: 2;
  grid-row: 1;
  font-size: 15px;
}

.yayloyalty-redeem[data-mode="checkout"] .yayloyalty-redeem__title-checkout {
  flex-basis: 100%;
}

.yayloyalty-redeem[data-mode="checkout"] .yayloyalty-redeem__balance {
  margin-left: 0;
}

.yayloyalty-redeem[data-mode="checkout"][data-applied] :is(.yayloyalty-redeem__balance, .yayloyalty-redeem__worth) {
  display: none;
}

.yayloyalty-redeem[data-mode="checkout"] .yayloyalty-redeem__summary {
  grid-column: 2;
  grid-row: 2;
  font-size: 13px;
  color: var(--yayloyalty-redeem-success);
}

.yayloyalty-redeem[data-mode="checkout"] :is(.yayloyalty-redeem__change, .yayloyalty-redeem__update) {
  grid-column: 3;
  grid-row: 1 / span 2;
}

/* Collapsed: the grey header is the whole card. */

.yayloyalty-redeem[data-mode="checkout"][data-applied]:not([data-expanded]) {
  background: var(--yayloyalty-redeem-surface);
}

.yayloyalty-redeem[data-mode="checkout"][data-applied]:not([data-expanded]) .yayloyalty-redeem__header {
  border-bottom: 0;
}

.yayloyalty-redeem[data-mode="checkout"][data-applied]:not([data-expanded]) .yayloyalty-redeem__list {
  display: none;
}

/* With the list hidden, the notice is the card's last row. */
.yayloyalty-redeem[data-mode="checkout"][data-applied]:not([data-expanded]) .yayloyalty-redeem__alert {
  margin-bottom: 12px;
}

/*
 * Open: Update in Change's place. Both share one grid cell and the hidden one keeps its box, so the column
 * stays as wide as the wider label and the header does not shift when they swap.
 */

.yayloyalty-redeem[data-mode="checkout"][data-applied]:not([data-expanded]) .yayloyalty-redeem__update,
.yayloyalty-redeem[data-mode="checkout"]:is(:not([data-applied]), [data-expanded]) .yayloyalty-redeem__change {
  visibility: hidden;
}

.yayloyalty-redeem :is(.yayloyalty-redeem__change, .yayloyalty-redeem__update) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto;
  min-width: 0;
  height: 36px;
  min-height: 0;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: var(--yayloyalty-redeem-radius);
  box-shadow: none;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.15s;
}

.yayloyalty-redeem .yayloyalty-redeem__change {
  border-color: var(--yayloyalty-redeem-border);
  background: var(--yayloyalty-redeem-field) none;
  color: var(--yayloyalty-redeem-text);
}

.yayloyalty-redeem .yayloyalty-redeem__change:hover {
  background: var(--yayloyalty-redeem-selected) none;
  color: var(--yayloyalty-redeem-text);
}

.yayloyalty-redeem .yayloyalty-redeem__update {
  background: var(--yayloyalty-redeem-accent) none;
  color: var(--yayloyalty-redeem-accent-text);
}

.yayloyalty-redeem .yayloyalty-redeem__update:hover {
  background: var(--yayloyalty-redeem-accent-hover) none;
  color: var(--yayloyalty-redeem-accent-text);
}

@media (max-width: 360px) {
  .yayloyalty-redeem[data-mode="checkout"] :is(.yayloyalty-redeem__change, .yayloyalty-redeem__update) {
    grid-column: 2;
    grid-row: 3;
    justify-self: start;
  }
}

/* Focus and disabled states. */

.yayloyalty-redeem
  :is(
    .yayloyalty-redeem__points,
    .yayloyalty-redeem__signin,
    .yayloyalty-redeem__change,
    .yayloyalty-redeem__update
  ):focus-visible {
  outline: 2px solid var(--yayloyalty-redeem-accent);
  outline-offset: 2px;
}

/* The checkbox draws no focus ring, its own or a theme's: the design has none. */
.yayloyalty-redeem .yayloyalty-redeem__check:focus,
.yayloyalty-redeem .yayloyalty-redeem__check:focus-visible {
  outline: none;
  box-shadow: none;
}

.yayloyalty-redeem :is(input, button):disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.yayloyalty-redeem button:disabled {
  pointer-events: none;
}
