/* Themes EDD's own checkout/cart/receipt/purchase-history markup to match
   the PluginSprout design system, without overriding EDD's PHP templates. */

#edd_checkout_form_wrap,
.edd_download_purchase_form,
.edd_purchase_receipt,
#edd_checkout_wrap {
  font-family: inherit;
  color: var(--ink);
}

#edd_checkout_form_wrap input[type=text],
#edd_checkout_form_wrap input[type=email],
#edd_checkout_form_wrap input[type=password],
#edd_checkout_form_wrap input[type=tel],
#edd_checkout_form_wrap select,
#edd_checkout_form_wrap textarea,
.edd_download_purchase_form select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  font-family: inherit;
  font-size: .92rem;
  margin-bottom: 14px;
  background: var(--paper);
}

a.edd-submit,
.edd-submit.button,
#edd_checkout_form_wrap .edd-submit,
#edd_purchase_submit input[type=submit] {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 12px 21px;
  border-radius: var(--r-sm);
  font-weight: 550;
  font-size: .92rem;
  border: 1px solid transparent;
  cursor: pointer;
  background: var(--action);
  color: var(--on-accent) !important;
  text-decoration: none !important;
  font-family: inherit;
}
a.edd-submit:hover,
.edd-submit.button:hover,
#edd_purchase_submit input[type=submit]:hover {
  background: var(--action-hover);
}

table.edd_cart,
table.purchase_history {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-size: .91rem;
}
table.edd_cart th,
table.edd_cart td,
table.purchase_history th,
table.purchase_history td {
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
table.edd_cart th,
table.purchase_history th {
  background: var(--warm);
  font-weight: 600;
  font-size: .84rem;
  border-bottom: 2px solid var(--line);
}

.edd_download_purchase_form .edd_price_options {
  list-style: none;
  margin-bottom: 14px;
}
.edd_download_purchase_form .edd_price_options li {
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}
.edd_download_purchase_form .edd_price_options li:last-child {
  border-bottom: 0;
}

/* One button style for every EDD purchase / checkout button. EDD's own
   stylesheet targets .edd-submit.button.<colour>; the colour class is
   removed in inc/edd-integration.php and these rules take over. */
body .edd-submit.button,
body a.edd-submit,
body .edd_go_to_checkout,
body #edd-purchase-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 12px 21px;
  border-radius: var(--r-sm);
  border: 0;
  background: var(--action);
  color: var(--on-accent) !important;
  font-family: inherit;
  font-weight: 600;
  font-size: .95rem;
  line-height: 1.3;
  box-shadow: none;
  text-shadow: none;
  cursor: pointer;
  text-decoration: none !important;
}
body .edd-submit.button:hover,
body a.edd-submit:hover,
body .edd_go_to_checkout:hover,
body #edd-purchase-button:hover {
  background: var(--action-hover);
}
.buypanel .edd-submit.button,
.buypanel .edd_go_to_checkout,
body #edd-purchase-button {
  width: 100%;
  padding: 14px 21px;
}
.edd_purchase_submit_wrapper .edd-cart-added-alert {
  display: block;
  margin-top: 10px;
  font-size: .88rem;
  color: var(--sprout-deep);
}
#edd_checkout_cart_form + #edd_checkout_form_wrap,
#edd_purchase_submit {
  margin-top: 8px;
}

/* Empty cart */
.edd_empty_cart {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 16px;
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--warm);
}
.edd_empty_cart .empty-cart strong {
  display: block;
  font-size: 1.1rem;
  color: var(--ink);
  margin-bottom: 4px;
}

/* Add-to-cart feedback: EDD's inline alert is absolutely positioned under
   the button and overlaps the next element; assets/cart.js shows a toast
   instead. */
.edd-cart-ajax-alert,
.edd-cart-added-alert {
  display: none !important;
}

/* EDD's ".edd-submit.button:visited { background:#f0f0f0 }" outranks the
   base rule above once /checkout/ has been visited (grey button, white
   text). Cover every link state with higher specificity. */
body a.edd_go_to_checkout.edd-submit.button,
body a.edd_go_to_checkout.edd-submit.button:link,
body a.edd_go_to_checkout.edd-submit.button:visited,
body a.edd_go_to_checkout.edd-submit.button:focus,
body a.edd_go_to_checkout.edd-submit.button:active {
  background: var(--accent);
  border-color: transparent;
  color: var(--on-accent) !important;
}
body a.edd_go_to_checkout.edd-submit.button:hover {
  background: var(--accent-hover);
}
body .edd-submit.button:visited {
  background: var(--action);
  color: var(--on-accent) !important;
}

