/* Cart drawer + checkout (behaviour in /js/cart.js).
   Matches clickcase.co: cream paper, 2px charcoal outlines, offset "3px 3px 0" shadows, pill buttons.
   Tokens come from /brand/theme.css with ClickCase fallbacks. */
.cart {
  --cart-paper: #FFFBF3;
  --cart-ink: var(--brand-ink, #333);
  --cart-soft: var(--brand-ink-soft, #6B6B6B);
  --cart-peach: var(--brand-primary, #FFA891);
  --cart-peach-strong: var(--brand-primary-strong, #F58E73);
  --cart-blue: var(--brand-secondary, #96C0CE);
  --cart-yellow: var(--brand-highlight, #FFF3B0);
  --cart-mint: var(--brand-success, #A8E6CF);
  --cart-line: 2px solid var(--cart-ink);
  --cart-shadow: 3px 3px 0 var(--cart-ink);
  --cart-pad: 24px;
}

.cart-locked, .cart-locked body { overflow: hidden; }
.cart-sr { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* ---------- shell ---------- */
.scrim { position: fixed; inset: 0; z-index: 40; background: color-mix(in srgb, var(--brand-ink, #333) 50%, transparent); opacity: 0; transition: opacity .22s ease; }
.scrim.open { opacity: 1; }
.cart {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 41;
  width: min(440px, 100%); height: 100%; height: 100dvh;
  display: flex; flex-direction: column;
  background: var(--cart-paper); color: var(--cart-ink);
  border-left: var(--cart-line);
  transform: translateX(104%); transition: transform .3s cubic-bezier(.2, .8, .2, 1);
  font-family: var(--font-body);
}
.cart.open { transform: none; }
.cart :focus-visible { outline: 3px solid var(--cart-blue); outline-offset: 2px; }

.cart-head { display: flex; align-items: center; gap: 10px; padding: 20px var(--cart-pad) 14px; border-bottom: var(--cart-line); }
.cart-head h2 { font-size: 32px; line-height: 1; margin: 0; }
.cart-head-count { font-size: 13px; font-weight: 700; color: var(--cart-soft); margin-right: auto; padding-top: 4px; }
.cart-close {
  flex: none; width: 40px; height: 40px; margin-left: auto; display: grid; place-items: center;
  background: var(--cart-paper); border: var(--cart-line); border-radius: 999px; box-shadow: var(--cart-shadow); color: var(--cart-ink);
  transition: transform .12s ease, box-shadow .12s ease;
}
.cart-close svg { width: 18px; height: 18px; }
.cart-close:hover { transform: translate(-1px, -1px); box-shadow: 4px 4px 0 var(--cart-ink); }
.cart-close:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--cart-ink); }

/* ---------- free-shipping meter ---------- */
.cart-ship { margin: 16px var(--cart-pad) 4px; padding: 12px 14px; background: var(--cart-yellow); border: var(--cart-line); border-radius: 16px; }
.cart-meter-text { margin: 0; font-size: 14px; font-weight: 700; line-height: 1.35; }
.cart-meter { height: 12px; margin-top: 9px; background: var(--cart-paper); border: var(--cart-line); border-radius: 999px; overflow: hidden; }
.cart-meter-fill { display: block; height: 100%; width: 0; background: var(--cart-peach); border-right: 2px solid var(--cart-ink); transition: width .35s ease; }
.cart-meter.is-done .cart-meter-fill { background: var(--cart-mint); border-right: 0; }

/* ---------- lines ---------- */
.cart-lines { list-style: none; margin: 0; padding: 4px var(--cart-pad); flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.cart-line { display: grid; grid-template-columns: 64px minmax(0, 1fr) auto; gap: 14px; align-items: start; padding: 16px 0; border-bottom: 1.5px dashed color-mix(in srgb, var(--cart-ink) 35%, transparent); }
.cart-line:last-child { border-bottom: 0; }
.cart-thumb { width: 64px; height: 84px; border: var(--cart-line); border-radius: 12px; overflow: hidden; display: grid; place-items: center; background: var(--cart-blue); }
.cart-thumb img { width: 100%; height: 100%; object-fit: cover; }
.cart-thumb.is-placeholder.alt-1 { background: var(--cart-peach); }
.cart-thumb.is-placeholder.alt-2 { background: var(--cart-yellow); }
.cart-thumb.is-placeholder.alt-3 { background: var(--cart-mint); }
.cart-thumb img.mark { width: 55%; height: auto; object-fit: contain; }
.cart-line-info { display: grid; gap: 2px; min-width: 0; }
.cart-line-name { margin: 0; font-weight: 800; font-size: 15px; line-height: 1.3; overflow-wrap: anywhere; }
.cart-line-model { margin: 0; font-size: 13px; font-weight: 600; color: var(--cart-soft); overflow-wrap: anywhere; }
.cart-flag { justify-self: start; margin: 4px 0 0; padding: 2px 9px; font-size: 11px; font-weight: 800; letter-spacing: .03em; text-transform: uppercase; background: var(--cart-yellow); border: 1.5px solid var(--cart-ink); border-radius: 999px; }
.cart-flag.is-out { background: var(--cart-ink); color: var(--cart-paper); }
.cart-line.is-flagged .cart-thumb { filter: grayscale(1); opacity: .6; }
.cart-line-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin-top: 10px; }
.cart-stepper { display: inline-flex; align-items: center; border: var(--cart-line); border-radius: 999px; background: var(--cart-paper); box-shadow: var(--cart-shadow); }
.cart-step { width: 38px; height: 36px; border: 0; background: none; border-radius: 999px; font-size: 18px; font-weight: 800; line-height: 1; color: var(--cart-ink); }
.cart-step:hover:not([disabled]) { background: var(--cart-yellow); }
.cart-step[disabled] { opacity: .3; cursor: not-allowed; }
.cart-qty { min-width: 26px; text-align: center; font-weight: 800; font-size: 15px; font-variant-numeric: tabular-nums; }
.cart-remove { border: 0; background: none; padding: 8px 2px; font-size: 13px; font-weight: 700; color: var(--cart-ink); text-decoration: underline; text-decoration-thickness: 1.5px; text-underline-offset: 3px; }
.cart-remove:hover { color: var(--cart-peach-strong); }
.cart-max { margin: 6px 0 0; font-size: 12px; font-weight: 600; color: var(--cart-soft); }
.cart-line-price { display: grid; justify-items: end; gap: 2px; font-weight: 800; font-size: 15px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.cart-each { font-size: 12px; font-weight: 600; color: var(--cart-soft); }
.cart-strike { text-decoration: line-through; color: var(--cart-soft); }
.cart.is-busy .cart-lines { opacity: .6; pointer-events: none; }

/* loading skeleton (cart restored from storage before the catalog arrives) */
.cart-line.is-pending { grid-template-columns: 64px 1fr; }
.cart-thumb.is-loading, .cart-bone { background: linear-gradient(90deg, #F1EBDD, #FBF6EC, #F1EBDD); background-size: 200% 100%; animation: cart-shimmer 1.2s infinite linear; }
.cart-thumb.is-loading { border-color: #E3DACA; }
.cart-bone { display: block; height: 14px; width: 80%; border-radius: 999px; margin-top: 6px; }
.cart-bone.short { width: 45%; }
@keyframes cart-shimmer { to { background-position: -200% 0; } }

/* empty / error state */
.cart-empty { display: grid; justify-items: center; gap: 6px; text-align: center; padding: 56px 8px; }
.cart-empty p { margin: 0; color: var(--cart-soft); font-weight: 500; }
.cart-empty .cart-empty-title { font-size: 28px; line-height: 1.1; color: var(--cart-ink); margin-bottom: 4px; }
.cart-ghost {
  margin-top: 14px; padding: 11px 22px; border: var(--cart-line); border-radius: 999px; background: var(--cart-paper);
  font-weight: 800; font-size: 15px; color: var(--cart-ink); box-shadow: var(--cart-shadow); transition: transform .12s ease, box-shadow .12s ease;
}
.cart-ghost:hover { transform: translate(-1px, -1px); box-shadow: 4px 4px 0 var(--cart-ink); background: var(--cart-yellow); }

/* ---------- alerts ---------- */
.cart-alert { margin: 0 var(--cart-pad) 12px; padding: 12px 14px; border: var(--cart-line); border-radius: 14px; background: #FFE1D8; display: grid; gap: 8px; }
.cart-alert.is-info { background: var(--cart-yellow); }
.cart-alert p { margin: 0; }
.cart-alert-msg { font-size: 14px; font-weight: 700; line-height: 1.4; }
.cart-alert-meta { font-size: 12px; color: var(--cart-soft); overflow-wrap: anywhere; }
.cart-alert-meta a { color: var(--cart-ink); font-weight: 700; }
.cart-alert-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.cart-alert-btn { padding: 7px 16px; border: var(--cart-line); border-radius: 999px; background: var(--cart-paper); font-weight: 800; font-size: 13px; color: var(--cart-ink); box-shadow: 2px 2px 0 var(--cart-ink); }
.cart-alert-btn:active { transform: translate(1px, 1px); box-shadow: 1px 1px 0 var(--cart-ink); }

/* ---------- footer ---------- */
.cart-foot { flex: none; display: grid; gap: 10px; padding: 16px var(--cart-pad) calc(18px + env(safe-area-inset-bottom, 0px)); border-top: var(--cart-line); background: var(--cart-paper); }
.cart-subtotal { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; font-size: 18px; font-weight: 800; font-variant-numeric: tabular-nums; }
.cart-note { margin: 0; font-size: 13px; line-height: 1.45; color: var(--cart-soft); }
.cart-blocked { margin: 0; font-size: 13px; font-weight: 700; color: #8A2E17; }
.cart-ts { display: grid; justify-items: center; gap: 6px; }
.cart-ts-hint { margin: 0; font-size: 13px; font-weight: 700; text-align: center; }
.cart-ts-box { max-width: 100%; overflow: hidden; }
.cart-checkout {
  position: relative; display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; min-height: 54px; padding: 14px 24px;
  border: var(--cart-line); border-radius: 999px; background: var(--cart-peach); color: var(--cart-ink);
  font-size: 17px; font-weight: 800; box-shadow: var(--cart-shadow); transition: transform .12s ease, box-shadow .12s ease, background-color .12s ease;
}
.cart-checkout:hover:not([disabled]):not([aria-disabled="true"]) { background: var(--cart-peach-strong); transform: translate(-1px, -1px); box-shadow: 4px 4px 0 var(--cart-ink); }
.cart-checkout:active:not([disabled]):not([aria-disabled="true"]) { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--cart-ink); }
.cart-checkout[disabled], .cart-checkout[aria-disabled="true"] { cursor: not-allowed; background: #EDE6D8; color: var(--cart-soft); box-shadow: none; }
.cart-checkout.is-busy { cursor: progress; background: var(--cart-peach); color: var(--cart-ink); box-shadow: var(--cart-shadow); }
.cart-spinner { display: none; width: 18px; height: 18px; border: 2.5px solid var(--cart-ink); border-right-color: transparent; border-radius: 999px; animation: cart-spin .7s linear infinite; }
.cart-checkout.is-busy .cart-spinner { display: inline-block; }
@keyframes cart-spin { to { transform: rotate(360deg); } }
.cart-secure { display: flex; align-items: center; justify-content: center; gap: 6px; margin: 0; font-size: 12px; font-weight: 600; color: var(--cart-soft); }
.cart-secure svg { width: 13px; height: 13px; }

/* header badge hook (header itself is styled in style.css) */
.count.is-empty { opacity: .75; }

/* ---------- small screens (down to 320px) ---------- */
@media (max-width: 480px) {
  .cart { --cart-pad: 16px; width: 100%; border-left: 0; }
  .cart-head h2 { font-size: 28px; }
  .cart-line { grid-template-columns: 56px minmax(0, 1fr) auto; gap: 12px; }
  .cart-thumb { width: 56px; height: 74px; }
  .cart-line.is-pending { grid-template-columns: 56px 1fr; }
}
@media (max-width: 359px) {
  .cart-line { grid-template-columns: 48px minmax(0, 1fr); }
  .cart-thumb { width: 48px; height: 64px; }
  .cart-line-price { grid-column: 2; justify-items: start; }
}
@media (prefers-reduced-motion: reduce) {
  .cart, .scrim, .cart-meter-fill { transition: none; }
  .cart-spinner { animation-duration: 2s; }
}

/* ---------- "Need a frame?" hint (cart has backs but no frame) ---------- */
.cart-hint { flex: none; margin: 0 var(--cart-pad) 12px; padding: 10px 12px 10px 14px; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 10px; background: var(--cart-mint); border: var(--cart-line); border-radius: 14px; }
.cart-hint p { margin: 0; font-size: 13.5px; font-weight: 700; line-height: 1.35; }
.cart-hint-btn { padding: 7px 14px; border: var(--cart-line); border-radius: 999px; background: var(--cart-paper); font-weight: 800; font-size: 13px; color: var(--cart-ink); box-shadow: 2px 2px 0 var(--cart-ink); }
.cart-hint-btn:hover { background: var(--cart-yellow); }
.cart-hint-btn:active { transform: translate(1px, 1px); box-shadow: 1px 1px 0 var(--cart-ink); }
