/* ════════════════════════════════════════════════════════════════
   SPRINT 8.2 — Premium Product Pricing UX (UI only)
   Single visual layer on top of the existing storefront design system.
   Pricing math stays exclusively in js/pricing.js (StorePricing).
   Loaded last so these rules win across all prior style layers.
   ════════════════════════════════════════════════════════════════ */

/* ──────────────────────────────────────────────
   PART 1 — Product Card: hierarchical price block
   Variant cards: small "FROM" eyebrow above the price.
   Non-variant cards: plain price, no eyebrow.
   ────────────────────────────────────────────── */
.product-card__price {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.18rem;
  line-height: 1.15;
  white-space: normal;
}

.product-card__price .price-from {
  font-size: 0.58rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--color-text-light);
  margin: 0;
}

.product-card__price-value {
  font-size: 0.98rem;
  font-weight: 800;
  color: var(--color-accent-dark);
  letter-spacing: -0.01em;
  line-height: 1;
  white-space: nowrap;
}

/* ──────────────────────────────────────────────
   PART 2 — Product Detail: pricing block
   "Starting from" eyebrow + large price + live
   selected option + automatic price range pill.
   ────────────────────────────────────────────── */
.product-detail__pricing {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.product-detail__eyebrow {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--color-text-light);
  margin: 0;
}

.product-detail__price {
  font-size: 2rem;
  line-height: 1.1;
  letter-spacing: -0.02em;
  margin: 0;
}

.product-detail__selected {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-text-muted);
  margin: 0;
}

.product-detail__range {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--color-text);
  background: var(--color-accent-light);
  border: 1px solid var(--color-border-soft);
  border-radius: var(--radius-full);
  padding: 0.32rem 0.75rem;
  width: fit-content;
  margin: 0.1rem 0 0;
  white-space: nowrap;
}

/* ──────────────────────────────────────────────
   PART 3 — Variant Options: name + absolute price
   Selected option is highlighted with a gold ring.
   ────────────────────────────────────────────── */
.variant-option__name {
  flex: 1;
  min-width: 0;
}

.variant-option__price {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--color-accent-dark);
  white-space: nowrap;
}

.variant-option:has(input:checked) {
  border-color: var(--color-accent);
  background: var(--color-primary-bg);
  box-shadow: var(--shadow-glow);
}

.variant-option:has(input:focus-visible) {
  outline: 2px solid var(--st-accent);
  outline-offset: 2px;
}

/* ──────────────────────────────────────────────
   PART 4 — Live Summary panel
   Selected / Unit price / Quantity / Total.
   ────────────────────────────────────────────── */
.product-detail__summary {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--color-border-soft);
  border-radius: var(--radius-lg);
  background: var(--color-surface-soft);
  overflow: hidden;
}

.product-detail__summary-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.7rem 0.95rem;
  border-bottom: 1px solid var(--color-border-soft);
  min-height: 44px;
}

.product-detail__summary-row:last-child {
  border-bottom: 0;
}

.product-detail__summary-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-muted);
  flex-shrink: 0;
  white-space: nowrap;
}

.product-detail__summary-value {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--color-text);
  text-align: right;
  min-width: 0;
  white-space: nowrap;
}

.product-detail__summary-row--qty {
  cursor: pointer;
}

.product-detail__summary-row--qty .qty-input {
  width: 4.5rem;
  min-height: 40px;
}

.product-detail__summary-row--total {
  background: var(--color-surface);
}

.product-detail__summary-row--total .product-detail__summary-value {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--color-accent-dark);
}

/* ──────────────────────────────────────────────
   PART 5 — Add To Cart: two-line button label
   "Add to cart" + smaller live total underneath.
   ────────────────────────────────────────────── */
.product-detail__add-btn {
  min-height: 56px;
  padding: 0.7rem 1.25rem;
}

.product-detail__add-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.12rem;
  line-height: 1.2;
  text-align: center;
}

.product-detail__add-total {
  font-size: 0.78rem;
  font-weight: 700;
  opacity: 0.95;
}

/* ──────────────────────────────────────────────
   PART 8 — Mobile: 320–430px
   No overflow, no clipped prices, no wrapped totals.
   ────────────────────────────────────────────── */
@media (max-width: 479px) {
  .product-detail__price {
    font-size: 1.7rem;
  }
  .product-detail__summary-row {
    padding: 0.6rem 0.8rem;
  }
  .product-card__price-value {
    font-size: 0.88rem;
  }
  .product-card__price .price-from {
    font-size: 0.55rem;
  }
}

