/* Load after bookshop.css. Cart contents scroll; totals stay in view. */
.web-bookshop-cart {
    --cart-top: 24px;
    position: sticky;
    top: var(--cart-top);
    display: flex;
    flex-direction: column;
    max-height: var(--cart-available-height, calc(100vh - var(--cart-top) - 16px));
    max-height: var(--cart-available-height, calc(100dvh - var(--cart-top) - 16px));
    min-width: 0;
    min-height: 0;
}

.web-bookshop-cart > header,
.web-bookshop-cart > footer,
.web-bookshop-cart > .eyebrow,
.web-bookshop-cart > h2 {
    flex: 0 0 auto;
}

.web-bookshop-cart-items {
    display: grid;
    gap: 16px;
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior-y: contain;
    scrollbar-gutter: stable;
    scrollbar-width: thin;
    scrollbar-color: var(--accent) transparent;
    padding: 2px 6px 4px 2px;
    overflow-wrap: anywhere;
}

.web-bookshop-cart-items:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
}

.web-bookshop-cart-empty {
    min-height: 0;
    overflow-y: auto;
}

/* The existing mobile layout places the cart above the catalog. */
@media (max-width: 900px) {
    .web-bookshop-cart {
        position: static;
        max-height: min(44rem, calc(100vh - 32px));
        max-height: min(44rem, calc(100dvh - 32px));
    }
}

/* At extreme zoom / short landscape heights, allow page scrolling too. */
@media (max-height: 540px) {
    .web-bookshop-cart {
        position: static;
        max-height: none;
    }

    .web-bookshop-cart-items {
        flex: 0 1 auto;
        max-height: 50vh;
        max-height: 50dvh;
    }
}
