/*
 * Storefront redesign: cart page (body.itm-cart-page, woocommerce/cart/cart.php).
 * Tokens come from itm-base.css. Martfury and WooCommerce style the cart table
 * with many specific rules, so selectors here are anchored on the body class.
 */

/* Part A: page heading, notices, layout */
body.itm-cart-page #content {
  padding-bottom: 80px;
}

body.itm-cart-page .entry-content > .woocommerce {
  display: flex;
  flex-direction: column;
  gap: 32px;
  padding-top: 40px;
}

body.itm-cart-page .entry-content > .woocommerce::before,
body.itm-cart-page .entry-content > .woocommerce::after {
  display: none;
}

body.itm-cart-page .itm-cart-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px 14px;
}

body.itm-cart-page h1.itm-cart-head__title {
  margin: 0;
  font-family: var(--itm-font);
  font-size: 44px;
  font-weight: 700;
  line-height: 1.04;
  letter-spacing: -0.025em;
  text-transform: none;
  color: var(--itm-ink);
}

body.itm-cart-page .itm-cart-head__count {
  font-size: 17px;
  color: var(--itm-muted-2);
}

/* Lines card and summary card side by side; the summary drops below at ~930px. */
body.itm-cart-page .itm-cart-layout {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 32px;
}

body.itm-cart-page .itm-cart-lines {
  container-type: inline-size;
  flex: 999 1 560px;
  min-width: 0;
  margin: 0;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--itm-line);
  border-radius: 24px;
  background: var(--itm-white);
}

body.itm-cart-page .itm-cart-summary {
  flex: 1 1 340px;
  min-width: 0;
  margin: 0;
}

/* Part B: cart lines as a list (the table markup stays for WooCommerce). */
body.itm-cart-page.woocommerce-cart table.shop_table.cart,
body.itm-cart-page.woocommerce-cart table.shop_table.cart tbody {
  display: block;
  width: 100%;
  margin: 0 !important;
  border: 0;
  border-collapse: separate;
  border-radius: 0;
  background: none;
}

/* One row: thumbnail, name, quantity, total, remove. In a narrow lines card
   (below 680px) the three controls move together to a second row, right-aligned. */
body.itm-cart-page.woocommerce-cart table.shop_table.cart tr.cart_item {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr) auto auto auto;
  grid-template-areas: "thumb name qty total remove";
  align-items: center;
  gap: 16px 24px;
  margin: 0;
  padding: 28px;
  border: 0;
  border-bottom: 1px solid var(--itm-line);
  background: none;
}

body.itm-cart-page.woocommerce-cart table.shop_table.cart tr.cart_item td {
  display: block;
  width: auto;
  margin: 0;
  padding: 0 !important; /* Martfury: 10px 0 (desktop), 0 0 10px (phone) */
  border: 0;
  background: none;
  text-align: left;
  vertical-align: middle;
}

