/**
 * Shop cart sidebar — desktop column + mobile slide-out drawer.
 *
 * @package Manjits_2025
 */

/* Desktop: sticky cart column */
.manjits-shop-cart-desktop {
    align-self: start;
}

.manjits-shop-cart-desktop .manjits-cart-sidebar-host {
    max-height: calc(100vh - 120px);
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(251, 191, 36, 0.45) rgba(17, 24, 39, 0.6);
}

/* Mobile cart tab — fixed right edge, morphism */
.manjits-mobile-cart-tab {
    position: fixed;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    z-index: 9985;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    min-width: 52px;
    padding: 0.85rem 0.55rem;
    border: none;
    border-radius: 14px 0 0 14px;
    cursor: pointer;
    color: #111827;
    font-family: Inter, system-ui, sans-serif;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    background: linear-gradient(145deg, #fcd34d 0%, #f59e0b 55%, #d97706 100%);
    box-shadow:
        inset 2px 2px 4px rgba(255, 255, 255, 0.45),
        inset -2px -2px 5px rgba(146, 64, 14, 0.35),
        -6px 0 18px rgba(0, 0, 0, 0.35);
    transition: transform 0.25s ease, box-shadow 0.25s ease, filter 0.25s ease;
}

.manjits-mobile-cart-tab:hover,
.manjits-mobile-cart-tab:focus-visible {
    filter: brightness(1.05);
    box-shadow:
        inset 2px 2px 4px rgba(255, 255, 255, 0.5),
        inset -2px -2px 5px rgba(146, 64, 14, 0.4),
        -8px 0 22px rgba(0, 0, 0, 0.4);
    outline: none;
}

.manjits-mobile-cart-tab.is-open {
    transform: translateY(-50%) translateX(-4px);
}

.manjits-mobile-cart-tab__icon svg {
    display: block;
    width: 26px;
    height: 26px;
    fill: currentColor;
    filter: drop-shadow(0 1px 1px rgba(255, 255, 255, 0.35));
}

.manjits-mobile-cart-tab__label {
    writing-mode: vertical-rl;
    text-orientation: mixed;
    transform: rotate(180deg);
    line-height: 1;
}

.manjits-mobile-cart-tab__count {
    position: absolute;
    top: 6px;
    left: 6px;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    border-radius: 999px;
    background: #ef4444;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    line-height: 20px;
    text-align: center;
    border: 2px solid #fbbf24;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
}

.manjits-mobile-cart-tab__count.hidden {
    display: none !important;
}

.manjits-mobile-cart-tab.is-pulse {
    animation: manjitsMobileCartTabPulse 0.85s ease;
}

@keyframes manjitsMobileCartTabPulse {
    0%, 100% { transform: translateY(-50%) scale(1); }
    50% { transform: translateY(-50%) scale(1.06); }
}

/* Mobile drawer */
.manjits-mobile-cart-drawer {
    position: fixed;
    inset: 0;
    z-index: 9990;
    pointer-events: none;
    visibility: hidden;
}

.manjits-mobile-cart-drawer.is-open {
    pointer-events: auto;
    visibility: visible;
}

.manjits-mobile-cart-drawer__backdrop {
    position: absolute;
    inset: 0;
    border: none;
    padding: 0;
    margin: 0;
    background: rgba(15, 23, 42, 0.72);
    opacity: 0;
    transition: opacity 0.3s ease;
    cursor: pointer;
}

.manjits-mobile-cart-drawer.is-open .manjits-mobile-cart-drawer__backdrop {
    opacity: 1;
}

.manjits-mobile-cart-drawer__panel {
    position: absolute;
    top: 0;
    right: 0;
    width: min(92vw, 380px);
    height: 100%;
    display: flex;
    flex-direction: column;
    background: linear-gradient(165deg, #1f2937 0%, #111827 100%);
    border-left: 1px solid rgba(251, 191, 36, 0.25);
    box-shadow:
        -12px 0 32px rgba(0, 0, 0, 0.45),
        inset 1px 0 0 rgba(255, 255, 255, 0.06);
    transform: translateX(100%);
    transition: transform 0.32s cubic-bezier(0.4, 0, 0.2, 1);
}

.manjits-mobile-cart-drawer.is-open .manjits-mobile-cart-drawer__panel {
    transform: translateX(0);
}

.manjits-mobile-cart-drawer__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 1rem 1rem 0.75rem;
    border-bottom: 1px solid rgba(251, 191, 36, 0.2);
    background: linear-gradient(180deg, rgba(251, 191, 36, 0.12) 0%, transparent 100%);
}

.manjits-mobile-cart-drawer__header h3 {
    margin: 0;
    font-family: "Playfair Display", Georgia, serif;
    font-size: 1.35rem;
    color: #fef3c7;
}

.manjits-mobile-cart-drawer__close {
    width: 36px;
    height: 36px;
    border: 1px solid rgba(251, 191, 36, 0.35);
    border-radius: 10px;
    background: linear-gradient(145deg, #374151, #1f2937);
    color: #fbbf24;
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
    box-shadow:
        inset 1px 1px 2px rgba(255, 255, 255, 0.12),
        inset -1px -1px 2px rgba(0, 0, 0, 0.35);
}

.manjits-mobile-cart-drawer__body {
    flex: 1;
    overflow-y: auto;
    padding: 0.75rem;
    -webkit-overflow-scrolling: touch;
}

.manjits-mobile-cart-drawer .cart-sidebar > h3:first-child {
    display: none;
}

.manjits-cart-sidebar-host.is-loading {
    opacity: 0.55;
    pointer-events: none;
    min-height: 140px;
    position: relative;
}

.manjits-cart-sidebar-host.is-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 28px;
    height: 28px;
    margin: -14px 0 0 -14px;
    border: 3px solid rgba(251, 191, 36, 0.25);
    border-top-color: #fbbf24;
    border-radius: 50%;
    animation: manjitsCartHostSpin 0.75s linear infinite;
}

@keyframes manjitsCartHostSpin {
    to { transform: rotate(360deg); }
}

body.manjits-mobile-cart-open {
    overflow: hidden;
}

@media (min-width: 1024px) {
    .manjits-mobile-cart-tab,
    .manjits-mobile-cart-drawer {
        display: none !important;
    }
}
