/* ══════════════════════════════════════════════════════════════
   CALMACH CART
   Shared by index / product / index-shop / product-shop.

   Dark panel in the site's own palette — cream on ink with orange
   accents, Barlow Condensed for the header. No backdrop blur: the
   page stays readable behind the scrim.

   The signature move is the entry. The panel's leading edge starts
   as a deep ellipse and straightens as it arrives, so it reads as
   liquid pulling across the screen rather than a box sliding in.
   ══════════════════════════════════════════════════════════════ */

:root {
  --cart-ink: #0F172A;
  --cart-ink-2: #161f38;
  --cart-accent: #FF8C42;
  --cart-cream: #F4F1EB;
  --cart-dim: rgba(244, 241, 235, 0.56);
  --cart-hair: rgba(244, 241, 235, 0.12);

  /* Fast, with just enough overshoot to feel elastic */
  --liquid: cubic-bezier(0.16, 1.08, 0.3, 1);
  --snap: cubic-bezier(0.32, 0.9, 0.24, 1);

  /* Button feel. A press that compresses and releases at the same speed
     reads as a click; compressing fast and releasing slow on a spring is
     what reads as elastic. Every control below uses this pair. */
  --press: 0.13s cubic-bezier(0.3, 0, 0.2, 1);
  --release: linear(
    0, 0.0186 2.2%, 0.0716 4.6%, 0.2757 10.1%, 0.5042 15.6%, 0.7043 21%,
    0.8593 26.6%, 0.9631 32.4%, 1.0179 38.1%, 1.0378 43.6%, 1.0348 51.2%,
    1.0173 62.1%, 1.0025 79%, 1
  );
  --flow: cubic-bezier(0.25, 0.7, 0.25, 1);
}

/* Shared control motion: colour eases long, transform springs home */
.cart-btn,
.cart-close,
.cart-line-rm,
.cart-qty button,
.cart-btn-secondary,
.cart-checkout,
.cart-upsell-add,
.cart-empty-cta {
  transition:
    transform 0.62s var(--release),
    background 0.42s var(--flow),
    color 0.42s var(--flow),
    border-color 0.42s var(--flow),
    box-shadow 0.42s var(--flow);
}

.cart-btn:active,
.cart-close:active,
.cart-line-rm:active,
.cart-qty button:active:not(:disabled),
.cart-btn-secondary:active,
.cart-checkout:active,
.cart-upsell-add:active:not(:disabled),
.cart-empty-cta:active {
  transition: transform var(--press), background var(--press);
}

/* ─────────── nav button ─────────── */

.cart-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: clamp(44px, 3.6vw, 52px);
  height: clamp(44px, 3.6vw, 52px);
  margin-right: 10px;
  padding: 0;
  border: none;
  border-radius: 100px;
  background: var(--cart-cream);
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.14);
  color: var(--cart-ink);
  cursor: pointer;
  flex: none;
}

