/*
    Add-to-cart buttons on the recommendation cards of the AjaxCart "product added to cart" popup.

    AjaxCart's Emporium stylesheet hides every product box button in its popups. The buttons are shown again
    only once AjaxCart has converted them (it adds .sevenspikes-ajaxcart to the product item, see
    ajax-cart-popup-buttons.js), so a card never offers the core add-to-cart, which would bypass the popup.
*/

/*
    Cards of one row share a height whatever their title and price, and the button sits at the bottom of each
    card so the buttons line up. The theme lays the cards out as inline blocks, which size to their content.
*/
.ajaxCart .productAddedToCartWindow .product-grid .item-grid {
    display: flex;
    flex-wrap: wrap;
    align-items: stretch;
}

.ajaxCart .productAddedToCartWindow .product-grid .item-box {
    display: flex;
    float: none;
    max-height: none;
}

.ajaxCart .productAddedToCartWindow .product-grid .item-box .product-item {
    display: flex;
    align-items: stretch;
    width: 100%;
}

.ajaxCart .productAddedToCartWindow .product-grid .item-box .product-item > div:first-child {
    flex: 0 0 120px;
    align-self: center;
}

.ajaxCart .productAddedToCartWindow .product-grid .item-box .details {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-width: 0;
}

/*
    A title always takes the room of two lines, so the prices line up too. A longer one is cut at two lines;
    the theme's max-height alone lets the third line run over the rating.
*/
.ajaxCart .productAddedToCartWindow .product-grid .item-box .product-title {
    min-height: 39px;
    overflow: hidden;
}

/* the clamp goes on the link: the theme makes it a block and gives the title its own display */
.ajaxCart .productAddedToCartWindow .product-grid .item-box .product-title a {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
}

.ajaxCart .productAddedToCartWindow .product-grid .item-box .product-item.sevenspikes-ajaxcart .buttons {
    display: block;
    margin-top: auto;
    padding-top: 8px;
}

/* the card is too narrow for a quantity box; a popup add always adds the product's default quantity */
.ajaxCart .productAddedToCartWindow .product-grid .item-box .add-to-cart-qty-wrapper,
.ajaxCart .productAddedToCartWindow .product-grid .item-box .productQuantityDropdown {
    display: none;
}

.ajaxCart .productAddedToCartWindow .product-grid .item-box .ajax-cart-button-wrapper .product-box-add-to-cart-button {
    width: 100%;
    height: auto;
    min-height: 36px;
    padding: 8px 10px;
    font-size: 13px;
    line-height: 1.3;
    white-space: normal;
}

/* two cards side by side leave no room for the button next to a 120px picture on a phone: stack them */
@media (max-width: 640px) {
    .ajaxCart .productAddedToCartWindow .product-grid .item-box,
    .ajaxCart .productAddedToCartWindow .product-grid .item-box:nth-child(2n+1) {
        width: 100%;
        margin: 0 0 10px 0;
        border-left: 1px solid #eee;
        border-radius: 3px;
    }

    .ajaxCart .productAddedToCartWindow .product-grid .item-box .product-item > div:first-child {
        flex-basis: 100px;
        width: 100px;
    }

    .ajaxCart .productAddedToCartWindow .product-grid .item-box .details {
        width: calc(100% - 100px);
    }
}
