/**
 * HF-40 Phase 1 — Clean restart (staging only) · 2026-11-08
 *
 * Build ON live prod:
 *   - Desktop: theme sticky GALLERY (.product-carousel__wrap) — image stays, summary scrolls
 *   - ATC chrome: theme .atc-row / .qty-control / .btn-atc ONLY — do not invent
 *   - Pick-helper lives OUTSIDE .atc-row in single-product.php
 *   - overflow: clip on body (prod pattern) — never overflow-x:hidden (kills sticky)
 *
 * Phone add-ons: identity → square gallery → purchase; sticky primary bar.
 * Sticky qty: theme .qty-control on phone bar once options ready (syncs to #qty).
 * Sold-out (fix list 1–17 + §18): no price; one photo; hide pills;
 * Similar under photo then description; HF-40 Request gold pill;
 * phone sticky hides over Similar; desktop CTAs row; white-on-red Shop similar;
 * no delivery/trust on OOS. In-stock Pack Man untouched.
 */

#product-detail-template.hf40-ready,
#product-detail-template:has(.hf40-product-layout) {
  --hf40-action: #c83a24;
  --hf40-ink: #1a1a1a;
  --hf40-muted: #63482e;
  --hf40-chip-in-bg: #e7f6ea;
  --hf40-chip-in: #1f7a3a;
  --hf40-chip-out-bg: #fde8e6;
  --hf40-chip-out: #b42318;
  --hf40-chip-flavor-bg: #f3ebe0;
  --hf40-chip-flavor: #5c4633;
  --hf40-sticky-h: calc(64px + env(safe-area-inset-bottom, 0px));
  /* Square gallery fills content width (match prod ~358 at 390); was 290px. */
  --hf40-gallery-phone: 100%;
}

#product-detail-template .breadcrumb-sec {
  display: none !important;
}

#product-detail-template .hf-staging-back-to-shop-wrap,
#product-detail-template .hf-production-back-to-shop-wrap {
  display: none !important;
}

.hf40-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem 0.5rem;
  margin: 0 0 0.75rem;
  font-family: "DM Sans", var(--font-body), sans-serif;
}

.hf40-nav .hf40-back,
.hf40-nav .hf-staging-back-to-shop {
  color: var(--hf40-action) !important;
  font-family: "DM Sans", sans-serif !important;
  font-size: 16px !important;
  font-weight: 700 !important;
  letter-spacing: 0.01em;
  text-decoration: none !important;
  line-height: 1.3;
}

.hf40-nav-sep {
  color: var(--hf40-muted);
  font-weight: 600;
}

.hf40-cat-link {
  color: var(--hf40-muted) !important;
  font-family: "DM Sans", sans-serif !important;
  font-size: 16px !important;
  font-weight: 600 !important;
  text-decoration: none !important;
}

.hf40-cat-link:hover,
.hf40-cat-link:focus-visible {
  color: var(--hf40-action) !important;
  text-decoration: underline !important;
}

.hf40-title.product-title,
#product-detail-template .hf40-title {
  font-family: "DM Sans", var(--font-body), sans-serif !important;
  font-weight: 700 !important;
  font-size: 26px !important;
  line-height: 1.15 !important;
  color: var(--hf40-ink) !important;
  margin: 0 0 0.5rem !important;
}

/* Identity stacks title → price/chips → #hf-stock-badge (prod: under price, before Flavors) */
.hf40-identity {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.35rem;
  width: 100%;
}

.hf40-identity #hf-stock-badge {
  margin-top: 0.15rem;
}

.hf40-price-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  margin: 0 0 0.75rem;
}

.hf40-price.product-price,
#product-detail-template .hf40-price {
  font-family: "DM Sans", var(--font-body), sans-serif !important;
  font-size: 1.35rem !important;
  font-weight: 700 !important;
  color: var(--hf40-ink) !important;
  margin: 0 !important;
}

.hf40-price-prefix {
  font-weight: 700;
  margin-right: 0.2em;
}

.hf40-chips {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
}

.hf40-chip {
  display: inline-flex;
  align-items: center;
  padding: 0.28rem 0.65rem;
  border-radius: 999px;
  font-family: "DM Sans", sans-serif;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
}

