/**
 * CC One-Page Cart — Slide-out drawer
 * Warm neutral palette to match mattresscenter.com
 */

/* ── Variables ──────────────────────────────────────────────────────────────── */

:root {
    --cc-cart-width:        420px;
    --cc-cart-bg:           #fff;
    --cc-cart-border:       #e8ddd6;
    --cc-cart-text:         #2c1f13;
    --cc-cart-muted:        #9e8a7e;
    --cc-cart-accent:       #8b6350;
    --cc-cart-accent-hover: #7a5542;
    --cc-cart-light:        #faf5f2;
    --cc-cart-shadow:       rgba(74, 55, 40, 0.18);
    --cc-cart-overlay-bg:   rgba(44, 31, 19, 0.5);
    --cc-cart-transition:   0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --cc-cart-radius:       12px;
}

/* ── [hidden] guard (2026-06-11) ─────────────────────────────────────────────
   The loading/empty/footer blocks use display:flex, which overrides the UA
   [hidden]{display:none} rule — so "Cart is empty" showed below real items.
   This guard restores correct hidden semantics inside the drawer. */
.cc-cart-drawer [hidden],
.cc-cart-toast[hidden] {
    display: none !important;
}

/* ── Overlay ─────────────────────────────────────────────────────────────────── */

.cc-cart-overlay {
    position: fixed;
    inset: 0;
    background: var(--cc-cart-overlay-bg);
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--cc-cart-transition), visibility var(--cc-cart-transition);
    z-index: 99998;
    backdrop-filter: blur(2px);
}

.cc-cart-overlay.is-visible {
    opacity: 1;
    visibility: visible;
}

/* ── Drawer ──────────────────────────────────────────────────────────────────── */

.cc-cart-drawer {
    position: fixed;
    top: 0;
    right: 0;
    height: 100%;
    width: var(--cc-cart-width);
    max-width: 100vw;
    background: var(--cc-cart-bg);
    box-shadow: -8px 0 40px var(--cc-cart-shadow);
    transform: translateX(100%);
    transition: transform var(--cc-cart-transition);
    z-index: 99999;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.cc-cart-drawer.is-open {
    transform: translateX(0);
}

/* body scroll lock */
body.cc-cart-open {
    overflow: hidden;
}

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

.cc-cart-drawer__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1.5px solid var(--cc-cart-border);
    flex-shrink: 0;
    background: var(--cc-cart-bg);
}

.cc-cart-drawer__title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--cc-cart-text);
    margin: 0;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.cc-cart-drawer__cart-icon {
    width: 22px;
    height: 22px;
    color: var(--cc-cart-accent);
    flex-shrink: 0;
}

.cc-cart-drawer__count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    border-radius: 999px;
    background: var(--cc-cart-accent);
    color: #fff;
    font-size: 0.75rem;
    font-weight: 700;
    line-height: 1;
}

.cc-cart-drawer__close {
    width: 40px;
    height: 40px;
    border: none;
    background: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    color: var(--cc-cart-muted);
    transition: background 0.15s, color 0.15s;
    flex-shrink: 0;
    padding: 0;
}

.cc-cart-drawer__close:hover {
    background: var(--cc-cart-light);
    color: var(--cc-cart-text);
}

.cc-cart-drawer__close svg {
    width: 18px;
    height: 18px;
}

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

.cc-cart-drawer__body {
    flex: 1;
    overflow-y: auto;
    padding: 0;
    position: relative;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

/* Custom scrollbar */
.cc-cart-drawer__body::-webkit-scrollbar {
    width: 4px;
}
.cc-cart-drawer__body::-webkit-scrollbar-track {
    background: transparent;
}
.cc-cart-drawer__body::-webkit-scrollbar-thumb {
    background: var(--cc-cart-border);
    border-radius: 2px;
}

/* ── Loading spinner ─────────────────────────────────────────────────────────── */

.cc-cart-drawer__loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 60px 24px;
}

.cc-cart-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--cc-cart-border);
    border-top-color: var(--cc-cart-accent);
    border-radius: 50%;
    animation: cc-spin 0.7s linear infinite;
}

@keyframes cc-spin {
    to { transform: rotate(360deg); }
}

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

.cc-cart-drawer__empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 24px;
    text-align: center;
    gap: 12px;
}

.cc-cart-drawer__empty-icon {
    width: 72px;
    height: 72px;
    color: var(--cc-cart-border);
}

.cc-cart-drawer__empty-text {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--cc-cart-text);
    margin: 0;
}

