/* ===========================================
   Cart Drawer + Overlay
   Slides in from the right. Full-width on mobile.
   =========================================== */

/* Overlay */
.cart-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(8px);
    z-index: 9998;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--duration-base) var(--ease-smooth),
        visibility var(--duration-base);
}

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

/* Drawer */
.cart-drawer {
    position: fixed;
    top: 0;
    right: 0;
    width: 400px;
    max-width: 100vw;
    height: 100vh;
    height: 100dvh;
    height: 100vh;
    height: 100dvh;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px) saturate(180%);
    z-index: 9999;
    transform: translateX(100%);
    transition: transform 300ms var(--ease-smooth);
    display: flex;
    flex-direction: column;
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.08);
    will-change: transform;
}

@media (max-width: 480px) {
    .cart-drawer {
        width: 100vw;
        max-width: 100%;
    }
}

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

/* Header */
.cart-drawer__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-5) var(--space-6);
    border-bottom: var(--border-thin) solid var(--border-light);
    flex-shrink: 0;
}

.cart-drawer__title {
    font-family: var(--font-serif);
    font-size: var(--text-xl);
    color: var(--ink-base);
}

.cart-drawer__close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    color: var(--ink-muted);
    cursor: pointer;
    border-radius: var(--radius-base);
    transition: background-color var(--duration-base);
}

.cart-drawer__close:hover {
    background-color: var(--bone-warm);
    color: var(--ink-base);
}

/* Shipping Progress */
.cart-shipping {
    padding: var(--space-4) var(--space-6);
    border-bottom: var(--border-thin) solid var(--border-light);
    flex-shrink: 0;
}

.shipping-progress-track {
    width: 100%;
    height: 4px;
    background: var(--bone-warm);
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: var(--space-2);
}

.shipping-progress-bar {
    height: 100%;
    width: 0%;
    background: var(--color-accent);
    border-radius: 2px;
    transition: width 400ms var(--ease-smooth);
}

.shipping-progress--complete {
    background: var(--color-accent);
}

.shipping-message {
    font-size: var(--text-xs);
    color: var(--ink-muted);
}

/* Empty State */
.cart-drawer__empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-6);
    flex: 1;
    padding: var(--space-10);
    text-align: center;
    color: var(--ink-muted);
}

/* Filled State */
.cart-drawer__filled {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
}

/* Cart Items (scrollable) */
.cart-items {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-4) var(--space-6);
}

/* Individual Cart Item */
.cart-item {
    display: grid;
    grid-template-columns: 56px 1fr auto;
    gap: var(--space-4);
    align-items: center;
    padding: var(--space-4) 0;
    border-bottom: var(--border-thin) solid var(--border-light);
}

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

.cart-item__img {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-base);
    object-fit: cover;
}

.cart-item__info {
    min-width: 0;
}

.cart-item__name {
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    color: var(--ink-base);
    margin-bottom: var(--space-1);
}

.cart-item__meta {
    font-size: var(--text-xs);
    color: var(--ink-muted);
    margin-bottom: var(--space-1);
}

.cart-item__price {
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    color: var(--ink-base);
}

/* Quantity Controls */
.cart-item__actions {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.cart-item__qty-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: var(--border-thin) solid var(--border-light);
    background: var(--white);
    border-radius: var(--radius-base);
    font-size: var(--text-base);
    color: var(--ink-soft);
    cursor: pointer;
    transition: all var(--duration-base);
}

.cart-item__qty-btn:hover {
    border-color: var(--ink-muted);
    color: var(--ink-base);
}

.cart-item__qty {
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    min-width: 20px;
    text-align: center;
}

.cart-item__remove {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    color: var(--ink-lightest);
    cursor: pointer;
    border-radius: var(--radius-base);
    transition: all var(--duration-base);
    margin-left: var(--space-2);
}

.cart-item__remove:hover {
    background: rgba(200, 50, 50, 0.08);
    color: var(--color-danger);
}

/* Upsell */
/* Upsell */
.cart-upsell {
    margin: var(--space-4) var(--space-6);
    padding: var(--space-4);
    background: linear-gradient(135deg, var(--bone-warm) 0%, var(--white) 100%);
    border: 1px solid var(--accent-sage);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    box-shadow: var(--shadow-sm);
}

.cart-upsell__msg {
    font-size: var(--text-sm);
    color: var(--ink-base);
    font-weight: var(--font-medium);
    line-height: 1.4;
}

/* Drawer Footer */
.cart-drawer__footer {
    padding: var(--space-5) var(--space-6);
    /* Fallback */
    padding-bottom: calc(var(--space-5) + env(safe-area-inset-bottom));
    border-top: var(--border-thin) solid var(--border-light);
    flex-shrink: 0;
    background: var(--bone-base);
}

.cart-drawer__subtotal {
    display: flex;
    justify-content: space-between;
    font-family: var(--font-serif);
    font-size: var(--text-lg);
    color: var(--ink-base);
    margin-bottom: var(--space-3);
}

.cart-drawer__shipping-note {
    font-size: var(--text-xs);
    color: var(--ink-muted);
    margin-bottom: var(--space-4);
}

.cart-drawer__guarantee {
    font-size: var(--text-xs);
    color: var(--ink-muted);
    text-align: center;
    margin-top: var(--space-3);
}

/* Cart Icon in Header */
.cart-toggle {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border: 1px solid transparent;
    background: transparent;
    cursor: pointer;
    color: var(--ink-base);
    border-radius: 50%;
    transition: background-color 0.2s ease, border-color 0.2s ease;
    z-index: 1001;
    /* Ensure it stays clickable/visible */
}

/* Hover state to make it feel interactive/distinct */
.cart-toggle:hover {
    background-color: rgba(0, 0, 0, 0.05);
    border-color: rgba(0, 0, 0, 0.1);
}

.cart-toggle__icon {
    width: 22px;
    height: 22px;
}

.cart-count {
    position: absolute;
    top: 4px;
    right: 2px;
    display: none;
    align-items: center;
    justify-content: center;
    min-width: 16px;
    height: 16px;
    background: var(--color-accent);
    color: var(--white);
    font-size: 10px;
    font-weight: var(--font-bold);
    border-radius: 999px;
    padding: 0 4px;
}