/*
 * Floating cart bubble + slide-up panel. Loaded sitewide so it behaves like the XT Floating Cart plugin it replaces, but
 * uses our own markup/classes so it can talk to the shop grid's popovers.
 */

.fpx-fcart {
  position: fixed;
  right: 20px;
  /* --fpx-sticky-atc-h is set by the PDP's mobile sticky Add to Cart bar
     (template-parts/product/summary.php) to its own height while visible,
     and 0px otherwise/everywhere else on the site — without this the bubble
     sat at a fixed bottom:20px regardless and the sticky bar's full-width
     Add to Cart button ended up underneath it. */
  bottom: calc(20px + var(--fpx-sticky-atc-h, 0px));
  transition: bottom 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 300;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
  /*
   * Explicit, not `inherit`: the cart shows sitewide, so pin it to the
   * theme's own brand font rather than whatever a page's body font is.
   */
  font-family: "Inter", sans-serif;
}

/*
 * Neutral baseline for every <button> in the floating cart and the cart
 * drawer (they live outside .fpx-woo, so the global.css reset doesn't
 * reach them): no browser padding, radius, background or border.
 */
/*
 * Also scoped to `.fpx-cdrawer` (the sidebar cart drawer): the drawer reuses
 * this file's item-row/qty/remove-button classes directly (see CLAUDE.md's
 * Cart Drawer section) but lives in its own `#fpx-cart-drawer` subtree, not
 * inside `#fpx-fcart` — without also matching `.fpx-cdrawer` here, its
 * buttons never got this neutral-baseline reset and fell back to the raw
 * browser default `<button>` border (a chunky 2px outset box).
 */
.fpx-fcart button,
.fpx-cdrawer button {
  padding: 0 !important;
  margin: 0 !important;
  background-image: none !important;
  border: none !important;
  box-shadow: none !important;
  color: inherit !important;
  font: inherit;
  cursor: pointer;
}
.fpx-fcart button:focus-visible,
.fpx-fcart a:focus-visible,
.fpx-cdrawer button:focus-visible,
.fpx-cdrawer a:focus-visible {
  outline: 2px solid var(--brand-deep);
  outline-offset: 2px;
}

/*
 * ── Trigger bubble ──
 * Selectors here are prefixed with the `button` tag (matching
 * `button.fpx-fcart-trigger` instead of bare `.fpx-fcart-trigger`) to match
 * the specificity of the `.fpx-fcart button` reset above (class+tag = 0,1,1
 * vs. a bare class' 0,1,0) — otherwise that reset's `background-image: none
 * !important` always won regardless of source order, since a bare class
 * selector can never outrank a class+tag one at equal !important. Without
 * this the trigger's gradient silently never painted, leaving it looking
 * like a plain white/grey button.
 */
