/* Taj Catalog 5.49.5 - product card alignment on phones (home page "Popular products" and every other card grid).
   Separate file so taj-catalog.css stays untouched and a cached copy of it can never hide these rules.

   What was wrong on a phone (3 cards per row on the home page):
   1. "Add to cart" wraps onto two lines in a narrow card, so the button became taller than the quantity box beside it.
   2. The "Extra packing on delivery" tag could not wrap, so it ran out of its card over the neighbouring card and
      pushed the price of that card higher than the prices of the other cards in the row.
   3. A card without a quantity box (Read more / Ask Price) started its button row at a different height. */

/* A. Everywhere: the quantity box is always exactly as tall as the Add to cart button next to it. */
body.taj-active .taj-addcart .taj-qty {
    height: auto !important;
    min-height: 38px;
    align-self: stretch;
    box-sizing: border-box;
}

/* B. Everywhere: the "Extra packing" tag stays inside its card (wraps instead of overflowing). */
body.taj-active .taj-card-buy .taj-pack-badge {
    box-sizing: border-box;
    max-width: 100%;
    margin: 0;
    white-space: normal;
    line-height: 1.25;
}

/* C. Home page on phones: 3 cards per row. */
@media (max-width: 720px) {
    /* Tag goes ABOVE the price, so the price and the buttons sit at the same height in every card of the row. */
    body.taj-active.taj-is-home .taj-feature .taj-card-buy .taj-pack-badge {
        order: -1;
        gap: 3px;
        padding: 2px 6px;
        font-size: 9.5px;
    }
    body.taj-active.taj-is-home .taj-feature .taj-price-ask {
        font-size: 12.5px;
        line-height: 1.25;
    }

    /* Quantity box + Add to cart share one row of one height; Order now / Ask Price fill the row below.
       Cards without a quantity box (Read more, Select options) get that row at the same height. */
    body.taj-active.taj-is-home .taj-withbar-main .taj-feature .taj-addcart {
        display: grid;
        grid-template-columns: 42px minmax(0, 1fr);
        grid-template-rows: minmax(46px, auto);
        gap: 6px;
        align-items: stretch;
    }
    body.taj-active.taj-is-home .taj-withbar-main .taj-feature .taj-addcart .taj-qty {
        width: auto;
        min-width: 0;
        flex: none;
        padding: 0 2px;
    }
    body.taj-active.taj-is-home .taj-withbar-main .taj-feature .taj-addcart .button:not(.taj-ordernow) {
        width: auto;
        min-width: 0;
        flex: none;
        line-height: 1.2;
        text-align: center;
    }
    body.taj-active.taj-is-home .taj-withbar-main .taj-feature .taj-addcart:not(.has-qty) > .button:not(.taj-ordernow),
    body.taj-active.taj-is-home .taj-withbar-main .taj-feature .taj-addcart .taj-ordernow,
    body.taj-active.taj-is-home .taj-withbar-main .taj-feature .taj-addcart .added_to_cart {
        grid-column: 1 / -1;
    }
}

/* Small phones: a little less padding so "Add to cart" still fits on two lines. */
@media (max-width: 380px) {
    body.taj-active.taj-is-home .taj-withbar-main .taj-feature .taj-addcart {
        grid-template-columns: 36px minmax(0, 1fr);
        gap: 4px;
    }
    body.taj-active.taj-is-home .taj-withbar-main .taj-feature .taj-addcart .button:not(.taj-ordernow) {
        padding: 4px 3px !important;
        font-size: 12px !important;
    }
    body.taj-active.taj-is-home .taj-withbar-main .taj-feature .taj-addcart .taj-qty {
        font-size: 13px;
    }
    /* "Order now" must stay on one line, or its card ends up taller than the others in the row. */
    body.taj-active.taj-is-home .taj-withbar-main .taj-feature .taj-addcart .taj-ordernow {
        padding: 6px 4px !important;
        font-size: 12.5px !important;
    }
}

/* Smallest phones (320px wide): cards are only ~89px wide. */
@media (max-width: 345px) {
    body.taj-active.taj-is-home .taj-withbar-main .taj-feature .taj-addcart {
        grid-template-columns: 30px minmax(0, 1fr);
        gap: 3px;
    }
    body.taj-active.taj-is-home .taj-withbar-main .taj-feature .taj-addcart .button:not(.taj-ordernow) {
        padding: 3px 2px !important;
        font-size: 11px !important;
    }
    body.taj-active.taj-is-home .taj-withbar-main .taj-feature .taj-addcart .taj-qty {
        font-size: 12px;
        padding: 0;
    }
    body.taj-active.taj-is-home .taj-withbar-main .taj-feature .taj-addcart .taj-ordernow {
        font-size: 12px !important;
    }
}
