/* REWAA Phase 42.5 — responsive product hero, gallery sticky behavior, and compare action.
   Loaded last on the product detail page so these scoped corrections take precedence. */
.p384-page {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow-x: clip;
}
.p384-page .product-breadcrumb-wrap,
.p384-page .product-hero-grid,
.p384-page .p384-gallery,
.p384-page .product-buy-panel {
  min-width: 0;
  max-width: 100%;
}
.p384-page .product-hero-grid {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  align-items: start;
  gap: clamp(18px, 2.4vw, 38px);
}
.p384-page .p384-gallery {
  position: relative;
  align-self: start;
  width: 100%;
  margin: 0;
}
.p384-page .p384-main {
  width: 100%;
  min-width: 0;
  aspect-ratio: 4 / 5;
  max-height: min(75vh, 740px);
  background: #f8fafc;
}
.p384-page .p384-main > img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
}
.p384-page .p384-thumbs {
  min-width: 0;
  overscroll-behavior: contain;
}
.p384-page .p425-compare-action[aria-pressed="true"],
.p384-page .p425-compare-action.active {
  color: #087eaa;
  border-color: #75cce8;
  background: #eaf8fe;
}
.p384-page .p425-compare-action:focus-visible {
  outline: 3px solid #7bd2ee;
  outline-offset: 2px;
}

/* The gallery sticks only while the two-column purchase hero is in view.
   Its containing hero section limits the sticky range to the end of the purchase panel. */
@media (min-width: 851px) {
  .p384-page .p384-gallery {
    position: sticky;
    top: calc(var(--header-h, 68px) + 16px);
    z-index: 4;
  }
}

/* Tablet and mobile: one fluid column, no sticky behavior, no fixed-width leftovers. */
@media (max-width: 850px) {
  .p384-page .product-hero-grid.container {
    width: 100%;
    max-width: var(--container, 1320px);
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 18px;
    padding-inline: clamp(12px, 3.5vw, 22px);
  }
  .p384-page .p384-gallery,
  .p384-page .product-buy-panel {
    position: static;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    margin-inline: 0;
  }
  .p384-page .p384-gallery {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
  }
  .p384-page .p384-main {
    grid-column: 1;
    grid-row: 1;
    width: 100%;
    aspect-ratio: 4 / 5;
    max-height: none;
    min-height: 0;
  }
  .p384-page .p384-thumbs {
    grid-column: 1;
    grid-row: 2;
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    width: 100%;
    max-width: 100%;
    max-height: none;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 3px 2px 6px;
    gap: 8px;
    -webkit-overflow-scrolling: touch;
  }
  .p384-page .p384-thumbs > .gallery-thumb {
    width: clamp(56px, 15vw, 72px);
    height: auto;
    flex: 0 0 clamp(56px, 15vw, 72px);
  }
  .p384-page .p385a-gallery-actions {
    top: 10px;
    left: 10px;
    right: auto;
    gap: 7px;
  }
}

@media (max-width: 380px) {
  .p384-page .product-hero-grid.container {
    padding-inline: 12px;
  }
  .p384-page .p384-main {
    border-radius: 16px;
  }
  .p384-page .p385a-gallery-actions > .round-action {
    width: 35px;
    height: 35px;
    border-radius: 10px;
  }
  .p384-page .p384-gallery-counter {
    right: 9px;
    bottom: 9px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .p384-page .p425-compare-action {
    transition: none !important;
  }
}