button.fpx-fcart-trigger {
  position: relative;
  z-index: 2; /* same reasoning as .fpx-fcart-panel — stay above the mobile backdrop */
  width: 58px !important;
  height: 58px !important;
  border-radius: 999px !important;
  background: var(--brand-grad) !important;
  color: #fff !important;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 10px rgba(20, 141, 159, 0.24), 0 12px 28px rgba(20, 141, 159, 0.3);
  transition: box-shadow 0.2s ease, transform 0.15s ease;
  flex-shrink: 0;
}
button.fpx-fcart-trigger:hover {
  box-shadow: 0 6px 14px rgba(20, 141, 159, 0.3), 0 16px 34px rgba(20, 141, 159, 0.38);
  transform: translateY(-2px);
}
button.fpx-fcart-trigger:active {
  transform: translateY(0) scale(0.96);
}
.fpx-fcart-trigger__icon {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.fpx-fcart-trigger__icon svg {
  width: 24px;
  height: 24px;
}
.fpx-fcart-trigger__icon--close {
  opacity: 0;
  transform: scale(0.5) rotate(-45deg);
}
.fpx-fcart.is-open .fpx-fcart-trigger__icon--cart {
  opacity: 0;
  transform: scale(0.5) rotate(45deg);
}
.fpx-fcart.is-open .fpx-fcart-trigger__icon--close {
  opacity: 1;
  transform: scale(1) rotate(0deg);
}

.fpx-fcart-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 999px;
  background: #e6484b;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 20px;
  text-align: center;
  border: 2px solid #fff;
  opacity: 0;
  transform: scale(0.6);
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.fpx-fcart-badge.is-visible {
  opacity: 1;
  transform: scale(1);
}
.fpx-fcart-badge.is-bumped {
  animation: fpx-fcart-badge-bump 0.26s ease;
}
@keyframes fpx-fcart-badge-bump {
  0% { transform: scale(1); }
  40% { transform: scale(1.35); }
  100% { transform: scale(1); }
}

/* ── Panel ── */
.fpx-fcart-panel {
  /*
   * Needs its own explicit stacking position: the mobile backdrop below is a
   * fixed element with a non-auto z-index, which paints *above* any plain
   * in-flow sibling (the panel is just a flex item with position:auto/
   * z-index:auto otherwise) regardless of DOM order. Without this the
   * backdrop's blur was compositing on top of our own panel instead of only
   * the page behind it, making the whole cart look blurred out.
   */
  position: relative;
  z-index: 2;
  width: min(392px, 90vw);
  max-height: min(72vh, 580px);
  background: #fff;
  border-radius: 26px;
  box-shadow: 0 4px 12px rgba(17, 24, 39, 0.06), 0 24px 56px rgba(17, 24, 39, 0.18);
  /*
   * Grid, not flex, for the header/scrollable-body/footer split: with a flex
   * column, `max-height` (as opposed to a definite `height`) doesn't reliably
   * give the browser a size to shrink flex children against — the body kept
   * being sized as if the footer didn't exist, pushing the footer (and its
   * View Cart/Checkout buttons) below the panel's own bottom edge, where
   * `overflow: hidden` silently clipped them off entirely. Grid's
   * `auto / minmax(0,1fr) / auto` row template doesn't have that ambiguity.
   */
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
  transform-origin: bottom right;
  opacity: 0;
  transform: scale(0.9) translateY(12px);
  pointer-events: none;
  transition: opacity 0.24s ease, transform 0.24s cubic-bezier(0.34, 1.2, 0.64, 1);
}
.fpx-fcart.is-open .fpx-fcart-panel {
  opacity: 1;
  transform: scale(1) translateY(0);
  pointer-events: auto;
}
.fpx-fcart-panel[hidden] {
  display: none;
}

/* Tinted masthead, matching the Order Summary card on both the Cart and
   Checkout pages (`.fpx-summary-head` / `.fpx-checkout-summary__head` in
   global.css). Those two plus this panel and the slide-in drawer are the
   four cart surfaces on the site; they should open the same way. The
   drawer's own header mirrors this rule — see cart-drawer.css. */
.fpx-fcart-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 18px 16px 22px;
  background: var(--brand-grad-soft), #fff; /* two-colour wash, see global.css :root */
  border-bottom: 1px solid var(--color-border, #e5e7eb);
  flex-shrink: 0;
  position: relative;
  z-index: 1;
}
.fpx-fcart-panel__header .fpx-fcart-panel__title {
  color: var(--color-primary-dark);
}
.fpx-fcart-panel__title-group {
  display: flex;
  align-items: center;
  gap: 8px;
}
.fpx-fcart-panel__icon {
  display: flex;
  color: var(--brand-deep);
}
.fpx-fcart-panel__icon svg {
  width: 19px;
  height: 19px;
}
.fpx-fcart-panel__title {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--color-text);
}
.fpx-fcart-panel__count {
  display: none;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: rgba(86, 204, 242, 0.2);
  color: var(--color-primary-dark);
  font-size: 11.5px;
  font-weight: 700;
  line-height: 20px;
  text-align: center;
}
.fpx-fcart-panel__count.is-visible {
  display: inline-block;
}
/* button-tag-prefixed for the same reason as button.fpx-fcart-item__remove
   above — a bare single class here would lose the `color` property to the
   shared `.fpx-fcart button, .fpx-cdrawer button` reset's higher specificity. */
button.fpx-fcart-close {
  width: 30px !important;
  height: 30px !important;
  border-radius: 999px !important;
  background: #f6f7f8 !important;
  color: #6b7280 !important;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.15s ease, color 0.15s ease, transform 0.15s ease;
}
button.fpx-fcart-close:hover {
  background: #eef0f2 !important;
  color: #374151 !important;
  transform: rotate(90deg);
}
.fpx-fcart-close svg {
  width: 14px;
  height: 14px;
}

.fpx-fcart-panel-body {
  overflow-y: auto;
  flex: 1 1 auto;
  /* A flex item defaults to min-height:auto (i.e. its content size), which
     stops it from ever shrinking below that — so overflow-y:auto never
     actually kicked in with more than a couple of items; the panel just grew
     past its own max-height and off the bottom of the viewport instead of
     scrolling internally. */
  min-height: 0;
  transition: opacity 0.15s ease;
  /* Firefox */
  scrollbar-width: thin;
  scrollbar-color: #d1d5db transparent;
}
.fpx-fcart-panel-body.is-loading {
  opacity: 0.5;
  pointer-events: none;
}
/* Chrome/Safari/Edge — replace the default blocky OS scrollbar with a thin,
   rounded, brand-neutral one that only shows up as a subtle affordance. */