/* Toast */
.cart-toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 16px;
  max-width: calc(100vw - 32px);
  padding: 13px 18px;
  border-radius: var(--r-sm);
  background: var(--ink);
  color: var(--bg);
  font-size: .92rem;
  box-shadow: var(--shadow);
  transform: translate(-50%, 20px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
}
.cart-toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
  pointer-events: auto;
}
.cart-toast-msg {
  white-space: nowrap;
}
.cart-toast-msg {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.cart-toast-msg::before {
  content: '';
  width: 16px;
  height: 16px;
  background: currentColor;
  -webkit-mask: url(icons/check.svg) center / contain no-repeat;
  mask: url(icons/check.svg) center / contain no-repeat;
}
.cart-toast-link {
  color: var(--bg);
  font-weight: 600;
  white-space: nowrap;
  text-decoration: underline;
}

/* Purchase buttons outside the buy box (product hero, closing CTA). */
.cta-row .edd_download_purchase_form,
.dark .edd_download_purchase_form {
  margin: 0;
}
.dark .edd_download_purchase_form {
  display: inline-block;
}
body .edd-submit.button,
body .edd_go_to_checkout {
  white-space: normal;
  text-align: center;
  max-width: 100%;
}

/* ---------- Checkout form (EDD checkout block) ---------- */
body #edd_checkout_form_wrap .edd-input,
body #edd_checkout_form_wrap .edd-select,
body #edd_checkout_form_wrap input[type=text],
body #edd_checkout_form_wrap input[type=email],
body #edd_checkout_form_wrap input[type=tel],
body #edd_checkout_form_wrap select {
  min-height: 46px;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  font-size: 1rem;
  line-height: 1.3;
  background: var(--paper);
  margin-bottom: 0;
}
body #edd_checkout_form_wrap .edd-input:focus,
body #edd_checkout_form_wrap select:focus {
  border-color: var(--sprout);
  outline: 2px solid color-mix(in srgb, var(--accent) 35%, transparent);
  outline-offset: 0;
}
body #edd_checkout_form_wrap fieldset {
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 22px 24px 8px;
  margin: 0 0 20px;
  background: var(--paper);
}
body #edd_checkout_form_wrap fieldset#edd_purchase_submit {
  border: 0;
  padding: 0;
  background: none;
}
body #edd_checkout_form_wrap legend {
  float: left;
  width: 100%;
  padding: 0;
  margin: 0 0 14px;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--ink);
}
body #edd_checkout_form_wrap legend + * {
  clear: both;
}
body #edd_checkout_form_wrap label {
  font-size: .9rem;
  font-weight: 600;
  margin-bottom: 6px;
}
body #edd_checkout_form_wrap p,
body #edd_checkout_form_wrap .edd-blocks-form__group {
  margin-bottom: 16px;
}
/* Filler helper text under first/last name. */
#edd_checkout_form_wrap p:has(> #edd-first) .edd-description,
#edd_checkout_form_wrap p:has(> #edd-last) .edd-description,
#edd_checkout_form_wrap div:has(> #edd-first) .edd-description,
#edd_checkout_form_wrap div:has(> #edd-last) .edd-description {
  display: none;
}
/* 25px blurry product thumbnails in the cart table. */
#edd_checkout_form_wrap .edd_cart_item_image {
  display: none;
}
/* Stripe's form takes several seconds to appear; don't show a blank box. */
/* assets/cart.js adds .ps-ready once Stripe's iframe has real height. */
#edd-stripe-payment-element:not(.ps-ready) {
  position: relative;
  min-height: 120px;
}
#edd-stripe-payment-element:not(.ps-ready)::before {
  content: 'Loading the secure payment form';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px dashed var(--line);
  border-radius: var(--r-sm);
  color: var(--ink-muted);
  font-size: .92rem;
}
.checkout-reassure {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin: 14px 0 0;
  padding: 12px 14px;
  border: 1px solid var(--sprout-line);
  border-radius: var(--r-sm);
  background: var(--sprout-light);
  font-size: .93rem;
  line-height: 1.5;
  color: var(--ink);
}
.checkout-reassure svg {
  flex: none;
  margin-top: 2px;
  color: var(--sprout-deep);
}

/* Fields read in both colour schemes. */
body #edd_checkout_form_wrap input,
body #edd_checkout_form_wrap select,
body #edd_checkout_form_wrap textarea {
  color: var(--ink);
  border-color: var(--field-line);
}
body #edd_checkout_form_wrap input::placeholder {
  color: var(--muted);
  opacity: 1;
}

/* Remove-item and remove-discount buttons. EDD draws the bin as a
   background SVG, which can't take the text colour and so disappears on
   the dark scheme. The Phosphor bin is masked onto a pseudo-element in the
   theme's colour instead, leaving the link itself free for the focus ring. */
body .edd-blocks-form__cart .edd-blocks-cart__action-remove,
body .edd-blocks-form__cart .edd_discount_remove {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  margin: -8px;
  border-radius: var(--r-sm);
  background: none;
  color: var(--muted);
  opacity: 1;
}
body .edd-blocks-form__cart .edd-blocks-cart__action-remove::before,
body .edd-blocks-form__cart .edd_discount_remove::before {
  content: '';
  width: 18px;
  height: 18px;
  background: currentColor;
  -webkit-mask: url(icons/trash.svg) center / contain no-repeat;
  mask: url(icons/trash.svg) center / contain no-repeat;
}
body .edd-blocks-form__cart .edd-blocks-cart__action-remove:hover,
body .edd-blocks-form__cart .edd-blocks-cart__action-remove:focus-visible,
body .edd-blocks-form__cart .edd_discount_remove:hover,
body .edd-blocks-form__cart .edd_discount_remove:focus-visible {
  background: var(--sunken);
  color: var(--danger);
}

/* EDD's block checkout hard-codes #eee borders, which glare on the dark
   scheme; every EDD block border takes the theme's line colour instead. */
body [class*="edd-blocks"],
body [class*="edd-blocks"] * {
  border-color: var(--line) !important; /* EDD's own rules are more specific */
}
body .edd-blocks-cart {
  border-radius: var(--r);
  background: var(--surface);
  overflow: hidden;
}