body.itm-cart-page.woocommerce-cart table.shop_table.cart thead {
  position: absolute !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

/* WooCommerce's small-screen table adds a "Title:" label before each cell. */
body.itm-cart-page.woocommerce-cart table.shop_table.cart tr.cart_item td::before {
  display: none;
}

body.itm-cart-page.woocommerce-cart table.shop_table.cart tr.cart_item td.product-thumbnail {
  grid-area: thumb;
  width: 72px !important; /* Martfury collapses it on phones */
  min-width: 0;
}

body.itm-cart-page.woocommerce-cart table.shop_table.cart td.product-thumbnail a {
  position: static !important; /* Martfury positions it absolutely on phones */
  display: block;
}

body.itm-cart-page.woocommerce-cart table.shop_table.cart td.product-thumbnail picture {
  display: contents;
}

body.itm-cart-page.woocommerce-cart table.shop_table.cart td.product-thumbnail img {
  display: block;
  width: 72px !important;
  max-width: none;
  height: 72px !important;
  margin: 0 !important; /* Martfury shifts it left on phones */
  position: static !important;
  border-radius: 18px;
  background: var(--itm-soft);
  object-fit: contain;
}

body.itm-cart-page.woocommerce-cart table.shop_table.cart tr.cart_item td.product-name {
  grid-area: name;
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}

body.itm-cart-page.woocommerce-cart table.shop_table.cart td.product-name > a {
  font-family: var(--itm-font);
  font-size: 18px;
  font-weight: 600;
  line-height: 1.25;
  color: var(--itm-ink);
}

body.itm-cart-page.woocommerce-cart table.shop_table.cart td.product-name > a:hover {
  text-decoration: underline;
}

body.itm-cart-page .itm-cart-line__unit .amount {
  display: inline !important; /* hidden next to product names by older theme CSS */
}

body.itm-cart-page .itm-cart-line__unit,
body.itm-cart-page .itm-cart-line__unit .amount {
  font-size: 14px;
  font-weight: 400;
  line-height: 1.4;
  color: var(--itm-muted-2) !important;
}

body.itm-cart-page .itm-cart-line__unit br,
body.itm-cart-page .itm-cart-line__unit .woocommerce-price-suffix {
  display: none;
}

/* Product meta: one muted mono line ("Resurse: 10 · …"). */
body.itm-cart-page.woocommerce-cart table.shop_table.cart td.product-name dl.variation {
  display: flex;
  flex-wrap: wrap;
  gap: 0 6px;
  margin: 0;
  font-family: var(--itm-font-mono);
  font-size: 12px;
  line-height: 1.5;
  color: var(--itm-muted-3);
}

body.itm-cart-page.woocommerce-cart table.shop_table.cart td.product-name dl.variation :is(dt, dd, p) {
  float: none;
  margin: 0;
  padding: 0;
  font: inherit;
  color: inherit;
}

body.itm-cart-page.woocommerce-cart table.shop_table.cart td.product-name dl.variation dd + dt::before {
  content: "\00b7";
  margin-right: 6px;
}

/* Controls: quantity, line total and remove stay together on the right. */
body.itm-cart-page.woocommerce-cart table.shop_table.cart td.product-quantity {
  grid-area: qty;
}

body.itm-cart-page.woocommerce-cart table.shop_table.cart td.product-remove {
  grid-area: remove;
}

@container (max-width: 680px) {
  body.itm-cart-page.woocommerce-cart table.shop_table.cart tr.cart_item {
    grid-template-areas:
      "thumb name name name name"
      ". . qty total remove";
    gap: 14px 16px;
  }
}

body.itm-cart-page.woocommerce-cart table.shop_table.cart td.product-quantity .quantity {
  margin: 0;
}

body.itm-cart-page.woocommerce-cart table.shop_table.cart td.product-quantity .qty-box {
  display: inline-flex;
  align-items: center;
  width: auto;
  height: 44px;
  margin: 0;
  padding: 0;
  border: 1px solid var(--itm-input-border) !important;
  border-radius: 999px !important;
  background: var(--itm-white);
}

body.itm-cart-page.woocommerce-cart table.shop_table.cart td.product-quantity .qty-box :is(.increase, .decrease) {
  position: static;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 42px;
  margin: 0;
  font-size: 15px;
  color: var(--itm-muted);
  cursor: pointer;
  transform: none;
}

body.itm-cart-page.woocommerce-cart table.shop_table.cart td.product-quantity .qty-box :is(.increase, .decrease):hover {
  color: var(--itm-ink);
}

body.itm-cart-page.woocommerce-cart table.shop_table.cart td.product-quantity .qty-box input.qty {
  width: 28px;
  height: 42px;
  margin: 0;
  padding: 0;
  border: 0 !important;
  background: none;
  box-shadow: none;
  font-family: var(--itm-font);
  font-size: 16px;
  font-weight: 600;
  text-align: center;
  color: var(--itm-ink);
  -moz-appearance: textfield;
}

body.itm-cart-page.woocommerce-cart table.shop_table.cart td.product-quantity .qty-box input.qty::-webkit-inner-spin-button,
body.itm-cart-page.woocommerce-cart table.shop_table.cart td.product-quantity .qty-box input.qty::-webkit-outer-spin-button {
  margin: 0;
  -webkit-appearance: none;
}

body.itm-cart-page.woocommerce-cart table.shop_table.cart td.product-subtotal {
  grid-area: total;
  min-width: 120px;
  text-align: right;
}

body.itm-cart-page.woocommerce-cart table.shop_table.cart td.product-subtotal,
body.itm-cart-page.woocommerce-cart table.shop_table.cart td.product-subtotal .amount {
  font-size: 18px;
  font-weight: 700;
  white-space: nowrap;
  color: var(--itm-ink) !important;
}

body.itm-cart-page.woocommerce-cart table.shop_table.cart td.product-subtotal :is(br, small, .woocommerce-price-suffix) {
  display: none;
}

body.itm-cart-page.woocommerce-cart table.shop_table.cart td.product-remove a.itm-cart-line__remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--itm-line);
  border-radius: 50%;
  background: var(--itm-white);
  font-size: 20px;
  line-height: 1;
  color: var(--itm-muted-2) !important;
}

