/*
 * shop/css/cart-drawer.css — global slide-in cart drawer + header cart link.
 *
 * Loaded from index.html AND every shop page (via shop.css @import). All
 * rules are scoped to their own .cart-* classes so nothing leaks into the
 * surrounding page. Relies on the brand CSS custom properties defined in
 * the host page's :root (--gold, --bg-card, --border, etc.) — index.html
 * declares them; shop.css redeclares them.
 *
 * No global resets here. This file must be safe to drop into any HTML
 * page without breaking layout.
 */

/* ---------- Nav cart link (inside index.html's existing nav) ----------
 * No display override here — let it inherit the same inline-anchor
 * baseline as the other .nav-links a items, so "Cart (n)" sits flush
 * with Music / About / Gallery / etc.
 *
 * Hide the cart link entirely when the cart is empty. cart.js toggles
 * the `.is-empty` class on .nav-cart itself (and on the inner badge).
 */
.nav-cart.is-empty {
    display: none;
}

/* ---------- Overlay behind the drawer ---------- */

.cart-drawer-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
    z-index: 900;
}
.cart-drawer-overlay.is-open {
    opacity: 1;
    pointer-events: auto;
}

/* ---------- The drawer panel itself ---------- */

aside.cart-drawer {
    position: fixed;
    top: 0;
    right: 0;
    width: min(420px, 100vw);
    /* `100vh` includes the area behind iOS Safari's address bar and the
       Android Chrome bottom UI, so the footer (Checkout button) ends up
       below the visible viewport on mobile. `100dvh` is the dynamic
       viewport height — resizes with the browser chrome, so the drawer
       always fits exactly the visible area. Falls back to 100vh on the
       handful of older browsers that don't grok dvh. */
    height: 100vh;
    height: 100dvh;
    max-height: 100vh;
    max-height: 100dvh;
    background: var(--bg-card);
    border-left: 1px solid var(--border);
    box-shadow: -16px 0 40px rgba(0, 0, 0, 0.4);
    transform: translateX(100%);
    transition: transform 0.3s ease;
    z-index: 950;
    display: flex;
    flex-direction: column;
    font-family: 'Inter', -apple-system, sans-serif;
    color: var(--text-primary);
    /* Reset margins/padding inside the drawer without nuking the host page. */
    margin: 0;
    padding: 0;
}
aside.cart-drawer.is-open { transform: translateX(0); }

aside.cart-drawer * { box-sizing: border-box; }

.cart-drawer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.cart-drawer-header h2 {
    font-family: 'Cinzel', Georgia, serif;
    color: var(--gold);
    font-size: 1.25rem;
    margin: 0;
}
.cart-drawer-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.8rem;
    line-height: 1;
    cursor: pointer;
    padding: 0 6px;
    transition: color 0.15s;
}
.cart-drawer-close:hover { color: var(--gold); }

.cart-drawer-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px 24px;
}

.cart-empty {
    color: var(--text-muted);
    text-align: center;
    padding: 48px 0;
    font-size: 0.95rem;
}
.cart-empty a { color: var(--gold); margin-left: 6px; }

.cart-reject-note {
    background: rgba(200, 168, 110, 0.08);
    border: 1px solid var(--gold-dark);
    color: var(--text-muted);
    font-size: 0.85rem;
    padding: 10px 14px;
    border-radius: 6px;
    margin-bottom: 16px;
}

.cart-line {
    display: grid;
    grid-template-columns: 64px 1fr auto;
    gap: 12px;
    padding: 14px 0;
    border-bottom: 1px solid var(--border);
    align-items: start;
}
.cart-line:last-child { border-bottom: none; }

.cart-line-img {
    width: 64px;
    height: 64px;
    object-fit: cover;
    background: #0f0f0f;
    border-radius: 4px;
}

.cart-line-title {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-primary);
    line-height: 1.3;
}
.cart-line-sub {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 2px;
}
.cart-line-qty {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 8px;
    font-size: 0.85rem;
}
.cart-line-qty button {
    background: var(--bg-dark);
    border: 1px solid var(--border);
    color: var(--text-primary);
    width: 24px;
    height: 24px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 0.85rem;
    line-height: 1;
    font-family: inherit;
    padding: 0;
}
.cart-line-qty button:hover { border-color: var(--gold-dark); }
.cart-line-qty span {
    min-width: 18px;
    text-align: center;
    padding: 0 2px;
}
.cart-line-remove {
    background: none !important;
    border: none !important;
    color: var(--text-muted) !important;
    width: auto !important;
    height: auto !important;
    padding: 0 0 0 10px !important;
    font-size: 0.75rem !important;
    text-decoration: underline;
}
.cart-line-remove:hover { color: var(--gold) !important; }

.cart-line-price {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--gold);
    white-space: nowrap;
}

.cart-drawer-footer {
    /* iOS home-indicator safe area: env(safe-area-inset-bottom) is
       non-zero on iPhone X+ devices, zero everywhere else, so this
       silently does the right thing. */
    padding: 20px 24px calc(20px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--border);
    background: var(--bg-dark);
    flex-shrink: 0;
}
.cart-subtotal {
    display: flex;
    justify-content: space-between;
    font-size: 1rem;
    font-weight: 500;
    margin-bottom: 4px;
}
.cart-shipping-note {
    color: var(--text-muted);
    font-size: 0.78rem;
    margin: 0 0 16px;
}
.cart-checkout-btn {
    display: block;
    width: 100%;
    padding: 14px 20px;
    background: var(--gold);
    color: var(--bg-dark);
    text-align: center;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    font-size: 0.85rem;
    border-radius: 4px;
    border: none;
    font-family: inherit;
    cursor: pointer;
    text-decoration: none;
}
.cart-checkout-btn:hover { background: var(--gold-light); }
.cart-keep-shopping {
    display: block;
    width: 100%;
    margin-top: 10px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.85rem;
    padding: 8px 0;
    cursor: pointer;
    font-family: inherit;
}
.cart-keep-shopping:hover { color: var(--gold); }

.link-like {
    background: none;
    border: none;
    color: var(--gold);
    text-decoration: underline;
    cursor: pointer;
    font: inherit;
    padding: 0;
}

body.cart-drawer-locked { overflow: hidden; }
