/*
 * Minis3D — official WooCommerce Mix and Match 2.9.5 presentation only.
 * The plugin owns the form, quantities, reset, validation, price and cart data.
 * No copied templates, substitute selector, generated product images or engine.
 * Paint reuses the approved theme tokens and native product-card vocabulary.
 * Scope: the real `elegi` product, identified by the server-side m3-elegi class.
 * Load after minis3d-theme and wc-mnm-frontend. Native Grid + Inline layout.
 */

/* The theme's ordinary cart is a flex row; the complete MiM form is not. */
body.single-product.m3-elegi form.mnm_form {
  display: block;
  width: 100%;
  min-width: 0;
  margin: 20px 0 0;
  color: var(--m3-ink);
  font-family: var(--m3-font);
}

/* Real child products keep their native DOM and source order at every width. */
body.single-product.m3-elegi form.mnm_form.layout_grid ul.mnm_child_products {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 148px), 1fr));
  gap: 12px;
  width: 100%;
  min-width: 0;
  margin: 0 0 16px;
  padding: 0;
  list-style: none;
}

/* Woo's clearfix pseudo-elements would otherwise occupy grid cells. */
body.single-product.m3-elegi form.mnm_form.layout_grid ul.mnm_child_products::before,
body.single-product.m3-elegi form.mnm_form.layout_grid ul.mnm_child_products::after {
  content: none;
}

body.single-product.m3-elegi form.mnm_form.layout_grid ul.mnm_child_products > li.child-item {
  display: flex;
  flex-direction: column;
  gap: 8px;
  float: none;
  clear: none;
  width: 100% !important;
  min-width: 0;
  margin: 0 !important;
  padding: 10px;
  border: 1px solid var(--m3-line);
  border-radius: 14px;
  background: #fff;
  text-align: center;
  box-shadow: none;
}

body.single-product.m3-elegi form.mnm_form.layout_grid .child-item > .product-thumbnail,
body.single-product.m3-elegi form.mnm_form.layout_grid .child-item > .product-details,
body.single-product.m3-elegi form.mnm_form.layout_grid .child-item > .product-quantity {
  flex: 0 0 auto;
  width: 100%;
  min-width: 0;
  margin: 0;
  padding: 0;
  text-align: center;
}

body.single-product.m3-elegi form.mnm_form.layout_grid .child-item > .product-quantity {
  margin-top: auto;
}

/* Preserve the real Woo image and aspect ratio; never crop a mini to a tile. */
body.single-product.m3-elegi form.mnm_form.layout_grid .mnm_child_product_images,
body.single-product.m3-elegi form.mnm_form.layout_grid .mnm_child_product_image {
  width: 100%;
  margin: 0;
}

body.single-product.m3-elegi form.mnm_form.layout_grid .mnm_child_product_image img {
  display: block;
  width: 100%;
  height: 132px;
  margin: 0 auto;
  object-fit: contain;
  object-position: center;
}

