/* Website cart (views/partials/cart.ejs, assets/js/cart.js): only loaded while web ordering is on.
   Colours and shapes follow style.css (sand pills, pink prices, muted text). */

/* Add buttons: beside the WhatsApp button on dish rows, on the corner of menu cards */
.cart-add {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.75rem;
    height: 2.75rem;
    flex-shrink: 0;
    padding: 0;
    border: 1px solid var(--sand);
    border-radius: 50%;
    background: #fff;
    color: var(--ink);
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
}

.cart-add:hover,
.cart-add:focus-visible {
    background: var(--cream);
}

.cart-add.is-in-cart {
    border-color: var(--ink);
    background: var(--ink);
    color: #fff;
    font-size: 1.05rem;
}

/* Phone rows: one more column after the WhatsApp button */
@media (max-width: 576px) {
    .dish-row:has(.cart-add) {
        grid-template-columns: 64px minmax(0, 1fr) auto auto;
        grid-template-areas:
            "thumb info order add"
            "thumb price order add";
    }

    .dish-row .cart-add {
        grid-area: add;
        align-self: center;
    }
}

/* Menu cards are links: the button sits beside the link, over the photo */
.cart-card {
    position: relative;
}

.cart-card .cart-add {
    position: absolute;
    /* On the photo, in the corner opposite the day badge */
    top: 1rem;
    right: calc(var(--bs-gutter-x, 1.5rem) * 0.5 + 0.5rem);
    z-index: 2;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18);
}

.cart-pill-count:empty {
    display: none;
}

.cart-pill-count {
    min-width: 1.4rem;
    padding: 0 0.35rem;
    border-radius: 999px;
    background: var(--ink);
    color: #fff;
    font-size: 0.8rem;
    line-height: 1.4rem;
}

/* The cart button: above the order bar on phones, above the order button on wide screens */
.cart-open {
    position: fixed;
    bottom: 84px;
    left: 24px;
    z-index: 1001;
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    max-width: calc(100vw - 32px);
    min-height: 48px;
    padding: 0.4rem 1rem;
    border: 1px solid var(--sand);
    border-radius: 999px;
    background: var(--sand);
    color: var(--ink);
    font-size: 1rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
    cursor: pointer;
}

.cart-open[hidden] {
    display: none;
}

.cart-open-count {
    min-width: 1.6rem;
    border-radius: 999px;
    background: var(--ink);
    color: #fff;
    font-size: 0.85rem;
    line-height: 1.6rem;
    text-align: center;
}

.cart-open-total {
    white-space: nowrap;
    font-size: 0.9rem;
}

.cart-open.is-bumped {
    animation: cart-bump 0.35s ease-out;
}

@keyframes cart-bump {
    40% { transform: scale(1.08); }
}