.fpx-fcart-panel-body::-webkit-scrollbar {
  width: 6px;
}
.fpx-fcart-panel-body::-webkit-scrollbar-track {
  background: transparent;
}
.fpx-fcart-panel-body::-webkit-scrollbar-thumb {
  background-color: #d1d5db;
  border-radius: 999px;
}
.fpx-fcart-panel-body::-webkit-scrollbar-thumb:hover {
  background-color: #9ca3af;
}

/* ── Item rows ── */
.fpx-fcart-list {
  list-style: none;
  margin: 0;
  padding: 8px 12px 8px;
}
.fpx-fcart-item {
  display: flex;
  gap: 12px;
  padding: 10px;
  margin: 2px 0;
  border-radius: 16px;
  transition: background-color 0.15s ease;
}
.fpx-fcart-item:hover {
  background: #f8fafb;
}
.fpx-fcart-item + .fpx-fcart-item {
  border-top: 1px solid #f2f3f5;
}
.fpx-fcart-item__thumb {
  width: 62px;
  height: 62px;
  border-radius: 14px;
  overflow: hidden;
  background: #f2f4f5; /* fills in behind a missing/broken product image */
  flex-shrink: 0;
  box-shadow: 0 1px 3px rgba(17, 24, 39, 0.08);
}
.fpx-fcart-item__thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  /* Hide the OS broken-image glyph + alt text if a thumbnail 404s — the
     neutral background above reads better than a half-broken icon. */
  color: transparent;
}
.fpx-fcart-item__body {
  flex: 1;
  min-width: 0;
  padding-top: 1px;
}
.fpx-fcart-item__top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}
.fpx-fcart-item__title a,
.fpx-fcart-item__title {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 13.5px;
  font-weight: 700;
  /* !important: keeps the link colour against global a { color } rules. */
  color: var(--color-text) !important;
  text-decoration: none;
  line-height: 1.35;
  letter-spacing: -0.01em;
}
.fpx-fcart-item__title a:hover {
  color: var(--color-primary-dark) !important;
}
/*
 * `button` tag-prefixed: a bare single class here has lower specificity
 * (0,1,0) than the shared `.fpx-fcart button, .fpx-cdrawer button` reset
 * (0,1,1) above, which was winning the `color` property with its
 * `color: inherit !important` — matching or beating that specificity, same
 * pattern as `button.fpx-fcart-trigger` elsewhere in this file.
 */
button.fpx-fcart-item__remove {
  flex-shrink: 0;
  width: 24px !important;
  height: 24px !important;
  border-radius: 999px !important;
  background: transparent !important;
  color: #c1c7cf !important;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s ease, background-color 0.15s ease;
}
button.fpx-fcart-item__remove:hover {
  color: #ef4444 !important;
  background: #fef2f2 !important;
}
.fpx-fcart-item__remove svg {
  width: 13px;
  height: 13px;
}
.fpx-fcart-item__meta {
  font-size: 11.5px;
  color: #9099a3;
  margin-top: 2px;
  line-height: 1.4;
}
.fpx-fcart-item__meta p {
  margin: 0;
}
.fpx-fcart-item__bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 9px;
}
/* Tactile "floating pill" stepper — a light-grey track with raised white
   circular buttons, closer to modern delivery-app cart UIs than a flat
   bordered rectangle. */
.fpx-fcart-item__qty {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  background: #f2f4f5;
  border-radius: 999px;
  padding: 3px;
  height: 30px;
}
.fpx-fcart-item__qty button {
  width: 24px !important;
  height: 24px !important;
  border-radius: 999px !important;
  background: #fff !important;
  color: #4b5563 !important;
  box-shadow: 0 1px 2px rgba(17, 24, 39, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s ease, box-shadow 0.15s ease, transform 0.1s ease;
}
.fpx-fcart-item__qty button svg {
  width: 12px;
  height: 12px;
}
.fpx-fcart-item__qty button:hover {
  color: var(--brand-deep) !important;
  box-shadow: 0 2px 6px rgba(17, 24, 39, 0.16);
}
.fpx-fcart-item__qty button:active {
  transform: scale(0.92);
}
.fpx-fcart-qty-value {
  min-width: 22px;
  text-align: center;
  font-size: 13px;
  font-weight: 700;
  color: var(--color-text);
}
.fpx-fcart-item__price {
  font-size: 14px;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--color-primary-dark);
}

