/*
 * pn_better_product_card — Showcase page shell, buy slot defaults, animation helpers, sticky buy bar.
 * Loaded only on product pages with an active Showcase card. The card brings its own CSS (scoped to .pn-card).
 * Rule for helpers: the final (visible) state is the default; animations only define the "from" state.
 */

:root {
  --pn-bottom-offset: 0px;
}

/* ---------- Page shell ---------- */

.pn-sc-page {
  margin: 0;
  padding: 0;
}

/* Full-bleed card in the full-width layout; in column layouts it simply fills the content column. */
.layout-full-width .pn-sc-card {
  margin-left: calc(50% - 50vw);
  margin-right: calc(50% - 50vw);
}

html:has(.layout-full-width .pn-sc-card) body {
  overflow-x: clip;
}

.pn-sc-native[hidden] {
  display: none !important;
}

/* ---------- Native buy slot: neutral defaults, the card may restyle it ---------- */

.pn-buy {
  --pn-buy-max: 640px;
  box-sizing: border-box;
  max-width: var(--pn-buy-max);
  margin: 0 auto;
  padding: 24px 16px;
  scroll-margin-top: 96px;
}

.pn-buy .product-container {
  margin: 0;
}

.pn-buy .product-actions {
  margin-top: 16px;
}

/* ---------- Animation helpers (opt-in via data-pn-anim) ---------- */

@keyframes pn-sc-fade-up {
  from {
    opacity: 0;
    transform: translateY(40px);
  }
}

@keyframes pn-sc-scale-in {
  from {
    opacity: 0.4;
    transform: scale(0.92);
  }
}

@keyframes pn-sc-parallax {
  from {
    transform: translateY(-6%) scale(1.12);
  }
  to {
    transform: translateY(6%) scale(1.12);
  }
}

@media (prefers-reduced-motion: no-preference) {
  @supports (animation-timeline: view()) {
    .pn-sc-card [data-pn-anim="reveal"] {
      animation: pn-sc-fade-up linear both;
      animation-timeline: view();
      animation-range: entry 0% entry 70%;
    }

    .pn-sc-card [data-pn-anim="scale"] {
      animation: pn-sc-scale-in linear both;
      animation-timeline: view();
      animation-range: entry 0% cover 35%;
    }

    /* Named timeline on the container: its own overflow:hidden must not become the scroller of the image. */
    .pn-sc-card [data-pn-anim="parallax"] {
      overflow: hidden;
      view-timeline: --pn-parallax block;
    }

    .pn-sc-card [data-pn-anim="parallax"] img {
      animation: pn-sc-parallax linear both;
      animation-timeline: --pn-parallax;
      animation-range: cover 0% cover 100%;
    }
  }

  /* IntersectionObserver fallback (class set on <html> by showcase.js only without scroll timelines). */
  .pn-sc-io .pn-sc-card [data-pn-anim="reveal"],
  .pn-sc-io .pn-sc-card [data-pn-anim="scale"] {
    transition: opacity 0.8s ease, transform 0.8s cubic-bezier(0.2, 0.7, 0.2, 1);
  }

  .pn-sc-io .pn-sc-card [data-pn-anim="reveal"]:not(.is-in) {
    opacity: 0;
    transform: translateY(40px);
  }

  .pn-sc-io .pn-sc-card [data-pn-anim="scale"]:not(.is-in) {
    opacity: 0.4;
    transform: scale(0.92);
  }
}

@media (prefers-reduced-motion: reduce) {
  .pn-sc-card [data-pn-anim],
  .pn-sc-card [data-pn-anim] img,
  .pn-sbar {
    animation: none !important;
    transition: none !important;
  }
}

/* ---------- Sticky buy bar ---------- */