@media (max-width: 370px) {
  .product-card__price-value {
    font-size: 0.8rem;
  }
  .product-card__price .price-from {
    font-size: 0.5rem;
  }
  .product-detail__price {
    font-size: 1.55rem;
  }
  .product-detail__summary-label {
    font-size: 0.68rem;
  }
  .product-detail__summary-value {
    font-size: 0.85rem;
  }
  .product-detail__summary-row--total .product-detail__summary-value {
    font-size: 1.1rem;
  }
}

/* ──────────────────────────────────────────────
   PART 9 — RTL alignment
   ────────────────────────────────────────────── */
body.store-body.is-rtl .product-detail__eyebrow,
body.store-body.is-rtl .product-detail__selected,
body.store-body.is-rtl .product-detail__range {
  text-align: right;
}

body.store-body.is-rtl .variant-option__price {
  margin-right: auto;
}

body.store-body.is-rtl .product-detail__summary-row--qty .qty-input {
  direction: ltr;
}

/* ──────────────────────────────────────────────
   PART 9 — Dark mode refinements
   Tokens auto-adapt; only fine-tuning here.
   ────────────────────────────────────────────── */
[data-theme="dark"] .product-detail__range {
  background: var(--color-accent-soft);
}

[data-theme="dark"] .variant-option:has(input:checked) {
  box-shadow: var(--shadow-glow-strong);
}

/* ──────────────────────────────────────────────
   PART 10 — SPRINT 8.3 · Phase A — Product Card
   Badges · rating · description · card rhythm.
   UI-only; data from existing product fields.
   ────────────────────────────────────────────── */

/* Badges overlay — media is position:relative;
   heart button occupies the top-end corner, so
   badges live top-start (flipped in RTL). */
.product-card__badges {
  position: absolute;
  top: 0.5rem;
  left: 0.5rem;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.35rem;
  max-width: calc(100% - 4.5rem);
  pointer-events: none;
}

body.store-body.is-rtl .product-card__badges {
  left: auto;
  right: 0.5rem;
}

.product-badge {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  padding: 0.28rem 0.6rem;
  border-radius: var(--radius-full);
  font-size: 0.58rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  line-height: 1;
  color: #fff;
  box-shadow: 0 2px 8px rgba(44, 24, 16, 0.2);
}

.product-badge--new {
  background: var(--color-accent);
}

.product-badge--best {
  background: #2b241c;
}

.product-badge--limited {
  background: #b85c2c;
}

.product-badge--low {
  background: #b8860b;
}

.product-badge--fresh {
  background: var(--color-success);
}

.product-badge--sold {
  background: var(--color-danger);
}

[data-theme="dark"] .product-badge--best {
  background: #efe7da;
  color: #2b241c;
}

/* Description — 2-line clamp, muted, small */
.product-card__desc {
  margin: 0.3rem 0 0;
  font-size: 0.72rem;
  line-height: 1.5;
  color: var(--color-text-muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  line-clamp: 2;
  overflow: hidden;
}

/* Rating line — computed from product.rating /
   ReviewsStore.approvedReviews only */
.product-card__rating {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.4rem;
  min-height: 1.1rem;
}

.product-card__rating-stars {
  font-size: 0.74rem;
  line-height: 1;
  letter-spacing: 0.06em;
  color: #d9a428;
}

[data-theme="dark"] .product-card__rating-stars {
  color: #e0b64d;
}

.product-card__rating-score {
  font-size: 0.7rem;
  font-weight: 800;
  color: var(--color-text);
  line-height: 1;
}

.product-card__rating-count {
  font-size: 0.66rem;
  color: var(--color-text-muted);
  line-height: 1;
}

.product-card__rating--empty .product-card__rating-stars {
  color: rgba(44, 24, 16, 0.22);
}

.product-card__rating--empty .product-card__rating-note {
  font-size: 0.66rem;
  font-style: italic;
  color: var(--color-text-muted);
  line-height: 1;
}

[data-theme="dark"] .product-card__rating--empty .product-card__rating-stars {
  color: rgba(255, 255, 255, 0.22);
}

/* Keep price row anchored to bottom regardless of
   description / rating length */
.product-card__meta {
  margin-top: auto;
}

@media (max-width: 479px) {
  .product-badge {
    font-size: 0.54rem;
    padding: 0.24rem 0.52rem;
  }
  .product-card__desc {
    font-size: 0.68rem;
  }
  .product-card__rating-stars {
    font-size: 0.68rem;
  }
}

/* ──────────────────────────────────────────────
   PART 11 — SPRINT 8.3 · Phase B — Detail Gallery
   Thumbnail strip · skeleton · main-image fade.
   The renderer now nests .product-detail__gallery-main
   + .product-detail__thumbs inside the existing
   .product-detail__gallery, so the outer element's
   aspect-ratio:1/1 must collapse to a block container
   and the square/radius moves onto the main wrapper.
   ────────────────────────────────────────────── */

/* Outer gallery becomes a plain block container so the
   thumbnail strip is not clipped by the old 1/1 ratio. */
.product-detail__gallery {
  aspect-ratio: auto;
  display: block;
  padding: 0;
}

/* Main image wrapper owns the square + radius now */
.product-detail__gallery-main {
  position: relative;
  aspect-ratio: 1/1;
  border-radius: 16px;
  overflow: hidden;
  background: var(--color-surface-soft);
}

.product-detail__skeleton {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    110deg,
    #e5dcd3 0%,
    #efe8e0 42%,
    #f7f1ea 50%,
    #efe8e0 58%,
    #e5dcd3 100%
  );
  background-size: 220% 100%;
  animation: productCardShimmer 1.15s ease-in-out infinite;
}

