/* =====================================================================
   Beauty Retouch · Slideout cart · ralab2026
   Theme: brunn-child — BR design system tokens.
   ===================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Geist:wght@300;400;500;600;700&family=Geist+Mono:wght@400;500&family=Instrument+Serif:ital@0;1&display=swap');

/* ---------- Design tokens (scoped to slideout + loader) ---------- */
.ralab-ajax-cart,
.ralab-cart-loader {
    --br-paper: #fbf9f4;
    --br-bg: #f1eee7;
    --br-bg-2: #ece8df;
    --br-line: rgba(17, 17, 16, 0.10);
    --br-line-2: rgba(17, 17, 16, 0.06);
    --br-line-strong: rgba(17, 17, 16, 0.18);
    --br-ink: #111110;
    --br-ink-2: #2a2826;
    --br-muted: #6b6760;
    --br-frame-dark: #1c1a17;
    --br-accent: #C70606;
    --br-accent-hover: #a30505;
    --br-accent-ink: #ffffff;

    --br-sans: 'Geist', system-ui, -apple-system, sans-serif;
    --br-serif: 'Instrument Serif', Georgia, serif;
    --br-mono: 'Geist Mono', ui-monospace, monospace;

    --br-r-sm: 4px;
    --br-r-md: 8px;
    --br-r-pill: 999px;

    --br-shadow-input: 0 1px 2px rgba(17, 17, 16, 0.02);
    --br-shadow-focus: 0 0 0 3px rgba(17, 17, 16, 0.08);

    --slideout-dur: 280ms;
    --slideout-ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

/* =====================================================================
   LOADING OVERLAY — between click and slideout opening.
   ===================================================================== */
.ralab-cart-loader {
    position: fixed;
    inset: 0;
    z-index: 100000;
    pointer-events: none;
    background: rgba(28, 26, 23, 0.72);
    opacity: 0;
    visibility: hidden;
    transition: opacity 220ms var(--slideout-ease),
                visibility 0s linear 220ms;
}
.ralab-cart-loader.is-active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transition: opacity 180ms var(--slideout-ease),
                visibility 0s linear 0s;
}
.ralab-cart-loader__spinner {
    position: absolute;
    top: 50%;
    left: 50%;
    margin: -22px 0 0 -22px;
    width: 44px;
    height: 44px;
    border: 2px solid rgba(251, 249, 244, 0.25);
    border-top-color: var(--br-paper);
    border-radius: 50%;
    animation: ralab-loader-spin 0.8s linear infinite;
}
.ralab-cart-loader__sr {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}
@keyframes ralab-loader-spin {
    to { transform: rotate(360deg); }
}
@media (prefers-reduced-motion: reduce) {
    .ralab-cart-loader__spinner { animation: none; }
}

/* =====================================================================
   SLIDEOUT shell
   ---------------------------------------------------------------------
   Visibility is on a delayed transition so close animations get to finish
   before the drawer disappears from the accessibility tree.
   ===================================================================== */
html.ralab-ajax-cart-open,
html.ralab-ajax-cart-open body {
    overflow: hidden !important;
}

.ralab-ajax-cart {
    position: fixed;
    inset: 0;
    z-index: 99999;
    pointer-events: none;
    visibility: hidden;
    font-family: var(--br-sans);
    color: var(--br-ink);
    font-feature-settings: "tnum" 1;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition: visibility 0s linear var(--slideout-dur);
}
.ralab-ajax-cart.is-open {
    visibility: visible;
    pointer-events: auto;
    transition: visibility 0s linear 0s;
}

.ralab-ajax-cart__overlay {
    position: absolute;
    inset: 0;
    background: rgba(17, 17, 16, 0.42);
    opacity: 0;
    transition: opacity var(--slideout-dur) var(--slideout-ease);
    cursor: pointer;
}
.ralab-ajax-cart.is-open .ralab-ajax-cart__overlay { opacity: 1; }