.cc-cart-drawer__empty-hint {
    font-size: 0.9rem;
    color: var(--cc-cart-muted);
    margin: 0;
}

.cc-cart-drawer__continue {
    margin-top: 8px;
    padding: 10px 24px;
    border: 1.5px solid var(--cc-cart-accent);
    border-radius: var(--cc-cart-radius);
    background: none;
    color: var(--cc-cart-accent);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.cc-cart-drawer__continue:hover {
    background: var(--cc-cart-accent);
    color: #fff;
}

/* ── Cart items ──────────────────────────────────────────────────────────────── */

.cc-cart-drawer__items {
    padding: 0;
}

.cc-cart-item {
    display: flex;
    gap: 14px;
    padding: 18px 24px;
    border-bottom: 1px solid var(--cc-cart-border);
    background: var(--cc-cart-bg);
    transition: opacity 0.2s, transform 0.2s, background 0.15s;
    opacity: 0;
    transform: translateX(12px);
}

.cc-cart-item.is-visible {
    opacity: 1;
    transform: translateX(0);
}

.cc-cart-item.is-updating {
    opacity: 0.5;
    pointer-events: none;
}

.cc-cart-item.is-removing {
    opacity: 0;
    transform: translateX(40px);
    transition: opacity 0.2s, transform 0.2s;
}

.cc-cart-item:last-child {
    border-bottom: none;
}

.cc-cart-item__image-link {
    flex-shrink: 0;
}

.cc-cart-item__image {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: 8px;
    border: 1.5px solid var(--cc-cart-border);
    display: block;
}

.cc-cart-item__info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.cc-cart-item__name {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--cc-cart-text);
    text-decoration: none;
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.cc-cart-item__name:hover {
    color: var(--cc-cart-accent);
}

.cc-cart-item__variation {
    font-size: 0.8rem;
    color: var(--cc-cart-muted);
    background: var(--cc-cart-light);
    padding: 2px 8px;
    border-radius: 999px;
    display: inline-block;
    width: fit-content;
}

.cc-cart-item__price {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--cc-cart-accent);
    margin-top: 2px;
}

.cc-cart-item__price ins,
.cc-cart-item__price .amount {
    font-weight: 700;
    text-decoration: none;
}

/* ── Quantity controls ───────────────────────────────────────────────────────── */

.cc-cart-item__controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 8px;
    gap: 8px;
}

.cc-cart-qty {
    display: flex;
    align-items: center;
    border: 1.5px solid var(--cc-cart-border);
    border-radius: 8px;
    overflow: hidden;
    height: 34px;
}

.cc-cart-qty__btn {
    width: 32px;
    height: 100%;
    border: none;
    background: none;
    color: var(--cc-cart-text);
    font-size: 1.1rem;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.12s;
    flex-shrink: 0;
    padding: 0;
}

.cc-cart-qty__btn:hover {
    background: var(--cc-cart-light);
}

.cc-cart-qty__input {
    width: 36px;
    border: none !important;
    border-left: 1px solid var(--cc-cart-border) !important;
    border-right: 1px solid var(--cc-cart-border) !important;
    border-radius: 0 !important;
    text-align: center;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--cc-cart-text);
    background: transparent !important;
    height: 100%;
    padding: 0 !important;
    outline: none !important;
    box-shadow: none !important;
    min-height: unset !important;
    -moz-appearance: textfield;
}

.cc-cart-qty__input::-webkit-outer-spin-button,
.cc-cart-qty__input::-webkit-inner-spin-button {
    -webkit-appearance: none;
}

