/* The shop's cart (GreenleafCreations/cart#1): the Add to Cart control on a piece's page, the Cart
   button, and the cart page. cart.js draws all of it. */

/* === The Add to Cart control === */

p.cart-add {
    display: flex;
    align-items: center;
    gap: 0.4cm;
    flex-wrap: wrap;
}

span.cart-error,
p.cart-line-refusal,
#cart-message,
#cart-checkout-message {
    color: #cc2200;
}

/* === The Cart button === */

/* Fixed at the top-right, where the hamburger menu (top-left on a phone) does not reach. The size,
   ring and shadow of the floating bar's buttons, so that it reads as one of them. */
a.cart-button {
    position: fixed;
    top: 0.8rem;
    right: 0.8rem;
    z-index: 900;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.75rem;
    height: 2.75rem;
    box-sizing: border-box;
    border-radius: 50%;
    border: 2px solid #ffffff;
    background-color: var(--greenleaf-dark-green);
    box-shadow: 0 0.2rem 0.6rem rgba(0, 0, 0, 0.3);
}

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

/* The ring turns brown, as on the floating bar: the glyph is an image and stays white. */
a.cart-button:hover,
a.cart-button:focus-visible {
    border-color: var(--greenleaf-brown);
}

a.cart-button img {
    width: 1.4rem;
    height: 1.4rem;
}

/* The count: a dot over the bottom-right edge of the button. Flex centers the line in the dot, and
   the line keeps Roboto's room for descenders under the digits, which puts them high; the top padding
   moves them down by half that room. text-box-trim would do it without a measure, but it does not
   apply to a flex container. */
span.cart-count {
    position: absolute;
    right: -0.45rem;
    bottom: -0.45rem;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 1.5rem;
    height: 1.5rem;
    padding: 0 0.3rem;
    box-sizing: border-box;
    border-radius: 0.75rem;
    border: 2px solid #ffffff;
    background-color: var(--greenleaf-brown);
    color: #ffffff;
    font-size: 0.75rem;
    font-weight: 700;
    line-height: 1;
    padding-top: 0.15em;
}

@media print {
    a.cart-button {
        display: none;
    }
}

/* === The cart page === */

article#cart {
    max-width: 20cm;
    margin-left: auto;
    margin-right: auto;
}

ul#cart-lines {
    list-style: none;
    margin: 0 0 0.8cm 0;
    padding: 0;
}

li.cart-line {
    display: grid;
    grid-template-columns: 5rem minmax(0, 1fr) auto;
    align-items: center;
    column-gap: 0.5cm;
    padding: 0.4cm 0;
    border-bottom: 1px solid #ede9e1;
}

a.cart-line-photo img {
    display: block;
    width: 5rem;
    height: 5rem;
    border-radius: 0.1cm;
}

div.cart-line-text {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.1cm;
}

span.cart-line-price {
    white-space: nowrap;
}

/* Removing a piece is not the page's main action, so it is a small text button and not a green one. */
button.cart-remove,
button.cart-remove:not(:disabled):hover {
    background-color: transparent;
    padding: 0;
    font-weight: 400;
    font-size: 0.85em;
    text-decoration: underline;
}

button.cart-remove {
    color: #666666;
}

button.cart-remove:not(:disabled):hover {
    color: var(--greenleaf-brown);
}

p.cart-line-refusal {
    grid-column: 1 / -1;
    margin: 0.2cm 0 0 0;
}

li.cart-empty {
    padding: 0.4cm 0;
}

#cart-summary {
    background-color: #fdfbf9;
    border: 1px solid #cccccc;
    border-radius: 0.1cm;
    padding: 0.5cm;
}

#cart-summary[hidden] {
    display: none;
}

#cart-summary h3 {
    margin-top: 0;
}

dl.cart-figures {
    margin: 0 0 0.4cm 0;
}

dl.cart-figures div {
    display: flex;
    justify-content: space-between;
    gap: 0.5cm;
    padding: 0.1cm 0;
}

/* Two columns of figures, not the site's glossary list, so neither its marker nor its indent applies. */
dl.cart-figures dt {
    font-weight: 400;
    padding: 0;
    margin: 0;
}

dl.cart-figures dt::before {
    content: none;
}

dl.cart-figures dd {
    margin: 0;
    text-align: right;
}

#cart-total {
    font-weight: 600;
}

p.cart-note {
    color: #666666;
}

p.cart-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3cm;
}

#cart-summary p.cart-actions {
    flex-direction: column;
    margin-bottom: 0;
}

#cart-summary p.cart-actions > * {
    text-align: center;
}

/* The summary has its own Continue Shopping below Checkout, so this one is only for a cart that
   shows no summary: an empty cart, a cart that cannot be read, and a browser without JavaScript. */
#cart-summary:not([hidden]) + p.cart-continue {
    display: none;
}

p.cart-policies {
    text-align: center;
    margin-top: 0.5cm;
}

#cart-turnstile {
    margin: 0.5cm 0;
}
