/* =============================================================================
   cart.css — Nieryy Cart Drawer
   All selectors scoped to #nieryyCartDrawer and #nieryyCartOverlay.
   Relies on CSS custom properties defined in styles.css :root.
   ============================================================================= */

/* ---------------------------------------------------------------------------
   Overlay — full-screen backdrop behind the drawer
   --------------------------------------------------------------------------- */
#nieryyCartOverlay {
    position: fixed;
    inset: 0;
    z-index: 9980;
    background: rgba(26, 26, 26, 0.5);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.35s ease;
}

#nieryyCartOverlay.is-open {
    opacity: 1;
    pointer-events: auto;
}

/* ---------------------------------------------------------------------------
   Drawer shell — slides in from the right
   --------------------------------------------------------------------------- */
#nieryyCartDrawer {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 420px;
    max-width: 100vw;
    background: var(--bg-primary, #FDFCFA);
    z-index: 9981;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.45s var(--ease-out, cubic-bezier(0.16, 1, 0.3, 1)),
                opacity 0.45s var(--ease-out, cubic-bezier(0.16, 1, 0.3, 1));
    opacity: 0;
    box-shadow: -12px 0 60px rgba(0, 0, 0, 0.12);
}

#nieryyCartDrawer.is-open {
    transform: translateX(0);
    opacity: 1;
}

/* ---------------------------------------------------------------------------
   Header — title + item count + close button
   --------------------------------------------------------------------------- */
.cart-drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 24px 28px;
    border-bottom: 1px solid var(--border, rgba(90, 62, 50, 0.1));
    flex-shrink: 0;
}