.ralab-ajax-cart__panel {
    position: absolute;
    top: 0;
    right: 0;
    height: 100%;
    width: 440px;
    max-width: 100%;
    background: var(--br-paper);
    box-shadow: -24px 0 64px rgba(17, 17, 16, 0.14);
    display: flex;
    flex-direction: column;
    transform: translate3d(100%, 0, 0);
    transition: transform var(--slideout-dur) var(--slideout-ease);
    will-change: transform;
    overflow-x: hidden;
}
.ralab-ajax-cart.is-open .ralab-ajax-cart__panel {
    transform: translate3d(0, 0, 0);
}

/* =====================================================================
   HEADER
   ===================================================================== */
.ralab-ajax-cart__header {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 22px 28px 20px;
    border-bottom: 1px solid var(--br-line);
    background: var(--br-paper);
}
.ralab-ajax-cart__title {
    margin: 0;
    font-family: var(--br-serif);
    font-weight: 400;
    font-size: 26px;
    letter-spacing: -0.01em;
    line-height: 1.1;
    color: var(--br-ink);
    text-transform: none;
}
.ralab-ajax-cart__close {
    appearance: none;
    -webkit-appearance: none;
    background: transparent;
    border: 1px solid transparent;
    color: var(--br-ink);
    cursor: pointer;
    font-size: 28px;
    line-height: 1;
    width: 36px;
    height: 36px;
    padding: 0;
    margin: -4px -8px -4px 0;
    border-radius: var(--br-r-sm);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 140ms ease, border-color 140ms ease;
}
.ralab-ajax-cart__close:hover { background: var(--br-bg); }
.ralab-ajax-cart__close:focus-visible {
    outline: 0;
    box-shadow: var(--br-shadow-focus);
    border-color: var(--br-line-strong);
}

/* =====================================================================
   BODY container
   ===================================================================== */
.ralab-ajax-cart__body {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

/* =====================================================================
   ITEMS LIST — new structure
   ---------------------------------------------------------------------
   [ thumb ]   Name                          [trash]
               Variation: value
               [ − qty + ]            $subtotal
   ===================================================================== */
.ralab-ajax-cart__items {
    list-style: none;
    margin: 0;
    padding: 4px 0;
    flex: 1 1 auto;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    min-width: 0;
}
.ralab-ajax-cart__items::-webkit-scrollbar { width: 8px; }
.ralab-ajax-cart__items::-webkit-scrollbar-track { background: transparent; }
.ralab-ajax-cart__items::-webkit-scrollbar-thumb {
    background: rgba(17, 17, 16, 0.18);
    border-radius: 4px;
}
.ralab-ajax-cart__items::-webkit-scrollbar-thumb:hover { background: rgba(17, 17, 16, 0.32); }

.ralab-ajax-cart__item {
    display: grid;
    grid-template-columns: 88px 1fr;
    column-gap: 18px;
    padding: 22px 28px;
    border-bottom: 1px solid var(--br-line-2);
    min-width: 0;
    transition: background 140ms ease;
}
.ralab-ajax-cart__item:last-child { border-bottom: 0; }
.ralab-ajax-cart__item:hover { background: rgba(17, 17, 16, 0.015); }

.ralab-ajax-cart__item-thumb {
    width: 88px;
    height: 88px;
    border-radius: var(--br-r-md);
    overflow: hidden;
    background: var(--br-bg-2);
    border: 1px solid var(--br-line-2);
}
.ralab-ajax-cart__item-thumb a,
.ralab-ajax-cart__item-thumb img {
    display: block;
    width: 100%;
    height: 100%;
}
.ralab-ajax-cart__item-thumb img { object-fit: cover; }

.ralab-ajax-cart__item-body {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Top row: name + trash icon */
.ralab-ajax-cart__item-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    min-width: 0;
}
.ralab-ajax-cart__item-name {
    flex: 1 1 auto;
    min-width: 0;
    font-family: var(--br-sans);
    font-size: 15px;
    font-weight: 500;
    line-height: 1.35;
    letter-spacing: -0.005em;
    color: var(--br-ink);
    overflow-wrap: anywhere;
    word-break: break-word;
}
.ralab-ajax-cart__item-name a {
    color: inherit;
    text-decoration: none;
}
.ralab-ajax-cart__item-name a:hover {
    text-decoration: underline;
    text-underline-offset: 3px;
}

/* Trash icon — replaces the old text "Remove" link */
.ralab-ajax-cart__remove {
    flex: 0 0 28px;
    appearance: none;
    -webkit-appearance: none;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--br-r-sm);
    color: var(--br-muted);
    cursor: pointer;
    width: 28px;
    height: 28px;
    padding: 0;
    margin: -2px -4px 0 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: color 140ms ease, background 140ms ease, border-color 140ms ease;
}
.ralab-ajax-cart__remove:hover {
    color: var(--br-accent);
    background: rgba(199, 6, 6, 0.06);
}
.ralab-ajax-cart__remove:focus-visible {
    outline: 0;
    border-color: var(--br-line-strong);
    box-shadow: var(--br-shadow-focus);
}
.ralab-ajax-cart__remove .ralab-ajax-cart__icon {
    display: block;
}