.cart-btn:hover { background: #fff; transform: translateY(-2px); box-shadow: 0 8px 20px rgba(15, 23, 42, 0.2); }
.cart-btn:active { transform: scale(0.94); }
.cart-btn:focus-visible { outline: 2px solid var(--cart-accent); outline-offset: 3px; }
.cart-btn svg { width: 46%; height: 46%; }

.cart-btn-count {
  position: absolute;
  top: -2px;
  right: -2px;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 100px;
  background: var(--cart-accent);
  box-shadow: 0 2px 8px rgba(255, 140, 66, 0.55);
  color: #14141A;
  font-family: 'Barlow', sans-serif;
  font-weight: 800;
  font-size: 11px;
  line-height: 20px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.cart-btn-count.is-pop { animation: cartBadgePop 0.42s var(--liquid); }

@keyframes cartBadgePop {
  0%   { transform: scale(1); }
  38%  { transform: scale(1.55); }
  100% { transform: scale(1); }
}

/* ─────────── shell ─────────── */

body.cart-locked { overflow: hidden; }

.cart-root { position: fixed; inset: 0; z-index: 9999; pointer-events: none; }
.cart-root.is-open { pointer-events: auto; }

/* Plain scrim — no blur, the page stays legible behind it */
.cart-overlay {
  position: absolute;
  inset: 0;
  background: rgba(10, 14, 26, 0.58);
  opacity: 0;
  transition: opacity 0.32s var(--snap);
}

.cart-root.is-open .cart-overlay { opacity: 1; }

.cart-drawer {
  position: absolute;
  top: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  width: min(460px, 100vw);
  height: 100%;
  background: linear-gradient(170deg, var(--cart-ink-2), var(--cart-ink) 55%);
  box-shadow: -24px 0 60px rgba(10, 14, 26, 0.45);
  overflow: hidden;

  /* Leading edge starts as a deep ellipse and straightens on arrival */
  transform: translateX(100%);
  border-radius: 62% 0 0 62% / 46% 0 0 54%;
  transition:
    transform 0.5s var(--liquid),
    border-radius 0.66s var(--liquid);
}

.cart-root.is-open .cart-drawer {
  transform: none;
  border-radius: 0;
}

/* Orange filament down the leading edge, lit once the panel lands */
.cart-drawer::after {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 2px;
  background: linear-gradient(180deg, transparent, var(--cart-accent) 22%, var(--cart-accent) 78%, transparent);
  opacity: 0;
  transition: opacity 0.45s var(--snap) 0.15s;
  pointer-events: none;
}

.cart-root.is-open .cart-drawer::after { opacity: 0.85; }

/* Warm bloom off the top corner so the panel isn't flat black */
.cart-drawer::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 0;
  background: radial-gradient(90% 40% at 92% -6%, rgba(255, 140, 66, 0.16), transparent 62%);
  pointer-events: none;
}

.cart-drawer > * { position: relative; z-index: 1; }

/* Grab handle — mobile only, and it does what it looks like: the sheet
   drags down to dismiss (see wireSwipe in cart.js) */
.cart-grab {
  display: none;
  flex: none;
  width: 42px;
  height: 4px;
  margin: 10px auto 0;
  border-radius: 100px;
  background: rgba(244, 241, 235, 0.28);
}

.cart-root.is-busy .cart-body,
.cart-root.is-busy .cart-foot {
  opacity: 0.5;
  pointer-events: none;
  transition: opacity 0.2s linear;
}

/* ─────────── header ─────────── */

.cart-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 24px 22px 16px;
  flex: none;
}

.cart-title {
  margin: 0;
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 900;
  font-style: italic;
  text-transform: uppercase;
  letter-spacing: -0.01em;
  font-size: 1.95rem;
  line-height: 1;
  color: var(--cart-cream);
}

.cart-title-count { color: var(--cart-accent); }

.cart-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 1px solid var(--cart-hair);
  border-radius: 100px;
  background: rgba(244, 241, 235, 0.06);
  color: var(--cart-cream);
  cursor: pointer;
  flex: none;
}

.cart-close:hover { background: rgba(244, 241, 235, 0.16); transform: rotate(90deg); }
.cart-close:active { transform: rotate(90deg) scale(0.9); }
.cart-close:focus-visible { outline: 2px solid var(--cart-accent); outline-offset: 3px; }
.cart-close svg { width: 14px; height: 14px; }

/* ─────────── error ─────────── */

.cart-err {
  margin: 0 22px 10px;
  padding: 11px 14px;
  border: 1px solid rgba(255, 140, 66, 0.35);
  border-radius: 12px;
  background: rgba(255, 140, 66, 0.12);
  font-family: 'Barlow', sans-serif;
  font-size: 0.84rem;
  line-height: 1.45;
  color: #FFC9A0;
}

/* ─────────── lines ─────────── */

.cart-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.cart-body::-webkit-scrollbar { display: none; }
.cart-lines { padding: 4px 22px 20px; }

.cart-line {
  display: grid;
  grid-template-columns: 84px 1fr;
  gap: 14px;
  align-items: start;
  margin-bottom: 10px;
  padding: 13px;
  border: 1px solid var(--cart-hair);
  border-radius: 16px;
  background: rgba(244, 241, 235, 0.045);
  transition: border-color 0.45s var(--flow), background 0.45s var(--flow);
}

.cart-line:hover { background: rgba(244, 241, 235, 0.08); border-color: rgba(244, 241, 235, 0.22); }

/* Collapse on remove so the rows below slide up rather than snapping.
   The height is pinned inline first (see removeLine) so it has something
   to animate from. */