body.itm-cart-page.woocommerce-cart table.shop_table.cart td.product-remove a.itm-cart-line__remove:hover {
  border-color: var(--itm-ink);
  color: var(--itm-ink) !important;
}

/* Footer row: back to the shop on the left, empty cart on the right. */
body.itm-cart-page.woocommerce-cart table.shop_table.cart tr.itm-cart-actions {
  display: block;
}

body.itm-cart-page.woocommerce-cart table.shop_table.cart tr.itm-cart-actions td.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 28px;
  border: 0;
  background: none;
}

body.itm-cart-page .itm-cart-actions__back {
  font-size: 15px;
  font-weight: 600;
  color: var(--itm-ink);
}

body.itm-cart-page .itm-cart-actions__back:hover {
  text-decoration: underline;
}

body.itm-cart-page.woocommerce-cart table.shop_table.cart td.actions .btn-update.hidden {
  display: none;
}

body.itm-cart-page.woocommerce-cart table.shop_table.cart td.actions button.empty-cart-button {
  float: none;
  width: auto !important; /* Martfury: full width on phones */
  height: auto;
  margin: 0 0 0 auto;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: none !important;
  box-shadow: none;
  font-family: var(--itm-font);
  font-size: 15px;
  font-weight: 400 !important;
  line-height: 1.4;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-transform: none;
  color: var(--itm-muted-2) !important;
}

body.itm-cart-page.woocommerce-cart table.shop_table.cart td.actions button.empty-cart-button:hover {
  color: var(--itm-ink) !important;
}

/* Part C: summary card (woocommerce/cart/cart-totals.php). */
body.itm-cart-page .cart-collaterals .cart_totals.itm-cart-totals {
  float: none;
  display: flex;
  flex-direction: column;
  gap: 18px;
  width: 100%;
  margin: 0;
  padding: 28px;
  border: 1px solid var(--itm-line);
  border-radius: 24px;
  background: var(--itm-white);
}

body.itm-cart-page .itm-cart-totals h2.itm-cart-totals__title {
  display: block !important; /* Martfury hides the cart totals heading */
  margin: 0;
  padding: 0;
  border: 0;
  font-family: var(--itm-font);
  font-size: 20px;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: 0;
  text-align: left;
  text-transform: none;
  color: var(--itm-ink);
}

body.itm-cart-page .itm-cart-totals table.itm-cart-totals__table,
body.itm-cart-page .itm-cart-totals table.itm-cart-totals__table tbody {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  margin: 0 !important;
  padding: 0 !important; /* Martfury: bordered box with 30px sides */
  border: 0 !important;
  background: none;
}

body.itm-cart-page .itm-cart-totals table.itm-cart-totals__table tr {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
}

