/* Checkout revamp. Loaded only on pages that set ViewData["CheckoutStep"], and every rule is scoped
   to body.checkout-mode. Colours, fonts and motion tokens come from marketplace-home.css. */

body.checkout-mode {
    background: var(--wash) !important;
    color: var(--body);
    font-family: var(--ui);
}

/* Sticky footer: the page is at least one screen tall, the content takes the spare room, and the
   footer is always the last thing on the page (at the bottom edge on short pages like Payment). */
body.checkout-mode {
    display: flex;
    min-height: 100vh;
    min-height: 100dvh;
    flex-direction: column;
}

body.checkout-mode .marketplace-page-content {
    min-height: 0;
    flex: 1 0 auto;
    padding-block: clamp(24px, 4vw, 48px) 24px;
}

.co-sr {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

/* ---------- Header + step tracker ---------- */

.co-header {
    background: #fff;
    border-bottom: 1px solid var(--line);
}

.co-header__bar {
    display: flex;
    width: min(1120px, calc(100% - 32px));
    min-height: 68px;
    margin-inline: auto;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.co-brand { display: inline-flex; }
.co-brand img { display: block; width: auto; height: 32px; }

.co-secure {
    display: inline-flex;
    margin: 0;
    align-items: center;
    gap: 8px;
    color: var(--body);
    font-size: 14px;
    font-weight: 600;
}

.co-secure .icon-phosphor { color: var(--success); font-size: 18px; }

.co-steps {
    width: min(680px, calc(100% - 32px));
    margin: 0 auto;
    padding: 4px 0 22px;
}

.co-steps ol {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin: 0;
    padding: 0;
    list-style: none;
}

.co-step { position: relative; text-align: center; }

/* The connector runs from the previous dot to this one; ::after is the purple fill. */
.co-step + .co-step::before,
.co-step + .co-step::after {
    position: absolute;
    top: 15px;
    right: 50%;
    width: 100%;
    height: 2px;
    content: "";
}

.co-step + .co-step::before { background: var(--line); }
.co-step + .co-step::after { background: var(--purple-800); transform: scaleX(0); transform-origin: left; }
.co-step.is-done + .co-step::after,
.co-step + .co-step.is-done::after { transform: scaleX(1); }
.co-step + .co-step.is-current::after { animation: co-line-fill var(--motion-duration-deliberate) var(--ease-out-smooth) 120ms both; }

.co-step__link {
    position: relative;
    z-index: 1;
    display: inline-grid;
    justify-items: center;
    gap: 8px;
    color: inherit;
}

a.co-step__link:hover .co-step__label { color: var(--purple-800); }

.co-step__dot {
    position: relative;
    display: grid;
    width: 32px;
    height: 32px;
    place-items: center;
    border: 2px solid var(--line);
    border-radius: 50%;
    background: #fff;
    color: var(--muted);
    font-size: 14px;
    font-weight: 700;
    transition: background var(--motion-duration-normal) var(--ease-out-smooth), border-color var(--motion-duration-normal) var(--ease-out-smooth), box-shadow var(--motion-duration-normal) var(--ease-out-smooth);
}

.co-step.is-current .co-step__dot {
    border-color: var(--purple-800);
    background: var(--purple-800);
    box-shadow: 0 0 0 5px rgba(107, 30, 116, 0.14);
    color: #fff;
}

.co-step.is-done .co-step__dot {
    border-color: var(--purple-800);
    background: var(--purple-800);
    color: transparent;
}

.co-step.is-done .co-step__dot::after {
    position: absolute;
    width: 6px;
    height: 11px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    content: "";
    transform: translateY(-1px) rotate(45deg);
}

.co-step__label { color: var(--muted); font-size: 13px; font-weight: 600; }
.co-step.is-current .co-step__label { color: var(--ink); font-weight: 700; }
.co-step.is-done .co-step__label { color: var(--body); }

@keyframes co-line-fill { to { transform: scaleX(1); } }

/* ---------- Page frame ---------- */

.co-shell { width: min(1120px, calc(100% - 32px)); margin-inline: auto; }

.co-title {
    margin: 0 0 8px;
    font-size: clamp(30px, 4.4vw, 44px);
    font-weight: 750;
    line-height: 1.08;
    letter-spacing: -0.03em;
}

.co-lede { margin: 0 0 clamp(22px, 3vw, 32px); color: var(--muted); font-size: 17px; line-height: 1.5; }

.co-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 400px;
    gap: 40px;
    align-items: start;
}

.co-panel {
    min-width: 0;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fff;
}

.co-section { padding: clamp(22px, 3vw, 32px); }
.co-section + .co-section { border-top: 1px solid var(--line); }

.co-section__head { display: flex; align-items: center; gap: 14px; margin-bottom: 20px; }

.co-section__num {
    display: grid;
    width: 28px;
    height: 28px;
    flex: 0 0 28px;
    place-items: center;
    border: 1.5px solid var(--purple-800);
    border-radius: 50%;
    color: var(--purple-800);
    font-size: 13px;
    font-weight: 700;
}

.co-section__head h2 { margin: 0; font-size: 24px; line-height: 1.15; }
.co-section__hint { margin: -8px 0 18px 42px; color: var(--muted); font-size: 14px; line-height: 1.45; }

/* ---------- Choice tiles (address + delivery method) ---------- */

.co-choices { display: grid; gap: 12px; }
.co-choices--methods { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.co-choice {
    position: relative;
    display: grid;
    min-width: 0;
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fff;
    cursor: pointer;
    transition: border-color var(--motion-duration-fast) ease, background var(--motion-duration-fast) ease, box-shadow var(--motion-duration-fast) ease;
}

.co-choice:hover { border-color: #d5b9d7; }
.co-choice:has(input:checked) { border-color: var(--purple-800); background: #fcf8fc; box-shadow: 0 0 0 1px var(--purple-800); }
.co-choice:has(input:focus-visible) { outline: 3px solid rgba(107, 30, 116, 0.25); outline-offset: 2px; }

.co-choice input { position: absolute; width: 1px; height: 1px; opacity: 0; }

.co-choice__mark {
    display: grid;
    width: 20px;
    height: 20px;
    place-items: center;
    border: 1.5px solid #b7adb9;
    border-radius: 50%;
    transition: border-color var(--motion-duration-fast) ease;
}

.co-choice__mark::after {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--purple-800);
    content: "";
    opacity: 0;
    transform: scale(0.4);
    transition: opacity var(--motion-duration-fast) ease, transform var(--motion-duration-fast) var(--ease-out-smooth);
}

.co-choice:has(input:checked) .co-choice__mark { border-color: var(--purple-800); }
.co-choice:has(input:checked) .co-choice__mark::after { opacity: 1; transform: scale(1); }

.co-choice__body { display: grid; min-width: 0; gap: 3px; }
.co-choice__body strong { color: var(--ink); font-size: 16px; font-weight: 650; }
.co-choice__body span { overflow-wrap: anywhere; color: var(--muted); font-size: 14px; line-height: 1.4; }

.co-tag {
    margin-left: 8px;
    padding: 3px 8px;
    border-radius: 999px;
    background: var(--wash);
    color: var(--purple-800);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    vertical-align: 2px;
}

.co-choice--address {
    grid-template-columns: auto minmax(0, 1fr);
    align-items: start;
    gap: 14px;
}

.co-choice--address .co-choice__mark { margin-top: 2px; }

/* Pickup branches that cannot fill this cart. */
.co-choice.is-disabled { cursor: not-allowed; background: #faf7fa; }
.co-choice.is-disabled:hover { border-color: var(--line); }
.co-choice.is-disabled .co-choice__body strong,
.co-choice.is-disabled .co-choice__body span { color: #8f8392; }
.co-choice.is-disabled .co-choice__mark { opacity: 0.5; }
.co-choice .co-choice__body .co-choice__stock,
.co-choice.is-disabled .co-choice__body .co-choice__stock { color: #9b2940; font-size: 13px; font-weight: 650; }

.co-choice--method { align-content: start; gap: 10px; padding: 18px 18px 16px; }
.co-choice--method .co-choice__mark { position: absolute; top: 16px; right: 16px; }

.co-choice__icon {
    display: grid;
    width: 40px;
    height: 40px;
    place-items: center;
    border-radius: 50%;
    background: var(--wash);
    color: var(--purple-800);
    font-size: 22px;
}

.co-choice__price { color: var(--ink); font-size: 15px; font-weight: 650; }

.co-add {
    display: flex;
    min-height: 56px;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 0 18px;
    border: 1.5px dashed #d7c9d8;
    border-radius: 12px;
    color: var(--purple-800);
    font-size: 15px;
    font-weight: 650;
    transition: border-color var(--motion-duration-fast) ease, background var(--motion-duration-fast) ease;
}

.co-add:hover { border-color: var(--purple-800); background: #fcf8fc; }
.co-add::before { content: "+"; font-size: 20px; font-weight: 500; line-height: 1; }

.co-empty {
    display: grid;
    justify-items: start;
    gap: 6px;
    padding: 22px;
    border: 1.5px dashed #d7c9d8;
    border-radius: 12px;
    background: #fcf8fc;
}

.co-empty h3 { margin: 0; font-size: 20px; }
.co-empty p { margin: 0 0 12px; color: var(--muted); font-size: 15px; line-height: 1.45; }

/* ---------- Buttons ---------- */

.co-button {
    display: inline-flex;
    width: 100%;
    min-height: 54px;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 0 22px;
    border: 0;
    border-radius: 12px;
    background: var(--purple-800);
    color: #fff !important;
    font-family: var(--ui);
    font-size: 16px;
    font-weight: 650;
    cursor: pointer;
    transition: background var(--motion-duration-fast) ease, transform var(--motion-duration-fast) var(--ease-out-smooth), opacity var(--motion-duration-fast) ease;
}

.co-button:hover { background: var(--purple-950); }
.co-button:active { transform: scale(0.985); }
.co-button:disabled { cursor: not-allowed; opacity: 0.5; }
.co-button:disabled:hover { background: var(--purple-800); }
.co-button--inline { width: auto; min-height: 46px; }
.co-button .icon-phosphor { font-size: 20px; transition: transform var(--motion-duration-fast) var(--ease-out-smooth); }
.co-button:hover .icon-phosphor { transform: translateX(3px); }

.co-button.is-loading { cursor: wait; opacity: 0.85; pointer-events: none; }
.co-button.is-loading .icon-phosphor { display: none; }
.co-button.is-loading::before {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.35);
    border-top-color: #fff;
    border-radius: 50%;
    content: "";
    animation: co-spin 700ms linear infinite;
}

@keyframes co-spin { to { transform: rotate(360deg); } }

/* ---------- Order summary ---------- */

.co-summary {
    position: sticky;
    top: 24px;
    min-width: 0;
    padding: 26px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fff;
}

.co-summary__head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.co-summary__head h2 { margin: 0; font-size: 22px; }
.co-summary__head span { color: var(--muted); font-size: 14px; }

.co-lines { display: grid; gap: 16px; margin: 0; padding: 0 0 20px; border-bottom: 1px solid var(--line); list-style: none; }
.co-line { display: grid; grid-template-columns: 64px minmax(0, 1fr) auto; align-items: center; gap: 14px; }
.co-line__image { width: 64px; height: 64px; overflow: hidden; border-radius: 8px; background: var(--wash); }
.co-line__image img { display: block; width: 100%; height: 100%; object-fit: cover; }
.co-line__copy { display: grid; min-width: 0; gap: 4px; }
.co-line__copy strong { display: -webkit-box; overflow: hidden; color: var(--ink); font-size: 15px; font-weight: 600; line-height: 1.3; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.co-line__copy span { color: var(--muted); font-size: 13px; }
.co-line__amount { color: var(--ink); font-size: 15px; font-weight: 650; white-space: nowrap; }

.co-totals { display: grid; gap: 10px; margin: 0; padding: 18px 0 4px; }
.co-totals > div { display: flex; justify-content: space-between; gap: 16px; font-size: 15px; }
.co-totals dt { color: var(--body); font-weight: 400; }
.co-totals dd { margin: 0; color: var(--ink); font-weight: 650; text-align: right; }
.co-totals dd.is-soft { color: var(--muted); font-weight: 400; }

.co-cta { display: grid; gap: 12px; margin-top: 20px; }
.co-cta__total { display: none; }

.co-message { min-height: 0; color: var(--muted); font-size: 14px; line-height: 1.4; }
.co-message:empty { display: none; }
.co-message[data-state="error"] { padding: 10px 12px; border-radius: 8px; background: #fff0f3; color: #9b2940; }
.co-message[data-state="success"] { color: var(--success); }
.co-message[data-state="loading"] { color: var(--purple-800); }

.co-note { display: flex; align-items: flex-start; gap: 8px; margin: 0; color: var(--muted); font-size: 13px; line-height: 1.45; }
.co-note .icon-phosphor { flex: 0 0 auto; color: var(--purple-800); font-size: 17px; }

/* ---------- Footer ---------- */

.co-footer {
    display: flex;
    width: min(1120px, calc(100% - 32px));
    margin: 0 auto;
    padding: 24px 0 28px;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: 13px;
}

.co-footer nav { display: flex; gap: 20px; }
.co-footer a { color: var(--body); }
.co-footer a:hover { color: var(--purple-800); }

/* ---------- Tablet / mobile ---------- */

@media (max-width: 900px) {
    .co-layout,
    body.checkout-mode .cart-layout { grid-template-columns: minmax(0, 1fr); gap: 24px; padding-bottom: 150px; }
    .co-summary { position: static; padding: 22px; }

    /* The primary action becomes a bottom bar so it is always in reach. */
    .co-cta {
        position: fixed;
        z-index: 40;
        right: 0;
        bottom: 0;
        left: 0;
        margin: 0;
        padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
        border-top: 1px solid var(--line);
        background: #fff;
        box-shadow: 0 -10px 30px rgba(55, 18, 61, 0.1);
    }

    .co-cta__total { display: flex; align-items: baseline; justify-content: space-between; color: var(--body); font-size: 14px; }
    .co-cta__total strong { color: var(--ink); font-family: var(--display); font-size: 20px; }
    .co-note { display: none; }
}

@media (max-width: 640px) {
    .co-item { grid-template-columns: 80px minmax(0, 1fr); gap: 14px; }
    .co-item__image { width: 80px; height: 80px; }
    .co-item__price { grid-column: 2; text-align: left; }
    .co-choices--methods { grid-template-columns: minmax(0, 1fr); }
    .co-step__label { display: none; }
    .co-step.is-current .co-step__label { display: block; }
    .co-steps { padding-bottom: 16px; }
    .co-footer { flex-direction: column; align-items: flex-start; }
}

@media (prefers-reduced-motion: reduce) {
    body.checkout-mode *,
    body.checkout-mode *::before,
    body.checkout-mode *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ---------- Cart (step 1) ---------- */

body.checkout-mode .cart-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 400px;
    gap: 40px;
    align-items: start;
}

.co-cart { overflow: hidden; }

.co-seller {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px clamp(18px, 3vw, 28px);
    border-bottom: 1px solid var(--line);
    color: var(--ink);
    font-size: 15px;
    font-weight: 650;
    transition: color var(--motion-duration-fast) ease;
}

.co-item + .co-seller { border-top: 1px solid var(--line); }
.co-seller:hover { color: var(--purple-800); }

.co-seller .icon-phosphor {
    display: grid;
    width: 32px;
    height: 32px;
    place-items: center;
    border-radius: 50%;
    background: var(--wash);
    color: var(--purple-800);
    font-size: 18px;
}

.co-item {
    display: grid;
    grid-template-columns: 96px minmax(0, 1fr) auto;
    gap: 20px;
    padding: 24px clamp(18px, 3vw, 28px);
    border-bottom: 1px solid var(--line);
}

.co-item:last-child { border-bottom: 0; }

.co-item__image { display: block; width: 96px; height: 96px; overflow: hidden; border-radius: 8px; background: var(--wash); }
.co-item__image img { display: block; width: 100%; height: 100%; object-fit: cover; }

.co-item__main { display: grid; align-content: start; gap: 6px; min-width: 0; }
.co-item__name { color: var(--ink); font-size: 17px; font-weight: 600; line-height: 1.3; overflow-wrap: anywhere; transition: color var(--motion-duration-fast) ease; }
.co-item__name:hover { color: var(--purple-800); }
.co-item__variants { color: var(--muted); font-size: 14px; }
.co-item__variants span + span::before { content: " \00b7  "; }
.co-item__meta { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.4; }
.co-item__meta strong { color: var(--ink); font-weight: 650; }
.co-pickup-note { margin: 0 0 16px; padding: 12px 16px; border: 1px solid #ecd8bd; border-radius: 12px; background: #fdf6ea; color: #6a4410; font-size: 14px; line-height: 1.45; }
.co-item__actions { display: flex; flex-wrap: wrap; align-items: center; gap: 20px; margin-top: 10px; }
.co-item__price { color: var(--ink); font-size: 17px; font-weight: 650; text-align: right; white-space: nowrap; }

.co-remove {
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--muted);
    font-family: var(--ui);
    font-size: 14px;
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 3px;
    cursor: pointer;
    transition: color var(--motion-duration-fast) ease;
}

.co-remove:hover { color: #9b2940; }

.co-link { display: block; margin-top: 16px; color: var(--purple-800); font-size: 15px; font-weight: 650; text-align: center; }
.co-link:hover { text-decoration: underline; text-underline-offset: 3px; }

/* States the cart script builds or the server returns. The class names stay because the refresh script looks for them. */
body.checkout-mode .cart-empty,
body.checkout-mode .cart-load-state,
body.checkout-mode .cart-loading,
body.checkout-mode .cart-data-warning { border-radius: 12px; }
body.checkout-mode .cart-empty { min-height: 320px; border: 1px solid var(--line); background: #fff; }
body.checkout-mode .cart-empty h2 { font-size: clamp(24px, 3vw, 32px); }
body.checkout-mode .cart-status { margin: 0 0 16px; }

/* ---------- Payment (step 3) ---------- */

/* Elements the page script shows and hides with the hidden attribute must stay hidden. */
.co-button[hidden],
.co-link[hidden],
.co-connect[hidden],
.co-state[hidden],
.pay-message[hidden] { display: none; }

.co-back {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 18px;
    color: var(--body);
    font-size: 14px;
    font-weight: 600;
    transition: color var(--motion-duration-fast) ease;
}

.co-back .icon-phosphor { font-size: 18px; transition: transform var(--motion-duration-fast) var(--ease-out-smooth); }
.co-back:hover { color: var(--purple-800); }
.co-back:hover .icon-phosphor { transform: translateX(-3px); }

.co-stack { display: grid; gap: 20px; min-width: 0; }

.pay-incentive {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 16px;
    padding: 14px 16px;
    border: 1px solid rgba(255, 191, 83, 0.6);
    border-radius: 12px;
    background: rgba(255, 191, 83, 0.14);
}

.pay-incentive .icon-phosphor { flex: 0 0 auto; margin-top: 1px; color: #8a5a00; font-size: 22px; }
.pay-incentive strong { display: block; color: var(--ink); font-size: 15px; }
.pay-incentive p { margin: 3px 0 0; color: var(--body); font-size: 14px; line-height: 1.45; }

.pay-methods { display: grid; gap: 12px; min-width: 0; margin: 0; padding: 0; border: 0; }

/* Each method is its own rounded tile (same look as the address and delivery choices), so the
   selected outline always goes fully around it. */
.pay-method {
    position: relative;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 14px;
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fff;
    cursor: pointer;
    transition: border-color var(--motion-duration-fast) ease, background var(--motion-duration-fast) ease, box-shadow var(--motion-duration-fast) ease;
}

.pay-method:hover { border-color: #d5b9d7; }
.pay-method:has(input:checked) { border-color: var(--purple-800); background: #fcf8fc; box-shadow: 0 0 0 1px var(--purple-800); }
.pay-method:has(input:focus-visible) { outline: 3px solid rgba(107, 30, 116, 0.25); outline-offset: 2px; }
.pay-method input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.pay-method:has(input:checked) .co-choice__mark { border-color: var(--purple-800); }
.pay-method:has(input:checked) .co-choice__mark::after { opacity: 1; transform: scale(1); }

.pay-method__body { display: grid; min-width: 0; gap: 3px; }
.pay-method__body strong { color: var(--ink); font-size: 16px; font-weight: 650; }
.pay-method__body span { color: var(--muted); font-size: 14px; line-height: 1.4; }
.pay-method__tags { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.pay-method__tags .co-tag { margin-left: 0; vertical-align: baseline; }
.co-tag--gold { background: #f6e6c2; color: #5c4415; }

.co-connect { margin-top: 16px; padding: 22px; border: 1px solid var(--line); border-radius: 12px; background: #fcf8fc; }
.co-connect:not([hidden]) { animation: co-rise 260ms var(--ease-out-smooth); }
.co-connect__head { display: flex; align-items: flex-start; gap: 14px; margin-bottom: 18px; }

.co-connect__icon {
    display: grid;
    width: 40px;
    height: 40px;
    flex: 0 0 40px;
    place-items: center;
    border-radius: 50%;
    background: #fff;
    color: var(--purple-800);
    font-size: 22px;
}

.co-connect__head h3 { margin: 0; font-size: 18px; }
.co-connect__head p { margin: 4px 0 0; color: var(--muted); font-size: 14px; line-height: 1.45; }
.co-connect .dmp-connect-form { display: grid; gap: 14px; }

@keyframes co-rise { from { opacity: 0; transform: translateY(8px); } }

/* Result / progress panels the script reveals */
.co-state {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    padding: 22px 24px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fff;
}

.co-state:not([hidden]) { animation: co-rise 260ms var(--ease-out-smooth); }
.co-state > .icon-phosphor { flex: 0 0 auto; color: var(--purple-800); font-size: 28px; }
.co-state h2 { margin: 0; font-size: 20px; }
.co-state p { margin: 6px 0 0; color: var(--body); font-size: 15px; line-height: 1.5; }
.co-state__actions { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; margin-top: 16px; }
.co-state--success > .icon-phosphor { color: var(--success); }
.co-state--error { border-color: #ead0d8; background: #fff8f9; }
.co-state--error > .icon-phosphor { color: #9b2940; }
.co-state--error .co-button { flex: 0 0 auto; width: auto; margin-left: auto; }
.co-state--recovery { border-color: rgba(255, 191, 83, 0.7); background: rgba(255, 191, 83, 0.12); }
.co-state--recovery > .icon-phosphor { color: #8a5a00; }

.co-button--quiet { background: #fff; box-shadow: inset 0 0 0 1px var(--line); color: var(--ink) !important; }
.co-button--quiet:hover { background: var(--wash); }
.co-link--inline { display: inline; margin: 0; }

/* Status line above the pay button */
.pay-message {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 11px 14px;
    border-radius: 8px;
    background: var(--wash);
    color: var(--body);
    font-size: 14px;
    line-height: 1.4;
}

.pay-message__spinner {
    display: none;
    flex: 0 0 auto;
    width: 16px;
    height: 16px;
    margin-top: 2px;
    border: 2px solid rgba(107, 30, 116, 0.25);
    border-top-color: var(--purple-800);
    border-radius: 50%;
    animation: co-spin 700ms linear infinite;
}

/* The one status line sits under the pay button; while it is showing, the calm hold line steps aside. */
.pay-message { order: 4; }
.co-cta:has(.pay-message:not([hidden])) .co-hold[data-state="calm"] { display: none; }

.pay-message[data-state="loading"] { background: #fcf8fc; color: var(--purple-800); }
.pay-message[data-state="loading"] .pay-message__spinner { display: block; }
.pay-message[data-state="success"] { background: #eaf7ef; color: #1d6b4e; }
.pay-message[data-state="error"] { background: #fff0f3; color: #9b2940; }

/* "We're holding your items": one small line under the pay button while there is time; when time is
   short (or gone) it moves above the button as a notice with an edge bar. Only CSS reorders it. */
.co-hold {
    margin: 0;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.45;
    text-align: center;
}

.co-hold:empty { display: none; }
.co-hold[data-state="calm"] { order: 5; }

.co-hold[data-state="urgent"],
.co-hold[data-state="expired"] {
    order: -1;
    padding: 11px 14px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    text-align: left;
}

.co-hold[data-state="urgent"] { background: rgba(255, 191, 83, 0.2); box-shadow: inset 0 0 0 1px rgba(224, 138, 0, 0.4); color: #5c4415; }
.co-hold[data-state="expired"] { background: #fff0f3; box-shadow: inset 0 0 0 1px rgba(155, 41, 64, 0.3); color: #9b2940; }

.co-totals dd.is-discount { color: var(--success); }
.co-grand { margin-top: 10px; }

@media (max-width: 900px) {
    /* The bottom bar stays compact: the calm line is hidden, urgent and expired notices still show. */
    .co-hold[data-state="calm"] { display: none; }
}


.co-grand {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 16px;
    margin-top: 6px;
    padding-top: 16px;
    border-top: 1px solid var(--line);
    color: var(--ink);
    font-size: 16px;
    font-weight: 650;
}

.co-grand strong { font-family: var(--display); font-size: 26px; letter-spacing: -0.02em; }

@media (max-width: 640px) {
    .co-state--error { flex-wrap: wrap; }
    .co-state--error .co-button { margin-left: 0; }
    .pay-method { grid-template-columns: auto minmax(0, 1fr); }
    .pay-method__tags { grid-column: 2; justify-content: flex-start; }
}


/* ---------- Result pages (step 4: payment complete / still processing / needs attention) ---------- */

.co-result {
    width: min(640px, 100%);
    margin: 0 auto;
    padding-top: clamp(8px, 3vw, 32px);
    text-align: center;
}

.co-result h1 {
    max-width: 560px;
    margin: 0 auto 12px;
    font-size: clamp(30px, 5vw, 44px);
    font-weight: 750;
    line-height: 1.08;
    letter-spacing: -0.03em;
}

.co-result > p { max-width: 480px; margin: 0 auto; color: var(--muted); font-size: 17px; line-height: 1.55; }

.co-result__badge {
    position: relative;
    display: grid;
    width: 84px;
    height: 84px;
    margin: 0 auto 26px;
    place-items: center;
    border-radius: 50%;
    animation: co-pop 420ms var(--ease-spring-bounce) both;
}

@keyframes co-pop { from { opacity: 0; transform: scale(0.55); } }
@keyframes co-check { to { transform: translateY(-3px) rotate(-45deg) scale(1); } }

.co-result--success .co-result__badge { background: #e6f6ee; }
.co-result--success .co-result__badge::before {
    width: 30px;
    height: 15px;
    border: solid var(--success);
    border-width: 0 0 4px 4px;
    content: "";
    transform: translateY(-3px) rotate(-45deg) scale(0);
    animation: co-check 380ms var(--ease-spring-bounce) 260ms forwards;
}

.co-result--pending .co-result__badge { background: rgba(255, 191, 83, 0.22); }
.co-result--pending .co-result__badge::before {
    width: 34px;
    height: 34px;
    border: 3px solid rgba(138, 90, 0, 0.25);
    border-top-color: #8a5a00;
    border-radius: 50%;
    content: "";
    animation: co-spin 900ms linear infinite;
}

.co-result--error .co-result__badge { background: #fff0f3; }
.co-result--error .co-result__badge::before {
    color: #9b2940;
    content: "!";
    font-family: var(--display);
    font-size: 44px;
    font-weight: 800;
    line-height: 1;
}

.co-receipt {
    display: grid;
    margin: 28px 0 0;
    padding: 4px 24px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fff;
    text-align: left;
}

.co-receipt > div { display: flex; justify-content: space-between; gap: 16px; padding: 14px 0; font-size: 15px; }
.co-receipt > div + div { border-top: 1px solid var(--line); }
.co-receipt dt { color: var(--muted); font-weight: 400; }
.co-receipt dd { margin: 0; color: var(--ink); font-weight: 650; text-align: right; }

.co-next-panel { margin-top: 16px; padding: 24px 26px; text-align: left; }
.co-next-panel h2 { margin: 0 0 20px; font-size: 18px; }

.co-next { display: grid; gap: 22px; margin: 0; padding: 0; list-style: none; }
.co-next li { position: relative; display: grid; grid-template-columns: 24px minmax(0, 1fr); gap: 14px; }
.co-next li:not(:last-child)::before { position: absolute; top: 28px; bottom: -22px; left: 11px; width: 2px; background: var(--line); content: ""; }
.co-next li.is-done:not(:last-child)::before { background: var(--success); }

.co-next__dot {
    position: relative;
    display: block;
    width: 24px;
    height: 24px;
    border: 2px solid var(--line);
    border-radius: 50%;
    background: #fff;
}

.co-next li.is-done .co-next__dot { border-color: var(--success); background: var(--success); }
.co-next li.is-done .co-next__dot::after {
    position: absolute;
    top: 3px;
    left: 7px;
    width: 5px;
    height: 10px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    content: "";
    transform: rotate(45deg);
}

.co-next li.is-current .co-next__dot { border-color: var(--purple-800); box-shadow: 0 0 0 4px rgba(107, 30, 116, 0.14); }
.co-next li.is-current .co-next__dot::after {
    position: absolute;
    inset: 5px;
    border-radius: 50%;
    background: var(--purple-800);
    content: "";
}

.co-next strong { display: block; color: var(--ink); font-size: 15px; font-weight: 650; }
.co-next li span:not(.co-next__dot) { color: var(--muted); font-size: 14px; }

.co-result__actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; margin-top: 28px; }

@media (max-width: 640px) {
    .co-result__actions .co-button { width: 100%; }
}