.hf40-chip--in {
  background: var(--hf40-chip-in-bg);
  color: var(--hf40-chip-in);
}

.hf40-chip--out {
  background: var(--hf40-chip-out-bg);
  color: var(--hf40-chip-out);
}

.hf40-chip--flavors {
  background: var(--hf40-chip-flavor-bg);
  color: var(--hf40-chip-flavor);
}

.hf40-soldout-note {
  font-family: "DM Sans", sans-serif;
  font-size: 13px;
  color: var(--hf40-muted);
  font-weight: 500;
}

/* Fix #1: no price on fully sold-out pages (chip + line only). */
.hf40-is-soldout .hf40-price,
.hf40-is-soldout [data-hf40-price] {
  display: none !important;
}

/* Fix #4: hide all tag pills on sold-out pages. */
.hf40-is-soldout .hf-product-badges,
.hf40-is-soldout .hf40-badges-deferred {
  display: none !important;
}

/* Fix #17: hide ordering prompts on sold-out pages. */
.hf40-is-soldout .rm-anchor,
.hf40-is-soldout .hf-next-delivery-stack,
.hf40-is-soldout .trust-row,
.hf40-is-soldout .hf40-rest {
  display: none !important;
}

/* Square gallery — full content width (match prod fill), phone + desktop */
.hf40-gallery .product-carousel__wrap {
  width: 100%;
  max-width: 100%;
}

.hf40-gallery .product-carousel__featured {
  width: 100%;
  max-width: 100%;
  margin-left: 0;
  margin-right: 0;
}

/* Fix #3 + #14: sold-out = single square photo at full content width (no thumbs).
   Keep Splide constrained so the hidden track cannot blow out height. */
.hf40-is-soldout .hf40-gallery .product-carousel__wrap {
  width: 100%;
  max-width: 100%;
  margin-left: 0;
  margin-right: 0;
  gap: 0 !important;
}

.hf40-is-soldout .hf40-gallery .product-carousel__featured {
  max-width: 100%;
  width: 100% !important;
  height: auto !important;
  overflow: hidden;
}

.hf40-is-soldout .hf40-gallery .product-carousel__featured .splide__track,
.hf40-is-soldout .hf40-gallery .product-carousel__featured .splide__list,
.hf40-is-soldout .hf40-gallery .product-carousel__featured .splide__slide,
.hf40-is-soldout .hf40-gallery .product-carousel__featured .hf40-slide {
  max-width: 100% !important;
  width: 100% !important;
  height: auto !important;
}

.hf40-is-soldout .hf40-gallery .hf40-slide-frame {
  width: 100% !important;
  max-width: 100% !important;
  aspect-ratio: 1 / 1;
  height: auto !important;
  max-height: none;
}

.hf40-is-soldout .hf40-gallery .hf40-slide-img {
  max-height: none !important;
}

/* Splide leaves featured visibility:hidden until mount; OOS has no thumbs so mount can stall. */
.hf40-is-soldout .hf40-gallery .product-carousel__featured,
.hf40-is-soldout .hf40-gallery .product-carousel__featured .splide__track,
.hf40-is-soldout .hf40-gallery .product-carousel__featured .splide__list,
.hf40-is-soldout .hf40-gallery .product-carousel__featured .splide__slide,
.hf40-is-soldout .hf40-gallery .hf40-slide-frame,
.hf40-is-soldout .hf40-gallery .hf40-slide-img {
  visibility: visible !important;
  opacity: 1 !important;
}

/* Fix #3: no thumbnail strip on sold-out pages (single-photo rule). */
.hf40-is-soldout .product-carousel__thumb {
  display: none !important;
}

.hf40-slide-frame {
  aspect-ratio: 1 / 1;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f7f3ec;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid rgba(99, 72, 46, 0.12);
}

/* Match production: fill the square (no cream letterbox on portrait).
   No border/radius on the img — frame already clips (overflow + 12px). */
.hf40-slide-img,
.hf40-gallery .product-carousel__featured img,
.hf40-gallery .product-carousel__thumb img {
  width: 100% !important;
  height: 100% !important;
  max-height: none !important;
  object-fit: cover !important;
  object-position: center !important;
  display: block;
  border: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
}