body.itm-cart-page .itm-cart-totals table.itm-cart-totals__table :is(th, td) {
  display: block;
  width: auto;
  margin: 0;
  padding: 0 !important; /* Martfury pads totals rows */
  border: 0 !important;
  background: none;
  font-family: var(--itm-font);
  font-size: 15px;
  font-weight: 400;
  line-height: 1.4;
  text-align: left;
  text-transform: none;
  color: var(--itm-ink-2);
}

body.itm-cart-page .itm-cart-totals table.itm-cart-totals__table td {
  text-align: right;
}

body.itm-cart-page .itm-cart-totals table.itm-cart-totals__table td::before {
  display: none;
}

body.itm-cart-page .itm-cart-totals table.itm-cart-totals__table td,
body.itm-cart-page .itm-cart-totals table.itm-cart-totals__table td .amount {
  font-weight: 600;
  color: var(--itm-ink) !important;
}

body.itm-cart-page .itm-cart-totals table.itm-cart-totals__table tr.order-total {
  align-items: flex-end;
  margin-top: 6px;
  padding-top: 18px;
  border-top: 1px solid var(--itm-line);
}

body.itm-cart-page .itm-cart-totals table.itm-cart-totals__table tr.order-total th {
  font-size: 17px;
  font-weight: 600;
  color: var(--itm-ink);
}

body.itm-cart-page .itm-cart-totals table.itm-cart-totals__table tr.order-total td,
body.itm-cart-page .itm-cart-totals table.itm-cart-totals__table tr.order-total td :is(strong, .amount) {
  font-size: 30px !important; /* Martfury sets 20px on the order total */
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.015em;
  white-space: nowrap;
}

/* Anything custom_tax_value() adds after the amount sits under it, small. */
body.itm-cart-page .itm-cart-totals table.itm-cart-totals__table tr.order-total td small {
  display: block;
  margin-top: 4px;
  font-size: 13px;
  font-weight: 400;
  letter-spacing: 0;
  color: var(--itm-muted-3);
}

body.itm-cart-page .itm-cart-totals .wc-proceed-to-checkout {
  margin: 0;
  padding: 0;
}

body.itm-cart-page .itm-cart-totals .wc-proceed-to-checkout a.checkout-button {
  display: flex !important; /* Martfury: block with its own line height */
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 52px;
  margin: 0;
  padding: 0 12px;
  white-space: nowrap;
  border: 0;
  border-radius: 999px !important;
  background: var(--itm-ink) !important;
  box-shadow: none;
  font-family: var(--itm-font);
  font-size: 16px;
  font-weight: 600 !important;
  line-height: 1.2;
  text-align: center;
  text-transform: none;
  color: var(--itm-white) !important;
}

body.itm-cart-page .itm-cart-totals .wc-proceed-to-checkout a.checkout-button:hover {
  background: var(--itm-ink-2) !important;
}

body.itm-cart-page .itm-cart-totals .itm-cart-totals__trust {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 0;
  padding: 18px 0 0;
  border-top: 1px solid var(--itm-line);
  list-style: none;
}

body.itm-cart-page .itm-cart-totals .itm-cart-totals__trust li {
  margin: 0;
  padding: 0;
  font-size: 14px;
  line-height: 1.4;
  color: var(--itm-ink-2);
}

body.itm-cart-page .itm-cart-totals .itm-cart-totals__trust li::before {
  content: "\2713";
  margin-right: 6px;
  color: var(--itm-ink);
}

body.itm-cart-page .itm-cart-totals .itm-cart-totals__badge img {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--itm-row-line, #f1ece5);
  border-radius: 12px;
}

body.itm-cart-page .itm-cart-totals a.itm-cart-totals__quote {
  font-size: 14px;
  font-weight: 600;
  text-align: center;
  color: var(--itm-ink);
}

body.itm-cart-page .itm-cart-totals a.itm-cart-totals__quote:hover {
  text-decoration: underline;
}

