/* ═══════════════════════════════════════════════════════════════════════════
   CHECKOUT — storefront/checkout/{index,pay,success}
   Mobile-first, one template for every viewport. Namespace: .ck-*
   Tokens come from storefront.css (--sf-*). Loaded only on checkout pages.
   ═══════════════════════════════════════════════════════════════════════════ */
.ck {
    --ck-ink: #0c0c0c;
    --ck-muted: #6b7280;
    --ck-line: #e6e6e3;
    --ck-soft: #f7f7f5;
    --ck-radius: 12px;
    --ck-focus: 0 0 0 3px rgba(12, 12, 12, .12);
    max-width: 1120px;
    margin: 0 auto;
    padding: 20px 16px calc(96px + env(safe-area-inset-bottom, 0px));
    color: var(--ck-ink);
    font-family: var(--sf-font-body, -apple-system, 'Segoe UI', sans-serif);
}
.ck *, .ck *::before, .ck *::after { box-sizing: border-box; }

/* Head */
.ck-head { display: grid; grid-template-columns: 1fr auto; align-items: baseline; gap: 6px 12px; margin-bottom: 18px; }
.ck-back { grid-column: 1 / -1; font-size: 13px; color: var(--ck-muted); text-decoration: none; }
.ck-back:hover { color: var(--ck-ink); }
.ck-title { margin: 0; font-size: 26px; font-weight: 700; letter-spacing: -.02em; }
.ck-steps { display: flex; gap: 14px; margin: 0; padding: 0; list-style: none; font-size: 12px; color: var(--ck-muted); }
.ck-steps li { position: relative; padding-left: 16px; }
.ck-steps li::before { content: ''; position: absolute; left: 0; top: 50%; width: 8px; height: 8px; border-radius: 50%; transform: translateY(-50%); background: var(--ck-line); }
.ck-steps li.is-current { color: var(--ck-ink); font-weight: 600; }
.ck-steps li.is-current::before { background: var(--ck-ink); }