.hf40-gallery .product-carousel__thumb .hf40-slide-frame {
  border-radius: 8px;
}

/* Helper OUTSIDE .atc-row — never invent .btn-atc / qty chrome */
.hf40-pick-helper {
  display: block;
  width: 100%;
  margin: 0;
  font-family: "DM Sans", sans-serif;
  font-size: 13px;
  color: var(--hf40-muted);
}

.hf40-pick-helper[hidden] {
  display: none !important;
}

.hf40-purchase {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 1.25rem;
  width: 100%;
}

.hf40-purchase .variant-section {
  margin: 0;
  position: relative;
  z-index: 1;
}

.hf40-purchase .atc-row {
  margin: 0;
  position: relative;
  z-index: 0;
}

.hf40-purchase .hf-next-delivery-stack,
.hf40-summary .product-info > .hf-next-delivery-stack {
  margin-top: 0.25rem;
  margin-bottom: 0;
}

.hf40-summary .product-info > .rm-anchor {
  margin: 0;
}

.hf40-rest {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 1.25rem;
  width: 100%;
  min-height: 1px;
}

.hf40-rest .trust-row,
.hf40-rest .product-desc,
.hf40-rest .product-meta {
  display: block;
  width: 100%;
}

.hf40-qty-hidden,
.qty-control[hidden],
.qty-control.hf40-qty-hidden {
  display: none !important;
}

/* HF-40 §18 Request — gold pill; never .btn-atc
   Phone: compact, sized to text, left-aligned, ≥44px tall (not full width).
   Label “Request”; after tap “✓ Noted”; helper copy unchanged. */
.hf40-preorder {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  width: 100%;
  margin: 0.15rem 0 0.35rem;
}

.hf40-preorder-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto;
  max-width: 100%;
  align-self: flex-start;
  min-height: 44px;
  padding: 0.65rem 1.25rem;
  box-sizing: border-box;
  border-radius: 9999px;
  border: 1.5px solid #d9a91a;
  background: #f2c230;
  color: #1f1a14;
  font-family: "DM Sans", sans-serif;
  font-size: 0.9375rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
  white-space: nowrap;
  transition: filter 0.15s ease;
}

.hf40-preorder-btn:hover,
.hf40-preorder-btn:focus {
  filter: brightness(0.97);
  color: #1f1a14;
}

.hf40-preorder-btn:disabled {
  cursor: default;
  filter: none;
}

.hf40-preorder.is-requested .hf40-preorder-btn,
.hf40-preorder-btn.is-requested {
  background: #e7f6ea;
  border-color: #1f7a3a;
  color: #1f7a3a;
}

.hf40-preorder-help {
  margin: 0;
  font-family: "DM Sans", sans-serif;
  font-size: 13px;
  font-weight: 500;
  color: var(--hf40-muted);
  line-height: 1.35;
}

.hf40-preorder.is-requested .hf40-preorder-help {
  color: #1f7a3a;
}

.hf40-soldout-actions {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
}

/* Primary OOS CTA — own class, never .btn-atc (theme ATC binds all .btn-atc) */
.hf40-shop-similar-cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.625rem;
  width: 100%;
  min-height: 48px;
  padding: 0.875rem 2rem;
  box-sizing: border-box;
  border: none;
  border-radius: 9999px;
  background: var(--hf40-action, #c83a24);
  /* Fix #15: white text on red (≥4.5:1), not inherited brown link color */
  color: #fff !important;
  font-family: "DM Sans", sans-serif;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  transition: filter 0.15s ease;
}

.hf40-shop-similar-cta:hover,
.hf40-shop-similar-cta:focus {
  filter: brightness(0.95);
  color: #fff !important;
  text-decoration: none;
}

.hf40-see-all-secondary {
  /* Theme may force display:block on anchors — keep flex for true centering */
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 100%;
  min-height: 48px;
  /* Even vertical + horizontal centering (Shauna crop feedback) */
  padding: 0 1.25rem !important;
  box-sizing: border-box;
  border-radius: 999px;
  border: 1.5px solid #1a1a1a;
  background: #fff;
  color: #1a1a1a;
  font-family: "DM Sans", sans-serif;
  font-size: 15px;
  font-weight: 700;
  text-decoration: none;
  line-height: 1 !important;
  text-align: center;
}

