/* ============================================================
   SV CART DRAWER — slide-out cart (free-ship bar, Mix & Match rail, line items,
   note, You Save footer). Reproduces the Shopify drawer; token-driven so it reads
   correctly in light + dark.
   ============================================================ */
/* Visibility is driven by the [hidden] attribute; the is-open class only runs
   the animation. Keeping these separate is what makes the slide actually
   animate — flipping display and transform in the same frame skips the
   transition entirely (the old "flash" bug, Victor 2026-07-09). */
.sv-cart { position: fixed; inset: 0; z-index: 210; display: block; }
.sv-cart[hidden] { display: none !important; }
.sv-cart__scrim { position: absolute; inset: 0; background: rgba(0,0,0,.5); border: none; padding: 0; cursor: pointer; opacity: 0; transition: opacity .32s ease; }
.sv-cart.is-open .sv-cart__scrim { opacity: 1; }
.sv-cart__panel { position: absolute; top: 0; right: 0; bottom: 0; width: min(94vw, 420px); background: var(--sv-bg); color: var(--sv-text); box-shadow: -6px 0 34px rgba(0,0,0,.38); display: flex; flex-direction: column; transform: translateX(100%); transition: transform .32s cubic-bezier(.22, .8, .3, 1); }
.sv-cart.is-open .sv-cart__panel { transform: translateX(0); }
@media (prefers-reduced-motion: reduce) {
  .sv-cart__panel, .sv-cart__scrim { transition: none; }
}
.sv-cart-drawer__content { display: flex; flex-direction: column; height: 100%; min-height: 0; }

.sv-cart__head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px 12px; }
.sv-cart__title { font: 700 22px var(--sv-font); color: var(--sv-text); }
.sv-cart__title sup { font-size: 12px; font-weight: 700; opacity: .8; }
.sv-cart__close { background: none; border: 1px solid var(--sv-border); border-radius: 50%; width: 32px; height: 32px; font-size: 20px; line-height: 1; color: var(--sv-text); cursor: pointer; }
.sv-cart__scroll { flex: 1; overflow-y: auto; padding: 0 20px 12px; }
.sv-cart__empty { color: var(--sv-text-muted); text-align: center; padding: 40px 0; }

