/*
 * Sleepbetter.Baby v3.5 cart and checkout refinements.
 *
 * This layer loads after commerce-v320.css. It keeps the warm visual system
 * while limiting special behavior to theme-owned complimentary samples and
 * avoiding payment-provider button branding.
 */

/* Complimentary sample-only path. No totals, coupons, or gateways are changed. */
body.sbb-sample-only-order-v350
  :where(
    .woocommerce-cart-form .coupon,
    .woocommerce-form-coupon-toggle
  ) {
  display: none !important;
}

body.sbb-sample-only-order-v350.woocommerce-checkout
  .wc-block-components-totals-coupon {
  display: none !important;
}

body.sbb-sample-only-order-v350 .sbb-commerce-hero-v320--free {
  background:
    radial-gradient(circle at 88% 12%, rgba(255, 255, 255, .86), transparent 18rem),
    linear-gradient(132deg, #f4ddd0, #fff8ed 50%, #e5ecdf);
}

body.sbb-sample-only-order-v350
  .sbb-cart-assurance-v320--free
  .sbb-cart-assurance-v320__grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

/* A compact cover appears only for theme-owned samples in classic checkout. */
.sbb-checkout-line-item-v350 {
  display: grid;
  min-width: 0;
  grid-template-columns: 52px minmax(0, 1fr);
  align-items: start;
  gap: .7rem;
}

.sbb-checkout-line-item-v350 > img {
  width: 52px;
  height: 65px;
  margin: 0;
  overflow: hidden;
  border: 1px solid var(--sbb-commerce-line);
  border-radius: 9px;
  background: var(--sbb-commerce-paper);
  box-shadow: 0 6px 16px rgba(72, 48, 34, .1);
  object-fit: cover;
}

.sbb-checkout-line-item-v350 > span {
  min-width: 0;
}

/*
 * Own only the primary Cart/Checkout Block actions. Express-payment wrappers
 * remain neutral so PayPal, Stripe, Apple Pay, Google Pay, and other providers
 * can render their own controls without a theme-colored outer button.
 */
body:is(.woocommerce-cart, .woocommerce-checkout)
  :is(
    .wc-block-cart__submit-button,
    .wc-block-components-checkout-place-order-button
  ) {
  min-height: 54px;
  border: 1px solid var(--sbb-commerce-cocoa);
  border-radius: 999px;
  background: var(--sbb-commerce-cocoa);
  color: #fff;
  font-weight: 850;
}

body:is(.woocommerce-cart, .woocommerce-checkout)
  :is(
    .wc-block-cart__submit-button,
    .wc-block-components-checkout-place-order-button
  ):hover {
  border-color: var(--sbb-commerce-cocoa-deep);
  background: var(--sbb-commerce-cocoa-deep);
  color: #fff;
}

body:is(.woocommerce-cart, .woocommerce-checkout)
  .wc-block-components-totals-coupon__button {
  min-height: 46px;
  border: 1px solid var(--sbb-commerce-cocoa);
  border-radius: 999px;
  background: transparent;
  color: var(--sbb-commerce-cocoa-deep);
  transform: none;
}

body:is(.woocommerce-cart, .woocommerce-checkout)
  .wc-block-components-express-payment
  .wc-block-components-button:not(.is-link) {
  min-height: 44px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: inherit;
  box-shadow: none;
  font: inherit;
  letter-spacing: normal;
  transform: none;
}

body:is(.woocommerce-cart, .woocommerce-checkout)
  .wc-block-components-express-payment
  .wc-block-components-button:not(.is-link):hover {
  border: 0;
  background: transparent;
  color: inherit;
  box-shadow: none;
  transform: none;
}

body:is(.woocommerce-cart, .woocommerce-checkout)
  :is(
    .wc-block-cart__submit-button,
    .wc-block-components-checkout-place-order-button,
    .wc-block-components-totals-coupon__button
  ):is(:disabled, [aria-disabled="true"]) {
  opacity: .55;
  transform: none;
}

/* Clear, non-color-only validation and notice treatment for both contracts. */
body:is(.woocommerce-cart, .woocommerce-checkout)
  :where(.woocommerce-invalid input, .woocommerce-invalid select, .woocommerce-invalid textarea),
body:is(.woocommerce-cart, .woocommerce-checkout)
  :where(input, select, textarea)[aria-invalid="true"] {
  border-color: #9f4b42;
  outline: 2px solid rgba(159, 75, 66, .24);
  outline-offset: 2px;
}

body:is(.woocommerce-cart, .woocommerce-checkout)
  .wc-block-components-validation-error {
  margin-top: .35rem;
  color: #873f38;
  font-size: .78rem;
  font-weight: 700;
  line-height: 1.45;
}

body:is(.woocommerce-cart, .woocommerce-checkout)
  .wc-block-components-notice-banner {
  padding: .9rem 1rem;
  border: 1px solid var(--sbb-commerce-line);
  border-radius: 16px;
  background: var(--sbb-commerce-paper);
  color: var(--sbb-ink);
  box-shadow: var(--sbb-commerce-shadow-soft);
}

body:is(.woocommerce-cart, .woocommerce-checkout)
  .wc-block-components-notice-banner.is-error {
  border-color: rgba(159, 75, 66, .36);
  background: #fff4f2;
}

body:is(.woocommerce-cart, .woocommerce-checkout)
  .wc-block-components-notice-banner.is-success {
  border-color: rgba(91, 125, 95, .34);
  background: #f2f7f3;
}

body.woocommerce-cart
  .woocommerce
  table.shop_table.cart
  .product-remove
  a.remove {
  width: 44px;
  height: 44px;
}

@media (min-width: 921px) {
  body.woocommerce-checkout .woocommerce #order_review {
    position: sticky;
    top: calc(var(--sbb-header-height) + 1rem);
  }
}

