/* ==========================================================================
   WooCommerce Cart + Checkout blocks - shared brand skin.
   Everything the two pages have in common lives here: page frame, two-column
   layout, summary card, totals, coupon, shipping/payment option cards, honey
   buttons, product-fact pills. Page-only rules: cart.css, checkout.css.
   Markup comes from WooCommerce Blocks (React), so this only restyles it.
   Palette tokens come from base.css. Loaded on is_cart() and is_checkout().
   ========================================================================== */

/* ---- Page frame ---------------------------------------------------------- */

body:is(.woocommerce-cart, .woocommerce-checkout) main.site-main {
  max-width: 82.5rem;
  margin-inline: auto;
  padding: 1.5rem 1.25rem 4rem;
}

body:is(.woocommerce-cart, .woocommerce-checkout) .page-header {
  margin: 0 0 2rem;
}

body:is(.woocommerce-cart, .woocommerce-checkout) .page-header .entry-title {
  margin: 0;
  font-family: 'Quicksand', sans-serif;
  font-size: clamp(2rem, 4vw, 2.75rem);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.02em;
  color: var(--sffr-ink);
}

/* The blocks ship as .alignwide, which pushes the page wider than the viewport. */
body:is(.woocommerce-cart, .woocommerce-checkout) .wp-block-woocommerce-cart.alignwide,
body:is(.woocommerce-cart, .woocommerce-checkout) .wp-block-woocommerce-checkout.alignwide {
  max-width: 100%;
  margin-inline: 0;
}

/* ---- Two-column layout --------------------------------------------------- */

body:is(.woocommerce-cart, .woocommerce-checkout) .wc-block-components-sidebar-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 24rem;
  gap: 2.5rem;
  align-items: start;
  margin: 0;
}

body:is(.woocommerce-cart, .woocommerce-checkout) .wc-block-components-sidebar-layout .wc-block-components-main,
body:is(.woocommerce-cart, .woocommerce-checkout) .wc-block-components-sidebar-layout .wc-block-components-sidebar {
  width: auto;
  max-width: none;
  margin: 0;
  padding: 0;
}

/* Summary card padding (same chain as the reset above, so it wins). */
body:is(.woocommerce-cart, .woocommerce-checkout) .wc-block-components-sidebar-layout .wc-block-components-sidebar {
  padding: 1.75rem;
}

/* ---- Summary card -------------------------------------------------------- */

body:is(.woocommerce-cart, .woocommerce-checkout) .wc-block-components-sidebar {
  position: sticky;
  top: 6.5rem;
  border-radius: 20px;
  background: var(--sffr-surface-low);
  font-family: 'Inter', sans-serif;
  color: var(--sffr-ink);
}

body:is(.woocommerce-cart, .woocommerce-checkout) .wc-block-components-sidebar h2.wc-block-cart__totals-title,
body:is(.woocommerce-cart, .woocommerce-checkout) .wc-block-components-sidebar .wc-block-components-checkout-order-summary__title-text {
  display: block;
  margin: 0 0 1.25rem;
  padding: 0;
  font-family: 'Quicksand', sans-serif;
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: 0;
  text-transform: none;
  text-align: left;
  color: var(--sffr-ink);
}

body:is(.woocommerce-cart, .woocommerce-checkout) .wc-block-components-sidebar .wc-block-components-totals-wrapper {
  padding: 1rem 0;
  border-top: 1px solid var(--sffr-line);
}

body:is(.woocommerce-cart, .woocommerce-checkout) .wc-block-components-sidebar .wc-block-components-totals-wrapper:empty {
  display: none;
}

body:is(.woocommerce-cart, .woocommerce-checkout) .wc-block-components-sidebar .wc-block-components-totals-item {
  padding-inline: 0;
}

body:is(.woocommerce-cart, .woocommerce-checkout) .wc-block-components-totals-item__label {
  font-size: 0.9375rem;
  color: var(--sffr-muted);
}

body:is(.woocommerce-cart, .woocommerce-checkout) .wc-block-components-totals-item__value {
  font-size: 0.9375rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  color: var(--sffr-ink);
}

body:is(.woocommerce-cart, .woocommerce-checkout) .wc-block-components-totals-item__description,
body:is(.woocommerce-cart, .woocommerce-checkout) .wc-block-components-totals-shipping__via {
  font-size: 0.8125rem;
  color: var(--sffr-muted);
}