.cart-line.is-removing {
  overflow: hidden;
  height: 0 !important;
  min-height: 0;
  margin-bottom: 0;
  padding-top: 0;
  padding-bottom: 0;
  border-width: 0;
  opacity: 0;
  transform: translateX(34px);
  transition:
    height 0.24s var(--flow),
    opacity 0.18s var(--flow),
    transform 0.24s var(--flow),
    margin 0.24s var(--flow),
    padding 0.24s var(--flow);
  pointer-events: none;
}
.cart-line:last-child { margin-bottom: 0; }
.cart-line.is-gone { opacity: 0.5; }

.cart-root.is-entering .cart-line {
  animation: cartLineIn 0.44s var(--liquid) both;
  animation-delay: calc(var(--i) * 45ms + 70ms);
}

@keyframes cartLineIn {
  from { opacity: 0; transform: translateX(38px) scale(0.95); }
  to   { opacity: 1; transform: none; }
}

.cart-root.is-entering .cart-foot {
  animation: cartFootIn 0.44s var(--liquid) both;
  animation-delay: 0.1s;
}

@keyframes cartFootIn {
  from { opacity: 0; transform: translateY(22px); }
  to   { opacity: 1; transform: none; }
}

.cart-line-img {
  width: 84px;
  aspect-ratio: 1 / 1;
  border-radius: 12px;
  background: var(--cart-cream);
  overflow: hidden;
}

.cart-line-img img { width: 100%; height: 100%; object-fit: cover; display: block; }

.cart-line-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.cart-line-title {
  margin: 0;
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.01em;
  font-size: 1.16rem;
  line-height: 1.1;
  color: var(--cart-cream);
}

.cart-line-variant,
.cart-line-calc,
.cart-line-gone {
  margin: 3px 0 0;
  font-family: 'Barlow', sans-serif;
  font-size: 0.79rem;
  line-height: 1.35;
  color: var(--cart-dim);
}

.cart-line-calc { margin-top: 7px; font-variant-numeric: tabular-nums; }
.cart-line-gone { color: #FFC9A0; font-weight: 600; }

.cart-line-rm {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  margin: -3px -4px 0 0;
  padding: 0;
  border: none;
  border-radius: 100px;
  background: transparent;
  color: rgba(244, 241, 235, 0.42);
  cursor: pointer;
  flex: none;
}

.cart-line-rm:hover { color: var(--cart-accent); background: rgba(255, 140, 66, 0.16); transform: scale(1.12); }
.cart-line-rm:active { transform: scale(0.9); }
.cart-line-rm:focus-visible { outline: 2px solid var(--cart-accent); outline-offset: 2px; }
.cart-line-rm svg { width: 16px; height: 16px; }

.cart-line-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
}

.cart-qty {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--cart-hair);
  border-radius: 100px;
  overflow: hidden;
}

.cart-qty button {
  width: 30px;
  height: 30px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--cart-cream);
  font-family: 'Barlow', sans-serif;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
}

.cart-qty button:hover:not(:disabled) { background: var(--cart-accent); color: #14141A; }
.cart-qty button:active:not(:disabled) { transform: scale(0.88); }
.cart-qty button:disabled { opacity: 0.25; cursor: default; }
.cart-qty button:focus-visible { outline: 2px solid var(--cart-accent); outline-offset: -2px; }

.cart-qty span {
  min-width: 26px;
  font-family: 'Barlow', sans-serif;
  font-weight: 700;
  font-size: 0.88rem;
  text-align: center;
  color: var(--cart-cream);
  font-variant-numeric: tabular-nums;
}

.cart-line-price {
  font-family: 'Barlow', sans-serif;
  font-weight: 800;
  font-size: 1rem;
  color: var(--cart-cream);
  font-variant-numeric: tabular-nums;
}

/* ─────────── upsell ─────────── */

.cart-upsell { padding: 0 22px 22px; }

.cart-upsell-kicker {
  margin: 0 0 9px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--cart-dim);
}

.cart-upsell-card {
  display: grid;
  grid-template-columns: 56px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 11px 12px;
  border: 1px dashed rgba(255, 140, 66, 0.55);
  border-radius: 16px;
  background: rgba(255, 140, 66, 0.07);
}

.cart-root.is-entering .cart-upsell {
  animation: cartFootIn 0.44s var(--liquid) both;
  animation-delay: 0.16s;
}

.cart-upsell-img {
  width: 56px;
  aspect-ratio: 1 / 1;
  border-radius: 10px;
  background: var(--cart-cream);
  overflow: hidden;
}

.cart-upsell-img img { width: 100%; height: 100%; object-fit: cover; display: block; }

.cart-upsell-main { min-width: 0; color: var(--cart-cream); }