.hf40-see-all-secondary:hover,
.hf40-see-all-secondary:focus {
  background: #faf7f2;
  color: #1a1a1a;
}

/* Similar items (OOS design boards) — sits under photo / photo+info row */
.hf40-similar {
  padding: 12px 0 8px;
  width: 100%;
  grid-column: 1 / -1;
}

/* Theme <section> padding (~80px) was opening a large gap above Similar on phone.
   Modest tighten — keep a little air, don’t crush to zero. Desktop unchanged below. */
@media (max-width: 999px) {
  #product-detail-template section.hf40-similar,
  #product-detail-template .hf40-similar {
    padding-top: 12px !important;
    padding-bottom: 8px !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
  }
  #product-detail-template .hf40-similar-head {
    margin-bottom: 12px;
  }
}

.hf40-similar-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

/* Fix #7: DM Sans 700 ~20px phone / ~24px desktop (not Playfair) */
.hf40-similar-title {
  margin: 0;
  font-family: "DM Sans", sans-serif !important;
  font-size: 20px !important;
  font-weight: 700 !important;
  color: var(--hf40-ink);
  line-height: 1.2;
  font-style: normal !important;
}

.hf40-similar-see-all {
  font-family: "DM Sans", sans-serif;
  font-size: 14px;
  font-weight: 600;
  color: var(--hf40-action);
  text-decoration: underline;
  text-underline-offset: 3px;
  white-space: nowrap;
}

.hf40-similar-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.hf40-similar-card {
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: inherit;
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  overflow: visible;
}

.hf40-similar-media {
  aspect-ratio: 1 / 1;
  width: 100%;
  border-radius: 12px;
  overflow: hidden;
  background: #f3ebe0;
  border: 1px solid rgba(99, 72, 46, 0.12);
}

.hf40-similar-media img,
.hf40-similar-img {
  width: 100% !important;
  height: 100% !important;
  object-fit: contain !important;
  display: block;
}

.hf40-similar-info {
  padding: 10px 2px 0;
}

/* Fix #8: card names max 2 lines with ellipsis */
.hf40-similar-name {
  font-family: "DM Sans", sans-serif;
  font-size: 14px;
  font-weight: 600;
  color: var(--hf40-ink);
  line-height: 1.3;
  margin: 0 0 4px;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hf40-similar-price {
  font-family: "DM Sans", sans-serif;
  font-size: 14px;
  font-weight: 700;
  color: var(--hf40-ink);
}

.hf40-similar-from {
  font-weight: 600;
  color: var(--hf40-muted);
}

.hf40-similar-empty {
  font-family: "DM Sans", sans-serif;
  font-size: 14px;
  color: var(--hf40-muted);
  margin: 0;
}

/* OOS description sits under photo/info, before Similar items */
.hf40-oos-below {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  width: 100%;
  padding: 4px 0 8px;
}

.hf40-oos-below .product-desc,
.hf40-oos-below .product-meta {
  display: block;
  width: 100%;
}

@media (min-width: 1000px) {
  .hf40-similar {
    padding: 24px 0 16px;
  }
  .hf40-similar-title {
    font-size: 24px !important;
  }
  .hf40-similar-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
  }
  /* Fix #16: desktop CTAs side by side, sized to text, board-like gap */
  .hf40-soldout-actions {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    width: auto;
    max-width: none;
    gap: 12px;
  }
  .hf40-shop-similar-cta,
  .hf40-see-all-secondary {
    width: auto;
    min-width: 0;
    flex: 0 0 auto;
  }
  /* §18 desktop: gold button sized to text; helper to the right */
  .hf40-preorder {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px 16px;
    width: auto;
    max-width: 100%;
  }
  .hf40-preorder-btn {
    width: auto;
    min-width: 0;
    flex: 0 0 auto;
  }
  .hf40-preorder-help {
    flex: 1 1 180px;
    max-width: 280px;
  }
}

/* -------- Phone sticky bar (not desktop ATC) -------- */
.hf40-sticky-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 360;
  background: #fff;
  border-top: 1px solid rgba(99, 72, 46, 0.16);
  box-shadow: 0 -6px 24px rgba(26, 26, 26, 0.08);
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom, 0px));
  box-sizing: border-box;
  overflow: visible;
}