/* ── Empty state ── */
.fpx-fcart-empty {
  text-align: center;
  padding: 48px 28px 40px;
  color: #6b7280;
}
.fpx-fcart-empty__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 68px;
  height: 68px;
  margin: 0 auto 16px;
  border-radius: 999px;
  background: #f2f4f5;
  color: #9ca3af;
}
.fpx-fcart-empty svg {
  width: 30px;
  height: 30px;
}
.fpx-fcart-empty p {
  margin: 0 0 20px;
  font-size: 14px;
  font-weight: 500;
  color: #6b7280;
}
.fpx-fcart-browse {
  display: inline-block;
  padding: 11px 26px;
  border-radius: 999px;
  background: var(--brand-grad);
  /* !important on the link colours below keeps them against global
     a { color } rules. */
  color: #fff !important;
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  box-shadow: 0 8px 20px rgba(20, 141, 159, 0.25);
  transition: filter 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}
.fpx-fcart-browse:hover {
  filter: brightness(1.06);
  color: #fff !important;
  box-shadow: 0 10px 24px rgba(20, 141, 159, 0.32);
  transform: translateY(-1px);
}

/* ── Footer (subtotal + actions) ── */
.fpx-fcart-footer {
  /* Empty by default (empty cart) so it takes no space in the grid's own
     "auto" row — WC fragments need a matching element already in the DOM to
     replaceWith(), so this is always rendered, same as the badge/count pill. */
  display: none;
}
.fpx-fcart-footer.is-visible {
  display: block;
  padding: 16px 20px 20px;
  border-top: 1px solid var(--color-border, #e5e7eb);
  background: #fcfcfd;
}
/* Tinted strip, same device the Cart and Checkout summaries give their
   grand total — the figure the shopper is about to commit to shouldn't read
   as an ordinary label/value row. */
.fpx-fcart-subtotal {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--brand-grad-soft), #fff;
  border: 1px solid rgba(20, 141, 159, 0.12);
  font-size: 13.5px;
  font-weight: 600;
  color: var(--color-primary-dark);
}
.fpx-fcart-subtotal strong {
  font-size: 19px;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--color-primary-dark);
}
.fpx-fcart-actions {
  display: flex;
  gap: 10px;
}
.fpx-fcart-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-align: center;
  padding: 12px 10px;
  border-radius: 12px;
  font-size: 13.5px;
  font-weight: 700;
  text-decoration: none;
  transition: background-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}
.fpx-fcart-btn svg {
  width: 15px;
  height: 15px;
}
.fpx-fcart-btn--ghost {
  background: #fff;
  border: 1.5px solid var(--color-border, #e5e7eb);
  color: #374151 !important;
}
.fpx-fcart-btn--ghost:hover {
  border-color: var(--brand-deep);
  color: var(--color-primary-dark) !important;
}
/* Checkout: the brand gradient, same as every primary button on the site. */
.fpx-fcart-btn--solid {
  background: var(--brand-grad);
  border: none;
  color: #fff !important;
  box-shadow: 0 10px 22px rgba(20, 141, 159, 0.28);
}
.fpx-fcart-btn--solid:hover {
  filter: brightness(1.06);
  box-shadow: 0 12px 28px rgba(20, 141, 159, 0.38);
  transform: translateY(-1px);
  color: #fff !important;
}

/* ── Backdrop (mobile only, matches the product-popover modal treatment) ── */
.fpx-fcart-backdrop {
  display: none;
}

/* ── Mobile: bottom-sheet panel spanning the viewport width ── */
@media (max-width: 640px) {
  .fpx-fcart {
    left: 14px;
    right: 14px;
    /* Same --fpx-sticky-atc-h handoff as the root rule above — this
       mobile-width override was re-pinning bottom to a flat 14px, which
       silently cancelled that rule out at exactly the viewport where the
       PDP's sticky Add to Cart bar can be showing. */
    bottom: calc(14px + var(--fpx-sticky-atc-h, 0px));
    align-items: stretch;
  }
  .fpx-fcart-trigger {
    align-self: flex-end;
  }
  .fpx-fcart-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 1; /* below .fpx-fcart-panel/.fpx-fcart-trigger (z-index: 2) — see note on .fpx-fcart-panel */
    background: rgba(255, 255, 255, 0.55);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
  }
  .fpx-fcart.is-open .fpx-fcart-backdrop {
    opacity: 1;
    pointer-events: auto;
  }
  .fpx-fcart-panel {
    width: 100%;
    max-height: 78vh;
    border-radius: 26px 26px 20px 20px;
    transform-origin: bottom center;
  }
}
