/* ──────────────────────────────────────────────────────────────────────────────
   Quick cart drawer
   Shared by the marketplace layout and the Tailwind microsite layout, so it owns
   its own tokens and never relies on a utility class. Where the host app defines
   a matching token (marketplace.css) it is picked up; otherwise the fallback wins.
   ────────────────────────────────────────────────────────────────────────────── */

/* Tailwind's preflight leaves `[hidden]` to the UA sheet, where the badge's own
   `.flex` utility outranks it — so the microsite badge showed "0" on an empty cart.
   Kept to these two ids rather than a blanket [hidden] rule, which would override
   anything a stylesheet deliberately reveals. */
#cart-count-badge[hidden],
#cart-fab-badge[hidden] { display: none !important; }

.qc-root {
    /* Deliberately NOT inherited from the host page. The marketplace's tokens would
       map cleanly, but a merchant microsite defines --muted and --accent as oklch
       *surfaces* (and half the designs are dark-scheme), so inheriting there put
       near-white text on near-white cards. The drawer is platform chrome: it keeps
       one legible surface of its own on every design. */
    --qc-ink: #101214;
    --qc-muted: #5f6770;
    --qc-line: #e6e8eb;
    --qc-line-strong: #d4d9de;
    --qc-surface: #ffffff;
    --qc-soft: #f7f8f9;
    --qc-accent: #1f9d55;
    --qc-accent-ink: #0f6c37;
    --qc-danger: #b42318;

    position: fixed;
    inset: 0;
    z-index: 2000;
    font-family: "Public Sans", ui-sans-serif, system-ui, sans-serif;
    color: var(--qc-ink);
    line-height: 1.5;
}

.qc-root * { box-sizing: border-box; }

/* ── Scrim ─────────────────────────────────────────────────────────────────── */

.qc-scrim {
    position: absolute;
    inset: 0;
    background: rgba(12, 14, 16, 0.44);
    backdrop-filter: blur(2px);
    opacity: 0;
    transition: opacity 0.26s ease;
}

.qc-root.is-open .qc-scrim { opacity: 1; }

/* ── Panel ─────────────────────────────────────────────────────────────────── */

.qc-panel {
    position: absolute;
    top: 0;
    right: 0;
    display: flex;
    flex-direction: column;
    width: min(420px, 100vw);
    height: 100%;
    background: var(--qc-surface);
    border-left: 1px solid var(--qc-line);
    box-shadow: -24px 0 60px rgba(16, 18, 20, 0.16);
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
    outline: none;
}

.qc-root.is-open .qc-panel { transform: translateX(0); }

.qc-grip { display: none; }

/* ── Header ────────────────────────────────────────────────────────────────── */

.qc-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 18px 18px 14px;
    border-bottom: 1px solid var(--qc-line);
    background: var(--qc-surface);
}

.qc-title {
    margin: 0;
    font-family: "Archivo", ui-sans-serif, system-ui, sans-serif;
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--qc-ink);
}

.qc-sub {
    margin: 2px 0 0;
    font-size: 0.8rem;
    color: var(--qc-muted);
}

.qc-close {
    flex: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border: 1px solid var(--qc-line);
    border-radius: 999px;
    background: var(--qc-surface);
    color: var(--qc-ink);
    cursor: pointer;
    transition: background 0.16s ease, border-color 0.16s ease;
}

.qc-close:hover { background: var(--qc-soft); border-color: #cfd4d9; }

/* ── Body ──────────────────────────────────────────────────────────────────── */

.qc-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    padding: 14px 18px 18px;
}

.qc-notice {
    display: flex;
    gap: 8px;
    margin-bottom: 14px;
    padding: 10px 12px;
    border: 1px solid #fde4c2;
    border-radius: 12px;
    background: #fffaf2;
    font-size: 0.78rem;
    color: #8a5a10;
}

.qc-group + .qc-group {
    margin-top: 18px;
    padding-top: 16px;
    border-top: 1px dashed var(--qc-line);
}

.qc-group-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
}

.qc-group-name {
    font-size: 0.74rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--qc-muted);
}

.qc-group-sub {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--qc-ink);
}

/* ── Line item ─────────────────────────────────────────────────────────────── */

