/* ═══════════════════════════════════════════════════════════════════
   SFSC Cart Drawer — site-wide right-side slide-in shell.

   Phase 1 (skeleton): open/close mechanics + visual scaffold.
   Body and footer are placeholders for Phase 2-4 work.

   State machine: [data-state="open"|"closed"] on the .sfsc-cart-drawer
   root drives transitions. Reduced-motion drops the slide animation.
   ═══════════════════════════════════════════════════════════════════ */

/* Root — full-viewport overlay container. pointer-events:none in the
   closed state so clicks fall through to the page; flips to auto when
   open. No visibility:hidden because that would freeze transitions. */
.sfsc-cart-drawer {
    position: fixed;
    inset: 0;
    z-index: 1100;          /* Above sticky header (z=1000) */
    pointer-events: none;
}
.sfsc-cart-drawer[data-state="open"] {
    pointer-events: auto;
}

/* Overlay — full-cover scrim, fades in/out */
.sfsc-cart-drawer-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    opacity: 0;
    transition: opacity 280ms ease-out;
}
.sfsc-cart-drawer[data-state="open"] .sfsc-cart-drawer-overlay {
    opacity: 1;
}

/* Panel — slides in from the right edge */
.sfsc-cart-drawer-panel {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: clamp(320px, 90vw, 440px);
    background: #FFFFFF;
    transform: translateX(100%);
    transition: transform 280ms ease-out;
    display: flex;
    flex-direction: column;
    overflow: hidden;       /* Internal scroll lives on the body div */
}
.sfsc-cart-drawer[data-state="open"] .sfsc-cart-drawer-panel {
    transform: translateX(0);
}

/* Header — title + close button */
.sfsc-cart-drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid rgba(229, 231, 235, 0.8);
    flex-shrink: 0;
}
.sfsc-cart-drawer-title {
    font-family: 'Poppins', system-ui, sans-serif;
    font-size: 16px;
    font-weight: 600;
    color: #0B1622;
    margin: 0;
    line-height: 1.2;
}
.sfsc-cart-drawer-count {
    color: rgba(0, 0, 0, 0.55);
    font-weight: 500;
    margin-left: 4px;
}
.sfsc-cart-drawer-close {
    width: 36px;
    height: 36px;
    border: 0;
    background: transparent;
    border-radius: 9999px;
    color: rgba(0, 0, 0, 0.7);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background-color 200ms ease, color 200ms ease;
}
.sfsc-cart-drawer-close:hover {
    background: rgba(0, 0, 0, 0.05);
    color: #0B1622;
}
.sfsc-cart-drawer-close:focus-visible {
    outline: 2px solid rgba(0, 0, 0, 0.3);
    outline-offset: 2px;
}

/* Body — scrollable content area, populated in Phase 2 */
.sfsc-cart-drawer-body {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 1.5rem;
}

/* Footer — promo / subtotal / checkout in Phase 4. Hidden in Phase 1
   since the empty markup would otherwise render a thin border + padding
   band. Phase 4 will swap to display: block (or flex) when populating. */
.sfsc-cart-drawer-footer {
    display: none;
    flex-shrink: 0;
    border-top: 1px solid rgba(229, 231, 235, 0.8);
    padding: 1rem 1.5rem;
}

/* Reduced motion — instant snap, no slide animation */
@media (prefers-reduced-motion: reduce) {
    .sfsc-cart-drawer-panel,
    .sfsc-cart-drawer-overlay {
        transition: none;
    }
}


/* ═══════════════════════════════════════════════════════════════════
   Phase 2 — cart state UI: loading, empty, error, populated.
   States are mutually exclusive; toggled via [data-cart-state]
   attribute on the .sfsc-cart-drawer root.
   ═══════════════════════════════════════════════════════════════════ */

/* All state containers hidden by default; data-cart-state shows one */
.sfsc-cart-drawer-loading,
.sfsc-cart-drawer-empty,
.sfsc-cart-drawer-error,
.sfsc-cart-drawer-list {
    display: none;
}
.sfsc-cart-drawer[data-cart-state="loading"] .sfsc-cart-drawer-loading,
.sfsc-cart-drawer[data-cart-state="empty"]   .sfsc-cart-drawer-empty,
.sfsc-cart-drawer[data-cart-state="error"]   .sfsc-cart-drawer-error {
    display: flex;
}
.sfsc-cart-drawer[data-cart-state="populated"] .sfsc-cart-drawer-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.sfsc-cart-drawer[data-cart-state="populated"] .sfsc-cart-drawer-footer {
    display: block;   /* Overrides Phase 1's display: none */
}

