/* =========================================================
   Primo Paints — cart (header button, drawer, cart page, toasts)
   Extends primo.css; uses the same brand tokens.
   ========================================================= */

/* ---------- Header button ---------- */
.cart-btn {
    position: relative; display: inline-grid; place-items: center; flex: none;
    width: 44px; height: 44px; margin-left: 6px; border-radius: 50%;
    color: var(--ink); background: transparent;
    transition: background .2s, color .2s, transform .2s var(--ease);
}
.cart-btn:hover { background: var(--brand-light); color: var(--brand); }
.cart-btn .cart-count {
    position: absolute; top: 2px; right: 0; min-width: 19px; height: 19px; padding: 0 5px;
    display: inline-flex; align-items: center; justify-content: center;
    font-family: 'Sora', sans-serif; font-weight: 700; font-size: .68rem; line-height: 1;
    color: #fff; background: var(--accent); border: 2px solid #fff; border-radius: 100px;
}
.cart-btn .cart-count[hidden] { display: none; }
@keyframes cart-bump {
    0% { transform: scale(1); }
    35% { transform: scale(1.18); }
    100% { transform: scale(1); }
}
.cart-btn.is-bump { animation: cart-bump .45s var(--ease); }

/* ---------- Add to cart (product cards) ---------- */
.p-add-form { margin-top: 14px; }
.p-add {
    display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%;
    font: inherit; font-family: 'Sora', sans-serif; font-weight: 600; font-size: .9rem;
    color: var(--brand); background: var(--brand-light); border: 0; border-radius: 100px;
    padding: 12px 18px; cursor: pointer; text-align: center;
    transition: background .25s, color .25s, box-shadow .25s;
}
.p-add:hover { background: var(--brand); color: #fff; box-shadow: var(--shadow-brand); }
.p-add:focus-visible { outline: 2px solid var(--brand); outline-offset: 3px; }
.p-add.is-busy { opacity: .6; cursor: progress; }
a.p-add { margin-top: 14px; }
a.p-add--opts { background: transparent; box-shadow: inset 0 0 0 1.5px var(--line); }
a.p-add--opts:hover { box-shadow: inset 0 0 0 1.5px var(--brand); background: var(--brand-light); color: var(--brand); }
.p-add.is-disabled {
    margin-top: 14px; color: var(--muted); background: var(--bg-soft); cursor: not-allowed;
    box-shadow: none;
}
.p-add.is-disabled:hover { background: var(--bg-soft); color: var(--muted); box-shadow: none; }

/* ---------- Quantity stepper ---------- */
.qty-stepper {
    display: inline-flex; align-items: center; gap: 2px; flex: none;
    border: 1px solid var(--line); border-radius: 100px; padding: 3px; background: #fff;
}
.qty-stepper .step {
    width: 30px; height: 30px; flex: none; border: 0; border-radius: 50%; cursor: pointer;
    background: transparent; color: var(--ink-soft); font-size: 1.05rem; line-height: 1;
    display: grid; place-items: center; transition: background .2s, color .2s;
}
.qty-stepper .step:hover { background: var(--brand-light); color: var(--brand); }
.qty-stepper .step:disabled { opacity: .5; cursor: default; }
.qty-stepper input[type="number"] {
    width: 44px; border: 0; background: transparent; text-align: center;
    font: inherit; font-family: 'Sora', sans-serif; font-weight: 600; font-size: .92rem; color: var(--ink);
    -moz-appearance: textfield; appearance: textfield;
}
.qty-stepper input::-webkit-outer-spin-button,
.qty-stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.qty-stepper input:focus { outline: none; }
.qty-stepper .qty-value {
    min-width: 34px; text-align: center;
    font-family: 'Sora', sans-serif; font-weight: 600; font-size: .92rem;
}
.qty-stepper--lg { padding: 5px; }
.qty-stepper--lg .step { width: 38px; height: 38px; font-size: 1.2rem; }
.qty-stepper--lg input[type="number"] { width: 52px; font-size: 1rem; }
.qty-stepper--sm { margin-top: 10px; padding: 2px; }
.qty-stepper--sm .step { width: 26px; height: 26px; }

/* The "Update" button only matters without JS — the steppers submit for us. */
.qty-apply {
    font: inherit; font-size: .78rem; font-weight: 600; color: var(--brand);
    background: none; border: 0; cursor: pointer; padding: 0 8px; text-decoration: underline;
}
.qty-stepper.is-busy { opacity: .6; }

/* ---------- Product details buy row ---------- */
.pd-buy { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 30px; }
.pd-buy .pd-add { flex: 1; min-width: 200px; justify-content: center; }
.pd-actions { margin-top: 16px; }
.pd-soldout {
    margin-top: 28px; padding: 16px 20px; border-radius: var(--radius);
    background: var(--bg-soft); color: var(--ink-soft); font-size: .94rem;
}
.pd-soldout a { color: var(--brand); font-weight: 600; }

/* ---------- Drawer ---------- */
body.cart-locked { overflow: hidden; }

.cart-drawer { position: fixed; inset: 0; z-index: 120; }
.cart-drawer[hidden] { display: none; }
.cart-drawer-scrim {
    position: absolute; inset: 0; background: rgba(12, 16, 28, .5);
    opacity: 0; transition: opacity .3s var(--ease); backdrop-filter: blur(2px);
}
.cart-drawer.is-open .cart-drawer-scrim { opacity: 1; }

.cart-panel {
    position: absolute; top: 0; right: 0; bottom: 0; width: min(420px, 100%);
    display: flex; flex-direction: column; background: #fff;
    box-shadow: var(--shadow-lg); transform: translateX(100%);
    transition: transform .35s var(--ease);
}
.cart-drawer.is-open .cart-panel { transform: translateX(0); }

.cart-panel-head {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 22px 24px; border-bottom: 1px solid var(--line); flex: none;
}
.cart-panel-head h2 { font-size: 1.15rem; font-weight: 700; }
.cart-panel-head .n { color: var(--muted); font-weight: 500; }
.cart-close {
    width: 38px; height: 38px; flex: none; border: 0; border-radius: 50%; cursor: pointer;
    background: var(--bg-soft); color: var(--ink-soft); display: grid; place-items: center;
    transition: background .2s, color .2s;
}
.cart-close:hover { background: var(--brand-light); color: var(--brand); }

.cart-panel-body { flex: 1; overflow-y: auto; padding: 8px 24px; }
.cart-panel-foot { flex: none; padding: 20px 24px 24px; border-top: 1px solid var(--line); background: var(--bg-soft); }
.cart-panel-foot[hidden] { display: none; }
.cart-checkout { width: 100%; justify-content: center; margin-top: 6px; }
.cart-keep {
    display: block; width: 100%; margin-top: 10px; padding: 10px; cursor: pointer;
    font: inherit; font-size: .88rem; color: var(--ink-soft); background: none; border: 0;
}
.cart-keep:hover { color: var(--brand); text-decoration: underline; }
.cart-note { font-size: .8rem; color: var(--muted); margin: 12px 0 0; }

.cart-empty { text-align: center; padding: 60px 10px; }
.cart-empty p { color: var(--ink-soft); margin-bottom: 20px; }

/* ---------- Cart line (shared by drawer + page) ---------- */
.cart-line {
    display: grid; grid-template-columns: 76px 1fr auto; gap: 16px; align-items: start;
    padding: 18px 0; border-bottom: 1px solid var(--line);
}
.cart-line:last-of-type { border-bottom: 0; }
.cart-line.is-dead { opacity: .55; }
.cart-line-media {
    width: 76px; height: 76px; border-radius: 14px; overflow: hidden; flex: none;
    display: grid; place-items: center; background: var(--bg-soft); position: relative;
}
.cart-line-media img { width: 100%; height: 100%; object-fit: contain; padding: 6px; }
.cart-line-media svg { width: 30px; height: 30px; }
.cart-line-media:has(svg) { background: var(--tint, var(--brand)); }
.cart-line-info { min-width: 0; }
.cart-line-info h3 { font-size: .98rem; line-height: 1.35; margin-bottom: 4px; }
.cart-line-info h3 a { transition: color .2s; }
.cart-line-info h3 a:hover { color: var(--brand); }
.cart-line-variant {
    display: inline-block; font-size: .78rem; color: var(--ink-soft);
    background: var(--bg-soft); padding: 3px 10px; border-radius: 100px; margin-bottom: 6px;
}
.cart-line-unit { font-size: .85rem; color: var(--muted); }
.cart-line-unit .was { text-decoration: line-through; opacity: .8; margin-left: 4px; }
.cart-line-note { font-size: .8rem; color: var(--accent); font-weight: 600; margin-top: 6px; }
.cart-line-side { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.cart-line-total { font-family: 'Sora', sans-serif; font-weight: 700; font-size: 1rem; color: var(--ink); white-space: nowrap; }
.cart-remove {
    font: inherit; font-size: .8rem; color: var(--muted); background: none; border: 0;
    cursor: pointer; padding: 0; transition: color .2s;
}
.cart-remove:hover { color: var(--accent); text-decoration: underline; }

/* ---------- Totals ---------- */
.cart-totals { display: grid; gap: 10px; }
.cart-totals .row { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; font-size: .92rem; }
.cart-totals dt { color: var(--ink-soft); }
.cart-totals dd { font-family: 'Sora', sans-serif; font-weight: 600; color: var(--ink); }
.cart-totals .muted { color: var(--muted); font-weight: 400; font-size: .85rem; }
.cart-totals .row--save dt, .cart-totals .row--save dd { color: var(--accent); }
.cart-totals .row--total {
    padding-top: 12px; margin-top: 4px; border-top: 1px solid var(--line);
}
.cart-totals .row--total dt { font-family: 'Sora', sans-serif; font-weight: 700; color: var(--ink); font-size: 1rem; }
.cart-totals .row--total dd { font-size: 1.35rem; font-weight: 800; color: var(--brand); }

/* ---------- Cart page ---------- */
.cart-flash {
    padding: 14px 20px; border-radius: var(--radius); margin-bottom: 24px; font-size: .92rem;
    background: var(--brand-light); color: var(--brand); font-weight: 500;
}
.cart-flash.is-err { background: rgba(230, 57, 70, .1); color: var(--accent-dark); }

.cart-layout { display: grid; grid-template-columns: 1fr 360px; gap: 40px; align-items: start; }
.cart-lines {
    background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 28px 24px;
}
.cart-lines-head {
    display: flex; align-items: center; justify-content: space-between; gap: 16px;
    padding: 20px 0 4px;
}
.cart-lines-head h2 { font-size: 1.1rem; font-weight: 700; }
.cart-clear-form { margin: 0; }
.cart-clear {
    font: inherit; font-size: .84rem; color: var(--muted); background: none; border: 0;
    cursor: pointer; transition: color .2s;
}
.cart-clear:hover { color: var(--accent); text-decoration: underline; }

.cart-line-actions { display: flex; flex-direction: column; align-items: flex-end; gap: 10px; }
.cart-line-actions .qty-stepper { order: -1; }
.cart-continue {
    display: inline-flex; align-items: center; gap: 8px; margin-top: 22px;
    font-family: 'Sora', sans-serif; font-weight: 600; font-size: .9rem; color: var(--brand);
    transition: gap .25s var(--ease);
}
.cart-continue:hover { gap: 13px; }

.cart-summary {
    position: sticky; top: 96px;
    background: var(--bg-soft); border: 1px solid var(--line); border-radius: var(--radius); padding: 28px;
}
.cart-summary h2 { font-size: 1.15rem; font-weight: 700; margin-bottom: 20px; }
.cart-summary .btn { width: 100%; justify-content: center; }
.cart-checkout-btn { margin-top: 22px; }
.cart-checkout-btn:disabled { opacity: .55; cursor: not-allowed; box-shadow: none; }
.cart-summary-note { font-size: .82rem; color: var(--muted); margin: 12px 0 14px; line-height: 1.55; }
.cart-wa { margin-bottom: 4px; }
.cart-warn {
    font-size: .85rem; color: var(--accent); font-weight: 600; margin-top: 16px;
    background: rgba(230, 57, 70, .08); padding: 10px 14px; border-radius: 12px;
}
.cart-signin-hint, .cart-trade-hint { font-size: .85rem; color: var(--ink-soft); margin-top: 16px; text-align: center; }
.cart-signin-hint a { color: var(--brand); font-weight: 600; }
.cart-signin-hint a:hover { text-decoration: underline; }
.cart-trade-hint { color: var(--accent); font-weight: 600; }

/* ---------- Toasts ---------- */
.toast-host {
    position: fixed; z-index: 140; left: 50%; bottom: 26px; transform: translateX(-50%);
    display: flex; flex-direction: column; gap: 10px; align-items: center;
    pointer-events: none; width: min(420px, calc(100% - 32px));
}
.toast {
    width: 100%; padding: 14px 20px; border-radius: 100px; text-align: center;
    font-family: 'Sora', sans-serif; font-weight: 600; font-size: .88rem; color: #fff;
    background: var(--ink); box-shadow: var(--shadow);
    opacity: 0; transform: translateY(14px); transition: opacity .28s var(--ease), transform .28s var(--ease);
}
.toast.is-in { opacity: 1; transform: translateY(0); }
.toast--err { background: var(--accent); }

/* ---------- Responsive ---------- */
@media (max-width: 1024px) {
    .cart-layout { grid-template-columns: 1fr; gap: 24px; }
    .cart-summary { position: static; }
}

@media (max-width: 720px) {
    /* The button sits beside the burger, outside the collapsing nav. */
    .cart-btn { margin-left: auto; margin-right: 4px; }
    .cart-lines { padding: 4px 18px 20px; }
    .cart-line { grid-template-columns: 64px 1fr; gap: 14px; padding: 16px 0; }
    .cart-line-media { width: 64px; height: 64px; }
    .cart-line-actions, .cart-line-side {
        grid-column: 1 / -1; flex-direction: row; align-items: center;
        justify-content: space-between; width: 100%;
    }
    .cart-line-actions .qty-stepper { order: 0; }
    .cart-panel { width: 100%; }
    .cart-panel-body { padding: 4px 18px; }
    .cart-panel-head, .cart-panel-foot { padding-left: 18px; padding-right: 18px; }
    .toast-host { bottom: 16px; }
}

@media (prefers-reduced-motion: reduce) {
    .cart-panel, .cart-drawer-scrim, .toast { transition: none; }
    .cart-btn.is-bump { animation: none; }
}