.qc-item {
    display: grid;
    grid-template-columns: 56px 1fr auto;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--qc-line);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.qc-item:last-child { border-bottom: 0; }

.qc-item.is-busy { opacity: 0.5; pointer-events: none; }

.qc-item.is-leaving {
    opacity: 0;
    transform: translateX(14px);
}

.qc-thumb {
    position: relative;
    display: grid;
    place-items: center;
    width: 56px;
    height: 56px;
    overflow: hidden;
    border: 1px solid var(--qc-line);
    border-radius: 12px;
    background-color: var(--qc-soft);
    color: #aab1b8;
}

.qc-thumb-img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.qc-item-body { display: block; min-width: 0; }

.qc-item-name {
    display: block;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--qc-ink);
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.qc-item-meta {
    display: block;
    margin-top: 2px;
    font-size: 0.74rem;
    color: var(--qc-muted);
}

.qc-item-badge {
    display: inline-block;
    margin-top: 6px;
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--qc-soft);
    border: 1px solid var(--qc-line);
    font-size: 0.66rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: var(--qc-muted);
}

.qc-item-badge--svc {
    background: #eef4ff;
    border-color: #d6e4ff;
    color: #2f5bb7;
}

.qc-item-side {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    justify-content: space-between;
    gap: 8px;
}

.qc-item-price {
    font-size: 0.88rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    color: var(--qc-ink);
}

.qc-item-unit {
    display: block;
    font-size: 0.7rem;
    font-weight: 400;
    color: var(--qc-muted);
}

/* ── Stepper ───────────────────────────────────────────────────────────────── */

.qc-stepper {
    display: inline-flex;
    align-items: center;
    border: 1px solid var(--qc-line);
    border-radius: 999px;
    background: var(--qc-surface);
    overflow: hidden;
}

.qc-step {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border: 0;
    background: transparent;
    color: var(--qc-ink);
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
    transition: background 0.14s ease, color 0.14s ease;
}