/* Loading state — centered spinner */
.sfsc-cart-drawer-loading {
    align-items: center;
    justify-content: center;
    padding: 3rem 1rem;
    flex-direction: column;
    gap: 0.75rem;
    color: rgba(0, 0, 0, 0.45);
}
.sfsc-cart-drawer-spinner {
    animation: sfsc-cart-drawer-spin 800ms linear infinite;
}
@keyframes sfsc-cart-drawer-spin {
    to { transform: rotate(360deg); }
}
@media (prefers-reduced-motion: reduce) {
    .sfsc-cart-drawer-spinner { animation: none; }
}
.sfsc-cart-drawer-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Empty state — icon wrap + heading + sub + CTA */
.sfsc-cart-drawer-empty {
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 3rem 1rem 1rem;
    gap: 0.75rem;
}
.sfsc-cart-drawer-empty__icon-wrap {
    width: 80px;
    height: 80px;
    border-radius: 16px;
    background: #f5f5f4;
    color: #d4d4d8;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 0.5rem;
}
.sfsc-cart-drawer-empty__heading {
    font-family: 'Poppins', system-ui, sans-serif;
    font-size: 18px;
    font-weight: 600;
    color: #0B1622;
    margin: 0;
    line-height: 1.3;
}
.sfsc-cart-drawer-empty__sub {
    font-size: 14px;
    color: rgba(0, 0, 0, 0.55);
    margin: 0;
    line-height: 1.5;
    max-width: 28ch;
}
.sfsc-cart-drawer-empty__cta {
    margin-top: 1rem;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 12px 24px;
    background: #0B1622;
    color: #FFFFFF;
    border-radius: 9999px;
    font-family: 'Poppins', system-ui, sans-serif;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    transition: background-color 200ms ease;
}
.sfsc-cart-drawer-empty__cta:hover { background: #27272a; }

/* Error state */
.sfsc-cart-drawer-error {
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 3rem 1rem;
    gap: 0.75rem;
}
.sfsc-cart-drawer-error__msg {
    font-size: 14px;
    color: rgba(0, 0, 0, 0.65);
    margin: 0;
}
.sfsc-cart-drawer-retry {
    padding: 8px 20px;
    border: 1px solid rgba(0, 0, 0, 0.15);
    background: transparent;
    border-radius: 9999px;
    font-family: 'Poppins', system-ui, sans-serif;
    font-size: 13px;
    font-weight: 500;
    color: #0B1622;
    cursor: pointer;
    transition: background-color 200ms ease;
}
.sfsc-cart-drawer-retry:hover { background: rgba(0, 0, 0, 0.04); }

/* Cart line — single product row */
.sfsc-cart-line {
    display: flex;
    gap: 12px;
    padding: 16px;
    background: #FFFFFF;
    border: 1px solid #e8e8e8;
    border-radius: 16px;
}
.sfsc-cart-line__thumb {
    flex-shrink: 0;
    width: 72px;
    height: 72px;
    border-radius: 12px;
    background: #f5f5f4;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}
.sfsc-cart-line__thumb img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}
.sfsc-cart-line__thumb-fallback { color: #d4d4d8; }
.sfsc-cart-line__main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.sfsc-cart-line__head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
}
.sfsc-cart-line__name {
    font-family: 'Poppins', system-ui, sans-serif;
    font-size: 16px;
    font-weight: 600;
    color: #0B1622;
    margin: 0;
    line-height: 1.25;
    text-decoration: none;
}
.sfsc-cart-line__name:hover { text-decoration: underline; }
.sfsc-cart-line__remove {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    color: rgba(0, 0, 0, 0.4);
    cursor: default;       /* Phase 2: no functionality, Phase 3 wires */
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.sfsc-cart-line__attr {
    font-size: 14px;
    color: rgba(0, 0, 0, 0.55);
    margin: 0;
}
.sfsc-cart-line__foot {
    margin-top: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}
.sfsc-cart-line__qty {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px 4px 14px;
    border: 1px solid #e8e8e8;
    border-radius: 9999px;
    font-family: 'Poppins', system-ui, sans-serif;
    font-size: 14px;
    font-weight: 500;
    color: #0B1622;
    cursor: default;       /* Phase 2: static, Phase 3 wires interactive */
}
.sfsc-cart-line__qty svg { color: rgba(0, 0, 0, 0.4); }
.sfsc-cart-line__price {
    font-family: 'Poppins', system-ui, sans-serif;
    font-size: 16px;
    font-weight: 600;
    color: #0B1622;
    font-variant-numeric: tabular-nums;
}

/* Shipment Protection row in footer (Phase 2: static "Free", Phase 3
   will wire the toggle). Sits inside .sfsc-cart-drawer-footer which
   only renders when the drawer is in [data-cart-state="populated"]. */
.sfsc-cart-shipment-protection {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: #FFFFFF;
    border: 1px solid #e8e8e8;
    border-radius: 16px;
    font-family: 'Poppins', system-ui, sans-serif;
    font-size: 14px;
    color: #0B1622;
}
.sfsc-cart-shipment-protection__label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: rgba(0, 0, 0, 0.7);
}
.sfsc-cart-shipment-protection__label svg { color: #16A34A; }
.sfsc-cart-shipment-protection__value {
    color: #16A34A;
    font-weight: 600;
}
