/**
 * Glowflare shop: 940px basket and checkout layout authority.
 *
 * The page shell has NO horizontal padding. The 600px + 10px + 330px layout
 * is applied once, to the actual two-column owner. Older WooCommerce styles
 * may also style .wc-block-checkout; do not let an outer checkout wrapper
 * become a second grid or the card form will be squeezed to sidebar width.
 *
 * Presentation only; WooCommerce and payment gateways own the form logic.
 */
@media (min-width: 960px) {
  body.na-commerce-live:is(.woocommerce-cart, .woocommerce-checkout) {
    --gf-commerce-width: 940px;
    --gf-commerce-main: 600px;
    --gf-commerce-sidebar: 330px;
    --gf-commerce-gap: 10px;
  }

  /* Make the shop page and every intermediate page wrapper align with the menu.
   * Horizontal margins auto centre the 940px page on larger desktop screens;
   * no extra margins or padding exist INSIDE that 940px content area. */
  body.na-commerce-live:is(.woocommerce-cart, .woocommerce-checkout)
    :is(#shop-content, #primary, .content-area, .site-main, main.site-main,
        article.page, .entry-content, .page-content, .wp-block-post-content,
        .woocommerce, .na-basket-live, .na-checkout-live, .na-commerce-shell,
        .na-commerce-block-intro, .gf-block-journey,
        .wp-block-woocommerce-cart, .wp-block-woocommerce-checkout,
        .wc-block-cart, .wc-block-checkout) {
    box-sizing: border-box !important;
    width: 100% !important;
    max-width: var(--gf-commerce-width) !important;
    min-width: 0 !important;
    margin-left: auto !important;
    margin-right: auto !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
    float: none !important;
  }

  body.na-commerce-live:is(.woocommerce-cart, .woocommerce-checkout)
    :is(#shop-content, article.page, .entry-content, .page-content,
        .wp-block-post-content, .woocommerce, .na-commerce-shell,
        .na-commerce-block-intro, .wp-block-woocommerce-cart,
        .wp-block-woocommerce-checkout) {
    background: transparent !important;
    border: 0 !important;
    box-shadow: none !important;
  }

  /* A WooCommerce Block can contain a SECOND element called wc-block-checkout.
   * The outer wrapper must not ALSO create a 600px/330px grid. */
  body.woocommerce-cart.na-commerce-live
    :is(.wc-block-cart, .wp-block-woocommerce-cart):not(.wc-block-components-sidebar-layout),
  body.woocommerce-checkout.na-commerce-live
    :is(.wc-block-checkout, .wp-block-woocommerce-checkout):not(.wc-block-components-sidebar-layout) {
    display: block !important;
    grid-template-columns: none !important;
  }

  /* Only the real WooCommerce block sidebar layout owns the two columns. */
  body.woocommerce-cart.na-commerce-live .wc-block-components-sidebar-layout,
  body.woocommerce-cart.na-commerce-live .wc-block-cart.wc-block-components-sidebar-layout,
  body.woocommerce-cart.na-commerce-live .wp-block-woocommerce-cart .wc-block-components-sidebar-layout,
  body.woocommerce-checkout.na-commerce-live .wc-block-components-sidebar-layout,
  body.woocommerce-checkout.na-commerce-live .wc-block-checkout.wc-block-components-sidebar-layout,
  body.woocommerce-checkout.na-commerce-live .wp-block-woocommerce-checkout .wc-block-components-sidebar-layout {
    box-sizing: border-box !important;
    display: grid !important;
    grid-template-columns: minmax(0, var(--gf-commerce-main)) minmax(0, var(--gf-commerce-sidebar)) !important;
    gap: var(--gf-commerce-gap) !important;
    width: 100% !important;
    max-width: var(--gf-commerce-width) !important;
    min-width: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    justify-content: stretch !important;
    align-items: start !important;
    float: none !important;
  }

  /* Target both WooCommerce's general and cart/checkout-specific class names.
   * This is essential: older code styled __main but the live renderer often
   * uses wc-block-components-main, leaving a narrow payment form behind. */
  body.woocommerce-cart.na-commerce-live
    :is(.wc-block-components-main, .wc-block-cart__main),
  body.woocommerce-checkout.na-commerce-live
    :is(.wc-block-components-main, .wc-block-checkout__main) {
    grid-column: 1 !important;
    grid-row: 1 !important;
    box-sizing: border-box !important;
    /* A single 600px column whose major cards share the same 10px rhythm.
       Earlier source CSS sets a 20px grid gap, and an older final rule set
       display:block (which removed card spacing altogether). */
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    gap: var(--gf-commerce-gap) !important;
    align-content: start !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    position: relative !important;
    inset: auto !important;
    transform: none !important;
    float: none !important;
    flex: 0 1 auto !important;
    align-self: start !important;
  }

  /* Separate contact, billing, delivery, payment, order notes and actions
     with actual card spacing; do not alter hosted gateway fields or iframes. */
  body.woocommerce-checkout.na-commerce-live
    :is(.wc-block-components-main, .wc-block-checkout__main) > * {
    min-width: 0 !important;
    max-width: 100% !important;
    margin-top: 0 !important;
    margin-bottom: 0 !important;
  }
  body.woocommerce-checkout.na-commerce-live .wc-block-components-checkout-step {
    margin: 0 !important;
  }

  body.woocommerce-cart.na-commerce-live
    :is(.wc-block-components-sidebar, .wc-block-cart__sidebar),
  body.woocommerce-checkout.na-commerce-live
    :is(.wc-block-components-sidebar, .wc-block-checkout__sidebar) {
    grid-column: 2 !important;
    grid-row: 1 !important;
    box-sizing: border-box !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    margin: 0 !important;
    padding: 18px !important; /* Inside the white summary card only. */
    position: relative !important;
    inset: auto !important;
    transform: none !important;
    float: none !important;
    flex: 0 1 auto !important;
    align-self: start !important;
    background: #fff !important;
    border: 1px solid rgba(53,53,53,.15) !important;
    border-radius: 15px !important;
  }

  /* Every form/card fills its 600px parent, without being pulled back to a
   * narrower percentage or adding side margins inside the page shell. */
  body.na-commerce-live:is(.woocommerce-cart, .woocommerce-checkout)
    :is(.wc-block-components-checkout-step,
        .wc-block-components-checkout-step__container,
        .wc-block-checkout__actions,
        .wc-block-cart-items,
        .wc-block-cart-items__row,
        .wc-block-components-payment-methods,
        .wc-block-components-payment-methods__container,
        .wc-block-components-radio-control,
        .wc-block-components-radio-control__option) {
    box-sizing: border-box !important;
    min-width: 0 !important;
    max-width: 100% !important;
  }
  body.woocommerce-checkout.na-commerce-live
    :is(.wc-block-components-payment-methods,
        .wc-block-components-payment-methods__container,
        .wc-block-components-radio-control,
        .wc-block-components-radio-control__option) {
    width: 100% !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
  }
  /* Do not alter Stripe/PayPal hosted payment iframes or their internals. */

  /* Classic shortcode templates are a distinct renderer, but use the same
   * 940 = 600 + 10 + 330 geometry and no external white page shell. */
  body.woocommerce-cart.na-commerce-live .na-cart-reference-grid,
  body.woocommerce-checkout.na-commerce-live .na-checkout-native-layout {
    box-sizing: border-box !important;
    display: grid !important;
    grid-template-columns: minmax(0, var(--gf-commerce-main)) minmax(0, var(--gf-commerce-sidebar)) !important;
    gap: var(--gf-commerce-gap) !important;
    width: 100% !important;
    max-width: var(--gf-commerce-width) !important;
    margin: 0 !important;
    padding: 0 !important;
    background: transparent !important;
  }
  body.na-commerce-live:is(.woocommerce-cart, .woocommerce-checkout)
    :is(.na-cart-reference-grid, .na-checkout-native-layout) > * {
    box-sizing: border-box !important;
    min-width: 0 !important;
    max-width: 100% !important;
  }

  /* Keep the classic shortcode renderer and surrounding journey on the
     same 10px card-to-card spacing as WooCommerce Blocks. */
  body.woocommerce-checkout.na-commerce-live .na-checkout-native-main,
  body.woocommerce-cart.na-commerce-live .na-cart-list,
  body.woocommerce-cart.na-commerce-live .na-basket-live,
  body.woocommerce-checkout.na-commerce-live .na-checkout-live,
  body.woocommerce-checkout.na-commerce-live .na-commerce-block-intro {
    gap: var(--gf-commerce-gap) !important;
  }
  body.woocommerce-checkout.na-commerce-live .na-commerce-block-intro,
  body.woocommerce-cart.na-commerce-live .na-basket-live {
    margin-bottom: var(--gf-commerce-gap) !important;
  }

  /* Journey progress, breadcrumbs and partner placement share the same edge. */
  body.na-commerce-live:is(.woocommerce-cart, .woocommerce-checkout)
    :is(.gf-journey-progress, .woocommerce-breadcrumb,
        .fm-sponsor-render--footer_partner, .fm-sponsor-render--footer_banner) {
    box-sizing: border-box !important;
    width: 100% !important;
    max-width: var(--gf-commerce-width) !important;
    margin-left: auto !important;
    margin-right: auto !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
  }
}

/* Preserve the established responsive design. The WooCommerce block summary
 * follows the checkout fields on phones/tablets rather than floating over it. */
@media (max-width: 959px) {
  body.woocommerce-cart.na-commerce-live .wc-block-cart,
  body.woocommerce-checkout.na-commerce-live .wc-block-checkout {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 10px !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
  }
  body.woocommerce-cart.na-commerce-live :is(.wc-block-cart__main,.wc-block-cart__sidebar),
  body.woocommerce-checkout.na-commerce-live :is(.wc-block-checkout__main,.wc-block-checkout__sidebar) {
    grid-column: 1 !important;
    grid-row: auto !important;
    position: static !important;
    inset: auto !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    margin: 0 !important;
    float: none !important;
    transform: none !important;
  }
}
