/*
 * bottom-sheet.css
 *
 * Phone and portrait-tablet layout (up to 900px) of the basket: the same
 * .cart-sheet markup becomes a floating bottom sheet (above the bottom
 * navigation on phones). sheetState in sale.js switches between 'collapsed'
 * (summary bar) and 'partial' (full basket).
 */

@media (max-width: 900px) {
    .sale-view {
        display: block;
    }

    .sale-view .view-main {
        padding-bottom: 96px;
    }

    .cart-side {
        position: fixed;
        left: auto;
        right: 16px;
        width: min(480px, calc(100vw - 32px));
        bottom: calc(16px + env(safe-area-inset-bottom));
        top: auto;
        z-index: var(--z-cart);
        max-height: none;
    }

    .cart-side > .cart-sheet {
        max-height: calc(100vh - 176px);
        max-height: calc(100dvh - 176px);
        overflow: hidden;
        box-shadow: 0 -8px 40px rgba(20, 22, 27, .18), 0 2px 6px rgba(20, 22, 27, .05);
        border-radius: var(--r-28);
    }

    .cart-sheet__grab {
        cursor: grab;
    }

    .cart-sheet__bar {
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 4px 16px 14px;
        cursor: pointer;
        user-select: none;
    }

    .cart-sheet__bar-info {
        flex: 1;
        min-width: 0;
        display: flex;
        flex-direction: column;
        font-size: var(--fs-secondary);
    }

    .cart-sheet__bar-title {
        font-weight: 800;
        font-size: var(--fs-button);
    }

    .cart-sheet__bar-figures {
        display: flex;
        flex-direction: column;
        align-items: flex-end;
        line-height: 1.15;
    }

    .cart-sheet__bar-was {
        font-size: var(--fs-caption);
        font-weight: 700;
        color: var(--muted);
        white-space: nowrap;
    }

    .cart-sheet__bar-total {
        font-size: calc(var(--fs-section) * var(--amount-scale, 1));
        white-space: nowrap;
        font-weight: 800;
        letter-spacing: -0.02em;
        font-variant-numeric: tabular-nums;
    }

    .cart-sheet__bar-pay {
        height: 44px;
        padding: 0 18px;
        border-radius: var(--r-14);
    }

    .cart-sheet__body {
        flex: 1 1 auto;
        min-height: 0;
        overflow: hidden;
        padding: 0 16px 16px;
        gap: 12px;
    }

    .cart-sheet__scroll {
        flex: 1 1 auto;
        margin: 0 -16px;
        padding: 0 16px;
        -webkit-overflow-scrolling: touch;
    }

    .cart-sheet__footer {
        gap: 12px;
        padding-top: 4px;
    }

    .cart-sheet__head {
        min-height: 44px;
    }

    .cart-sheet__collapse {
        display: inline-flex;
    }

    /* Dimmed page behind the open basket; tapping it closes the basket */
    .cart-backdrop {
        display: none;
    }

    .cart-backdrop.is-open {
        display: block;
        position: fixed;
        inset: 0;
        z-index: var(--z-cart-backdrop);
        background: rgba(201, 205, 213, .6);
        backdrop-filter: blur(3px);
        -webkit-backdrop-filter: blur(3px);
        animation: sf-fade var(--dur-fast) var(--ease);
    }

    .cart-sheet__bar-count {
        margin-left: 2px;
        color: var(--muted);
        font-weight: 700;
    }

    .cart-sheet__bar-added {
        color: var(--accent-strong);
        font-weight: 600;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .cart-sheet__bar.is-bumped {
        animation: basket-bump .45s var(--ease);
    }

    .cart-sheet.sheet-collapsed .cart-sheet__body {
        display: none;
    }

    .cart-sheet.sheet-partial .cart-sheet__bar {
        display: none;
    }

    .cart-tiles {
        gap: 10px;
    }

    .customer-tile,
    .taxfree-tile {
        padding: 14px;
        border-radius: var(--r-20);
    }

    .cart-total__amount {
        font-size: calc(var(--fs-amount) * var(--amount-scale, 1));
    }

    .btn--xl {
        min-height: 64px;
    }
}

@media (max-width: 767px) {
    .cart-side {
        left: 12px;
        right: 12px;
        width: auto;
        bottom: calc(80px + env(safe-area-inset-bottom));
    }

    .cart-side > .cart-sheet {
        max-height: calc(100vh - 160px);
        max-height: calc(100dvh - 160px);
    }

    .customer-tile__clear {
        height: 40px;
        padding: 0 16px;
    }
}

@media (max-width: 600px) {
    .product-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 10px;
    }

    .product-tile {
        padding: 10px;
        border-radius: var(--r-22);
    }

    .product-tile__qty {
        top: 8px;
        right: 8px;
        min-width: 28px;
        height: 28px;
    }
}

@keyframes basket-bump {
    0% {
        transform: scale(1);
    }

    35% {
        transform: scale(1.03);
    }

    100% {
        transform: scale(1);
    }
}

/* Phones: customer and Tax Free as two compact full-width rows so the lines get the room */
@media (max-width: 600px) {
    .cart-tiles {
        grid-template-columns: minmax(0, 1fr);
        gap: 8px;
    }

    .customer-tile,
    .taxfree-tile {
        flex-direction: row;
        align-items: center;
        justify-content: flex-start;
        gap: 12px;
        min-height: 60px;
        padding: 10px 10px 10px 12px;
        border-radius: var(--r-18);
    }

    .customer-tile__top {
        flex: none;
    }

    .customer-tile__top .chip,
    .customer-tile__clear {
        display: none;
    }

    .customer-tile .avatar {
        width: 36px;
        height: 36px;
        font-size: var(--fs-secondary);
    }

    .customer-tile__text,
    .taxfree-tile__text {
        flex: 1;
        min-width: 0;
    }

    .customer-tile__name,
    .taxfree-tile__title {
        font-size: var(--fs-body);
    }

    .customer-tile__meta,
    .taxfree-tile__hint {
        font-size: var(--fs-caption);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .customer-tile__x {
        display: inline-flex;
        flex: none;
        width: 40px;
        height: 40px;
        background: var(--surface);
    }

    /* Tax Free tile: icon, text, switch in one row */
    .taxfree-tile__top {
        display: contents;
    }

    .taxfree-tile__top > svg {
        order: 0;
        width: 22px;
        height: 22px;
    }

    .taxfree-tile__text {
        order: 1;
    }

    .taxfree-tile .switch {
        order: 2;
        width: 40px;
        height: 24px;
    }

    .taxfree-tile .switch__knob {
        width: 18px;
        height: 18px;
    }

    .taxfree-tile .switch input:checked + .switch__track .switch__knob {
        transform: translateX(16px);
    }

    .cart-line {
        padding: 8px 0;
    }

    .cart-line__thumb {
        width: 48px;
        height: 48px;
    }

    .stepper__btn {
        width: 40px;
        height: 40px;
    }
}
