/*
 * HYGSI.SK: linked package values + quantity discounts layout fix.
 *
 * Some products contain both a virtual package/variant selector and Shoptet's
 * quantity-discount table. Earlier desktop compacting rules fixed the variant
 * grid row to 50 px; the selector is much taller, so it rendered on top of the
 * price/discount table and, around 992-1024 px, on top of the cart controls.
 *
 * Scope is deliberately narrow: ordinary products, products with only
 * quantity discounts and manual product sets are unchanged.
 */

@media (min-width: 1025px) {
  html body.type-detail:not(.hygsi-manual-set)
  #product-detail-form.hygsi-buy-form.hygsi-has-quantity-discounts:has(> .hygsi-linked-variants) {
    display: grid !important;
    grid-template-columns: 125px minmax(0, 1fr) 58px !important;
    grid-template-areas:
      "info discounts discounts"
      "variants variants variants"
      "quantity buy favorite" !important;
    grid-template-rows: auto auto 58px !important;
    align-items: start !important;
    align-content: start !important;
  }

  html body.type-detail:not(.hygsi-manual-set)
  #product-detail-form.hygsi-buy-form.hygsi-has-quantity-discounts:has(> .hygsi-linked-variants)
  > .hygsi-purchase-info {
    grid-column: 1 / 2 !important;
    grid-row: 1 / 2 !important;
    align-self: start !important;
  }

  html body.type-detail:not(.hygsi-manual-set)
  #product-detail-form.hygsi-buy-form.hygsi-has-quantity-discounts:has(> .hygsi-linked-variants)
  > .hygsi-quantity-discounts {
    grid-column: 2 / 4 !important;
    grid-row: 1 / 2 !important;
    align-self: start !important;
  }

  html body.type-detail:not(.hygsi-manual-set)
  #product-detail-form.hygsi-buy-form.hygsi-has-quantity-discounts:has(> .hygsi-linked-variants)
  > .hygsi-linked-variants {
    grid-column: 1 / 4 !important;
    grid-row: 2 / 3 !important;
    align-self: start !important;
    width: 100% !important;
    min-width: 0 !important;
    margin: 40px 0 52px !important;
  }

  html body.type-detail:not(.hygsi-manual-set)
  #product-detail-form.hygsi-buy-form.hygsi-has-quantity-discounts:has(> .hygsi-linked-variants)
  .p-to-cart-block > .add-to-cart {
    grid-column: 1 / 2 !important;
    grid-row: 3 / 4 !important;
  }

  html body.type-detail:not(.hygsi-manual-set)
  #product-detail-form.hygsi-buy-form.hygsi-has-quantity-discounts:has(> .hygsi-linked-variants)
  .p-to-cart-block > .add-to-cart-button {
    grid-column: 2 / 3 !important;
    grid-row: 3 / 4 !important;
  }

  html body.type-detail:not(.hygsi-manual-set)
  #product-detail-form.hygsi-buy-form.hygsi-has-quantity-discounts:has(> .hygsi-linked-variants)
  > .hygsi-watchdog-button {
    grid-column: 3 / 4 !important;
    grid-row: 3 / 4 !important;
  }
}

@media (max-width: 1024px) {
  html body.type-detail:not(.hygsi-manual-set)
  #product-detail-form.hygsi-buy-form.hygsi-has-quantity-discounts:has(> .hygsi-linked-variants) {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    grid-template-areas:
      "info"
      "discounts"
      "variants"
      "quantity"
      "buy" !important;
    grid-template-rows: auto auto auto 58px 58px !important;
    align-items: start !important;
    align-content: start !important;
    width: 100% !important;
    min-width: 0 !important;
    column-gap: 0 !important;
  }

  html body.type-detail:not(.hygsi-manual-set)
  #product-detail-form.hygsi-buy-form.hygsi-has-quantity-discounts:has(> .hygsi-linked-variants)
  > .hygsi-purchase-info {
    grid-column: 1 !important;
    grid-row: 1 !important;
    width: 100% !important;
    min-width: 0 !important;
  }

  html body.type-detail:not(.hygsi-manual-set)
  #product-detail-form.hygsi-buy-form.hygsi-has-quantity-discounts:has(> .hygsi-linked-variants)
  > .hygsi-quantity-discounts {
    grid-column: 1 !important;
    grid-row: 2 !important;
    width: 100% !important;
    max-width: none !important;
    min-width: 0 !important;
    margin: 28px 0 0 !important;
    align-self: start !important;
    justify-self: stretch !important;
  }

  html body.type-detail:not(.hygsi-manual-set)
  #product-detail-form.hygsi-buy-form.hygsi-has-quantity-discounts:has(> .hygsi-linked-variants)
  > .hygsi-linked-variants {
    grid-column: 1 !important;
    grid-row: 3 !important;
    width: 100% !important;
    min-width: 0 !important;
    margin: 28px 0 44px !important;
    align-self: start !important;
  }

  html body.type-detail:not(.hygsi-manual-set)
  #product-detail-form.hygsi-buy-form.hygsi-has-quantity-discounts:has(> .hygsi-linked-variants)
  .p-to-cart-block > .add-to-cart {
    grid-column: 1 !important;
    grid-row: 4 !important;
    width: 100% !important;
    min-width: 0 !important;
  }

  html body.type-detail:not(.hygsi-manual-set)
  #product-detail-form.hygsi-buy-form.hygsi-has-quantity-discounts:has(> .hygsi-linked-variants)
  .p-to-cart-block > .add-to-cart-button {
    grid-column: 1 !important;
    grid-row: 5 !important;
    width: 100% !important;
    min-width: 0 !important;
  }
}
