/*
 * Phone storefront (767px and down). Nearly every rule that changes existing
 * markup sits inside the media query, and the few elements added for phones
 * (.ap-m-only) are hidden above it. Exception: the checkout "new card" rules
 * below apply at every width (the old p.add-new-account-instructions hint is
 * hidden on desktop too).
 */
:root {
    --ap-rust: #872503;
    --ap-rust-dark: #5e1a02;
    --ap-taupe: #635956;
    --ap-cream: #f7f3ef;
    --ap-line: #e4ddd6;
    --ap-ink: #1c1c1c;
    --ap-muted: #6f6763;
    --ap-tap: 44px;
}

.ap-m-only,
.ap-cart-added { display: none; }
/* Checkout "new card" button replaces the "click Proceed to Payment" hint on every screen size */
p.add-new-account-instructions { display: none !important; }
.ap-m-new-acct button {
    min-height: 44px; padding: 0 28px; border: 0; border-radius: 6px;
    background: var(--ap-rust); color: #fff; font: 600 16px Roboto, sans-serif; cursor: pointer;
}
.ap-m-new-acct button:hover, .ap-m-new-acct button:focus { background: var(--ap-rust-dark); }
.ap-m-new-acct button:focus-visible { outline: 3px solid #f0b48f; outline-offset: 2px; }

@media (max-width: 767px) {
    .ap-m-only { display: block; }

    .ap-m-btn {
        display: flex; align-items: center; justify-content: center;
        min-height: var(--ap-tap); padding: 0 14px; width: 100%;
        border: 1px solid var(--ap-rust); border-radius: 6px;
        background: #fff; color: var(--ap-rust);
        font: 600 15px/1.1 Roboto, sans-serif; text-decoration: none; cursor: pointer;
        transition: background-color .15s, transform .1s;
    }
    .ap-m-btn:hover, .ap-m-btn:focus { color: var(--ap-rust); text-decoration: none; }
    .ap-m-btn:active { transform: scale(.98); }
    .ap-m-btn--primary { background: var(--ap-rust); color: #fff; }
    .ap-m-btn--primary:hover, .ap-m-btn--primary:focus { background: var(--ap-rust-dark); color: #fff; }
    .ap-m-btn:focus-visible { outline: 3px solid #f0b48f; outline-offset: 2px; }

    /* ---------- Header: one row, then a full-width search ---------- */
    .ossvn--header { padding: 8px 12px; background: #fff; border-bottom: 1px solid var(--ap-line); }
    .ossvn--header .container { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; }
    .ossvn--header .container::before, .ossvn--header .container::after { display: none; }
    .ossvn--header .logo--header { margin: 0; float: none; display: block; }
    .ossvn--header .logo--header img { height: 40px; width: auto !important; max-width: none; } /* beats style.css width: 40%/34% !important */
    /* contents: the right-side items join the header row, so the cutoff line can wrap under the whole bar */
    .ossvn--header .header--right { display: contents; }
    .ossvn--header .ap-m-cart { margin-left: auto; margin-right: 10px; }
    .ossvn--header .menu--header .menu,
    .ossvn--header .dropdown--address { display: none; }
    /* the logged-in "Order Cutoff" line stays, as a slim strip under the bar */
    .ossvn--header .menu--header { order: 3; flex-basis: 100%; padding: 0; }
    .ossvn--header .menu--header p { margin: 6px 0 0; font-size: 13px; color: var(--ap-rust); font-weight: 600; text-align: right; }
    .ossvn--header .menumobile--toggle { height: var(--ap-tap); padding: 0 11px; border-radius: 6px; }

    .ap-m-cart {
        position: relative; display: flex; align-items: center; justify-content: center;
        width: var(--ap-tap); height: var(--ap-tap); border-radius: 6px;
        color: var(--ap-ink); font-size: 22px; text-decoration: none;
    }
    .ap-m-cart:hover, .ap-m-cart:focus { color: var(--ap-rust); }
    .ap-m-cart .ap-cart-count {
        position: absolute; top: 2px; right: 0; min-width: 20px; height: 20px; padding: 0 5px;
        border-radius: 10px; background: var(--ap-rust); color: #fff;
        font: 700 12px/20px Roboto, sans-serif; text-align: center;
    }

    .search-text { padding: 8px 12px 10px; background: #fff; border-bottom: 1px solid var(--ap-line); }
    .search-text .row { margin: 0; }
    .search-text #search-form { display: flex; margin: 0; }
    .search-text #search-form .inp--text {
        flex: 1; width: auto !important; min-width: 0; height: var(--ap-tap); margin: 0;
        padding: 0 14px; border: 2px solid var(--ap-taupe); border-right: 0; border-radius: 6px 0 0 6px;
        font-size: 16px; /* 16px stops iOS zooming in on focus */
    }
    .search-text #search-form button {
        width: 52px; height: var(--ap-tap); padding: 0; margin: 0;
        border: 0; border-radius: 0 6px 6px 0; background: var(--ap-taupe); color: #fff;
    }

    /* ---------- Search results: the 9-column table becomes a 2-up grid ---------- */
    #advsearch-page, #advsearch-page > .container { padding-left: 8px; padding-right: 8px; }
    #advsearch-page .row { margin-left: 0; margin-right: 0; } /* -15px row margins overflow the 8px padding */
    #search-results > .col-md-10 { padding: 0; }
    #search-results table, #search-results tbody { display: block; margin: 12px 0 0 !important; }
    #search-results thead { display: none; }
    #search-results tbody { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
    #search-results tr {
        display: grid; grid-template-columns: 48px 1fr; column-gap: 6px; align-content: start;
        padding: 10px; background: #fff; border: 1px solid var(--ap-line); border-radius: 8px;
    }
    #search-results td { grid-column: 1 / -1; display: block; width: auto; margin: 0; padding: 0 !important; border: 0 !important; }
    #search-results td:nth-child(1) { order: 1; text-align: center; }
    #search-results td:nth-child(2) { order: 2; }
    #search-results td:nth-child(7) { order: 3; }
    #search-results td:nth-child(6) { order: 4; }
    #search-results td:nth-child(3) { order: 5; }
    #search-results td:nth-child(4) { order: 6; }
    #search-results td:nth-child(5) { order: 7; }
    #search-results td:nth-child(8) { order: 8; grid-column: 1; align-self: end; margin-top: 8px; }
    #search-results td:nth-child(9) { order: 9; grid-column: 2; align-self: end; margin-top: 8px; }

    #search-results .img-thumbnail { width: 100% !important; height: 130px; object-fit: contain; border: 0; padding: 0; }
    #search-results .product-name { margin: 8px 0 4px; font-size: 14px; line-height: 1.3; color: var(--ap-ink);
        display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
    #search-results td:nth-child(7) { font: 700 20px/1.2 Roboto, sans-serif; color: var(--ap-rust); margin-bottom: 4px; }
    #search-results td:nth-child(7) span[style*="line-through"] { display: block; font-size: 13px; font-weight: 400; color: var(--ap-muted); }
    #search-results .productCasePricing { max-width: none; min-width: 0; margin: 2px 0 4px !important; }
    #search-results .sku, #search-results td:nth-child(4), #search-results td:nth-child(5) { margin: 0; font-size: 12px; color: var(--ap-muted); }
    #search-results .sku::before { content: "SKU "; }
    #search-results td:nth-child(4)::after { content: " in stock"; }
    #search-results .qty {
        width: 100% !important; height: var(--ap-tap); padding: 0 2px; text-align: center; font-size: 16px;
        border: 1px solid #bdb3ab; border-radius: 6px;
    }
    #search-results .add-to-cart {
        float: none !important; width: 100%; height: var(--ap-tap); padding: 0 4px;
        border: 0; border-radius: 6px; background: var(--ap-rust); color: #fff; font-weight: 600; font-size: 14px;
    }
    #search-results .add-to-cart.btn-primary { background: var(--ap-taupe); }

    /* ---------- Category pages: 2-up tiles with a real Add to Cart ---------- */
    .woocommerce-ordering { display: none; }
    ul.products.ap-grid { display: flex; flex-wrap: wrap; margin: 0 -4px; padding: 0; }
    ul.products.ap-grid::before, ul.products.ap-grid::after { display: none; }
    ul.products.ap-grid > li { width: 50%; float: none; padding: 4px; margin: 0; }
    ul.products.ap-grid .item--product-grid {
        height: 100%; display: flex; flex-direction: column; padding: 10px; margin: 0;
        background: #fff; border: 1px solid var(--ap-line); border-radius: 8px; text-align: left;
    }
    ul.products.ap-grid .list--hover { display: none; }
    ul.products.ap-grid .images--wrap img { height: 130px !important; width: 100%; object-fit: contain; }
    ul.products.ap-grid .item--link { flex: 1; }
    ul.products.ap-grid .item--link hr { display: none; }
    ul.products.ap-grid h4.item--title { min-height: 0; margin: 8px 0 4px; font-size: 14px; line-height: 1.3;
        display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
    ul.products.ap-grid .item--link > div { min-height: 0 !important; }
    ul.products.ap-grid .item--link br { display: none; }
    ul.products.ap-grid .price + .price { margin-top: 4px; }
    ul.products.ap-grid .pull-left, ul.products.ap-grid .pull-right { float: none !important; }
    ul.products.ap-grid .price { display: block; font-size: 12px !important; color: var(--ap-muted); }
    ul.products.ap-grid .price ins, ul.products.ap-grid .price ins .amount { font: 700 20px/1.2 Roboto, sans-serif; color: var(--ap-rust) !important; text-decoration: none; }
    ul.products.ap-grid .productCasePricing { max-width: none; min-width: 0; margin: 4px 0 0 !important; }
    ul.products.ap-grid .ap-m-add { margin-top: 10px; }
    ul.products.ap-grid .ap-m-add:not(.ap-m-btn--primary) { font-size: 13px; }

    /* ---------- Added-to-cart panel ---------- */
    .ap-cart-added {
        display: block; position: fixed; top: 0; left: 0; right: 0; z-index: 13002;
        padding: 14px 16px 16px; background: #fff; border-bottom: 3px solid var(--ap-rust);
        box-shadow: 0 8px 24px rgba(0,0,0,.18);
        transform: translateY(-110%); visibility: hidden;
        transition: transform .25s ease-out, visibility 0s linear .25s;
    }
    .ap-cart-added.is-open { transform: translateY(0); visibility: visible; transition: transform .25s ease-out; }
    .ap-cart-added__msg { margin: 0 32px 12px 0; font: 600 16px/1.3 Roboto, sans-serif; color: var(--ap-ink); }
    .ap-cart-added__msg .fa { color: #2e8540; margin-right: 6px; }
    .ap-cart-added__actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
    .ap-cart-added__close {
        position: absolute; top: 6px; right: 6px; width: var(--ap-tap); height: var(--ap-tap);
        border: 0; background: none; font-size: 26px; line-height: 1; color: var(--ap-muted);
    }
    @media (prefers-reduced-motion: reduce) { .ap-cart-added, .ap-cart-added.is-open { transition: none; } }

    .ap-m-new-acct button { min-height: 50px; font-size: 17px; }
}