@media (max-width: 768px) {
  /* Checkout is a focused task; navigation and floating chat remain elsewhere. */
  body.sbb-theme-v320.woocommerce-checkout {
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  body.woocommerce-checkout
    :where(
      .sbb-mobile-app-nav,
      .sbb-floating-chat-toggle,
      .sbb-floating-chat-panel
    ) {
    display: none !important;
  }

  body:is(.woocommerce-cart, .woocommerce-checkout) .sbb-commerce-hero-v320 {
    gap: .85rem;
    margin-bottom: 1.15rem;
    padding: .95rem;
    border-radius: 20px;
  }

  body:is(.woocommerce-cart, .woocommerce-checkout)
    .sbb-commerce-hero-v320__copy
    h1 {
    margin-bottom: .45rem;
    font-size: clamp(1.85rem, 8vw, 2.55rem);
    line-height: 1.06;
  }

  body:is(.woocommerce-cart, .woocommerce-checkout)
    .sbb-commerce-hero-v320__copy
    > p:not(.sbb-section-label) {
    margin-bottom: 0;
    font-size: .84rem;
    line-height: 1.55;
  }

  body.woocommerce-cart .sbb-cart-hero .sbb-commerce-hero-v320__media {
    display: none;
  }

  body.woocommerce-checkout .sbb-commerce-hero-v320__trust {
    display: flex;
    overflow-x: auto;
    gap: .55rem;
    padding-bottom: .2rem;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
  }

  body.woocommerce-checkout .sbb-commerce-hero-v320__trust::-webkit-scrollbar {
    display: none;
  }

  body.woocommerce-checkout .sbb-commerce-hero-v320__trust > div {
    flex: 0 0 min(230px, 78vw);
    min-height: 62px;
    padding: .5rem .6rem;
    grid-template-columns: 38px minmax(0, 1fr);
    gap: .55rem;
    scroll-snap-align: start;
  }

  body.woocommerce-checkout .sbb-commerce-hero-v320__trust img {
    width: 38px;
    height: 38px;
  }

  body:is(.woocommerce-cart, .woocommerce-checkout)
    .sbb-commerce-progress-v320 {
    margin-top: .8rem;
  }

  body:is(.woocommerce-cart, .woocommerce-checkout)
    .sbb-commerce-progress-v320
    ol {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: .3rem;
  }

  body:is(.woocommerce-cart, .woocommerce-checkout)
    .sbb-commerce-progress-v320
    li {
    min-height: 44px;
    padding: .35rem;
    grid-template-columns: 24px minmax(0, 1fr);
    gap: .35rem;
  }

  body:is(.woocommerce-cart, .woocommerce-checkout)
    .sbb-commerce-progress-v320
    li
    > span {
    width: 24px;
    height: 24px;
    font-size: .62rem;
  }

  body:is(.woocommerce-cart, .woocommerce-checkout)
    .sbb-commerce-progress-v320
    li
    strong {
    font-size: .6rem;
  }

  .sbb-cart-assurance-v320__grid,
  body.sbb-sample-only-order-v350
    .sbb-cart-assurance-v320--free
    .sbb-cart-assurance-v320__grid {
    display: flex;
    overflow-x: auto;
    gap: .65rem;
    padding-bottom: .25rem;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
  }

  .sbb-cart-assurance-v320__grid::-webkit-scrollbar {
    display: none;
  }

  .sbb-cart-assurance-v320__grid article {
    flex: 0 0 min(220px, 78vw);
    scroll-snap-align: start;
  }

  .sbb-checkout-line-item-v350 {
    grid-template-columns: 46px minmax(0, 1fr);
    gap: .55rem;
  }

  .sbb-checkout-line-item-v350 > img {
    width: 46px;
    height: 58px;
  }
}

@media (max-width: 480px) {
  body:is(.woocommerce-cart, .woocommerce-checkout)
    .sbb-commerce-progress-v320
    ol {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  body:is(.woocommerce-cart, .woocommerce-checkout)
    .sbb-commerce-progress-v320
    li {
    min-height: 42px;
    grid-template-columns: 22px minmax(0, 1fr);
  }

  body:is(.woocommerce-cart, .woocommerce-checkout)
    .sbb-commerce-progress-v320
    li
    > span {
    width: 22px;
    height: 22px;
  }
}

@media (prefers-reduced-motion: reduce) {
  body:is(.woocommerce-cart, .woocommerce-checkout)
    :is(
      .wc-block-cart__submit-button,
      .wc-block-components-checkout-place-order-button,
      .wc-block-components-totals-coupon__button
    ) {
    transition: none;
    transform: none;
  }
}