.cart-drawer-title {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* "Your Bag" label */
.cart-drawer-label {
    font-family: var(--font-body, 'Lora', 'Georgia', serif);
    font-size: 11px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--text-primary, #1a1a1a);
    font-weight: 500;
}

/* Item count badge e.g. "(3)" */
.cart-drawer-count {
    font-family: var(--font-body, 'Lora', 'Georgia', serif);
    font-size: 12px;
    color: var(--accent-gold, #C9A45D);
    letter-spacing: 0.05em;
}

/* × close button */
.cart-drawer-close {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-primary, #1a1a1a);
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.6;
    transition: opacity 0.2s;
}

.cart-drawer-close:hover {
    opacity: 1;
}

/* ---------------------------------------------------------------------------
   Body — scrollable line-item list
   --------------------------------------------------------------------------- */
.cart-drawer-body {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
}

/* Thin gold-tinted scrollbar on WebKit */
.cart-drawer-body::-webkit-scrollbar {
    width: 3px;
}

.cart-drawer-body::-webkit-scrollbar-track {
    background: transparent;
}

.cart-drawer-body::-webkit-scrollbar-thumb {
    background: var(--border, rgba(90, 62, 50, 0.1));
    border-radius: 2px;
}

/* ---------------------------------------------------------------------------
   Empty state
   --------------------------------------------------------------------------- */
.cart-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 64px 32px;
    text-align: center;
    gap: 12px;
}

.cart-empty-icon {
    color: var(--accent-gold, #C9A45D);
    opacity: 0.6;
    margin-bottom: 8px;
}

.cart-empty-title {
    font-family: var(--font-heading, 'TanAegean', 'Georgia', serif);
    font-weight: 400;
    font-size: 20px;
    color: var(--text-primary, #1a1a1a);
    margin: 0;
}

.cart-empty-text {
    font-family: var(--font-body, 'Lora', 'Georgia', serif);
    font-size: 13px;
    color: var(--text-muted, #9e8a7e);
    font-style: italic;
    margin: 0;
}

/* "Explore the Edit" CTA link */
.cart-empty-cta {
    margin-top: 8px;
    font-family: var(--font-body, 'Lora', 'Georgia', serif);
    font-size: 12px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-primary, #1a1a1a);
    text-decoration: underline;
    text-underline-offset: 4px;
    transition: color 0.2s;
}

.cart-empty-cta:hover {
    color: var(--rose, #D63362);
}

/* ---------------------------------------------------------------------------
   Line items
   --------------------------------------------------------------------------- */
.cart-line {
    display: flex;
    gap: 16px;
    padding: 20px 28px;
    border-bottom: 1px solid var(--border, rgba(90, 62, 50, 0.1));
    max-height: 140px;
    overflow: hidden;
    transition: max-height 0.35s var(--ease-out, cubic-bezier(0.16, 1, 0.3, 1)),
                opacity 0.3s ease,
                padding 0.3s ease;
}

/* Animated removal: collapse height and fade out */
.cart-line.is-removing {
    max-height: 0;
    opacity: 0;
    padding-top: 0;
    padding-bottom: 0;
    pointer-events: none;
}

/* Product image link wrapper */
.cart-line-image {
    flex-shrink: 0;
    display: block;
}

/* Product image */
.cart-line-img {
    width: 72px;
    height: 96px;
    object-fit: cover;
    background: var(--bg-secondary, #F5F1EB);
    display: block;
}

/* Placeholder when no image available */
.cart-line-img-placeholder {
    width: 72px;
    height: 96px;
    background: var(--bg-secondary, #F5F1EB);
}

/* Details column */
.cart-line-details {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 0;
}

/* Top row: title + remove button */
.cart-line-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
}

/* Product title */
.cart-line-title {
    font-family: var(--font-body, 'Lora', 'Georgia', serif);
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary, #1a1a1a);
    margin: 0;
    line-height: 1.4;
}

/* Variant subtitle e.g. "M / Rose" */
.cart-line-variant {
    font-family: var(--font-body, 'Lora', 'Georgia', serif);
    font-size: 11px;
    color: var(--text-muted, #9e8a7e);
    font-style: italic;
    margin: 4px 0 0;
}

/* × remove button */
.cart-line-remove {
    background: none;
    border: none;
    cursor: pointer;
    flex-shrink: 0;
    color: var(--text-muted, #9e8a7e);
    padding: 2px;
    display: flex;
    align-items: center;
    transition: color 0.2s;
    line-height: 1;
}

.cart-line-remove:hover {
    color: var(--rose, #D63362);
}

/* Bottom row: qty controls + line price */
.cart-line-bottom {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: auto;
}

/* ---------------------------------------------------------------------------
   Quantity controls
   --------------------------------------------------------------------------- */
.cart-qty {
    display: flex;
    align-items: center;
    gap: 0;
    border: 1px solid var(--border, rgba(90, 62, 50, 0.1));
    border-radius: 2px;
    overflow: hidden;
}

/* Disabled state while API call is in-flight */
.cart-qty.is-updating {
    opacity: 0.4;
    pointer-events: none;
}

/* − and + buttons */
.cart-qty-btn {
    background: none;
    border: none;
    cursor: pointer;
    width: 30px;
    height: 28px;
    font-family: var(--font-body, 'Lora', 'Georgia', serif);
    font-size: 16px;
    font-weight: 300;
    color: var(--text-primary, #1a1a1a);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, color 0.2s;
}

.cart-qty-btn:hover {
    background: var(--bg-secondary, #F5F1EB);
}

/* Numeric value display */
.cart-qty-val {
    min-width: 28px;
    text-align: center;
    font-family: var(--font-body, 'Lora', 'Georgia', serif);
    font-size: 13px;
    color: var(--text-primary, #1a1a1a);
    border-left: 1px solid var(--border, rgba(90, 62, 50, 0.1));
    border-right: 1px solid var(--border, rgba(90, 62, 50, 0.1));
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Line total (qty × unit price) */
.cart-line-price {
    font-family: var(--font-body, 'Lora', 'Georgia', serif);
    font-size: 13px;
    color: var(--text-primary, #1a1a1a);
    font-weight: 500;
}

/* ---------------------------------------------------------------------------
   Footer — subtotal, checkout, continue shopping
   Hidden when cart is empty (toggled via JS)
   --------------------------------------------------------------------------- */
.cart-drawer-footer {
    display: none; /* shown via JS when cart has items */
    flex-direction: column;
    gap: 12px;
    padding: 20px 28px 28px;
    border-top: 1px solid var(--border, rgba(90, 62, 50, 0.1));
    flex-shrink: 0;
    background: var(--bg-primary, #FDFCFA);
}

/* Subtotal row */
.cart-drawer-subtotal {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.cart-drawer-subtotal-label {
    font-family: var(--font-body, 'Lora', 'Georgia', serif);
    font-size: 12px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-muted, #9e8a7e);
}

/* Large subtotal amount in heading font */
.cart-drawer-subtotal-value {
    font-family: var(--font-heading, 'TanAegean', 'Georgia', serif);
    font-size: 20px;
    color: var(--text-primary, #1a1a1a);
    font-weight: 400;
}

/* Small italic note */
.cart-drawer-note {
    font-family: var(--font-body, 'Lora', 'Georgia', serif);
    font-size: 11px;
    color: var(--text-muted, #9e8a7e);
    font-style: italic;
    margin: 0;
    text-align: center;
}

/* Primary checkout CTA button */
.cart-drawer-checkout {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 16px;
    background: var(--text-primary, #1a1a1a);
    color: #FDFCFA;
    font-family: var(--font-body, 'Lora', 'Georgia', serif);
    font-size: 12px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    border: none;
    cursor: pointer;
    border-radius: 2px;
    transition: background 0.3s ease;
}

.cart-drawer-checkout:hover {
    background: var(--rose, #D63362);
}

/* Arrow icon slides right on hover */
.cart-drawer-checkout svg {
    transition: transform 0.3s ease;
}

.cart-drawer-checkout:hover svg {
    transform: translateX(4px);
}

/* "Continue Shopping" text link */
.cart-drawer-continue {
    display: block;
    text-align: center;
    font-family: var(--font-body, 'Lora', 'Georgia', serif);
    font-size: 11px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-muted, #9e8a7e);
    text-decoration: underline;
    text-underline-offset: 3px;
    transition: color 0.2s;
}

.cart-drawer-continue:hover {
    color: var(--text-primary, #1a1a1a);
}

/* ---------------------------------------------------------------------------
   Mobile — full-width drawer, tighter padding
   --------------------------------------------------------------------------- */
@media (max-width: 480px) {
    #nieryyCartDrawer {
        width: 100vw;
    }

    .cart-drawer-header,
    .cart-line,
    .cart-drawer-footer {
        padding-left: 20px;
        padding-right: 20px;
    }
}
