/* ============================================================================
 * Pro Peptide v6 — Pack Size Tier Cards
 *
 * Restyles the existing .pp-pack-pill markup (rendered by
 * woocommerce/single-product/add-to-cart/variable.php) into a 3-column
 * tier-card grid that matches the pp-pack-selector.jsx visual spec.
 *
 * Selector-only override. No JS, no PHP, no DOM changes.
 * Click + price/cart/qty sync is handled by ppBuyboxInit (pro-peptide.js)
 * and pp-pack-sizes.js — leave them alone.
 *
 * Supersedes the vertical full-width pack-pill layout in style.css ~L19355.
 * Loads after style.css via the pro-peptide-style dependency.
 * ============================================================================ */

.pp-selector-group[data-attribute="pa_pack-size"] .pp-pack-row {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr) !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    gap: 12px !important;
}

.pp-selector-group[data-attribute="pa_pack-size"] .pp-pack-row .pp-pack-pill {
    flex: 0 0 auto !important;
}

.pp-selector-group[data-attribute="pa_pack-size"] .pp-pack-pill {
    display: grid !important;
    grid-template-columns: 1fr !important;
    grid-template-areas:
        "name"
        "priceline"
        "savings" !important;
    align-items: start !important;
    column-gap: 0 !important;
    row-gap: 0 !important;
    padding: 20px 16px 18px !important;
    text-align: left;
    position: relative;
    width: 100%;
}

/* Radio dot from the previous vertical-card design isn't part of the
   tier-card spec. Hide it. */
.pp-selector-group[data-attribute="pa_pack-size"] .pp-pack-pill__radio {
    display: none !important;
}

/* Flatten .pp-pack-pill__main so its children (name + savings) become
   direct grid items in the new card layout. */
.pp-selector-group[data-attribute="pa_pack-size"] .pp-pack-pill__main {
    display: contents !important;
}

.pp-selector-group[data-attribute="pa_pack-size"] .pp-pack-pill__name {
    grid-area: name;
    font-family: 'Montserrat', 'DM Sans', sans-serif;
    font-size: 14px;
    font-weight: 600;
    color: #343434;
    line-height: 1.3;
    margin: 0 0 10px;
    text-transform: none;
    letter-spacing: 0;
}
.pp-selector-group[data-attribute="pa_pack-size"] .pp-pack-pill.is-active .pp-pack-pill__name,
.pp-selector-group[data-attribute="pa_pack-size"] .pp-pack-pill[aria-pressed="true"] .pp-pack-pill__name {
    color: #0e6a99;
}

/* Price + CAD stay inline together in the price row. */
.pp-selector-group[data-attribute="pa_pack-size"] .pp-pack-pill__pricing {
    grid-area: priceline;
    display: flex;
    flex-direction: row !important;
    align-items: baseline !important;
    justify-content: flex-start;
    gap: 4px;
    margin: 0 0 4px;
    line-height: 1.1;
}

.pp-selector-group[data-attribute="pa_pack-size"] .pp-pack-pill__price {
    font-family: 'Montserrat', 'DM Sans', sans-serif;
    font-size: 22px;
    font-weight: 600;
    letter-spacing: -0.5px;
    color: #343434;
    line-height: 1.1;
}
.pp-selector-group[data-attribute="pa_pack-size"] .pp-pack-pill.is-active .pp-pack-pill__price,
.pp-selector-group[data-attribute="pa_pack-size"] .pp-pack-pill[aria-pressed="true"] .pp-pack-pill__price {
    color: #0e6a99;
}
.pp-selector-group[data-attribute="pa_pack-size"] .pp-pack-pill__price .woocommerce-Price-amount,
.pp-selector-group[data-attribute="pa_pack-size"] .pp-pack-pill__price .amount,
.pp-selector-group[data-attribute="pa_pack-size"] .pp-pack-pill__price bdi {
    font: inherit;
    color: inherit;
}

.pp-selector-group[data-attribute="pa_pack-size"] .pp-pack-pill__cad {
    font-family: 'Montserrat', 'DM Sans', sans-serif;
    font-size: 10px;
    font-weight: 500;
    color: #6b7280;
    line-height: 1;
    letter-spacing: 0;
}

/* Savings sits in the helper-line slot under price — same slot the JSX
   uses for "$X / vial". Keeps the existing "Save N%" copy. */
.pp-selector-group[data-attribute="pa_pack-size"] .pp-pack-pill__savings {
    grid-area: savings;
    display: block;
    font-family: 'Montserrat', 'DM Sans', sans-serif;
    font-size: 11px;
    font-weight: 500;
    color: #15803d;
    line-height: 1.1;
    margin: 0;
    text-transform: none;
    letter-spacing: 0;
}
.pp-selector-group[data-attribute="pa_pack-size"] .pp-pack-pill__savings[hidden] {
    display: none;
}

/* Out-of-stock state driven by .is-disabled (added by pro-peptide.js
   refreshPackPills when no matching variation entry exists or in_stock=false). */
.pp-selector-group[data-attribute="pa_pack-size"] .pp-pack-pill.is-disabled {
    opacity: 0.55;
    cursor: not-allowed;
}
.pp-selector-group[data-attribute="pa_pack-size"] .pp-pack-pill.is-disabled:hover {
    border-color: #E5E7EB;
}
.pp-selector-group[data-attribute="pa_pack-size"] .pp-pack-pill.is-disabled::before {
    content: 'Out of stock';
    position: absolute;
    top: -10px;
    right: 12px;
    background: #ef4444;
    color: #fafafa;
    font-family: 'Montserrat', 'DM Sans', sans-serif;
    font-size: 9px;
    font-weight: 600;
    padding: 4px 8px;
    border-radius: 6px;
    letter-spacing: 0.4px;
    text-transform: uppercase;
    line-height: 1;
}

@media (max-width: 600px) {
    .pp-selector-group[data-attribute="pa_pack-size"] .pp-pack-row {
        grid-template-columns: 1fr !important;
    }
}