/* Cards */
.ck-card { background: #fff; border: 1px solid var(--ck-line); border-radius: var(--ck-radius); padding: 18px 16px; margin-bottom: 14px; }
.ck-card-title { display: flex; align-items: center; gap: 10px; margin: 0 0 14px; font-size: 16px; font-weight: 700; }
.ck-num { width: 24px; height: 24px; border-radius: 50%; background: var(--ck-ink); color: #fff; font-size: 12px; display: inline-flex; align-items: center; justify-content: center; flex: none; }
.ck-label { display: block; margin: 16px 0 8px; font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--ck-muted); }
.ck-card-title + .ck-label, .ck-block > .ck-label:first-child, fieldset > .ck-label { margin-top: 0; }
.ck-hint { margin: 10px 0 0; font-size: 12.5px; color: var(--ck-muted); line-height: 1.5; }
.ck-link { font-size: 13px; color: var(--ck-ink); text-decoration: underline; text-underline-offset: 3px; }
.ck-optional { font-weight: 400; color: var(--ck-muted); text-transform: none; letter-spacing: 0; }
.ck-error { margin: 6px 0 0; font-size: 12.5px; color: #b42318; }
.ck-alert { border-radius: 10px; padding: 12px 14px; font-size: 13.5px; margin-bottom: 14px; }
.ck-alert-error { background: #fef3f2; border: 1px solid #fecdca; color: #b42318; }

/* Contact */
.ck-contact { display: flex; align-items: center; gap: 12px; }
.ck-avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--ck-ink); color: #fff; font-weight: 600; }
.ck-contact-text { display: flex; flex-direction: column; min-width: 0; flex: 1; font-size: 14px; }
.ck-contact-text span { color: var(--ck-muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; }

/* Fields */
.ck-field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; min-width: 0; }
.ck-field label { font-size: 13px; font-weight: 500; }
.ck-field input, .ck-field select, .ck-notes textarea {
    width: 100%; min-height: 46px; padding: 11px 13px; font: inherit; font-size: 15px; color: var(--ck-ink);
    background: #fff; border: 1px solid var(--ck-line); border-radius: 10px; transition: border-color .15s, box-shadow .15s;
}
.ck-field select { appearance: none; -webkit-appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 13px center; padding-right: 36px; }
.ck-field input:focus, .ck-field select:focus, .ck-notes textarea:focus { outline: none; border-color: var(--ck-ink); box-shadow: var(--ck-focus); }
.ck-field.is-invalid input, .ck-field.is-invalid select { border-color: #f04438; }
.ck-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
.ck-address { border: 0; padding: 0; margin: 0 0 4px; min-width: 0; }
.ck-check { display: flex; align-items: center; gap: 10px; margin: 6px 0 4px; font-size: 14px; cursor: pointer; min-height: 44px; }
.ck-check input { width: 18px; height: 18px; accent-color: var(--ck-ink); margin: 0; }

/* Segmented control + option cards (shared look) */
.ck-segment { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
.ck-segment-opt input, .ck-store input, .ck-rate input, .ck-pay input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.ck-segment-opt, .ck-store, .ck-rate, .ck-pay {
    position: relative; display: flex; align-items: center; gap: 12px; padding: 13px 14px; min-height: 56px;
    border: 1.5px solid var(--ck-line); border-radius: 10px; background: #fff; cursor: pointer; transition: border-color .15s, background-color .15s, box-shadow .15s;
}
.ck-segment-opt:has(input:checked), .ck-store:has(input:checked), .ck-rate:has(input:checked), .ck-pay:has(input:checked) { border-color: var(--ck-ink); background: var(--ck-soft); }
.ck-segment-opt:has(input:focus-visible), .ck-store:has(input:focus-visible), .ck-rate:has(input:focus-visible), .ck-pay:has(input:focus-visible), .ck-check:has(input:focus-visible) { box-shadow: var(--ck-focus); }
.ck-segment-opt span, .ck-store-body, .ck-rate-body, .ck-pay-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.ck-segment-opt strong, .ck-store strong, .ck-rate strong, .ck-pay strong { font-size: 14px; font-weight: 600; }
.ck-segment-opt small, .ck-store small, .ck-rate small, .ck-pay small { font-size: 12px; color: var(--ck-muted); }
.ck-store-grid, .ck-rates, .ck-pay-grid { display: grid; gap: 10px; }
.ck-rate-price { font-weight: 600; font-size: 14px; white-space: nowrap; }
.ck-rate-none { margin: 0; padding: 13px 14px; border: 1px dashed var(--ck-line); border-radius: 10px; font-size: 13.5px; color: var(--ck-muted); }
.ck-rates.is-loading { opacity: .5; pointer-events: none; }
.ck-pay-check { width: 20px; height: 20px; border-radius: 50%; border: 1.5px solid var(--ck-line); flex: none; position: relative; }
.ck-pay:has(input:checked) .ck-pay-check { border-color: var(--ck-ink); }
.ck-pay:has(input:checked) .ck-pay-check::after { content: ''; position: absolute; inset: 4px; border-radius: 50%; background: var(--ck-ink); }
.ck-notes { margin-top: 14px; font-size: 13.5px; }
.ck-notes summary { cursor: pointer; color: var(--ck-muted); min-height: 44px; display: flex; align-items: center; }
.ck-notes textarea { margin-top: 8px; resize: vertical; min-height: 80px; }
.ck-legal { font-size: 12px; color: var(--ck-muted); line-height: 1.55; margin: 4px 2px 0; }

/* Summary */
.ck-mobile-summary { border: 1px solid var(--ck-line); border-radius: var(--ck-radius); background: #fff; margin-bottom: 14px; }
.ck-mobile-summary summary { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; font-size: 14px; cursor: pointer; list-style: none; min-height: 48px; }
.ck-mobile-summary summary::-webkit-details-marker { display: none; }
.ck-mobile-summary summary::after { content: '⌄'; margin-left: 10px; color: var(--ck-muted); }
.ck-mobile-summary[open] summary::after { content: '⌃'; }
.ck-mobile-summary-body { padding: 0 16px 14px; border-top: 1px solid var(--ck-line); }
.ck-items { list-style: none; margin: 14px 0; padding: 0; display: grid; gap: 12px; }
.ck-item { display: grid; grid-template-columns: 56px 1fr auto; gap: 12px; align-items: center; }
.ck-item-img { position: relative; width: 56px; height: 56px; border-radius: 8px; overflow: hidden; background: var(--ck-soft); display: flex; align-items: center; justify-content: center; font-weight: 600; color: var(--ck-muted); }
.ck-item-img img { width: 100%; height: 100%; object-fit: cover; }
.ck-item-qty { position: absolute; top: -4px; right: -4px; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--ck-ink); color: #fff; font-size: 11px; display: flex; align-items: center; justify-content: center; }
.ck-item-text { display: flex; flex-direction: column; min-width: 0; font-size: 14px; }
.ck-item-text small { color: var(--ck-muted); font-size: 12px; }
.ck-item-name { overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.ck-item-price { font-size: 14px; font-weight: 600; white-space: nowrap; }
.ck-totals { margin: 0; display: grid; gap: 8px; font-size: 14px; border-top: 1px solid var(--ck-line); padding-top: 14px; }
.ck-totals > div { display: flex; justify-content: space-between; gap: 12px; }
.ck-totals dt { color: var(--ck-muted); font-weight: 400; }
.ck-totals dd { margin: 0; font-weight: 500; }
.ck-totals-grand { border-top: 1px solid var(--ck-line); padding-top: 10px; margin-top: 4px; font-size: 17px; }
.ck-totals-grand dt { color: var(--ck-ink); font-weight: 600; }
.ck-totals-grand dd { font-weight: 700; }

/* CTA */
.ck-cta {
    width: 100%; min-height: 52px; border: 0; border-radius: 12px; background: var(--ck-ink); color: #fff;
    font: inherit; font-size: 15px; font-weight: 600; cursor: pointer; transition: transform .12s, opacity .15s, box-shadow .15s;
}
.ck-cta:hover { box-shadow: 0 8px 22px rgba(0, 0, 0, .18); }
.ck-cta:active { transform: scale(.985); }
.ck-cta:focus-visible { outline: none; box-shadow: var(--ck-focus), 0 0 0 5px #fff inset; }
.ck-cta[disabled] { opacity: .65; cursor: progress; }
.ck-secure { margin: 10px 0 0; text-align: center; font-size: 12px; color: var(--ck-muted); }
.ck-aside { display: none; }
.ck-sticky-cta {
    position: fixed; left: 0; right: 0; bottom: calc(var(--mob-bn-h, 0px) + env(safe-area-inset-bottom, 0px)); z-index: 150;
    display: flex; align-items: center; gap: 12px; padding: 10px 16px; background: rgba(255, 255, 255, .96); backdrop-filter: blur(8px);
    border-top: 1px solid var(--ck-line);
}
.ck-sticky-total { display: flex; flex-direction: column; font-size: 12px; color: var(--ck-muted); line-height: 1.2; }
.ck-sticky-total strong { font-size: 17px; color: var(--ck-ink); }
.ck-sticky-cta .ck-cta { flex: 1; }

/* Pay (retry) + success */
.ck-status { text-align: center; padding: 8px 0 18px; }
.ck-status-icon { width: 64px; height: 64px; border-radius: 50%; margin: 0 auto 14px; display: flex; align-items: center; justify-content: center; background: #ecfdf3; color: #067647; font-size: 26px; }
.ck-status-icon.is-pending { background: #fffaeb; color: #b54708; }
.ck-status h1 { margin: 0 0 6px; font-size: 26px; letter-spacing: -.02em; }
.ck-status p { margin: 0; color: var(--ck-muted); font-size: 14.5px; }
.ck-kv { margin: 0; display: grid; gap: 10px; font-size: 14px; }
.ck-kv > div { display: flex; justify-content: space-between; gap: 12px; }
.ck-kv dt { color: var(--ck-muted); }
.ck-kv dd { margin: 0; font-weight: 600; text-align: right; }
.ck-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.ck-btn-outline { flex: 1; min-height: 48px; display: inline-flex; align-items: center; justify-content: center; border: 1.5px solid var(--ck-ink); border-radius: 12px; color: var(--ck-ink); text-decoration: none; font-weight: 600; font-size: 14px; }
.ck-ref { display: inline-block; padding: 8px 14px; border-radius: 8px; background: var(--ck-soft); font-family: ui-monospace, monospace; font-size: 18px; letter-spacing: .12em; }

@media (min-width: 640px) {
    .ck { padding-top: 28px; }
    .ck-card { padding: 22px; }
}
@media (min-width: 1024px) {
    .ck { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 28px; padding-bottom: 60px; }
    .ck-head { grid-column: 1; }
    .ck-mobile-summary, .ck-sticky-cta { display: none; }
    .ck-aside { display: block; }
    .ck-aside-inner { position: sticky; top: 92px; background: #fff; border: 1px solid var(--ck-line); border-radius: var(--ck-radius); padding: 22px; }
    .ck-aside-title { margin: 0; font-size: 16px; font-weight: 700; }
    .ck-form { min-width: 0; }
    .ck-narrow { grid-template-columns: minmax(0, 640px); justify-content: center; }
}
@media (prefers-reduced-motion: reduce) { .ck * { transition: none !important; } }

/* ═══ Cart — same system, page-specific pieces (storefront/cart/index) ═══ */
.cart-title-count { font-size: 14px; font-weight: 500; color: var(--ck-muted); margin-left: 6px; letter-spacing: 0; }
.cart-ship { padding: 14px 16px; }
.cart-ship-text { margin: 0 0 10px; font-size: 13.5px; }
.cart-ship-bar { height: 6px; border-radius: 3px; background: var(--ck-soft); overflow: hidden; }
.cart-ship-bar span { display: block; height: 100%; background: var(--ck-ink); border-radius: 3px; transition: width .3s ease; }
.cart-lines { padding: 0 16px; }
.cart-line { position: relative; display: grid; grid-template-columns: 88px minmax(0, 1fr); gap: 14px; padding: 16px 0; border-bottom: 1px solid var(--ck-line); }
.cart-line:last-child { border-bottom: 0; }
.cart-line-img { width: 88px; height: 110px; border-radius: 10px; overflow: hidden; background: var(--ck-soft); display: flex; align-items: center; justify-content: center; font-weight: 600; color: var(--ck-muted); text-decoration: none; }
.cart-line-img img { width: 100%; height: 100%; object-fit: cover; }
.cart-line-body { display: flex; flex-direction: column; justify-content: space-between; gap: 12px; min-width: 0; }
.cart-line-top { display: flex; justify-content: space-between; gap: 12px; }
.cart-line-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.cart-line-name { font-size: 15px; font-weight: 600; color: var(--ck-ink); text-decoration: none; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.cart-line-name:hover { text-decoration: underline; text-underline-offset: 3px; }
.cart-line-variant { font-size: 12.5px; color: var(--ck-muted); }
.cart-line-unit { font-size: 13px; color: var(--ck-muted); }
.cart-line-unit small { font-size: 11px; }
.cart-line-total { font-size: 15px; font-weight: 700; white-space: nowrap; }
.cart-line-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.cart-qty { display: inline-flex; align-items: center; border: 1px solid var(--ck-line); border-radius: 10px; overflow: hidden; background: #fff; }
.cart-qty-btn { width: 40px; height: 40px; border: 0; background: transparent; font: inherit; font-size: 18px; line-height: 1; color: var(--ck-ink); cursor: pointer; }
.cart-qty-btn:hover:not(:disabled) { background: var(--ck-soft); }
.cart-qty-btn:disabled { color: #c4c4c4; cursor: default; }
.cart-qty-input { width: 44px; height: 40px; border: 0; border-left: 1px solid var(--ck-line); border-right: 1px solid var(--ck-line); text-align: center; font: inherit; font-size: 14px; font-weight: 600; color: var(--ck-ink); background: #fff; -moz-appearance: textfield; appearance: textfield; }
.cart-qty-input::-webkit-outer-spin-button, .cart-qty-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.cart-qty-input:focus { outline: none; box-shadow: inset 0 0 0 2px var(--ck-ink); }
.cart-line-links { display: flex; gap: 14px; }
.cart-link { background: none; border: 0; padding: 4px 0; font: inherit; font-size: 13px; color: var(--ck-muted); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; min-height: 32px; }
.cart-link:hover { color: var(--ck-ink); }
.cart-link-danger:hover { color: #b42318; }
.cart-line-veil { position: absolute; inset: 0; display: none; align-items: center; justify-content: center; background: rgba(255, 255, 255, .6); border-radius: 8px; }
.cart-line.is-busy .cart-line-veil { display: flex; }
.cart-line.is-busy { pointer-events: none; }
.cart-line.is-removing { opacity: 0; transform: translateX(8px); transition: opacity .2s, transform .2s; }
.cart-spinner { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--ck-line); border-top-color: var(--ck-ink); animation: cart-spin .7s linear infinite; }
@keyframes cart-spin { to { transform: rotate(360deg); } }
.cart-note { margin: 2px 4px 0; }
.cart-summary.is-updating .ck-totals, .cart-summary.is-updating .cart-cta { opacity: .55; }
.cart-promo { margin-bottom: 16px; }
.cart-promo .ck-label { margin-top: 0; }
.cart-promo-row { display: flex; gap: 8px; }
.cart-promo-input { flex: 1; min-width: 0; min-height: 44px; padding: 10px 12px; font: inherit; font-size: 14px; text-transform: uppercase; border: 1px solid var(--ck-line); border-radius: 10px; }
.cart-promo-input:focus { outline: none; border-color: var(--ck-ink); box-shadow: var(--ck-focus); }
.cart-promo-btn { min-height: 44px; padding: 0 16px; border: 1.5px solid var(--ck-ink); border-radius: 10px; background: #fff; font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; }
.cart-promo-btn:hover { background: var(--ck-soft); }
.cart-promo-btn[disabled] { opacity: .6; cursor: progress; }
.cart-promo-applied { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; background: #ecfdf3; color: #067647; font-size: 13.5px; }
.cart-promo-applied .cart-link { color: #067647; min-height: 28px; }
.cart-discount { color: #067647; }
.cart-muted { color: var(--ck-muted); font-weight: 400; }
.cart-cta { display: flex; align-items: center; justify-content: center; gap: 6px; text-decoration: none; margin-top: 16px; }
.cart-cta[aria-disabled="true"] { pointer-events: none; opacity: .65; }
.cart-empty { padding: 40px 0 30px; }
.cart-empty-icon { background: var(--ck-soft); color: var(--ck-muted); }
.cart-empty-cta { display: inline-flex; align-items: center; justify-content: center; width: auto; min-width: 220px; padding: 0 28px; text-decoration: none; margin-top: 22px; }
.cart-empty-link { display: block; margin-top: 16px; }
.ck-sticky-cta .ck-cta { min-height: 48px; }
@media (max-width: 479px) {
    .cart-line { grid-template-columns: 72px minmax(0, 1fr); gap: 12px; }
    .cart-line-img { width: 72px; height: 90px; }
    .cart-line-total { font-size: 14px; }
}
@media (min-width: 1024px) {
    .cart-lines { padding: 4px 22px; }
    .cart-line-img { width: 96px; height: 120px; }
    .cart-line { grid-template-columns: 96px minmax(0, 1fr); }
}
.ck-mobile-summary-body .cart-promo { margin-top: 14px; }
/* Cart head: title + count stay on one line; the step dots drop underneath on narrow screens */
@media (max-width: 639px) {
    .cart-head { grid-template-columns: 1fr; }
    .cart-head .ck-title { white-space: nowrap; }
}
/* While the sticky checkout bar is showing (below 1024px), lift the WhatsApp launcher above it */
@media (max-width: 1023px) {
    .ck-sticky-cta ~ * .wax-launcher, body:has(.ck-sticky-cta) .wax-launcher { bottom: calc(var(--mob-bn-h, 0px) + env(safe-area-inset-bottom, 0px) + 84px); }
}