.cc-cart-item__remove {
    width: 30px;
    height: 30px;
    border: none;
    background: none;
    cursor: pointer;
    color: var(--cc-cart-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.12s, color 0.12s;
    flex-shrink: 0;
    padding: 0;
}

.cc-cart-item__remove:hover {
    background: #fde8e7;
    color: #d93025;
}

.cc-cart-item__remove svg {
    width: 14px;
    height: 14px;
}

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

.cc-cart-drawer__footer {
    border-top: 1.5px solid var(--cc-cart-border);
    padding: 20px 24px 28px;
    flex-shrink: 0;
    background: var(--cc-cart-bg);
}

.cc-cart-drawer__subtotal {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
}

.cc-cart-drawer__subtotal-label {
    font-size: 0.9rem;
    color: var(--cc-cart-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.cc-cart-drawer__subtotal-value {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--cc-cart-text);
}

.cc-cart-drawer__subtotal-value .amount {
    font-weight: 800;
}

.cc-cart-drawer__shipping-note {
    font-size: 0.8rem;
    color: var(--cc-cart-muted);
    margin-bottom: 16px;
}

.cc-cart-drawer__checkout-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 15px 24px;
    background: var(--cc-cart-accent);
    color: #fff;
    text-decoration: none;
    font-size: 1rem;
    font-weight: 700;
    border-radius: var(--cc-cart-radius);
    transition: background 0.15s, transform 0.12s, box-shadow 0.15s;
    letter-spacing: 0.02em;
    box-shadow: 0 4px 12px rgba(139, 99, 80, 0.3);
    text-transform: uppercase;
    margin-bottom: 10px;
}

.cc-cart-drawer__checkout-btn svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.cc-cart-drawer__checkout-btn:hover {
    background: var(--cc-cart-accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(139, 99, 80, 0.4);
    color: #fff;
    text-decoration: none;
}

.cc-cart-drawer__checkout-btn:active {
    transform: translateY(0);
}

.cc-cart-drawer__view-cart {
    display: block;
    text-align: center;
    font-size: 0.85rem;
    color: var(--cc-cart-muted);
    text-decoration: none;
    transition: color 0.15s;
    padding: 4px;
}

.cc-cart-drawer__view-cart:hover {
    color: var(--cc-cart-accent);
    text-decoration: underline;
}

/* ── Floating trigger button ─────────────────────────────────────────────────── */

.cc-cart-trigger {
    position: fixed;
    bottom: 28px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--cc-cart-accent);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(139, 99, 80, 0.45);
    transition: transform 0.2s, box-shadow 0.2s, background 0.15s;
    z-index: 9997;
    padding: 0;
}

.cc-cart-trigger:hover {
    background: var(--cc-cart-accent-hover);
    transform: scale(1.08);
    box-shadow: 0 6px 24px rgba(139, 99, 80, 0.55);
}

.cc-cart-trigger:active {
    transform: scale(0.96);
}

.cc-cart-trigger svg {
    width: 24px;
    height: 24px;
}

.cc-cart-trigger__badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    border-radius: 999px;
    background: #2c1f13;
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    line-height: 20px;
    text-align: center;
    border: 2px solid #fff;
    transition: transform 0.2s;
}

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

.cc-cart-toast {
    position: fixed;
    bottom: 96px;
    right: 24px;
    background: #2c1f13;
    color: #fff;
    padding: 12px 18px;
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 20px rgba(44, 31, 19, 0.35);
    transform: translateY(16px);
    opacity: 0;
    visibility: hidden;
    transition: transform 0.25s, opacity 0.25s, visibility 0.25s;
    z-index: 99999;
    max-width: 280px;
}

.cc-cart-toast.is-visible {
    transform: translateY(0);
    opacity: 1;
    visibility: visible;
}

.cc-cart-toast__icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    color: #8bb86c;
}

/* ── Mobile ──────────────────────────────────────────────────────────────────── */

@media (max-width: 480px) {
    :root {
        --cc-cart-width: 100vw;
    }

    .cc-cart-drawer {
        border-radius: 0;
    }

    .cc-cart-drawer__header {
        padding: 16px 18px;
    }

    .cc-cart-item {
        padding: 14px 18px;
        gap: 12px;
    }

    .cc-cart-item__image {
        width: 68px;
        height: 68px;
    }

    /* 1.0.9 (2026-07-12): 48px tap targets for the qty stepper on mobile.
       Desktop stays compact (34px); phones (>90% of traffic) got a fiddly
       32x34px stepper - below the 48px minimum tap target. */
    .cc-cart-qty {
        height: 48px;
        border-radius: 10px;
    }

    .cc-cart-qty__btn {
        width: 48px;
        font-size: 1.4rem;
    }

    .cc-cart-qty__input {
        width: 52px;
        font-size: 1rem;
    }

    .cc-cart-item__remove {
        width: 44px;
        height: 44px;
    }

    .cc-cart-drawer__footer {
        padding: 16px 18px 24px;
    }

    .cc-cart-trigger {
        bottom: 20px;
        right: 16px;
    }

    .cc-cart-toast {
        bottom: 84px;
        right: 16px;
        left: 16px;
        max-width: none;
    }
}

/* ── Tablet ──────────────────────────────────────────────────────────────────── */

@media (min-width: 481px) and (max-width: 768px) {
    :root {
        --cc-cart-width: 380px;
    }
}
