/* Sticky buy bar: fixed to the bottom, hidden until the normal buy button is scrolled out of view */
.product-view-header {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 99999;
  max-width: none !important;
  padding-top: var(--hs-spacing-base);
  padding-bottom: calc(var(--hs-spacing-base) + env(safe-area-inset-bottom, 0px));
  background: var(--hs-palette-background, #fff);
  border-top: 1px solid var(--hs-color-border-light);
  box-shadow: 0 0 10px rgb(0 0 0 / 20%);
  transform: translateY(110%);
  visibility: hidden;
  transition:
    transform var(--hs-transitions-duration-base) var(--hs-transitions-easing),
    visibility 0s linear var(--hs-transitions-duration-base);
}

.product-view-header.product-view-header--stuck {
  transform: translateY(0);
  visibility: visible;
  transition: transform var(--hs-transitions-duration-base) var(--hs-transitions-easing);
}

/* Mobile: image + name/stock + price on the first row, quantity + button on the second */
.product-view-header__inner {
  display: grid;
  grid-template-columns: 4.8rem minmax(0, 1fr) auto;
  grid-template-areas:
    "image text price"
    "actions actions actions";
  align-items: center;
  gap: var(--hs-spacing-base) var(--hs-spacing-large);
}

.product-view-header__image {
  grid-area: image;
  width: 4.8rem;
}

.product-view-header__image img {
  margin: 0;
}

.product-view-header__text {
  grid-area: text;
  min-width: 0;
  font-size: var(--hs-typography-small-size);
}

.product-view-header__title {
  overflow: hidden;
  font-weight: 500;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.product-view-header__price {
  grid-area: price;
  text-align: right;
}

.product-view-header__price .product-price {
  gap: 0;
}

.product-view-header__actions {
  grid-area: actions;
  display: flex;
  gap: var(--hs-spacing-base);
}

.product-view-header__quantity {
  flex: 0 0 auto;
  max-width: 14rem;
}

.product-view-header__button {
  flex: 1;
}

/* Desktop: everything on one row */
@media (min-width: 960px) {
  .product-view-header__inner {
    grid-template-columns: 6.4rem minmax(0, 1fr) auto auto;
    grid-template-areas: "image text price actions";
    gap: calc(var(--hs-spacing-large) * 1.5);
    max-width: 1280px;
  }

  .product-view-header__image {
    width: 6.4rem;
  }

  .product-view-header__text {
    font-size: var(--hs-typography-base-size);
  }

  .product-view-header__button {
    min-width: 22rem;
  }
}

/* Keep page content (footer, scroll-to-top) reachable above the bar on mobile */
@media (max-width: 959.98px) {
  body:has(.product-view-header--stuck) .site-scroll-to-top {
    inset-block-end: 13rem;
  }
}