/* Panel toggles ("Dodaj kupon", "Dostarcza do ...") read as brown text links. */
body:is(.woocommerce-cart, .woocommerce-checkout) .wc-block-components-panel__button {
  padding: 0;
  border: 0;
  background: none;
  font-family: 'Inter', sans-serif;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--sffr-brand);
}

body:is(.woocommerce-cart, .woocommerce-checkout) .wc-block-components-panel__button:hover,
body:is(.woocommerce-cart, .woocommerce-checkout) .wc-block-components-panel__button:focus-visible {
  background: none;
  color: var(--sffr-deep);
}

/* Coupon form: blush pill field + ghost button. */
body:is(.woocommerce-cart, .woocommerce-checkout) .wc-block-components-totals-coupon__form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  align-items: stretch;
  margin-top: 0.75rem;
}

body:is(.woocommerce-cart, .woocommerce-checkout) .wc-block-components-totals-coupon__form .wc-block-components-totals-coupon__input {
  flex: none;
  height: auto;
  width: 100%;
  min-width: 0;
  margin: 0;
}

body:is(.woocommerce-cart, .woocommerce-checkout) .wc-block-components-totals-coupon__input input {
  height: 2.75rem;
  padding: 1rem 1rem 0.25rem 1em;
  border: 1px solid transparent;
  border-radius: 999px;
  background: var(--sffr-surface-high);
  color: var(--sffr-ink);
  box-shadow: none;
}

body:is(.woocommerce-cart, .woocommerce-checkout) .wc-block-components-totals-coupon__input input:focus {
  border-color: var(--sffr-brand);
  box-shadow: 0 0 0 1px var(--sffr-brand);
  outline: none;
}

body:is(.woocommerce-cart, .woocommerce-checkout) .wc-block-components-totals-coupon__button,
body:is(.woocommerce-cart, .woocommerce-checkout) .wc-block-components-totals-coupon__button.contained {
  width: 100%;
  min-height: 2.75rem;
  padding: 0 1.25rem;
  border: 1px solid var(--sffr-brand);
  border-radius: 999px;
  background: transparent;
  color: var(--sffr-brand);
  font-family: 'Inter', sans-serif;
  font-size: 0.9375rem;
  font-weight: 600;
  text-decoration: none;
}

body:is(.woocommerce-cart, .woocommerce-checkout) .wc-block-components-totals-coupon__button:hover:not(:disabled),
body:is(.woocommerce-cart, .woocommerce-checkout) .wc-block-components-totals-coupon__button:focus-visible:not(:disabled) {
  background: var(--sffr-surface-high);
  color: var(--sffr-brand);
}

/* Shipping options as selectable cards. */
body:is(.woocommerce-cart, .woocommerce-checkout) .wc-block-components-radio-control {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 0.75rem;
}

body:is(.woocommerce-cart, .woocommerce-checkout) .wc-block-components-radio-control__option {
  position: relative;
  margin: 0;
  padding: 1rem 1.1rem 1rem 3.5rem;
  border: 1px solid var(--sffr-line);
  border-radius: 15px;
  background: var(--sffr-surface);
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

body:is(.woocommerce-cart, .woocommerce-checkout) .wc-block-components-radio-control__option:hover {
  border-color: var(--sffr-outline);
}

body:is(.woocommerce-cart, .woocommerce-checkout) .wc-block-components-radio-control__option-checked {
  border-color: var(--sffr-brand);
  box-shadow: 0 0 0 1px var(--sffr-brand);
}

body:is(.woocommerce-cart, .woocommerce-checkout) .wc-block-components-radio-control .wc-block-components-radio-control__option .wc-block-components-radio-control__input {
  position: absolute;
  top: 50%;
  left: 1.1rem;
  width: 1.25rem;
  height: 1.25rem;
  margin: 0;
  transform: translateY(-50%);
  appearance: none;
  display: grid;
  place-items: center;
  border: 1.5px solid var(--sffr-outline);
  border-radius: 50%;
  background: var(--sffr-surface);
}

body:is(.woocommerce-cart, .woocommerce-checkout) .wc-block-components-radio-control__input::before,
body:is(.woocommerce-cart, .woocommerce-checkout) .wc-block-components-radio-control__input::after {
  display: none;
}

body:is(.woocommerce-cart, .woocommerce-checkout) .wc-block-components-radio-control__input:checked {
  border-color: var(--sffr-brand);
  background: var(--sffr-brand);
  box-shadow: inset 0 0 0 4px var(--sffr-surface);
}

body:is(.woocommerce-cart, .woocommerce-checkout) .wc-block-components-radio-control__label,
body:is(.woocommerce-cart, .woocommerce-checkout) .wc-block-components-radio-control__secondary-label {
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--sffr-ink);
}