/* Free-shipping bar */
.sv-fs { margin: 6px 0 16px; }
.sv-fs__row { display: flex; align-items: center; justify-content: space-between; gap: 8px; font: 600 13px var(--sv-font); }
.sv-fs__head { display: inline-flex; align-items: center; gap: 6px; color: #28c45e; }
.sv-fs__head svg { width: 15px; height: 15px; }
.sv-fs__status { color: var(--sv-text); }
.sv-fs__status b { color: var(--sv-text); }
.sv-fs__status--won { color: #28c45e; font-weight: 700; }
.sv-fs__track { height: 8px; border-radius: 999px; background: rgba(150,150,150,.28); margin-top: 7px; overflow: hidden; }
.sv-fs__fill { display: block; height: 100%; border-radius: 999px; background: #28c45e; background-image: linear-gradient(100deg,#1fa84f 0%,#5fe08a 50%,#1fa84f 100%); background-size: 200px 100%; animation: svfsShimmer 1.6s linear infinite; transition: width .5s ease; }
@keyframes svfsShimmer { 0% { background-position: -180px 0; } 100% { background-position: 180px 0; } }

/* Mix & Match rail */
.sv-mm { margin: 0 0 18px; }
.sv-mm__head { display: flex; align-items: center; gap: 6px; font: 700 13px var(--sv-font); color: #28c45e; margin-bottom: 12px; }
.sv-mm__head svg { width: 15px; height: 15px; }
/* Single progress rail — the green fill runs ON the checkpoint line; stops
   sit at true 0–5 positions (Buy 1 = 20%, Buy 2 = 40%, Buy 5 = 100%) so each
   added item advances the fill exactly one fifth. (Victor-approved proposal.) */
.sv-mm__railwrap { position: relative; height: 22px; margin: 0 11px 6px; }
.sv-mm__track, .sv-mm__fill { position: absolute; top: 8.5px; height: 5px; border-radius: 999px; }
.sv-mm__track { left: 0; right: 0; background: rgba(150,150,150,.28); }
.sv-mm__fill { left: 0; background: linear-gradient(90deg, #28c45e, #4ade80); transition: width .35s ease; }
.sv-mm__stop { position: absolute; top: 0; transform: translateX(-50%); width: 22px; height: 22px; box-sizing: border-box; border-radius: 50%; background: var(--sv-bg); border: 2px solid rgba(150,150,150,.5); display: flex; align-items: center; justify-content: center; font-size: 10px; color: var(--sv-text-muted); }
.sv-mm__stop.is-on { background: #28c45e; border-color: #28c45e; color: #fff; }
.sv-mm__labs { position: relative; margin: 6px 11px 12px; height: 28px; }
.sv-mm__lab { position: absolute; top: 0; transform: translateX(-50%); text-align: center; font: 600 10px var(--sv-font); color: var(--sv-text-muted); line-height: 1.35; white-space: nowrap; }
.sv-mm__lab b { display: block; color: var(--sv-text); font-weight: 700; }
.sv-mm__lab.is-on b { color: #28c45e; }
.sv-mm__lab--end { left: auto !important; right: 0; transform: none; text-align: right; }
.sv-mm__cta { text-align: center; font: 600 12.5px var(--sv-font); color: var(--sv-cream-text); background: var(--sv-cream); border-radius: 8px; padding: 8px 10px; }
.sv-mm__cta--won { color: #08351d; background: rgba(40,196,94,.18); }
/* dark mode: the tint darkens too — flip the text to light green (0.14.11) */
html[data-sv-theme="dark"] .sv-mm__cta--won { color: #7fdca6; }

/* Line items */
.sv-cart__items { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; border-top: 1px solid var(--sv-border); padding-top: 16px; }
.sv-cart__item { display: grid; grid-template-columns: 62px 1fr auto; gap: 12px; align-items: start; }
.sv-cart__thumb img { width: 62px; height: 62px; object-fit: cover; border-radius: 8px; background: var(--sv-bg-soft); }
.sv-cart__info { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.sv-cart__name { font: 600 13.5px/1.3 var(--sv-font); color: var(--sv-text); text-decoration: none; }
.sv-cart__vari { font: 500 11.5px var(--sv-font); color: var(--sv-text-muted); }
.sv-cart__price { font: 600 13px var(--sv-font); }
.sv-cart__was { color: var(--sv-text-muted); text-decoration: line-through; font-weight: 400; }
.sv-cart__now { color: var(--sv-text); }
.sv-cart__remove { align-self: flex-start; margin-top: 2px; background: none; border: none; padding: 0; color: var(--sv-text-muted); font: 500 11.5px var(--sv-font); text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }
.sv-cart__remove:hover { color: var(--sv-text); }
.sv-cart__qty { display: inline-flex; align-items: center; border: 1px solid var(--sv-border); border-radius: 999px; overflow: hidden; height: 34px; }
.sv-cart__q { width: 30px; height: 100%; border: none; background: none; font-size: 16px; line-height: 1; color: var(--sv-text); cursor: pointer; }
.sv-cart__q:hover { background: var(--sv-bg-soft); }
.sv-cart__qval { min-width: 26px; text-align: center; font: 700 13px var(--sv-font); color: var(--sv-text); }

/* Note */
.sv-cart__note { display: flex; align-items: flex-start; gap: 8px; margin: 16px 0 4px; border-top: 1px solid var(--sv-border); padding-top: 14px; }
.sv-cart__note svg { width: 18px; height: 18px; color: var(--sv-text-muted); flex: none; margin-top: 6px; }
.sv-cart-note { flex: 1; resize: vertical; min-height: 34px; border: 1px solid var(--sv-border); border-radius: 8px; background: var(--sv-card); color: var(--sv-text); font: 500 13px var(--sv-font); padding: 8px 10px; }
.sv-cart-note:focus { outline: none; border-color: var(--sv-gold); }

/* Footer */
.sv-cart__foot { border-top: 1px solid var(--sv-border); padding: 14px 20px calc(14px + env(safe-area-inset-bottom)); background: var(--sv-bg); }
.sv-cart__totals { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 12px; margin-bottom: 12px; }
/* Totals block (Victor-approved): Items / Mix&Match / excise w/ breakdown / Subtotal */
.sv-tot { display: block; }
.sv-tot__row { display: flex; justify-content: space-between; align-items: center; font: 500 12.5px var(--sv-font); color: var(--sv-text-muted); padding: 3px 0; }
.sv-tot__row--mm { color: #28c45e; }
.sv-tot__exv { color: var(--sv-text); }
.sv-tot__exi { background: none; border: 0; padding: 0; margin-left: 5px; cursor: pointer; color: #BA7517; display: inline-flex; vertical-align: -3px; }
.sv-tot__exi svg { width: 15px; height: 15px; }
.sv-tot__exi:hover { color: #EF9F27; }
.sv-tot__break { display: none; }
.sv-tot__break.is-open { display: block; }
.sv-tot__brow { display: flex; justify-content: space-between; font: 500 11.5px var(--sv-font); color: var(--sv-text-muted); padding: 2px 0 2px 14px; border-left: 2px solid var(--sv-border); margin-left: 4px; }
.sv-tot__grand { display: flex; justify-content: space-between; align-items: baseline; border-top: 1px solid var(--sv-border); margin-top: 8px; padding-top: 10px; }
.sv-tot__grand-l { font: 700 14px var(--sv-font); color: var(--sv-text); }
.sv-tot__grand-v { font: 800 18px var(--sv-font); color: var(--sv-text); }
.sv-tot__was { font: 600 13px var(--sv-font); color: var(--sv-text-muted); text-decoration: line-through; margin-right: 8px; }
.sv-tot__save { display: flex; justify-content: flex-end; align-items: center; gap: 6px; font: 700 12.5px var(--sv-font); color: #28c45e; margin-top: 3px; }
.sv-tot__save svg { width: 13px; height: 13px; flex: none; }
.sv-tot__note { font: 500 11px var(--sv-font); color: var(--sv-text-muted); text-align: right; margin-top: 2px; }
.sv-tot__hst { font: 400 11px/1.35 var(--sv-font); color: var(--sv-text-muted); margin-top: 8px; }
.sv-cart__tax { flex: 1 1 150px; font: 400 11.5px/1.35 var(--sv-font); color: var(--sv-text-muted); }
.sv-cart__sub { font: 600 15px var(--sv-font); color: var(--sv-text); }
.sv-cart__sub-l { font-weight: 500; color: var(--sv-text-muted); font-size: 12px; margin-right: 4px; }
.sv-cart__sub-was { color: var(--sv-text-muted); text-decoration: line-through; font-weight: 400; font-size: 13px; }
.sv-cart__save { flex-basis: 100%; text-align: right; font: 700 12.5px var(--sv-font); color: #28c45e; }
.sv-cart__actions { display: flex; gap: 10px; }
.sv-cart__noteic { display: none; } /* mobile-only (r11) — shown ≤820 */
.sv-cart__checkout { flex: 1.4; display: inline-flex; align-items: center; justify-content: center; gap: 8px; background: var(--sv-gold); color: var(--sv-navy); font: 800 15px var(--sv-font); text-decoration: none; padding: 14px; border-radius: 999px; }
.sv-cart__checkout svg { width: 16px; height: 16px; }
.sv-cart__checkout:hover { background: #ffc163; }
.sv-cart__viewcart { flex: 1; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--sv-gold); color: var(--sv-text); font: 700 14px var(--sv-font); text-decoration: none; padding: 14px; border-radius: 999px; }
.sv-cart__viewcart:hover { background: rgba(239,159,39,.1); }

@media (max-width: 420px) { .sv-cart__panel { width: 100vw; } }

/* ---- Busy state (0.16.3): drawer opens instantly on add, spinner until the
   server answers and the fragment swap lands. ---- */
/* 0.30.0 (Victor round 9): swipes + close-indents are RETIRED. On mobile the
   drawer and its scrim stop at the dock's top edge — the dock stays visible
   and its cart button toggles the drawer (▾ while open). Desktop unchanged
   (full-height side drawer, scrim, ✕).
   0.31.0 (round 10): on mobile the cart is a BOTTOM SHEET — it rises out of
   the dock's cart button (translateY, rounded shoulders, ~82% height) and
   tucks back into it; the ▾ literally points at where it goes. Totals lose
   the two small-print lines and the note field is one compact row. */
@media (max-width: 820px) {
  .sv-cart { bottom: calc(56px + env(safe-area-inset-bottom)); }
  /* 0.31.1 (Victor): the sheet spans ALL the way to the top — the 82% cap
     showed fewer items than the old side drawer despite the trimmed lines. */
  .sv-cart__panel { left: 0; right: 0; top: 0; bottom: 0; width: 100%; height: auto; border-radius: 18px 18px 0 0; border-top: 1px solid var(--sv-border); box-shadow: 0 -12px 34px rgba(0,0,0,.38); transform: translateY(102%); }
  .sv-cart.is-open .sv-cart__panel { transform: translateY(0); }
  .sv-tot__note, .sv-tot__hst { display: none; }
  /* r11 (0.32.0): the note collapses into an icon on the actions row — the
     pad unfolds above the row when tapped (moved into the foot by
     sv-cart.js); a gold dot on the icon = a note is saved. Thumb order:
     note · View cart · Check out (checkout closest to the thumb). */
  .sv-cart__note { display: none; margin: 0 0 8px; border-top: none; padding-top: 0; }
  .sv-cart__note.is-open { display: flex; }
  .sv-cart-note { resize: none; height: 52px; min-height: 52px; transition: none; }
  .sv-cart__noteic { display: flex; align-items: center; justify-content: center; order: 0; flex: none; width: 48px; border: 1px solid var(--sv-border); border-radius: 999px; background: none; color: var(--sv-text-muted); cursor: pointer; position: relative; padding: 0; }
  .sv-cart__noteic svg { width: 19px; height: 19px; }
  .sv-cart__noteic.has-note::after { content: ''; position: absolute; top: 6px; right: 6px; width: 7px; height: 7px; border-radius: 50%; background: var(--sv-gold); }
  .sv-cart__viewcart { order: 1; }
  .sv-cart__checkout { order: 2; }
}

.sv-cart.is-busy .sv-cart-drawer__content { opacity: .4; pointer-events: none; transition: opacity .15s ease; }
.sv-cart.is-busy .sv-cart__panel::after { content: ''; position: absolute; top: 50%; left: 50%; width: 30px; height: 30px; margin: -15px 0 0 -15px; border: 3px solid rgba(239,159,39,.25); border-top-color: var(--sv-gold, #EF9F27); border-radius: 50%; animation: sv-spin .7s linear infinite; z-index: 6; }
@keyframes sv-spin { to { transform: rotate(360deg); } }