.product-detail__gallery-main img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  opacity: 0;
  transition: opacity 0.45s var(--ease-out-expo), transform 0.6s var(--st-ease);
}

.product-detail__gallery-main img.product-detail__img--loaded {
  opacity: 1;
}

/* Hover zoom applies to the main image only, not thumbs */
.product-detail__gallery:hover .product-detail__gallery-main img.product-detail__img--loaded {
  transform: scale(1.03);
}

/* Thumbnail strip */
.product-detail__thumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.product-detail__thumb {
  position: relative;
  width: 64px;
  aspect-ratio: 1/1;
  padding: 0;
  border: 2px solid var(--color-border-soft);
  border-radius: 12px;
  overflow: hidden;
  background: var(--color-surface-soft);
  cursor: pointer;
  transition: border-color 0.2s var(--st-ease), transform 0.2s var(--st-ease);
}

.product-detail__thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.product-detail__thumb:hover {
  border-color: var(--color-accent-hover);
  transform: translateY(-1px);
}

.product-detail__thumb.is-active {
  border-color: var(--color-accent);
  box-shadow: var(--shadow-glow);
}

.product-detail__thumb:focus-visible {
  outline: 2px solid var(--st-accent);
  outline-offset: 2px;
}

/* Dark mode skeleton matches the dark surface */
[data-theme="dark"] .product-detail__skeleton {
  background: linear-gradient(
    110deg,
    #1e1a15 0%,
    #2a251e 42%,
    #322c24 50%,
    #2a251e 58%,
    #1e1a15 100%
  );
  background-size: 220% 100%;
}