body:is(.woocommerce-cart, .woocommerce-checkout) .wc-block-components-radio-control__description {
  font-size: 0.8125rem;
  color: var(--sffr-muted);
}

/* Footer total. */
body:is(.woocommerce-cart, .woocommerce-checkout) .wc-block-components-sidebar .wc-block-components-totals-footer-item {
  align-items: baseline;
}

body:is(.woocommerce-cart, .woocommerce-checkout) .wc-block-components-totals-footer-item .wc-block-components-totals-item__label {
  font-weight: 600;
  color: var(--sffr-ink);
}

body:is(.woocommerce-cart, .woocommerce-checkout) .wc-block-components-totals-footer-item .wc-block-components-totals-item__value {
  font-family: 'Quicksand', sans-serif;
  font-size: 1.875rem;
  font-weight: 700;
  color: var(--sffr-deep);
}

body:is(.woocommerce-cart, .woocommerce-checkout) .wc-block-components-totals-footer-item .wc-block-components-totals-item__description {
  font-size: 0.8125rem;
  color: var(--sffr-outline);
}

/* Cart "Przejdź do płatności" and checkout "Kupuję i płacę": same honey pill as "Do koszyka". */
body:is(.woocommerce-cart, .woocommerce-checkout) .wc-block-cart__submit-container {
  padding: 0;
  margin-top: 0.5rem;
}

body:is(.woocommerce-cart, .woocommerce-checkout) .wc-block-cart__submit-button,
body:is(.woocommerce-cart, .woocommerce-checkout) .page-content a.wc-block-cart__submit-button,
body:is(.woocommerce-cart, .woocommerce-checkout) .wc-block-checkout__actions .wc-block-components-button.wc-block-components-checkout-place-order-button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 3.25rem;
  padding: 0 1.5rem;
  border: 0;
  border-radius: 999px;
  background: var(--sffr-accent);
  color: var(--sffr-on-accent);
  font-family: 'Inter', sans-serif;
  font-size: 1rem;
  font-weight: 600;
  text-decoration: none;
  transition: background-color 0.2s ease, color 0.2s ease;
}

body:is(.woocommerce-cart, .woocommerce-checkout) .wc-block-cart__submit-button:hover,
body:is(.woocommerce-cart, .woocommerce-checkout) .wc-block-cart__submit-button:focus-visible,
body:is(.woocommerce-cart, .woocommerce-checkout) .page-content a.wc-block-cart__submit-button:hover,
body:is(.woocommerce-cart, .woocommerce-checkout) .wc-block-checkout__actions .wc-block-components-button.wc-block-components-checkout-place-order-button:hover,
body:is(.woocommerce-cart, .woocommerce-checkout) .wc-block-checkout__actions .wc-block-components-button.wc-block-components-checkout-place-order-button:focus-visible {
  background: #ffcb6b; /* same hover as the homepage hero button */
  color: var(--sffr-on-accent);
}

body:is(.woocommerce-cart, .woocommerce-checkout) .wc-block-cart__submit-button .wc-block-components-button__text,
body:is(.woocommerce-cart, .woocommerce-checkout) .wc-block-checkout__actions .wc-block-components-button.wc-block-components-checkout-place-order-button .wc-block-components-button__text {
  text-decoration: none;
}

/* ---- Overrides that lose to Woo / base.css on specificity ---------------- */

body:is(.woocommerce-cart, .woocommerce-checkout) .wc-block-cart a.wc-block-components-product-name {
  text-decoration: none;
}

body:is(.woocommerce-cart, .woocommerce-checkout) .wc-block-components-sidebar .wc-block-cart__submit-container:not(.wc-block-cart__submit-container--sticky) {
  background: transparent;
}

body:is(.woocommerce-cart, .woocommerce-checkout) .wc-block-components-sidebar .wc-block-components-panel__button,
body:is(.woocommerce-cart, .woocommerce-checkout) .wc-block-components-sidebar .wc-block-components-totals-coupon {
  padding-inline: 0;
}

/* ---- Product facts in the cart and in the order summary ------------------------------------------- */
/* The short description is replaced by the facts chosen in WooCommerce > Dane na karcie
   (they arrive as item data), so the raw description is hidden here. */