@media (max-width: 1100px) {
    /* Room to scroll the page's last lines clear of the cart button too */
    body:has(.cart-open:not([hidden])) {
        padding-bottom: calc(56px + env(safe-area-inset-bottom, 0px) + 72px);
    }

    .cart-open {
        bottom: calc(56px + env(safe-area-inset-bottom, 0px) + 12px);
        left: 16px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .cart-open.is-bumped {
        animation: none;
    }
}

/* Drawer */
.cart-drawer {
    --bs-offcanvas-width: 420px;
    max-width: 100%;
}

.cart-drawer-header {
    border-bottom: 1px solid rgba(33, 50, 91, 0.1);
}

.cart-title {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 500;
}

.cart-empty {
    color: var(--muted);
    text-align: center;
    padding: 2rem 0;
}

.cart-lines {
    list-style: none;
    margin: 0;
    padding: 0;
}

.cart-line {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
        "name step"
        "price step";
    column-gap: 0.75rem;
    align-items: center;
    padding: 0.6rem 0;
    border-bottom: 1px solid rgba(33, 50, 91, 0.08);
}

.cart-line-name {
    grid-area: name;
    color: var(--ink);
}

.cart-line-price {
    grid-area: price;
    color: var(--price);
    font-weight: 500;
    white-space: nowrap;
}

.cart-line-price small,
.cart-row small {
    color: var(--muted);
    font-weight: 400;
}

.cart-line-gone {
    grid-area: price;
    color: var(--muted);
    font-size: 0.875rem;
}

.cart-line.is-gone .cart-line-name {
    color: var(--muted);
    text-decoration: line-through;
}

.cart-step {
    grid-area: step;
    display: inline-flex;
    align-items: center;
    border: 1px solid rgba(33, 50, 91, 0.2);
    border-radius: 999px;
}

.cart-step-btn {
    width: 2.5rem;
    height: 2.5rem;
    border: 0;
    background: none;
    color: var(--ink);
    font-size: 1.25rem;
    line-height: 1;
    cursor: pointer;
}

.cart-step-btn:disabled {
    color: rgba(33, 50, 91, 0.3);
    cursor: default;
}

.cart-step-qty {
    min-width: 1.5rem;
    text-align: center;
}

.cart-row {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    margin: 0.4rem 0;
}

.cart-row-total {
    font-weight: 500;
}

.cart-row-total > span:last-child {
    color: var(--price);
}

.cart-note {
    margin: 0.75rem 0;
    color: var(--muted);
    font-size: 0.875rem;
    line-height: 1.8;
}

.cart-note-warn,
.cart-error {
    padding: 0.6rem 0.8rem;
    border-radius: 0.75rem;
    background: var(--cream-soft);
    box-shadow: inset 0 0 0 1px var(--sand);
    color: var(--ink);
}

.cart-error {
    margin: 0.75rem 0;
    font-size: 0.9rem;
    line-height: 1.8;
}

.cart-error[hidden],
.cart-note[hidden] {
    display: none;
}

/* Pre-order (outside the ordering hours): which day the cart is for, above every step */
.cart-day,
.order-placed-day {
    padding: 0.6rem 0.8rem;
    border-radius: 0.75rem;
    background: var(--cream);
    box-shadow: inset 0 0 0 1px var(--sand);
    color: var(--ink);
    font-weight: 500;
    line-height: 1.8;
}

.cart-day {
    margin: 0 0 0.75rem;
    font-size: 0.9rem;
}

.cart-primary {
    display: block;
    width: 100%;
    min-height: 48px;
    margin-top: 1rem;
    border: 0;
    border-radius: 999px;
    background: var(--ink);
    color: #fef7e0;
    font-size: 1.05rem;
    cursor: pointer;
}

.cart-primary:disabled {
    background: rgba(30, 32, 34, 0.35);
    cursor: default;
}

.cart-back {
    margin-bottom: 0.75rem;
    padding: 0.3rem 0;
    border: 0;
    background: none;
    color: var(--link);
    cursor: pointer;
}

.cart-back::before {
    content: "→ ";
}

.cart-checkout .form-label {
    display: block;
    margin: 0.75rem 0 0.3rem;
    font-size: 0.95rem;
}

.cart-checkout .form-control {
    /* 16px: phones don't zoom into the field */
    font-size: 1rem;
}

/* The public theme has no select styles: a plain field with a chevron on the left (RTL) */
.cart-checkout select.form-control {
    appearance: none;
    padding-left: 2.25rem;
    background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%233b4652' stroke-width='2' d='M2 5l6 6 6-6'/%3E%3C/svg%3E") no-repeat left 0.9rem center / 12px;
}

.cart-type {
    margin: 0;
    padding: 0;
    border: 0;
}

.cart-choice {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-height: 44px;
}

.cart-consent {
    align-items: flex-start;
    font-size: 0.9rem;
    line-height: 1.6;
}

.cart-summary {
    margin-top: 1rem;
    padding-top: 0.5rem;
    border-top: 1px solid rgba(33, 50, 91, 0.1);
}

/* Honeypot: off screen, not display:none (some bots skip hidden fields) */
.cart-hp {
    position: absolute;
    left: -10000px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

/* Confirmation page (views/order-placed.ejs) */
.order-placed-lines {
    list-style: none;
    margin: 0 0 1rem;
    padding: 0;
}

.order-placed-lines li {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.45rem 0;
    border-bottom: 1px solid rgba(33, 50, 91, 0.08);
}

.order-placed-status {
    padding: 0.75rem 1rem;
    border-radius: 0.9rem;
    background: var(--cream-soft);
    box-shadow: inset 0 0 0 1px var(--sand);
    /* Body grey is 4.3:1 on the cream */
    color: var(--ink-2);
}

/* SMS code step (only with an SMS panel): one big field for the 5 digits, resend with a countdown */
.cart-code-lead {
    margin: 0.25rem 0 0.5rem;
    line-height: 1.9;
}

.cart-code-phone {
    font-weight: 500;
    white-space: nowrap;
}

.cart-checkout .cart-code-input {
    max-width: 12rem;
    font-size: 1.6rem;
    letter-spacing: 0.5em;
    text-align: center;
    /* letter-spacing leaves room after the last digit; balance it so the digits sit centred */
    padding-left: calc(0.75rem + 0.5em);
}

.cart-resend {
    display: block;
    width: 100%;
    min-height: 44px;
    margin-top: 0.5rem;
    border: 0;
    background: none;
    color: var(--link);
    font-size: 0.95rem;
    cursor: pointer;
}

.cart-resend:disabled {
    color: var(--muted);
    cursor: default;
}

.cart-code-timer {
    font-variant-numeric: tabular-nums;
}