/* Mobile: slightly larger touch targets */
@media (max-width: 479px) {
  .product-detail__thumb {
    width: 56px;
    border-radius: 10px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .product-detail__skeleton {
    animation: none;
  }
  .product-detail__gallery-main img,
  .product-detail__gallery:hover .product-detail__gallery-main img.product-detail__img--loaded {
    transition: none;
    transform: none;
  }
  .product-detail__thumb:hover {
    transform: none;
  }
}

/* ──────────────────────────────────────────────
   PART 12 — SPRINT 8.3 · Phase C — Variant cards,
   Quantity stepper, Purchase bar (sticky mobile).
   Reuses existing .variant-option / .qty-input
   hooks; adds new selectable-card and stepper
   presentation on top.
   ────────────────────────────────────────────── */

/* Variant option → premium selectable card */
.variant-option {
  padding: 0.7rem 0.85rem;
  border-radius: 14px;
  box-shadow: 0 1px 2px rgba(44, 24, 16, 0.04);
  transition: border-color 0.2s var(--st-ease), background 0.2s var(--st-ease), transform 0.2s var(--st-ease), box-shadow 0.2s var(--st-ease);
}

.variant-option:hover {
  transform: translateY(-1px);
}

.variant-option:has(input:checked):hover {
  transform: none;
}

[data-theme="dark"] .variant-option {
  box-shadow: none;
}

/* Keep the extra-price chip aligned with the name */
.variant-option__label {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.variant-option__name {
  flex: 1;
  min-width: 0;
}

/* Quantity stepper */
.qty-stepper {
  display: inline-flex;
  align-items: stretch;
  border: 1px solid var(--color-border-soft);
  border-radius: 12px;
  overflow: hidden;
  background: var(--color-surface);
  min-height: 42px;
}

.qty-stepper__btn {
  width: 42px;
  min-width: 42px;
  border: none;
  background: transparent;
  cursor: pointer;
  font-family: inherit;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--color-text);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s var(--st-ease), color 0.2s var(--st-ease), transform 0.15s var(--st-ease);
}

.qty-stepper__btn:hover:not(:disabled) {
  background: var(--color-primary-bg);
  color: var(--color-accent-dark);
}

.qty-stepper__btn:active:not(:disabled) {
  transform: scale(0.94);
}

.qty-stepper__btn:focus-visible {
  outline: 2px solid var(--st-accent);
  outline-offset: -2px;
  position: relative;
  z-index: 1;
}

.qty-stepper__btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.qty-stepper .qty-input {
  width: 3.25rem;
  min-width: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  text-align: center;
  font-size: 0.92rem;
  font-weight: 800;
  padding: 0.45rem 0;
  min-height: 42px;
  -moz-appearance: textfield;
}

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

.qty-stepper .qty-input:focus {
  box-shadow: none;
  outline: 2px solid var(--st-accent);
  outline-offset: -2px;
  border-color: transparent;
}

/* The qty row is a plain row again, not a label */
.product-detail__summary-row--qty {
  cursor: default;
}

/* Compact stepper used in the purchase bar */
.qty-stepper__btn--sm {
  width: 34px;
  min-width: 34px;
  min-height: 34px;
  font-size: 0.95rem;
}

/* ── Sticky mobile purchase bar ── */
.purchase-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 200;
  background: var(--color-surface);
  border-top: 1px solid var(--color-border-soft);
  box-shadow: 0 -8px 30px rgba(44, 24, 16, 0.1);
  padding: 0.55rem 1rem calc(0.55rem + env(safe-area-inset-bottom, 0px));
  transform: translateY(110%);
  transition: transform 0.35s var(--ease-out-expo);
  visibility: hidden;
}

.purchase-bar.is-visible {
  transform: translateY(0);
  visibility: visible;
}

.purchase-bar__inner {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  max-width: 1200px;
  margin: 0 auto;
}

.purchase-bar__price {
  display: flex;
  flex-direction: column;
  justify-content: center;
  line-height: 1.15;
  flex-shrink: 0;
}

.purchase-bar__label {
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-muted);
}

.purchase-bar__value {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--color-accent-dark);
  white-space: nowrap;
}

.purchase-bar__qty {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  border: 1px solid var(--color-border-soft);
  border-radius: 10px;
  overflow: hidden;
  background: var(--color-surface-soft);
  flex-shrink: 0;
}

.purchase-bar__qty .qty-stepper__btn--sm {
  width: 30px;
  min-width: 30px;
  min-height: 36px;
}

.purchase-bar__qty-value {
  min-width: 2ch;
  text-align: center;
  font-size: 0.9rem;
  font-weight: 800;
  color: var(--color-text);
}

.purchase-bar__add {
  flex: 1;
  min-height: 44px;
  margin: 0;
  padding: 0.5rem 0.75rem;
  justify-content: center;
  flex-direction: column;
  gap: 0.1rem;
  line-height: 1.15;
  border-radius: 12px;
}

.purchase-bar__add-total {
  font-size: 0.7rem;
  font-weight: 700;
  opacity: 0.95;
}

/* Desktop: bar never shows */
@media (min-width: 768px) {
  .purchase-bar {
    display: none;
  }
}

@media (max-width: 767px) {
  body.has-purchase-bar {
    padding-bottom: 78px;
  }
}

@media (max-width: 430px) {
  .purchase-bar__inner {
    gap: 0.55rem;
  }
  .purchase-bar__value {
    font-size: 0.95rem;
  }
  .purchase-bar__qty .qty-stepper__btn--sm {
    width: 28px;
    min-width: 28px;
  }
}

@media (max-width: 370px) {
  .purchase-bar__label {
    display: none;
  }
}

/* Dark mode bar shadow */
[data-theme="dark"] .purchase-bar {
  box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.35);
}

/* Reduced motion: no slide, instant reveal */
@media (prefers-reduced-motion: reduce) {
  .purchase-bar {
    transition: none;
  }
  .variant-option,
  .variant-option:hover,
  .variant-option:has(input:checked):hover {
    transform: none;
  }
  .qty-stepper__btn:active:not(:disabled) {
    transform: none;
  }
}