.cart-upsell-title {
  margin: 0;
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.01em;
  font-size: 1.02rem;
  line-height: 1.1;
}

.cart-upsell-blurb {
  margin: 3px 0 0;
  font-size: 0.78rem;
  line-height: 1.35;
  color: var(--cart-dim);
}

.cart-upsell-price {
  margin: 4px 0 0;
  font-family: 'Barlow', sans-serif;
  font-weight: 800;
  font-size: 0.92rem;
  font-variant-numeric: tabular-nums;
}

.cart-upsell-add {
  min-width: 64px;
  height: 38px;
  padding: 0 16px;
  border: none;
  border-radius: 100px;
  background: var(--cart-accent);
  color: var(--cart-ink);
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 800;
  font-size: 0.98rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
}

.cart-upsell-add:hover { background: #ffa066; transform: translateY(-1px); }
.cart-upsell-add:active { transform: scale(0.94); }
.cart-upsell-add:focus-visible { outline: 2px solid var(--cart-cream); outline-offset: 3px; }
.cart-root.is-busy .cart-upsell-add { opacity: 0.55; pointer-events: none; }

/* ─────────── empty ─────────── */

.cart-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 40px 30px;
  text-align: center;
}

.cart-empty-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 68px;
  height: 68px;
  margin-bottom: 16px;
  border: 1px solid var(--cart-hair);
  border-radius: 100px;
  background: rgba(244, 241, 235, 0.05);
  color: rgba(244, 241, 235, 0.35);
}

.cart-empty-icon svg { width: 27px; height: 27px; }

.cart-empty-title {
  margin: 0 0 20px;
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 800;
  font-style: italic;
  text-transform: uppercase;
  font-size: 1.2rem;
  color: var(--cart-dim);
}

.cart-empty-cta {
  display: inline-flex;
  align-items: center;
  height: 50px;
  padding: 0 30px;
  border-radius: 100px;
  background: var(--cart-accent);
  color: #14141A;
  font-family: 'Barlow', sans-serif;
  font-weight: 800;
  font-size: 0.8rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  text-decoration: none;
}

.cart-empty-cta:hover { transform: translateY(-2px); box-shadow: 0 10px 26px rgba(255, 140, 66, 0.42); }
.cart-empty-cta:active { transform: scale(0.96); }

/* ─────────── footer ─────────── */

.cart-foot {
  flex: none;
  padding: 18px 22px calc(22px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--cart-hair);
  text-align: center;
}

.cart-totals {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 10px;
  font-family: 'Barlow', sans-serif;
  color: var(--cart-cream);
}

.cart-sub-label {
  font-weight: 600;
  font-size: 0.82rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--cart-dim);
}

.cart-sub-val {
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 900;
  font-style: italic;
  font-size: 1.85rem;
  font-variant-numeric: tabular-nums;
}

.cart-note {
  margin: 5px 0 14px;
  font-family: 'Barlow', sans-serif;
  font-size: 0.76rem;
  line-height: 1.4;
  color: rgba(244, 241, 235, 0.4);
}

.cart-actions {
  display: grid;
  grid-template-columns: 1fr 1.25fr;
  gap: 10px;
}

.cart-btn-secondary,
.cart-checkout {
  height: 52px;
  border-radius: 100px;
  font-family: 'Barlow', sans-serif;
  font-weight: 800;
  font-size: 0.79rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
}

.cart-btn-secondary {
  border: 1px solid rgba(244, 241, 235, 0.22);
  background: transparent;
  color: var(--cart-cream);
}

.cart-btn-secondary:hover { background: rgba(244, 241, 235, 0.1); }

.cart-checkout {
  position: relative;
  border: none;
  background: var(--cart-accent);
  box-shadow: 0 4px 14px rgba(255, 140, 66, 0.28);
  color: #14141A;
  overflow: hidden;
}

/* A sheen keyed to hover restarts from zero every time the pointer
   re-enters, which is the abrupt thing. This glow eases both ways, so
   leaving the button is as smooth as arriving. */
.cart-checkout::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(75% 140% at 50% 115%, rgba(255, 255, 255, 0.5), transparent 70%);
  opacity: 0;
  transition: opacity 0.5s var(--flow);
  pointer-events: none;
}

.cart-checkout:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 30px rgba(255, 140, 66, 0.45);
}

.cart-checkout:hover::after { opacity: 1; }

