/*
  Responsive layout for the Commerce cart and checkout (theme "dineke").

  Commerce registers its own layout.simple.css and style.simple.css just before </head>, after the theme CSS.
  This file is linked from frontend/checkout/cart.twig and frontend/checkout/wrapper.twig in the body, so it
  loads after the Commerce styles and wins at equal specificity.
*/

/*
  Colours: Commerce uses green (#cbf1d2, #7bdb8c, #219653) for active and selected states,
  replaced with the theme's yellow. Variables from styles.css, so the dark theme follows.
*/
/* Radio buttons and checkboxes: gold outline, gold dot or check when selected */
.c-checkout input[type=radio],
.c-checkout input[type=checkbox] {
    appearance: none;
    width: 1.125rem;
    height: 1.125rem;
    margin: 0;
    border: 2px solid var(--primary-color);
    background: var(--bs-body-bg) center / 100% no-repeat;
    vertical-align: -.2em;
    cursor: pointer;
}

.c-checkout input[type=radio] {
    border-radius: 50%;
}

.c-checkout input[type=checkbox] {
    border-radius: 3px;
}

.c-checkout input[type=radio]:checked {
    background-image: radial-gradient(circle, var(--primary-color) 0 45%, transparent 50%);
}

.c-checkout input[type=checkbox]:checked {
    background-color: var(--primary-color);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3.5 8.5l3 3 6-6.5' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

.c-checkout input[type=radio]:focus-visible,
.c-checkout input[type=checkbox]:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

.c-checkout-mode,
.c-method-radio:checked + .c-method-section {
    background-color: var(--primary-light-color);
}

/* Steps indicator: the arrows are box-shadows in the step colours, so these must be opaque */
.c-steps-indicator {
    --c-step-bg: #f1f1f1;
    --c-step-active-bg: var(--primary-light-color);
    --c-step-color: #555;
}

body[data-theme="dark"] .c-steps-indicator {
    --c-step-bg: #2B2F32;
    --c-step-active-bg: color-mix(in srgb, var(--primary-color) 35%, var(--bs-body-bg));
    --c-step-color: var(--bs-body-color);
}

.c-step {
    background-color: var(--c-step-bg);
    color: var(--c-step-color);
}

.c-step a,
.c-step a:hover,
.c-step a:focus {
    color: inherit;
}

.c-step::after {
    border-color: var(--bs-body-bg);
    box-shadow: 5px -5px 0 3px var(--c-step-bg);
}

.c-step.active {
    background-color: var(--c-step-active-bg);
    color: var(--c-step-color);
}

.c-step.active::after {
    box-shadow: 6px -6px 0 3px var(--c-step-active-bg);
    background: var(--c-step-bg);
}

.c-step.active + .c-step::after {
    background: var(--c-step-active-bg);
}

.c-primary-button {
    background: var(--primary-light-color);
}

.c-button:hover,
.c-button:focus {
    background: var(--primary-transparent-color);
}

.c-checkout .c-payment-method-options .c-payment-method-issuers__container,
.c-checkout .c-payment-method-options .c-shipping-method-opts__container,
.c-checkout .c-shipping-method-options .c-payment-method-issuers__container,
.c-checkout .c-shipping-method-options .c-shipping-method-opts__container,
.c-checkout .c-payment-method-issuer__input:checked + .c-payment-method-issuer__label,
.c-checkout .c-payment-method-option__input:checked + .c-payment-method-option__label,
.c-checkout .c-shipping-method-opt__input:checked + .c-shipping-method-opt__label,
.c-checkout .c-shipping-method-option__input:checked + .c-shipping-method-option__label {
    border-color: var(--primary-color);
}

/* The cart step inside the checkout (?step=cart) brings its own container, the wrapper already has one */
.c-step-wrapper > .container {
    max-width: none;
    margin-top: 0;
    padding-left: 0;
    padding-right: 0;
}

/* Steps indicator: Commerce stacks the steps below 1024px, keep them on one row */
.c-steps-indicator {
    display: flex;
}

.c-steps-indicator li.c-step {
    flex: 1 1 0;
    min-width: 0;
    width: auto;
}

@media (min-width: 768px) and (max-width: 1024px) {
    .c-steps-indicator li.c-step {
        height: 2em;
        padding-top: 0;
        padding-left: 1em;
    }

    .c-steps-indicator li.c-step::after {
        left: -1.25em;
        bottom: auto;
    }
}

/* Cart items: below 992px a smaller product image */
@media (max-width: 991.98px) {
    .c-cart-items td.c-cart-item-image img {
        max-width: 100px;
    }

    /* Long product descriptions: three lines */
    .c-cart-item-name small {
        display: -webkit-box;
        -webkit-line-clamp: 3;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }
}

@media (max-width: 767.98px) {
    /* Same side spacing as the navbar and the sections */
    .c-wrapper,
    .c-checkout-cart {
        padding-left: 1.25rem;
        padding-right: 1.25rem;
    }

    .c-wrapper .c-checkout-cart {
        padding-left: 0;
        padding-right: 0;
    }

    .c-checkout h2 {
        font-size: 1.75rem;
    }

    /* Steps indicator: numbered circles, only the current step shows its name */
    .c-steps-indicator {
        gap: .375rem;
        counter-reset: c-step;
        border-radius: 0;
    }

    .c-steps-indicator li.c-step {
        counter-increment: c-step;
        display: flex;
        align-items: center;
        justify-content: center;
        flex: 0 0 2.25rem;
        height: 2.25rem;
        padding: 0;
        border-radius: 1.125rem;
        font-size: 0;
        line-height: 1.2;
    }

    .c-steps-indicator li.c-step::before {
        content: counter(c-step);
        font-size: .875rem;
    }

    .c-steps-indicator li.c-step::after {
        display: none;
    }

    .c-steps-indicator li.c-step a {
        position: absolute;
        inset: 0;
    }

    .c-steps-indicator li.c-step.active {
        flex: 1 1 auto;
        justify-content: flex-start;
        gap: .5rem;
        padding: 0 .875rem 0 .375rem;
        font-size: .875rem;
    }

    .c-steps-indicator li.c-step.active::before {
        flex: 0 0 1.5rem;
        height: 1.5rem;
        line-height: 1.5rem;
        border-radius: 50%;
        background-color: rgba(0, 0, 0, .08);
        text-align: center;
    }

    .c-steps-indicator li.c-step.active a {
        position: static;
        width: auto;
        min-width: 0;
        height: auto;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    /* Cart items: one card per product instead of a six-column table */
    /* Flex so the tfoot (before the tbody in the markup) can be moved below the items */
    .c-cart-items {
        display: flex;
        flex-direction: column;
    }

    .c-cart-items tbody,
    .c-cart-items tfoot {
        display: block;
    }

    .c-cart-items tfoot {
        order: 1;
    }

    /* Visually hidden, the quantity inputs are labelled by the header */
    .c-cart-items thead {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0 0 0 0);
        white-space: nowrap;
    }

    .c-cart-items tbody .c-cart-item {
        position: relative;
        display: grid;
        grid-template-columns: 4.5rem minmax(4.5rem, 1fr) auto;
        grid-template-areas:
            "image name     name"
            "image price    price"
            "image quantity total";
        align-items: center;
        gap: .5rem .75rem;
        padding: 1rem .75rem;
    }

    .c-cart-items tbody .c-cart-item:not(:has(.c-cart-item-image img)) {
        grid-template-columns: minmax(4.5rem, 1fr) auto;
        grid-template-areas:
            "name     name"
            "price    price"
            "quantity total";
    }

    /* The cells are grid items now, so they are blockified */
    .c-cart-items tbody .c-cart-item > td {
        padding: 0;
    }

    .c-cart-items .c-cart-item-image {
        grid-area: image;
        align-self: start;
    }

    .c-cart-items tbody .c-cart-item:not(:has(.c-cart-item-image img)) .c-cart-item-image {
        display: none;
    }

    .c-cart-items td.c-cart-item-image img {
        display: block;
        width: 100%;
        max-width: 100%;
        height: auto;
        max-height: none;
    }

    .c-cart-items .c-cart-item-name {
        grid-area: name;
        overflow-wrap: break-word;
    }

    /* Room for the remove button */
    .c-cart-items tbody .c-cart-item > td.c-cart-item-name {
        padding-right: 2.75rem;
    }

    .c-cart-items .c-cart-item-price {
        grid-area: price;
    }

    .c-cart-items .c-cart-item-quantity {
        grid-area: quantity;
        display: flex;
        align-items: center;
        gap: .5rem;
    }

    .c-cart-items .c-cart-item-total {
        grid-area: total;
        text-align: right;
    }

    /* Top right corner of the card */
    .c-cart-items .c-cart-item-remove {
        position: absolute;
        top: .75rem;
        right: .75rem;
    }

    .c-checkout .c-cart-items .c-cart-item-quantity-input {
        flex: 0 0 4.5rem;
        width: 4.5rem;
        height: auto;
        margin: 0;
    }

    .c-cart-items .c-cart-item-price::before,
    .c-cart-items .c-cart-item-total::before {
        content: attr(data-label);
        margin-right: .375rem;
        font-size: .75rem;
        text-transform: uppercase;
        opacity: .7;
    }

    .c-cart-item-remove-button {
        width: 2.25rem;
        height: 2.25rem;
        padding: 0;
        line-height: 1;
    }

    .c-cart-items tfoot tr {
        display: block;
    }

    .c-cart-items tfoot td {
        display: flex;
        flex-wrap: wrap;
        justify-content: space-between;
        gap: .5rem;
        padding: 1rem .75rem;
    }

    /* Coupon: input and button next to each other at full width */
    .c-cart-coupon-form,
    #c-cart-coupon-label:checked + label + .c-cart-coupon-form {
        display: flex;
        flex-wrap: wrap;
        align-items: stretch;
        gap: .5rem;
    }

    .c-cart-coupon-form label {
        flex-basis: 100%;
    }

    .c-checkout .c-cart-coupon-form input[type=text] {
        flex: 1 1 10rem;
        width: auto;
        min-width: 0;
        height: auto;
        margin: 0;
    }

    /* Submit buttons at full width */
    .c-submit .btn,
    .c-checkout-step form > button[type=submit] {
        width: 100%;
    }
}