.pn-sbar {
  --pn-sbar-bg: rgba(255, 255, 255, 0.88);
  --pn-sbar-fg: #1d1d1f;
  --pn-sbar-muted: #6e6e73;
  --pn-sbar-line: #d2d2d7;
  --pn-sbar-accent: #0071e3;
  --pn-sbar-accent-fg: #fff;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1030;
  box-sizing: border-box;
  padding: 10px clamp(16px, 4vw, 48px) calc(10px + env(safe-area-inset-bottom, 0px));
  background: var(--pn-sbar-bg);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-top: 1px solid var(--pn-sbar-line);
  color: var(--pn-sbar-fg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  transform: translateY(0);
  transition: transform 0.35s cubic-bezier(0.2, 0.7, 0.2, 1), visibility 0s linear 0s;
}

.pn-sbar[hidden] {
  display: none;
}

.pn-sbar:not(.is-visible) {
  transform: translateY(110%);
  visibility: hidden;
  transition: transform 0.35s cubic-bezier(0.2, 0.7, 0.2, 1), visibility 0s linear 0.35s;
}

.pn-sbar__inner {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 1180px;
  margin: 0 auto;
}

.pn-sbar__thumb {
  flex: 0 0 auto;
  width: 48px;
  height: 48px;
  border-radius: 10px;
  object-fit: cover;
}

.pn-sbar__info {
  flex: 1 1 auto;
  min-width: 0;
}

.pn-sbar__name,
.pn-sbar__variant {
  margin: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.pn-sbar__name {
  font-size: 15px;
  font-weight: 600;
}

.pn-sbar__variant {
  font-size: 13px;
  color: var(--pn-sbar-muted);
}

.pn-sbar__variant:empty {
  display: none;
}

.pn-sbar__price {
  flex: 0 0 auto;
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  white-space: nowrap;
}

.pn-sbar__qty {
  display: flex;
  align-items: center;
  flex: 0 0 auto;
  border: 1px solid var(--pn-sbar-line);
  border-radius: 980px;
}

.pn-sbar__step {
  width: 36px;
  height: 40px;
  border: 0;
  background: none;
  color: inherit;
  font-size: 18px;
  cursor: pointer;
}

.pn-sbar__qty-input {
  width: 44px;
  height: 40px;
  border: 0;
  background: none;
  color: inherit;
  font-size: 16px;
  text-align: center;
  -moz-appearance: textfield;
}

.pn-sbar__qty-input::-webkit-outer-spin-button,
.pn-sbar__qty-input::-webkit-inner-spin-button {
  margin: 0;
  -webkit-appearance: none;
}

.pn-sbar__btn {
  flex: 0 0 auto;
  min-height: 44px;
  padding: 10px 22px;
  border: 0;
  border-radius: 980px;
  background: var(--pn-sbar-accent);
  color: var(--pn-sbar-accent-fg);
  font: inherit;
  font-size: 17px;
  font-weight: 500;
  cursor: pointer;
}

.pn-sbar__btn:hover {
  filter: brightness(1.08);
}

.pn-sbar__btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  filter: none;
}

.pn-sbar button:focus-visible,
.pn-sbar input:focus-visible {
  outline: 3px solid var(--pn-sbar-accent);
  outline-offset: 3px;
}

@media (max-width: 575px) {
  .pn-sbar__thumb,
  .pn-sbar__variant {
    display: none;
  }

  .pn-sbar__inner {
    flex-wrap: wrap;
    gap: 8px 12px;
  }

  .pn-sbar__info {
    flex-basis: calc(100% - 140px);
  }

  .pn-sbar__qty {
    order: 3;
  }

  .pn-sbar__btn {
    order: 4;
    flex: 1 1 auto;
  }
}

/* ---------- Bottom-fixed widgets: keep them above the bar (Showcase pages only) ---------- */

html:has(.pn-sbar) .hi-wap-chatbox-container,
html:has(.pn-sbar) .x13-counter-container.counter-fixedBottom {
  bottom: var(--pn-bottom-offset);
  transition: bottom 0.35s ease;
}

html:has(.pn-sbar) .hi-wap-chatbox {
  bottom: calc(80px + var(--pn-bottom-offset));
}

html:has(.pn-sbar) #accessibility-widget {
  bottom: calc(20px + var(--pn-bottom-offset));
  transition: bottom 0.35s ease;
}