/* Variation list */
.ralab-ajax-cart__item-variation {
    min-width: 0;
}
.ralab-ajax-cart__item-variation dl.variation {
    margin: 0;
    font-family: var(--br-sans);
    font-size: 12px;
    line-height: 1.45;
    color: var(--br-muted);
    overflow-wrap: anywhere;
    word-break: break-word;
}
.ralab-ajax-cart__item-variation dl.variation dt,
.ralab-ajax-cart__item-variation dl.variation dd {
    display: inline;
    margin: 0;
}
.ralab-ajax-cart__item-variation dl.variation dt { font-weight: 500; }
.ralab-ajax-cart__item-variation dl.variation dt::after { content: ": "; }
.ralab-ajax-cart__item-variation dl.variation dd + dt::before { content: " · "; }

/* Bottom row: qty on left, line subtotal on right */
.ralab-ajax-cart__item-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-width: 0;
    margin-top: 4px;
}

/* =====================================================================
   QUANTITY PILL — compact size
   ===================================================================== */
.ralab-ajax-cart__qty {
    display: inline-flex;
    align-items: stretch;
    background: var(--br-paper);
    border: 1px solid var(--br-line-strong);
    border-radius: var(--br-r-pill);
    overflow: hidden;
    height: 28px;
    flex: 0 0 auto;
    min-width: 0;
    box-shadow: var(--br-shadow-input);
}
.ralab-ajax-cart__qty-btn {
    appearance: none;
    -webkit-appearance: none;
    background: transparent;
    border: 0;
    color: var(--br-ink);
    cursor: pointer;
    flex: 0 0 26px;
    width: 26px;
    min-width: 26px;
    height: 100%;
    padding: 0;
    margin: 0;
    box-sizing: border-box;
    font-family: var(--br-sans);
    font-size: 14px;
    font-weight: 400;
    line-height: 1;
    transition: background 140ms ease, color 140ms ease;
}
.ralab-ajax-cart__qty-btn:hover { background: var(--br-bg); }
.ralab-ajax-cart__qty-btn:focus-visible {
    outline: 0;
    background: var(--br-bg);
    box-shadow: inset var(--br-shadow-focus);
}
.ralab-ajax-cart__qty-btn:active { background: var(--br-bg-2); }

.ralab-ajax-cart__qty-input,
.ralab-ajax-cart__qty-input[type="number"] {
    flex: 0 0 32px;
    width: 32px;
    min-width: 32px;
    max-width: 32px;
    height: 100%;
    padding: 0;
    margin: 0;
    box-sizing: border-box;
    border: 0;
    border-left: 1px solid var(--br-line);
    border-right: 1px solid var(--br-line);
    text-align: center;
    font-family: var(--br-mono);
    font-size: 12px;
    font-weight: 500;
    color: var(--br-ink);
    background: transparent;
    border-radius: 0;
    line-height: 26px;
    -moz-appearance: textfield;
    -webkit-appearance: none;
    appearance: none;
}
.ralab-ajax-cart__qty-input::-webkit-outer-spin-button,
.ralab-ajax-cart__qty-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
.ralab-ajax-cart__qty-input:focus-visible {
    outline: 0;
    background: var(--br-bg);
}