.hf40-sticky-bar[hidden] {
  display: none !important;
}

.hf40-sticky-inner {
  display: flex;
  flex-direction: row !important;
  flex-wrap: nowrap !important;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  box-sizing: border-box;
  overflow: visible;
}

.hf40-sticky-left {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1 1 auto;
}

.hf40-sticky-price-label {
  font-family: "DM Sans", sans-serif;
  font-size: 11px;
  font-weight: 600;
  color: var(--hf40-muted);
  line-height: 1.1;
}

.hf40-sticky-price {
  font-family: "DM Sans", sans-serif;
  font-size: 18px;
  font-weight: 700;
  color: var(--hf40-ink);
  line-height: 1.2;
}

.hf40-sticky-oos {
  font-family: "DM Sans", sans-serif;
  font-size: 15px;
  font-weight: 700;
  color: var(--hf40-chip-out);
}

.hf40-sticky-right {
  display: flex !important;
  flex-direction: row !important;
  flex: 0 0 auto !important;
  flex-shrink: 0 !important;
  align-items: center;
  gap: 10px;
  min-width: min-content !important;
  max-width: none !important;
  width: auto !important;
}

/* Theme .qty-control on sticky — compact so it fits phone ATC bar */
.hf40-sticky-bar .hf40-sticky-qty.qty-control {
  flex: 0 0 auto;
  width: auto;
  max-width: none;
  height: 42px;
  align-self: center;
}

.hf40-sticky-bar .hf40-sticky-qty .qty-btn {
  width: 2.25rem;
  height: 42px;
  font-size: 1.1rem;
  line-height: 1;
}

.hf40-sticky-bar .hf40-sticky-qty .qty-input,
.hf40-sticky-bar .hf40-sticky-qty input[type="number"] {
  width: 2.25rem;
  height: 42px;
  font-size: 0.95rem;
  font-weight: 600;
  text-align: center;
  border: none;
  background: transparent;
  outline: none;
  -moz-appearance: textfield;
}

.hf40-sticky-bar .hf40-sticky-qty input[type="number"]::-webkit-outer-spin-button,
.hf40-sticky-bar .hf40-sticky-qty input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.hf40-sticky-bar .hf40-sticky-qty.hf40-qty-hidden,
.hf40-sticky-bar .hf40-sticky-qty[hidden] {
  display: none !important;
}

.hf40-sticky-bar .hf40-sticky-cta,
.hf40-sticky-cta {
  appearance: none !important;
  -webkit-appearance: none !important;
  border: 0 !important;
  cursor: pointer;
  background: var(--hf40-action) !important;
  color: #fff !important;
  font-family: "DM Sans", sans-serif !important;
  font-size: 15px !important;
  font-weight: 700 !important;
  line-height: 1.2 !important;
  letter-spacing: normal !important;
  text-transform: none !important;
  text-align: center !important;
  border-radius: 9999px !important;
  padding: 10px 20px !important;
  min-height: 42px !important;
  height: auto !important;
  width: auto !important;
  min-width: max-content !important;
  max-width: none !important;
  white-space: nowrap !important;
  writing-mode: horizontal-tb !important;
  word-break: normal !important;
  overflow-wrap: normal !important;
  text-decoration: none !important;
  display: inline-flex !important;
  flex-direction: row !important;
  flex-wrap: nowrap !important;
  align-items: center !important;
  justify-content: center !important;
  flex: 0 0 auto !important;
  flex-shrink: 0 !important;
  overflow: visible !important;
  box-sizing: border-box !important;
}

.hf40-sticky-cta:hover,
.hf40-sticky-cta:focus-visible {
  filter: brightness(0.95);
  color: #fff;
}

.hf40-sticky-cta:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

body.hf40-sticky-visible #floating-cart-btn {
  bottom: calc(var(--hf40-sticky-h) + 12px) !important;
}

body.hf40-sticky-visible #chat-widget-minimized,
body.hf40-sticky-visible #chat-widget-container {
  bottom: calc(var(--hf40-sticky-h) + 12px) !important;
}