body.single-product.m3-elegi form.mnm_form .child-item .woocommerce-loop-product__title {
  margin: 0;
  padding: 0;
  color: var(--m3-purple);
  font-family: var(--m3-font);
  font-size: 16px;
  font-weight: 800;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

body.single-product.m3-elegi form.mnm_form .child-item .woocommerce-loop-product__title a {
  color: inherit;
  text-decoration: none;
}

body.single-product.m3-elegi form.mnm_form .child-item .woocommerce-loop-product__title a:hover {
  text-decoration: underline;
}

body.single-product.m3-elegi form.mnm_form .child-item .product-quantity .quantity {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  width: 128px;
  max-width: 100%;
  min-width: 0;
  height: 46px;
  margin: 0 auto !important;
  padding: 0;
  border: 1px solid var(--m3-control-line);
  border-radius: var(--m3-quantity-radius);
  background: #fff;
}

/* Override only the theme's generic CTA paint, not the native button state.
 * Do not set display: the plugin hides these buttons when JavaScript is absent.
 */
body.single-product.m3-elegi form.mnm_form .child-item .product-quantity button.button--minus,
body.single-product.m3-elegi form.mnm_form .child-item .product-quantity button.button--plus {
  flex: 0 0 44px;
  width: 44px;
  min-width: 44px;
  height: 44px;
  min-height: 44px;
  margin: 0;
  padding: 0 !important;
  border: 0 !important;
  border-radius: 9px !important;
  background: transparent !important;
  color: var(--m3-purple) !important;
  font-size: 24px;
  font-weight: 700;
  line-height: 1 !important;
  box-shadow: none !important;
}

body.single-product.m3-elegi form.mnm_form .child-item .product-quantity button.button--minus:hover:not(:disabled),
body.single-product.m3-elegi form.mnm_form .child-item .product-quantity button.button--plus:hover:not(:disabled) {
  background: var(--m3-lilac) !important;
}

body.single-product.m3-elegi form.mnm_form .child-item .product-quantity input.mnm-quantity {
  flex: 1 1 36px;
  width: 36px !important;
  min-width: 0;
  height: 44px;
  margin: 0;
  padding: 0;
  color: var(--m3-purple);
  font-size: 16px;
  font-weight: 800;
  line-height: 1.2;
  text-align: center;
}

body.single-product.m3-elegi form.mnm_form .child-item .stock,
body.single-product.m3-elegi form.mnm_form .child-item .unavailable {
  margin: 0;
  font-size: 14px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

/* Preserve readable availability, not the plugin's 50%-opacity text. */
body.single-product.m3-elegi form.mnm_form .child-item.outofstock,
body.single-product.m3-elegi form.mnm_form .child-item.unavailable {
  opacity: 1;
}

/* These are the native reset and status, with native visibility untouched. */
body.single-product.m3-elegi form.mnm_form .mnm_reset {
  min-height: 44px;
  margin: 0 0 12px !important;
  padding: 10px 16px !important;
  background: #fff !important;
  color: var(--m3-purple) !important;
}

body.single-product.m3-elegi form.mnm_form .mnm_status {
  width: 100%;
  min-width: 0;
}

body.single-product.m3-elegi form.mnm_form .mnm_price {
  margin: 8px 0 12px;
  color: var(--m3-purple);
  font-family: var(--m3-font);
  font-size: 18px;
  line-height: 1.5;
}

body.single-product.m3-elegi form.mnm_form .mnm_message {
  margin: 0 0 14px;
  border-radius: 13px;
  background: var(--m3-lilac);
  color: var(--m3-ink);
  font-size: 16px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

body.single-product.m3-elegi form.mnm_form .mnm_message_content {
  margin: 0;
  padding: 0;
  list-style: none;
}

body.single-product.m3-elegi form.mnm_form .mnm_button_wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-width: 0;
  margin-top: 12px;
}

body.single-product.m3-elegi form.mnm_form .mnm_button_wrap .single_add_to_cart_button {
  flex: 1 1 190px;
  margin: 0;
}

body.single-product.m3-elegi form.mnm_form :is(button, a, input):focus-visible {
  outline: 3px solid var(--m3-purple);
  outline-offset: 3px;
}

@media (max-width: 767px) {
  body.single-product.m3-elegi form.mnm_form {
    margin-top: 16px;
  }

  body.single-product.m3-elegi form.mnm_form.layout_grid ul.mnm_child_products {
    gap: 10px;
  }

  body.single-product.m3-elegi form.mnm_form.layout_grid .mnm_child_product_image img {
    height: 116px;
  }
}

@media (max-width: 359px) {
  body.single-product.m3-elegi form.mnm_form.layout_grid ul.mnm_child_products {
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 140px), 1fr));
    gap: 8px;
  }

  body.single-product.m3-elegi form.mnm_form.layout_grid ul.mnm_child_products > li.child-item {
    padding: 5px;
  }
}