.cart-btn-secondary:hover { transform: translateY(-2px); }

.cart-btn-secondary:active,
.cart-checkout:active { transform: scale(0.965); }

.cart-btn-secondary:focus-visible,
.cart-checkout:focus-visible { outline: 2px solid var(--cart-cream); outline-offset: 3px; }

/* ─────────── mobile ─────────── */

/* ─────────── mobile nav ───────────
   Both shop navs drop to a 3-column grid at this width and flatten
   .nav-actions / .nav-right with `display: contents`. Injecting the cart
   button made a 4th grid item, which pushed the CTA onto a second row.
   Menu | logo | cart is the standard mobile shape anyway — and mobile
   already carries Shop Now in the hero, the sticky bar and the menu. */
@media (max-width: 640px) {
  .site-nav .nav-cta,
  .hero-nav .nav-cta { display: none !important; }

  /* `display: contents` changes layout, not parentage — the button is still
     a DOM child of .nav-actions / .nav-right, so match on those. */
  .nav-actions .cart-btn,
  .nav-right .cart-btn {
    grid-column: 3 !important;
    grid-row: 1 !important;
    justify-self: end;
    margin-right: 0 !important;
  }
}

@media (max-width: 600px) {
  /* Full-screen sheet rising from the bottom, with the top edge starting
     round and flattening — the shape mobile users expect from a cart. */
  .cart-drawer {
    top: 0;
    right: 0;
    left: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    height: 100dvh;   /* keeps the checkout button clear of browser chrome */
    transform: translateY(100%);
    /* Same fold as desktop, turned to face the direction it travels: the
       leading edge is the top here, so that's the edge that bulges and
       flattens as the sheet arrives. */
    border-radius: 62% 62% 0 0 / 46% 54% 0 0;
    transition:
      transform 0.52s var(--liquid),
      border-radius 0.62s var(--liquid);
  }

  .cart-root.is-open .cart-drawer { transform: none; border-radius: 0; }

  /* Accent moves to the top edge — a left filament means nothing full-width */
  .cart-drawer::after {
    left: 0;
    right: 0;
    top: 0;
    bottom: auto;
    width: auto;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--cart-accent) 22%, var(--cart-accent) 78%, transparent);
  }

  .cart-grab { display: block; }

  .cart-btn { width: 44px; height: 44px; }
  .cart-head { padding: 6px 16px 12px; }
  .cart-title { font-size: 1.6rem; }
  .cart-close { width: 34px; height: 34px; }
  .cart-err { margin-inline: 16px; }
  .cart-lines { padding: 4px 16px 18px; }
  .cart-upsell { padding: 0 16px 18px; }
  .cart-line { grid-template-columns: 72px 1fr; gap: 12px; padding: 11px; }
  .cart-line-img { width: 72px; border-radius: 10px; }
  .cart-line-title { font-size: 1.06rem; }
  .cart-foot { padding: 15px 16px calc(18px + env(safe-area-inset-bottom, 0px)); }
  .cart-sub-val { font-size: 1.6rem; }
  .cart-btn-secondary, .cart-checkout { height: 48px; font-size: 0.72rem; letter-spacing: 0.05em; }
}

@media (max-width: 380px) {
  .cart-actions { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .cart-overlay,
  .cart-drawer { transition: opacity 0.2s linear; }
  .cart-drawer { border-radius: 0; }
  .cart-root.is-open .cart-drawer { transform: none; }

  .cart-root.is-entering .cart-line,
  .cart-root.is-entering .cart-foot,
  .cart-root.is-entering .cart-upsell,
  .cart-btn-count.is-pop { animation: none; }

  /* Keep colour feedback, drop the movement */
  .cart-btn,
  .cart-close,
  .cart-line-rm,
  .cart-qty button,
  .cart-btn-secondary,
  .cart-checkout,
  .cart-empty-cta {
    transition: background 0.15s linear, color 0.15s linear, border-color 0.15s linear;
  }

  .cart-btn:hover,
  .cart-btn:active,
  .cart-close:hover,
  .cart-close:active,
  .cart-line-rm:hover,
  .cart-line-rm:active,
  .cart-qty button:active:not(:disabled),
  .cart-btn-secondary:hover,
  .cart-btn-secondary:active,
  .cart-checkout:hover,
  .cart-checkout:active,
  .cart-empty-cta:hover,
  .cart-empty-cta:active { transform: none; }
}