.ralab-ajax-cart__item-subtotal {
    font-family: var(--br-mono);
    font-size: 14px;
    font-weight: 500;
    color: var(--br-ink);
    text-align: right;
    flex-shrink: 0;
    white-space: nowrap;
}
.ralab-ajax-cart__item-subtotal .woocommerce-Price-amount {
    font-family: inherit;
    font-size: inherit;
    color: inherit;
}

/* =====================================================================
   FOOTER
   ===================================================================== */
.ralab-ajax-cart__footer {
    flex: 0 0 auto;
    border-top: 1px solid var(--br-line);
    padding: 22px 28px calc(24px + env(safe-area-inset-bottom, 0px));
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: var(--br-paper);
    min-width: 0;
}
.ralab-ajax-cart__subtotal {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    min-width: 0;
}
.ralab-ajax-cart__subtotal-label {
    color: var(--br-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 11px;
    font-weight: 500;
    font-family: var(--br-sans);
}
.ralab-ajax-cart__subtotal-value {
    font-family: var(--br-mono);
    font-weight: 500;
    font-size: 20px;
    color: var(--br-ink);
    white-space: nowrap;
}
.ralab-ajax-cart__subtotal-value .woocommerce-Price-amount {
    font-family: inherit;
    font-size: inherit;
    color: inherit;
}

.ralab-ajax-cart__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 52px;
    padding: 0 24px;
    border-radius: var(--br-r-md);
    font-family: var(--br-sans);
    font-size: 14px;
    font-weight: 500;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    text-decoration: none;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    border: 1px solid transparent;
    transition: background 160ms ease, color 160ms ease, border-color 160ms ease, transform 60ms ease;
}
.ralab-ajax-cart__btn:active { transform: translateY(1px); }
.ralab-ajax-cart__btn--primary {
    background: var(--br-accent);
    color: var(--br-accent-ink);
}
.ralab-ajax-cart__btn--primary:hover {
    background: var(--br-accent-hover);
    color: var(--br-accent-ink);
}
.ralab-ajax-cart__btn--primary:focus-visible {
    outline: 0;
    box-shadow: 0 0 0 3px rgba(199, 6, 6, 0.18);
}
.ralab-ajax-cart__btn--ghost {
    background: transparent;
    color: var(--br-ink);
    border-color: var(--br-line-strong);
}
.ralab-ajax-cart__btn--ghost:hover { background: var(--br-bg); }

/* =====================================================================
   EMPTY STATE
   ===================================================================== */
.ralab-ajax-cart__empty {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 24px;
    padding: 64px 28px;
    text-align: center;
}
.ralab-ajax-cart__empty-msg {
    margin: 0;
    font-family: var(--br-serif);
    font-size: 22px;
    color: var(--br-muted);
    line-height: 1.3;
}

/* Loading state on add-to-cart triggers (page-level links) */
a.is-loading,
.add_to_cart_button.is-loading {
    opacity: 0.6;
    pointer-events: none;
}

/* =====================================================================
   MOBILE — full-screen takeover at ≤768px
   ===================================================================== */
@media (max-width: 768px) {
    .ralab-ajax-cart__panel { width: 100%; }
    .ralab-ajax-cart__header {
        padding: 18px 20px 16px;
    }
    .ralab-ajax-cart__title { font-size: 22px; }
    .ralab-ajax-cart__item {
        padding: 18px 20px;
        grid-template-columns: 72px 1fr;
        column-gap: 14px;
    }
    .ralab-ajax-cart__item-thumb {
        width: 72px;
        height: 72px;
    }
    .ralab-ajax-cart__footer {
        padding: 18px 20px calc(20px + env(safe-area-inset-bottom, 0px));
    }
    .ralab-ajax-cart__btn {
        height: 56px;
        font-size: 13px;
    }
    .ralab-cart-loader__spinner {
        width: 40px;
        height: 40px;
        margin: -20px 0 0 -20px;
    }
}

/* =====================================================================
   Reduced motion
   ===================================================================== */
@media (prefers-reduced-motion: reduce) {
    .ralab-ajax-cart,
    .ralab-ajax-cart__overlay,
    .ralab-ajax-cart__panel,
    .ralab-cart-loader {
        transition: none;
    }
}

