/**
 * ============================================================================
 *  BASKET — checkout button row  (editable, no build step)
 * ============================================================================
 *
 *  Loaded on the basket page only (see functions.php ->
 *  frogspark_enqueue_basket), AFTER the compiled bundle so these rules win.
 *
 *  THE PROBLEM
 *  `.wc-proceed-to-checkout` is a flex row with `flex-wrap: nowrap` holding
 *  three things:
 *      1. Continue Shopping      (~178px)
 *      2. Proceed To Checkout    (~187px)
 *      3. the Stripe express block (Google Pay / Onelink, ~280px and growing
 *         taller as each button loads)
 *  That is ~645px of content in a 661px column with no gap, so as soon as the
 *  express buttons render, the two theme buttons get squashed and their labels
 *  wrap onto two cramped lines.
 *
 *  THE FIX
 *  Let the row wrap: the two theme buttons share the first row at equal width,
 *  and the express payment buttons drop to their own full-width row underneath,
 *  introduced by a small "or pay with" label. That is the conventional
 *  express-checkout pattern and it stops the express block competing for
 *  horizontal space with the primary actions.
 *
 *  WATCH OUT: the container carries a Bootstrap-style clearfix
 *  (`::before`/`::after` with `content: " "; display: table`). In a flex
 *  container those pseudo-elements become FLEX ITEMS, which pushed each button
 *  onto its own line and made the 50/50 row impossible. They are switched off
 *  in [1] below — if the row ever collapses back to stacked buttons, check
 *  that rule first.
 * ============================================================================
 */


/* ---------------------------------------------------------------------------
 * [1] THE ROW
 * ------------------------------------------------------------------------- */
.wc-proceed-to-checkout {
  display: flex !important;
  flex-wrap: wrap !important;         /* was nowrap — the cause of the squash */
  align-items: stretch !important;
  gap: 12px !important;
}

/* clearfix pseudo-elements would otherwise count as flex items — see above */
.wc-proceed-to-checkout::before,
.wc-proceed-to-checkout::after {
  content: none !important;
  display: none !important;
}


/* ---------------------------------------------------------------------------
 * [2] THE TWO THEME BUTTONS — equal halves of the first row
 * ------------------------------------------------------------------------- */
.wc-proceed-to-checkout > a.btn-outline-quaternary,
.wc-proceed-to-checkout > a.checkout-button {
  flex: 1 1 calc(50% - 6px) !important;
  min-width: 0 !important;
  margin: 0 !important;

  /* centre the label properly instead of relying on line-height */
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  min-height: 56px !important;
  padding: 14px 18px !important;
  text-align: center !important;
  line-height: 1.25 !important;
}


/* ---------------------------------------------------------------------------
 * [3] EXPRESS PAYMENT BUTTONS — their own full-width row
 *     Matched via :has() so it only applies once Stripe has injected its
 *     element; if the express buttons are unavailable, nothing here applies.
 * ------------------------------------------------------------------------- */
.wc-proceed-to-checkout > div:has(.StripeElement) {
  display: block !important;          /* so the label below stacks above them */
  flex: 1 1 100% !important;
  width: 100% !important;
  margin: 4px 0 0 !important;
  text-align: left !important;        /* the totals column sets right-align */
}

.wc-proceed-to-checkout > div:has(.StripeElement) .StripeElement {
  width: 100% !important;
}

/* The label is tied to `iframe`, not just .StripeElement: Stripe creates the
   element up front but only mounts the iframe once it has a payment method to
   offer, so this way the heading can't sit above an empty gap for someone with
   no Google Pay / Onelink available. */
.wc-proceed-to-checkout > div:has(.StripeElement iframe)::before {
  content: "or pay with";
  display: block;
  margin-bottom: 10px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: #7C93A0;
}


/* ---------------------------------------------------------------------------
 * [4] NARROW SCREENS — one button per row
 * ------------------------------------------------------------------------- */
@media (max-width: 575.98px) {
  .wc-proceed-to-checkout > a.btn-outline-quaternary,
  .wc-proceed-to-checkout > a.checkout-button {
    flex: 1 1 100% !important;
  }
}