/* Part E: empty cart (woocommerce/cart/cart-empty.php). */
body.itm-cart-page .itm-cart-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  padding: 72px 24px;
  border: 1px solid var(--itm-line);
  border-radius: 24px;
  background: var(--itm-white);
  text-align: center;
}

body.itm-cart-page .itm-cart-empty__count {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--itm-soft);
  font-family: var(--itm-font-mono);
  font-size: 20px;
  color: var(--itm-muted-2);
}

body.itm-cart-page .itm-cart-empty p.cart-empty.itm-cart-empty__text {
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  font-family: var(--itm-font);
  font-size: 26px;
  font-weight: 700;
  line-height: 1.25;
  color: var(--itm-ink);
  text-wrap: balance;
}

body.itm-cart-page .itm-cart-empty p.cart-empty.itm-cart-empty__text::before {
  display: none;
}

body.itm-cart-page .itm-cart-empty .return-to-shop {
  margin: 0;
  padding: 0;
}

body.itm-cart-page .itm-cart-empty a.itm-cart-empty__button {
  display: inline-flex !important;
  align-items: center;
  height: 52px;
  margin: 0;
  padding: 0 28px;
  border: 0;
  border-radius: 999px !important;
  background: var(--itm-ink) !important;
  box-shadow: none;
  font-family: var(--itm-font);
  font-size: 16px;
  font-weight: 600 !important;
  line-height: 1.2;
  text-transform: none;
  color: var(--itm-white) !important;
}

body.itm-cart-page .itm-cart-empty a.itm-cart-empty__button:hover {
  background: var(--itm-ink-2) !important;
}

body.itm-cart-page .itm-cart-empty a.itm-cart-empty__button::before {
  display: none;
}

/* Part D: cross-sells in the category product card (itm-base.css). */
body.itm-cart-page .cross-sells {
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin: 0;
  padding-top: 48px;
}

body.itm-cart-page .cross-sells > h2 {
  margin: 0 !important;
  padding: 0;
  font-family: var(--itm-font);
  font-size: 30px;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.015em;
  text-align: left !important; /* Martfury centres related-product headings */
  text-transform: none;
  color: var(--itm-ink);
}

body.itm-cart-page .cross-sells > h2::after {
  display: none;
}

/* Keyboard focus: 2px ink outline. */
body.itm-cart-page :is(.qty-box .increase, .qty-box .decrease, input.qty, .itm-cart-line__remove, .itm-cart-actions__back, .empty-cart-button, .checkout-button):focus-visible {
  outline: 2px solid var(--itm-ink);
  outline-offset: 2px;
}

@media (max-width: 1100px) {
  body.itm-cart-page h1.itm-cart-head__title {
    font-size: 38px;
  }
}

@media (max-width: 760px) {
  body.itm-cart-page .entry-content > .woocommerce {
    gap: 24px;
    padding-top: 24px;
  }

  body.itm-cart-page h1.itm-cart-head__title {
    font-size: 32px;
  }

  body.itm-cart-page.woocommerce-cart table.shop_table.cart tr.cart_item {
    padding: 18px;
  }

  /* Quantity, total and remove share one row under the name. */
  body.itm-cart-page.woocommerce-cart table.shop_table.cart td.product-subtotal {
    min-width: 0;
  }

  body.itm-cart-page.woocommerce-cart table.shop_table.cart tr.itm-cart-actions td.actions {
    padding: 18px;
  }
  body.itm-cart-page .itm-cart-empty {
    padding: 40px 24px;
  }

  body.itm-cart-page .itm-cart-empty p.cart-empty.itm-cart-empty__text {
    font-size: 20px;
  }

  body.itm-cart-page .cross-sells {
    padding-top: 24px;
  }

  body.itm-cart-page .cross-sells > h2 {
    font-size: 24px;
  }

  /* Two cards per row on phones, as in the design (the catalog drops to one below 480px). */
  body.itm-cart-page .cross-sells ul.products:not(.slick-slider) {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
}