.qc-step:hover:not(:disabled) { background: var(--qc-soft); }
.qc-step:disabled { opacity: 0.35; cursor: not-allowed; }
.qc-step--trash:hover { color: var(--qc-danger); background: #fff1f0; }

.qc-qty {
    min-width: 26px;
    text-align: center;
    font-size: 0.82rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.qc-item-actions {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.qc-trash {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border: 1px solid var(--qc-line);
    border-radius: 999px;
    background: var(--qc-surface);
    color: var(--qc-muted);
    cursor: pointer;
    transition: color 0.14s ease, background 0.14s ease, border-color 0.14s ease;
}

.qc-trash:hover {
    color: var(--qc-danger);
    background: #fff1f0;
    border-color: #f6cfca;
}

/* ── Empty state ───────────────────────────────────────────────────────────── */

.qc-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 260px;
    padding: 24px 12px;
    text-align: center;
}

.qc-empty-icon {
    display: grid;
    place-items: center;
    width: 64px;
    height: 64px;
    margin-bottom: 6px;
    border-radius: 999px;
    background: var(--qc-soft);
    color: var(--qc-muted);
}

.qc-empty-title {
    font-family: "Archivo", ui-sans-serif, system-ui, sans-serif;
    font-size: 1rem;
    font-weight: 700;
    color: var(--qc-ink);
}

.qc-empty-text {
    max-width: 26ch;
    font-size: 0.82rem;
    color: var(--qc-muted);
}

.qc-empty-cta {
    max-width: 220px;
    margin-top: 14px;
}

/* ── Footer ────────────────────────────────────────────────────────────────── */

.qc-foot {
    flex: none;
    padding: 14px 18px calc(16px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--qc-line);
    background: var(--qc-surface);
    box-shadow: 0 -8px 24px rgba(16, 18, 20, 0.05);
}

.qc-foot-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    font-size: 0.88rem;
    color: var(--qc-muted);
}

.qc-foot-row strong {
    font-family: "Archivo", ui-sans-serif, system-ui, sans-serif;
    font-size: 1.22rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.02em;
    color: var(--qc-ink);
}

.qc-foot-note {
    margin: 4px 0 12px;
    font-size: 0.72rem;
    color: var(--qc-muted);
}

.qc-checkout {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 13px 18px;
    border-radius: 999px;
    background: var(--qc-ink);
    color: #fff;
    font-size: 0.92rem;
    font-weight: 700;
    text-decoration: none;
    transition: transform 0.14s ease, background 0.16s ease;
}

.qc-checkout:hover { background: #000; transform: translateY(-1px); }
.qc-checkout:active { transform: translateY(0); }

.qc-keep {
    display: block;
    width: 100%;
    margin-top: 8px;
    padding: 9px;
    border: 0;
    border-radius: 999px;
    background: none;
    color: var(--qc-muted);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
}

.qc-keep:hover { color: var(--qc-ink); background: var(--qc-soft); }

/* ── Skeleton ──────────────────────────────────────────────────────────────── */

.qc-sk-row {
    height: 56px;
    margin-bottom: 14px;
    border-radius: 12px;
    background: linear-gradient(90deg, #f1f3f5 0%, #e8ebee 50%, #f1f3f5 100%);
    background-size: 200% 100%;
    animation: qc-shimmer 1.3s ease-in-out infinite;
}

@keyframes qc-shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ── Toast ─────────────────────────────────────────────────────────────────── */

.qc-toast {
    position: fixed;
    left: 50%;
    bottom: 28px;
    z-index: 2100;
    display: flex;
    align-items: center;
    gap: 12px;
    font-family: "Public Sans", ui-sans-serif, system-ui, sans-serif;
    max-width: calc(100vw - 32px);
    padding: 10px 18px;
    border-radius: 999px;
    background: rgba(16, 18, 20, 0.94);
    color: #fff;
    font-size: 0.82rem;
    font-weight: 600;
    box-shadow: 0 12px 30px rgba(16, 18, 20, 0.28);
    transform: translate(-50%, 12px);
    opacity: 0;
    transition: opacity 0.2s ease, transform 0.2s ease;
    pointer-events: none;
}

.qc-toast.is-visible { opacity: 1; transform: translate(-50%, 0); }
.qc-toast.is-error { background: #a3160c; }

/* Only a toast offering an action may take a click; the rest stay inert so they
   never swallow a tap meant for the page behind them. */
.qc-toast.has-action { pointer-events: auto; }

.qc-toast-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.qc-toast-action {
    flex: none;
    padding: 4px 12px;
    border: 0;
    border-radius: 999px;
    background: #ffffff;
    color: #101214;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
    transition: opacity 0.14s ease;
}

.qc-toast-action:hover { opacity: 0.85; }

.qc-toast :focus-visible {
    outline: 2px solid #ffffff;
    outline-offset: 2px;
}

/* ── Badge pop, so the header count reads as a change ──────────────────────── */

.qc-badge-pop { animation: qc-pop 0.34s cubic-bezier(0.34, 1.56, 0.64, 1); }

@keyframes qc-pop {
    0%   { transform: scale(1); }
    45%  { transform: scale(1.38); }
    100% { transform: scale(1); }
}

/* ── Phones: bottom sheet instead of a side panel ──────────────────────────── */

@media (max-width: 640px) {
    .qc-panel {
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        height: auto;
        max-height: 88vh;
        border-left: 0;
        border-top: 1px solid var(--qc-line);
        border-radius: 22px 22px 0 0;
        box-shadow: 0 -20px 50px rgba(16, 18, 20, 0.22);
        transform: translateY(100%);
    }

    .qc-root.is-open .qc-panel { transform: translateY(0); }

    .qc-grip {
        display: block;
        width: 38px;
        height: 4px;
        margin: 8px auto 0;
        border-radius: 999px;
        background: var(--qc-line-strong);
    }

    .qc-head { padding-top: 12px; }
    .qc-toast { top: 14px; bottom: auto; }
}

/* ── Reduced motion ───────────────────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
    .qc-scrim,
    .qc-panel,
    .qc-item,
    .qc-toast,
    .qc-checkout { transition: none; }

    .qc-sk-row,
    .qc-badge-pop { animation: none; }
}

/* ── Focus visibility ─────────────────────────────────────────────────────── */

.qc-root :focus-visible {
    outline: 2px solid var(--qc-accent-ink);
    outline-offset: 2px;
    border-radius: 8px;
}

.qc-panel:focus { outline: none; }