body:is(.woocommerce-cart, .woocommerce-checkout) .wc-block-components-product-metadata__description {
  display: none;
}

body:is(.woocommerce-cart, .woocommerce-checkout) .wc-block-components-product-details {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

body:is(.woocommerce-cart, .woocommerce-checkout) .wc-block-components-product-details > div {
  margin: 0;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  background: rgba(253, 183, 66, 0.35);
  color: var(--sffr-on-accent);
  font-family: 'Inter', sans-serif;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
}

body:is(.woocommerce-cart, .woocommerce-checkout) .wc-block-components-product-details__name::after {
  content: ' ';
}

/* Coupon field: side padding for the typed text and the floating label
   (Woo's own input rules zero them out). */
body:is(.woocommerce-cart, .woocommerce-checkout) .wc-block-components-totals-coupon__form .wc-block-components-totals-coupon__input input {
  padding-left: 1em;
}

body:is(.woocommerce-cart, .woocommerce-checkout) .wc-block-components-totals-coupon__form .wc-block-components-totals-coupon__input label {
  padding-left: 0.5em;
}

/* ---- Tablet / phone ------------------------------------------------------ */

@media (max-width: 900px) {
  body:is(.woocommerce-cart, .woocommerce-checkout) .wc-block-components-sidebar-layout {
    grid-template-columns: minmax(0, 1fr);
    gap: 2rem;
  }

  body:is(.woocommerce-cart, .woocommerce-checkout) .wc-block-components-sidebar {
    position: static;
  }
}

@media (max-width: 560px) {
  body:is(.woocommerce-cart, .woocommerce-checkout) main.site-main {
    padding-inline: 1rem;
  }

  body:is(.woocommerce-cart, .woocommerce-checkout) .wc-block-components-sidebar-layout .wc-block-components-sidebar {
    padding: 1.25rem;
  }
}

/* Option cards: Woo's "highlight checked" variant adds a square inset ring; doubled class beats it. */
body:is(.woocommerce-cart, .woocommerce-checkout) .wc-block-components-radio-control.wc-block-components-radio-control .wc-block-components-radio-control__option {
  border-radius: 15px;
  box-shadow: none;
}

body:is(.woocommerce-cart, .woocommerce-checkout) .wc-block-components-radio-control.wc-block-components-radio-control .wc-block-components-radio-control__option-checked {
  border-color: var(--sffr-brand);
  box-shadow: 0 0 0 1px var(--sffr-brand);
}

/* Every shipping zone is Poland, so the "Dostarcza do ..." address line is noise on both pages. */
body:is(.woocommerce-cart, .woocommerce-checkout) .wc-block-components-totals-shipping .wc-block-components-shipping-address {
  display: none;
}

/* Product-fact pills may wrap in the narrow summary column. */
body:is(.woocommerce-cart, .woocommerce-checkout) .wc-block-components-product-details > div {
  border-radius: 1rem;
}

/* Woo draws an extra square outline around the whole option list ("highlight checked"); the cards have their own. */
body:is(.woocommerce-cart, .woocommerce-checkout) .wc-block-components-radio-control--highlight-checked::after,
body:is(.woocommerce-cart, .woocommerce-checkout) .wc-block-components-radio-control--highlight-checked .wc-block-components-radio-control__option::after,
body:is(.woocommerce-cart, .woocommerce-checkout) .wc-block-components-radio-control--highlight-checked .wc-block-components-radio-control__option-checked::after {
  display: none;
}

/* Phone: sticky "Przejdź do płatności" bar floats with space around it, no white panel or fade behind it. */
body.woocommerce-cart .wc-block-cart__submit-container.wc-block-cart__submit-container--sticky {
  padding: 0.75rem 1rem calc(0.75rem + env(safe-area-inset-bottom, 0px));
  margin-top: 0;
  background: transparent !important; /* Woo sets an inline white background from JS */
  box-shadow: none;
  border: 0;
}

body.woocommerce-cart .wc-block-cart__submit-container.wc-block-cart__submit-container--sticky::before {
  display: none;
}

/* ---- Cart summary on phones: a compact receipt (PC layout stays as is) ---- */
@media (max-width: 782px) {
  body.woocommerce-cart .wc-block-components-sidebar-layout .wc-block-components-sidebar {
    padding: 1.25rem 1.25rem 1.5rem;
    border-radius: 24px;
  }

  body.woocommerce-cart .wc-block-components-sidebar h2.wc-block-cart__totals-title {
    margin: 0 0 0.5rem;
    font-size: 1.25rem;
  }

  /* No hairline between every row: spacing groups them, one line sits above the total. */
  body.woocommerce-cart .wc-block-components-sidebar .wc-block-components-totals-wrapper {
    padding: 0.75rem 0;
    border-top: 0;
  }

  body.woocommerce-cart .wc-block-components-sidebar .wc-block-components-totals-wrapper:has(.wc-block-components-totals-coupon) {
    padding: 0.25rem 0 0.75rem;
    border-bottom: 1px solid var(--sffr-line);
  }

  body.woocommerce-cart .wc-block-components-sidebar .wc-block-components-totals-coupon .wc-block-components-panel__button {
    min-height: 2.75rem;
    font-size: 0.9375rem;
  }

  body.woocommerce-cart .wc-block-components-sidebar .wc-block-components-totals-item {
    align-items: baseline;
    gap: 1rem;
  }

  body.woocommerce-cart .wc-block-components-sidebar .wc-block-components-totals-item__label {
    font-size: 0.9375rem;
  }

  body.woocommerce-cart .wc-block-components-sidebar .wc-block-components-totals-item__value {
    font-size: 1rem;
    font-weight: 600;
    white-space: nowrap;
  }

  /* Shipping: carrier name sits under the label, price stays on the right. */
  body.woocommerce-cart .wc-block-components-sidebar .wc-block-components-totals-shipping .wc-block-components-totals-item {
    flex-wrap: wrap;
    row-gap: 0.125rem;
  }

  body.woocommerce-cart .wc-block-components-sidebar .wc-block-components-totals-shipping .wc-block-components-totals-item__description {
    flex-basis: 100%;
    order: 3;
    margin: 0;
    font-size: 0.8125rem;
    color: var(--sffr-muted);
  }

  /* Total: label left, big amount right, VAT note tucked under the amount. */
  body.woocommerce-cart .wc-block-components-sidebar .wc-block-components-totals-footer-item {
    flex-wrap: wrap;
    row-gap: 0.125rem;
    margin: 0;
    padding-top: 0.25rem;
  }

  body.woocommerce-cart .wc-block-components-sidebar .wc-block-components-totals-wrapper:has(.wc-block-components-totals-footer-item) {
    margin-top: 0.25rem;
    border-top: 1px solid var(--sffr-line);
    padding-top: 1rem;
  }

  body.woocommerce-cart .wc-block-components-totals-footer-item .wc-block-components-totals-item__value {
    font-size: 1.75rem;
    line-height: 1.1;
  }

  body.woocommerce-cart .wc-block-components-totals-footer-item .wc-block-components-totals-item__description {
    flex-basis: 100%;
    margin: 0;
    text-align: right;
    font-size: 0.8125rem;
    color: var(--sffr-muted);
  }

  body.woocommerce-cart .wc-block-components-sidebar .wc-block-cart__submit-container:not(.wc-block-cart__submit-container--sticky) {
    margin-top: 1rem;
  }
}

@media (max-width: 782px) {
  body.woocommerce-cart .wc-block-components-sidebar .wc-block-components-totals-coupon .wc-block-components-panel__button {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    margin: 0;
    padding: 0;
  }

  body.woocommerce-cart .wc-block-components-sidebar .wc-block-components-totals-coupon .wc-block-components-panel__button svg {
    position: static;
    margin: 0;
    flex: none;
  }

  body.woocommerce-cart .wc-block-components-sidebar .wc-block-components-totals-coupon .wc-block-components-panel__button-icon {
    position: static;
    margin: 0;
  }

  body.woocommerce-cart .wc-block-components-sidebar .wc-block-components-totals-wrapper:has(.wc-block-components-totals-shipping),
  body.woocommerce-cart .wc-block-components-sidebar .wc-block-components-totals-wrapper:has(.wc-block-components-totals-shipping) .wc-block-components-totals-shipping {
    padding-block: 0.25rem 0.5rem;
    margin: 0;
  }
}

@media (max-width: 782px) {
  body.woocommerce-cart .wc-block-components-sidebar .wc-block-components-totals-coupon .wc-block-components-panel__button .wc-block-components-panel__button-icon {
    order: 2;
    position: static;
    transform: none;
  }
}