body.hf-mm-open .hf40-sticky-bar,
body.hf-mm-lock .hf40-sticky-bar,
body:has(#hf-mm-root.is-open) .hf40-sticky-bar,
body:has(.custom_mini_cart_pop.active) .hf40-sticky-bar,
html.hf-lc-open .hf40-sticky-bar,
html.age-popup-active .hf40-sticky-bar,
body.age-popup-active .hf40-sticky-bar {
  display: none !important;
}

/* Match live prod overflow — clip does not kill position:sticky */
html.hf40-scroll-ok,
html:has(.hf40-product-layout):not(.age-popup-active):not(:has(body.age-popup-active)):not(:has(.custom_mini_cart_pop.active)) {
  overflow-x: clip !important;
  overflow-y: scroll !important;
  height: auto !important;
  max-height: none !important;
  position: static !important;
  overscroll-behavior-y: auto !important;
  touch-action: pan-y !important;
}

body.hf40-scroll-ok,
body.single-product:has(.hf40-product-layout):not(.age-popup-active):not(.hf-mm-open):not(.hf-mm-lock) {
  overflow: clip !important;
  height: auto !important;
  max-height: none !important;
  position: static !important;
  touch-action: pan-y !important;
  -webkit-overflow-scrolling: touch;
}

html.age-popup-active,
html:has(body.age-popup-active),
body.age-popup-active {
  overflow: hidden !important;
}

body.hf40-sticky-visible #product-detail-template {
  padding-bottom: calc(var(--hf40-sticky-h) + 16px);
}

/* Phone: identity → gallery → summary (no display:contents) */
@media (max-width: 999px) {
  .hf40-product-layout {
    padding-top: 0.75rem;
  }

  .hf40-grid.product-layout__grid {
    display: flex !important;
    flex-direction: column !important;
    gap: 0.85rem !important;
  }

  .hf40-summary.product-layout__right,
  .hf40-summary .product-info {
    display: flex !important;
    flex-direction: column !important;
    gap: 1.25rem !important;
    width: 100%;
  }

  .hf40-identity {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    width: 100%;
  }

  .hf40-gallery.product-layout__left {
    width: 100%;
  }

  .hf40-gallery .product-carousel__wrap {
    position: static !important;
    top: auto !important;
  }

  .hf40-sticky-bar:not([hidden]) {
    display: block;
  }

  /* Fix #12: no in-page Shop similar / See all on phone — sticky + See all by heading */
  .hf40-is-soldout .hf40-soldout-actions {
    display: none !important;
  }
  .hf40-is-soldout .hf40-summary.product-layout__right {
    display: none !important;
  }
}

/* Desktop OOS: identity holds H1 + chip + CTAs; collapse empty summary column */
@media (min-width: 1000px) {
  .hf40-is-soldout .hf40-identity {
    gap: 0.85rem;
  }
  .hf40-is-soldout .hf40-summary.product-layout__right {
    display: none !important;
  }
  .hf40-is-soldout .hf40-grid.product-layout__grid {
    grid-template-areas: "gallery identity";
    align-items: start;
  }
}

/* Desktop: sticky gallery (prod), summary scrolls, no phone bar */
@media (min-width: 1000px) {
  .hf40-sticky-bar {
    display: none !important;
  }

  body.hf40-sticky-visible #floating-cart-btn {
    bottom: 28px !important;
  }

  .hf40-title.product-title,
  #product-detail-template .hf40-title {
    font-size: 30px !important;
  }

  .hf40-grid.product-layout__grid {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-areas:
      "gallery identity"
      "gallery summary";
    gap: 1.25rem 3rem;
    align-items: stretch;
  }

  .hf40-nav {
    margin-bottom: 0.25rem;
  }

  .hf40-gallery.product-layout__left {
    grid-area: gallery;
    align-self: stretch;
    position: relative;
  }

  .hf40-identity {
    grid-area: identity;
    align-self: start;
  }

  .hf40-summary.product-layout__right {
    grid-area: summary;
    position: static;
    top: auto;
    align-self: start;
  }

  .hf40-gallery .product-carousel__wrap {
    position: sticky !important;
    top: var(--sticky-height, 96px) !important;
    align-self: start;
  }

  .hf40-gallery .product-carousel__featured {
    max-width: none;
  }

  .hf40-badges-deferred {
    margin-bottom: 0.35rem;
  }
}