/* =====================================================================
   In-slideout busy state — shown during qty/remove AJAX updates.
   Soft paper overlay + small spinner inside the body. Header (close) and
   overlay-click-to-close stay interactive; the items list and footer are
   blocked.
   ===================================================================== */
.ralab-ajax-cart__body { position: relative; }
.ralab-ajax-cart__body::before,
.ralab-ajax-cart__body::after {
    content: "";
    position: absolute;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 140ms ease, visibility 0s linear 140ms;
}
.ralab-ajax-cart__body::before {
    inset: 0;
    background: rgba(251, 249, 244, 0.62); /* var(--br-paper) @ ~62% */
    z-index: 1;
}
.ralab-ajax-cart__body::after {
    top: 50%;
    left: 50%;
    margin: -14px 0 0 -14px;
    width: 28px;
    height: 28px;
    border: 2px solid var(--br-line);
    border-top-color: var(--br-ink);
    border-radius: 50%;
    animation: ralab-loader-spin 0.8s linear infinite;
    animation-play-state: paused;
    z-index: 2;
}
.ralab-ajax-cart__body.is-updating {
    pointer-events: none;
}
.ralab-ajax-cart__body.is-updating::before,
.ralab-ajax-cart__body.is-updating::after {
    opacity: 1;
    visibility: visible;
    transition: opacity 140ms ease, visibility 0s linear 0s;
}
.ralab-ajax-cart__body.is-updating::after {
    animation-play-state: running;
}
@media (prefers-reduced-motion: reduce) {
    .ralab-ajax-cart__body.is-updating::after {
        animation: none;
    }
}

/* =====================================================================
   Primary CTA — mirror the checkout page's `#place_order` ("Pay Now").
   Padding-based sizing, 600 weight, wider tracking, same transitions
   and hover/active/disabled behavior as the Pay Now button so the
   slideout's checkout button reads as a sibling of it.
   ===================================================================== */
.ralab-ajax-cart .ralab-ajax-cart__btn--primary {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: auto;
    padding: 18px 24px;
    background: var(--br-accent);
    color: var(--br-accent-ink);
    border: none;
    border-radius: var(--br-r-md);
    box-shadow: none;
    font-family: var(--br-sans);
    font-weight: 600;
    font-size: 14px;
    letter-spacing: 0.06em;
    line-height: 1.2;
    text-transform: uppercase;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.1s ease;
}
.ralab-ajax-cart .ralab-ajax-cart__btn--primary:hover {
    background: var(--br-accent-hover);
    color: var(--br-accent-ink);
    filter: none;
}
.ralab-ajax-cart .ralab-ajax-cart__btn--primary:active {
    transform: translateY(1px);
}
.ralab-ajax-cart .ralab-ajax-cart__btn--primary:focus-visible {
    outline: 0;
    box-shadow: 0 0 0 3px rgba(199, 6, 6, 0.18);
}
.ralab-ajax-cart .ralab-ajax-cart__btn--primary:disabled,
.ralab-ajax-cart .ralab-ajax-cart__btn--primary.loading,
.ralab-ajax-cart .ralab-ajax-cart__btn--primary.is-loading {
    opacity: 0.7;
    cursor: wait;
}

@media (max-width: 768px) {
    .ralab-ajax-cart .ralab-ajax-cart__btn--primary {
        font-size: 13px;
        padding: 16px 18px;
    }
}

/* Box-sizing fix: width 100% + 24px padding was overflowing the footer. */
.ralab-ajax-cart .ralab-ajax-cart__btn,
.ralab-ajax-cart .ralab-ajax-cart__btn--primary {
    box-sizing: border-box;
}

/* =====================================================================
   After-swap layout adjustments.
   Price now lives on the name row → make it sit on the first baseline of
   the (potentially wrapping) name, and bump weight to match.
   Trash now lives on the qty row → clear the negative offset it had when
   it was paired with the name.
   ===================================================================== */
.ralab-ajax-cart__item-head {
    align-items: baseline;
}
.ralab-ajax-cart__item-head .ralab-ajax-cart__item-subtotal {
    font-size: 15px;
    color: var(--br-ink);
}
.ralab-ajax-cart__item-meta .ralab-ajax-cart__remove {
    margin: 0;
}
