/*
 * KKSET mobile layout fixes 1.1.1.
 * Each rule is scoped to the audited component and narrowest affected width.
 */

/* Keep desktop mega-menu centering from shifting open mobile submenus left. */
@media (max-width: 1190px) {
  body .kkset-primary-nav .kkset-has-mega:hover > .kkset-mega-menu,
  body .kkset-primary-nav .kkset-has-mega:focus-within > .kkset-mega-menu,
  body .kkset-primary-nav .kkset-has-mega.is-open > .kkset-mega-menu {
    transform: none;
  }
}

/* Keep frequently used storefront controls at a reliable mobile tap size. */
@media (max-width: 767px) {
  body .kkset-mobile-toggle,
  body .kkset-icon-button,
  body .kkset-nav-trigger button,
  body .kkset-search-close {
    min-width: 44px;
    min-height: 44px;
  }

  body .kkset-mobile-toggle,
  body .kkset-icon-button {
    width: 44px;
    height: 44px;
  }

  body .kkset-search-close {
    display: grid;
    place-items: center;
    padding: 0;
  }

  body .kkset-primary-nav .kkset-nav-list > li > a,
  body .kkset-primary-nav .kkset-nav-trigger > a,
  body .kkset-primary-nav .kkset-mega-column a {
    min-height: 44px;
    display: flex;
    align-items: center;
  }

  body.woocommerce-cart
  .wc-block-components-quantity-selector
  .wc-block-components-quantity-selector__button,
  body.woocommerce-cart
  .wc-block-components-quantity-selector
  .wc-block-components-quantity-selector__input,
  body.woocommerce-cart .quantity .minus,
  body.woocommerce-cart .quantity .plus,
  body.woocommerce-cart .quantity .qty {
    min-width: 44px;
    min-height: 44px;
  }

  body.woocommerce-cart .wc-block-cart-item__remove-link,
  body.woocommerce-cart a.remove {
    min-width: 44px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  /* Keep the WhatsApp shortcut clear of the fixed product purchase bar. */
  body.single-product.kkset-product-page-v15 .kkset-wa-float {
    bottom: calc(88px + env(safe-area-inset-bottom)) !important;
  }

  /* Payment actions must remain unobstructed; support remains available elsewhere. */
  body.woocommerce-cart .kkset-wa-float,
  body.woocommerce-checkout .kkset-wa-float {
    display: none !important;
  }
}

/* Four fixed 52px cards do not fit the 320-389px commerce-hero column. */
@media (max-width: 389px) {
  body.kkset-enhanced-category
  .kkset-category-page--commerce
  .kkset-commerce-stage {
    grid-template-columns: repeat(2, 52px);
  }
}

/* Prevent WooCommerce Blocks from creating implicit cart columns at 320-360px. */
@media (max-width: 360px) {
  body.woocommerce-cart
  .wp-block-woocommerce-cart
  .wc-block-cart
  table.wc-block-cart-items
  .wc-block-cart-items__row {
    grid-template-columns: 80px minmax(0, 1fr);
    column-gap: 12px;
  }

  body.woocommerce-cart
  .wp-block-woocommerce-cart
  .wc-block-cart
  table.wc-block-cart-items
  .wc-block-cart-items__row
  .wc-block-cart-item__image {
    grid-column: 1;
    padding-right: 12px;
  }

  body.woocommerce-cart
  .wp-block-woocommerce-cart
  .wc-block-cart
  table.wc-block-cart-items
  .wc-block-cart-items__row
  .wc-block-cart-item__product {
    grid-column: 2 / -1;
    min-width: 0;
  }

  body.woocommerce-cart
  .wp-block-woocommerce-cart
  .wc-block-cart
  table.wc-block-cart-items
  .wc-block-cart-items__row
  .wc-block-cart-item__total {
    grid-column: 2;
    grid-row: 2;
    justify-self: end;
    min-width: max-content;
  }

  body.woocommerce-cart
  .wp-block-woocommerce-cart
  .wc-block-cart-item__wrap,
  body.woocommerce-cart
  .wp-block-woocommerce-cart
  .wc-block-components-product-name {
    min-width: 0;
    max-width: 100%;
    overflow-wrap: anywhere;
  }
}
