/* =========================================
   ONE STEP — product.css
   صفحة تفاصيل المنتج
========================================= */

/* ===== BREADCRUMB ===== */
.breadcrumb-bar {
  background: var(--gray);
  border-bottom: 1px solid var(--border);
  padding: 14px 0;
  font-size: 13px;
}
.breadcrumb-bar .container {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
}
.breadcrumb-bar a { color: var(--muted); transition: color 0.2s; }
.breadcrumb-bar a:hover { color: var(--green-d); }
.breadcrumb-bar .bc-current { color: var(--navy); font-weight: 700; }
/* M36 · S8.4.6 (measured CLS 0.143): the product name arrived after the page painted and wrapped the breadcrumb to two lines, pushing the
   whole product down 21px. One line with an ellipsis — the full name is the page's <h1> right below. */
.breadcrumb-bar .container { min-width: 0; white-space: nowrap; }
.breadcrumb-bar .bc-current { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ===== PAGE ===== */
.product-page { padding: 36px 0 64px; }
.loading-state { text-align: center; padding: 80px 0; color: var(--muted); font-size: 16px; }

/* ===== LAYOUT ===== */
.product-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 48px;
  align-items: start;
}

/* ===== GALLERY (left) ===== */
.product-gallery {
  position: sticky;
  top: 88px;
}
.gallery-main {
  background: var(--photo-stage);
  border-radius: 24px;
  height: 420px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 180px;
  position: relative;
  overflow: hidden;
}
/* صورة المنتج الحقيقية بالمعرض — contain لإظهار المنتج كاملاً فوق مرحلة
   بيضاء ثابتة. الحاوية تعرف أبعادها قبل وصول الصورة (ارتفاع ثابت + inset:0)
   فلا قفزة تخطيط إطلاقاً — الصورة تظهر داخل مساحة محجوزة أصلاً (E3).
   ⚠️ z-index صريح لا يعتمد على ترتيب الـDOM: تبديل المتغيّر قد يُعيد إدراج
   هذا العنصر بعد الشارة في الشجرة (updateGalleryBg في js/product.js)،
   فالاعتماد على ترتيب الإدراج وحده كان يقلب الطبقات صامتاً. */
.gallery-photo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 26px;
  transition: opacity .18s ease;
  z-index: 1;
}
/* تلاشٍ سريع خفيف عند تبديل اللون (H1) — ١٨٠ms: محسوس كنعومة لا كانتظار */
.gallery-photo.is-swapping { opacity: 0; }
@media (prefers-reduced-motion: reduce) {
  .gallery-photo { transition: none; }
  .gallery-photo.is-swapping { opacity: 1; }
}
/* الشارة أعلى طبقةً من الصورة دوماً — رقمٌ محلّي أعلى من صورة المعرض
   وحدها، لا سباقاً مع سياقات تكديسٍ أخرى في الصفحة (see .gallery-photo). */
.gallery-badge {
  position: absolute;
  top: 18px;
  right: 18px;
  z-index: 2;
  /* Foreground on a filled-green surface: --on-green only.
     Value + full decision history live in css/style.css :root — never inline a
     literal here, a second literal is exactly how the two surfaces diverged. */
  background: var(--green);
  color: var(--on-green);
  font-size: 12px;
  font-weight: 700;
  padding: 6px 14px;
  border-radius: 20px;
}

/* ===== INFO (right) ===== */
.product-info { padding-top: 8px; }
/* ═══ شريط مصغّرات المتغيّرات ═══
   :empty يخفي الشريط كلياً (منتج بلونٍ واحد) فلا تبقى فجوة تحت الصورة.
   التمرير أفقي على الشاشات الضيّقة بدل الالتفاف: صفٌّ واحد يبقى مقروءاً
   ولا يدفع بقيّة الصفحة للأسفل على ٣٦٠ بكسل. */
.gallery-thumbs {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: thin;
}
.gallery-thumbs:empty { display: none; }
.gallery-thumb {
  flex: none;
  width: 62px;
  height: 62px;
  padding: 4px;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  background: var(--photo-stage);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color .18s ease, box-shadow .18s ease;
}
.gallery-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.gallery-thumb-ph { font-size: 11px; line-height: 1.2; color: var(--muted); text-align: center; }
.gallery-thumb:hover { border-color: var(--green); }
.gallery-thumb.is-preview {
  border-color: var(--green);
  box-shadow: 0 0 0 2px rgba(120,199,103,0.35);
}
.gallery-thumb.disabled { opacity: .4; cursor: not-allowed; }
.gallery-thumb:focus-visible {
  outline: 2px solid var(--navy);
  outline-offset: 2px;
}
/* M21: the approved A130097 photograph surface applies to every LIAO SKU. */
.liao-gallery { min-width: 0; }
.liao-gallery .gallery-main {
  width: min(100%, 480px);
  height: auto;
  aspect-ratio: 1;
  margin-inline: auto;
  background: transparent;
  border-radius: 0;
}
.liao-gallery .gallery-photo {
  position: relative;
  inset: auto;
  /* Published LIAO derivatives have a square image box. Reserve it before load. */
  width: 100%;
  aspect-ratio: 1;
  height: 100%;
  padding: 0;
  border-radius: 24px;
  object-fit: contain;
  display: block;
  box-shadow: 0 6px 22px rgba(5, 23, 62, .08);
}
/* The fallback SVG appears only when no photograph exists. */
.liao-gallery .gallery-main:has(.gallery-photo) > svg { visibility: hidden; }
.liao-gallery .gallery-thumbs {
  width: min(100%, 480px);
  margin-inline: auto;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
  padding: 3px 0 8px;
}
.liao-gallery .gallery-thumb {
  width: 100%;
  height: auto;
  aspect-ratio: 1;
  padding: 0;
  border: 0;
  border-radius: 12px;
  background: #fff;
  overflow: hidden;
}
.liao-gallery .gallery-thumb:hover,
.liao-gallery .gallery-thumb.is-preview {
  box-shadow: 0 0 0 2px var(--green);
}
.liao-gallery .gallery-thumb img { border-radius: 12px; }
@media (max-width: 600px) {
  .liao-gallery .gallery-photo { border-radius: 18px; }
}
@media (max-width: 430px) {
  .liao-gallery .gallery-thumbs { display: flex; }
  .liao-gallery .gallery-thumb { flex: 0 0 60px; }
}
@media (prefers-reduced-motion: reduce) {
  .gallery-thumb { transition: none; }
}

/* شارة العلامة على صفحة المنتج — سطرها الخاص فوق شارة القسم.
   المقاسات نفسها معرَّفة في css/style.css (.brand-badge--detail) المحمَّل هنا
   أيضاً؛ هذه القاعدة تضبط الموضع لا الحجم، فلا يتكرّر تعريف المقاس. */
.product-info > .brand-badge--detail {
  display: flex;
  margin-bottom: 10px;
}

.product-cat-label {
  display: inline-block;
  /* نظير ‎.cat-block-count‎ على صفحة المنتج: أخضر على طبقة خضراء ١٢٪ — الشكل
     المعتمَد، أُعيد بقرار المالك نفسه (٢٤ أغسطس ٢٠٢٦). القياس نفسه: ‎2.53:1‎،
     يسقط في AA للنصّ الصغير، والاسم نفسه يظهر في فتات الخبز أعلى الصفحة
     بلون ‎--navy‎ — فلا معلومة تُفقد بهذا اللون. انظر DESIGN.md. */
  color: var(--green-d);
  font-size: 13px;
  font-weight: 700;
  background: rgba(120,199,103,0.12);
  padding: 5px 14px;
  border-radius: 16px;
  margin-bottom: 14px;
}
.product-title {
  font-size: 32px;
  font-weight: var(--fw-medium);
  color: var(--navy);
  line-height: 1.25;
  margin-bottom: 12px;
}
.product-price-display {
  font-size: 30px;
  font-weight: 800;
  color: var(--navy);
  margin-bottom: 6px;
}
.product-price-display span { font-size: 16px; font-weight: 600; color: var(--muted); }
.product-availability {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--green-d);
  font-weight: 600;
  margin-bottom: 24px;
}
.avail-dot { width: 8px; height: 8px; background: var(--green); border-radius: 50%; }

.product-desc {
  font-size: 15px;
  color: var(--muted);
  line-height: 1.8;
  margin-bottom: 28px;
  padding-bottom: 28px;
  border-bottom: 1px solid var(--border);
}

/* ===== VARIANT SECTIONS ===== */
.variant-block { margin-bottom: 26px; }
.variant-label {
  font-size: 14px;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.variant-label .label-value {
  color: var(--green-d);
  font-weight: 600;
}

/* Size options */
.size-options { display: flex; flex-wrap: wrap; gap: 10px; }
.size-chip {
  border: 1.5px solid var(--border);
  background: #fff;
  border-radius: 12px;
  padding: 12px 20px;
  cursor: pointer;
  transition: all 0.18s;
  text-align: center;
  min-width: 90px;
}
.size-chip:hover { border-color: var(--green); }
.size-chip.active {
  border-color: var(--navy);
  background: var(--navy);
  color: #fff;
}
.size-chip .size-name { font-size: 14px; font-weight: 700; display: block; }
.size-chip .size-price { font-size: 12px; opacity: 0.8; margin-top: 2px; display: block; }

/* ===== إضافة دفعة أحجام (2026-08-23) =====
   كل شريحة حجمٍ تحمل الآن عدّاداً مستقلاً أسفلها — يسمح بضبط كمّية أكثر من
   حجم واحد قبل ضغطة إضافة واحدة. الشريحة نفسها (المتن) تبقى تُبدّل المعاينة
   فقط؛ العدّاد عنصر شقيق منفصل، لا زرٌّ داخل زرّ (ترميز غير صالح). */
.size-chip-wrap { display: flex; flex-direction: column; align-items: stretch; gap: 6px; }
.size-chip-qty {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 4px 6px;
}
.size-qty-btn {
  width: 24px; height: 24px;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 7px;
  cursor: pointer;
  font-size: 14px;
  color: var(--navy);
  display: flex; align-items: center; justify-content: center;
  transition: all 0.18s;
}
.size-qty-btn:hover { background: var(--green); color: var(--on-green); border-color: var(--green); }
.size-qty-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.size-qty-val { font-size: 13px; font-weight: 700; min-width: 16px; text-align: center; }
/* حجمٌ له كمّية مضبوطة > صفر: حدّ أخضر خفيف يميّزه بصرياً عن الأحجام غير
   المُدرَجة في الدفعة الحالية — إشارة سريعة قبل ضغط زرّ الإضافة. */
.size-chip-wrap.has-qty .size-chip:not(.active) { border-color: var(--green); }

/* ===== دوائر اللون/العطر — الحجم وحده =====
   ⚠️ كل ما يخصّ الحدّ وحالة الاختيار والتركيز وشطبة «غير متوفر» انتقل إلى
   النظام الموحّد ‎.scent-swatch‎ في css/style.css (المحمَّل قبل هذا الملف).
   القواعد المحلّية القديمة (border 3px + box-shadow حلقة + علامة ‎::after‎)
   حُذفت لسببين: كانت تُنتج حلقة خارجية — وهو بالضبط ما طلب المالك إزالته —
   وكانت **تعكس** موضعَي العنصرين الزائفين مقارنةً بالنظام الموحّد
   (‎::after‎ للعلامة و‎::before‎ للشطبة)، فبقاؤها كان سيرسم العلامة والشطبة
   معاً على نفس الدائرة. */
.scent-options { display: flex; flex-wrap: wrap; gap: 14px; }
.scent-circle {
  width: 44px;
  height: 44px;
}
/* المعاينة النشطة (Workstream H) — أيّ دائرة تعرضها الصورة الكبيرة الآن،
   مستقلّة عن "مُختار".
   ⚠️ Stage 2 (owner round، أغسطس ٢٠٢٦) — إصلاح جذريّ: كانت حلقة "معاين"
   كحليّة داكنة (‎rgba(5,23,62,0.35)‎) تُضاف **خارج** حلقة "مُختار" الخضراء
   في الحالة الشائعة (اختيار واحد ⇒ معاينة نفس الاختيار دائماً، انظر
   ‎select()‎ في js/variant-selection.js)، فتظهر فعلياً كعلامة داكنة فوق كل
   دائرة مُختارة — بالضبط شكوى المالك "علامة سوداء/داكنة فوق الدائرة الخضراء
   المختارة". لأن "مُختار" و"معاين" متطابقان دائماً في هذه الحالة الشائعة، لا
   حاجة لحلقة ثالثة أصلاً: الحالة المُدمَجة تُطابق الآن حلقة "مُختار" الجديدة
   (أبيض+أخضر، css/style.css) تماماً بلا طبقة داكنة إضافية. حالة "معاين بلا
   اختيار" غير قابلة للحدوث عملياً بنموذج الاختيار الحالي (المعاينة تتبع
   اختياراً موجوداً دوماً)؛ تُركت حلقتها هنا أخف وأدفأ (أخضر شفّاف لا كحليّ
   داكن) دفاعياً فقط، لا لأنها تُستعمَل اليوم. */
.scent-swatch.is-preview { box-shadow: 0 0 0 3px rgba(120,199,103,0.35); }
.scent-swatch.is-selected.is-preview {
  box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--green, #78c767);
}

/* ===== صفوف الألوان المُختارة (اختيار متعدّد، Workstream H) =====
   ⚠️ Stage 2: التصميم والتنسيق الكامل (‎.variant-selected-chips‎/
   ‎.variant-chip*‎) انتقل إلى css/style.css — نفس السبب الذي دفع
   ‎.variant-descriptor‎ إلى العيش هناك بالفعل (انظر تعليقها في ذلك الملف):
   صفحة المنتج تُحمِّل كِلا الملفين، فتعريفٌ واحد في style.css يكفي كل
   الأسطح الثلاثة (الرئيسية/الجملة عبر المعاينة السريعة، وصفحة المنتج) دون
   نسخة ثانية قد تنحرف عنها — القاعدة القديمة هنا كانت **لا تُحمَّل إطلاقاً**
   في المعاينة السريعة (index.html/wholesale.html لا يُحمِّلان هذا الملف)،
   وهو الجذر الحقيقي لشكوى "صفوف الاختيار تبدو نموذج مطوّر" هناك — كانت
   تُرسَم بلا أي تنسيق. لا تُعِد إضافة تعريفٍ ثانٍ هنا. */

/* ===== QUANTITY + ADD ===== */
.purchase-row {
  display: flex;
  gap: 14px;
  align-items: stretch;
  margin-top: 32px;
}
.qty-selector {
  display: flex;
  align-items: center;
  border: 1.5px solid var(--border);
  border-radius: 13px;
  overflow: hidden;
}
/* F-002: display:flex أعلاه يتقدّم على [hidden] الافتراضي من ورقة أنماط
   المتصفّح بصرف النظر عن الخصوصية (تصريح مؤلّف يسبق تصريح المتصفّح دوماً) —
   ضبط الخاصّية hidden وحده في JS كان لا يُخفي الصفّ بصرياً فعلياً. */
.qty-selector[hidden] { display: none; }
.qty-selector button {
  width: 46px;
  height: 100%;
  border: none;
  background: var(--gray);
  font-size: 20px;
  cursor: pointer;
  color: var(--navy);
  transition: background 0.2s;
}
.qty-selector button:hover { background: var(--border); }
.qty-selector .qty-num {
  min-width: 50px;
  text-align: center;
  font-size: 16px;
  font-weight: 700;
  color: var(--navy);
}
.add-cart-btn {
  flex: 1;
  /* Foreground on a filled-green surface: --on-green only.
     Value + full decision history live in css/style.css :root — never inline a
     literal here, a second literal is exactly how the two surfaces diverged. */
  background: var(--green);
  color: var(--on-green);
  border: none;
  border-radius: 13px;
  font-family: inherit;
  font-size: 16px;
  font-weight: var(--fw-medium);
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 16px;
}
.add-cart-btn:hover { background: var(--green-d); transform: translateY(-2px); box-shadow: 0 8px 22px rgba(120,199,103,0.35); }

/* trust badges */
.trust-row {
  display: flex;
  gap: 20px;
  margin-top: 28px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}
.trust-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
}
.trust-item .ti-icon { font-size: 20px; }

/* ===== RELATED ===== */
.related { margin-top: 64px; }
.related-title {
  font-size: 24px;
  font-weight: var(--fw-medium);
  color: var(--navy);
  margin-bottom: 24px;
}
/* M39: the similar-products row is a slider (.hcarousel in css/style.css) — snap, consistent card widths, no page overflow */
.related-slider { max-width: 100%; }
.related-slider .hcarousel {
  scroll-snap-type: x mandatory;
  overscroll-behavior-x: contain;
}
.related-slider .hcarousel > * { scroll-snap-align: start; }
.related-slider .hcarousel:focus-visible { outline: 2px solid var(--navy); outline-offset: 4px; border-radius: 12px; }
.related-slider .hcarousel-arrow:focus-visible { opacity: 1; outline: 2px solid var(--navy); outline-offset: 2px; }
.related-slider .hcarousel-arrow.h-prev { right: 0; }
.related-slider .hcarousel-arrow.h-next { left: 0; }

/* ===== RESPONSIVE ===== */
@media (max-width: 860px) {
  /* M34 (measured, real Chrome): `1fr` = minmax(auto, 1fr) — the column could not shrink below its widest child (412px), so the
     whole product page scrolled sideways at every phone width (390 → 426px). minmax(0, 1fr) lets it fit the screen. */
  .product-layout { grid-template-columns: minmax(0, 1fr); gap: 28px; }
  .product-layout > * { min-width: 0; }
  .product-gallery { position: static; }
  .gallery-main { height: 300px; font-size: 130px; }
  .product-title { font-size: 26px; }
}

@media (max-width: 480px) {
  .purchase-row { flex-direction: column; }
  .qty-selector { align-self: flex-start; }
  /* أهداف لمس مريحة بالموبايل */
  .qty-selector button { width: 50px; min-height: 48px; }
  .product-price-row { gap: 8px; }
  /* الاستجابة الموبايلية لصفوف الاختيار المتعدّد (‎.variant-chip‎) انتقلت مع
     تعريفها الكانوني إلى css/style.css (Stage 2) — لا تُكرَّر هنا. */
}

/* ===== REAL VARIANTS: متغيّر موقوف (غير متوفر) =====
   حالة «غير متوفر» (التبهيت + الشطبة) والتركيز صارا من ‎.scent-swatch‎
   الموحّد في css/style.css. القاعدة القديمة كانت تمدّ الشطبة إلى ‎-4px‎ خارج
   القرص — أي خطّاً خارجياً داكناً، وهو ما مُنع. */

/* ===== السعر النهائي ===== */
/* سعر واحد فقط: .product-old-price و .product-discount-badge أُزيلا مع
   نظام الخصم على مستوى المنتج. .product-barcode أُزيلت (Owner Round 4،
   Workstream E) — الباركود معلومة داخلية، لا تُعرض للزبون بعد الآن. */
.product-price-row {
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
}

/* ===== الوصف التسويقي المولّد (js/product-copy.js) ===== */
.pd-sections {
  margin-top: 30px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding-top: 22px;
}
.pd-section h3 {
  font-size: 16px;
  font-weight: var(--fw-medium);
  color: var(--navy);
  margin-bottom: 10px;
  position: relative;
  padding-right: 14px;
}
.pd-section h3::before {
  content: '';
  position: absolute;
  right: 0;
  top: 4px;
  bottom: 4px;
  width: 4px;
  border-radius: 2px;
  background: var(--green);
}
.pd-list {
  margin: 0 18px 0 0;
  display: flex;
  flex-direction: column;
  gap: 7px;
  font-size: 13.5px;
  color: var(--text);
  line-height: 1.8;
}
.pd-benefits li::marker { color: var(--green-d); }
.pd-usage li::marker { color: var(--green-d); font-weight: 700; }
/* «تفاصيل ومميزات» قد يضمّ قائمتين (مزايا + مواصفات) داخل قسم واحد الآن */
.pd-list + .pd-list { margin-top: 10px; }
.pd-why {
  font-size: 13.5px;
  color: var(--muted);
  line-height: 1.9;
  background: var(--gray);
  border-radius: 12px;
  padding: 14px 16px;
}

/* =========================================
   OUT OF STOCK — صفحة المنتج (العرض الشفاف: تفاصيل كاملة، شراء معطَّل)
========================================= */
.product-layout-oos .gallery-main { opacity: 0.6; }
.product-availability-oos {
  color: #c0392b;
  background: #fdecea;
  border: 1px solid rgba(192,57,43,0.25);
  border-radius: 10px;
  padding: 10px 14px;
  font-weight: 700;
}
.avail-dot-oos { background: #c0392b; }
.add-cart-btn-oos, .add-cart-btn[disabled] {
  background: var(--gray-2);
  color: var(--muted);
  cursor: not-allowed;
}
.add-cart-btn-oos:hover { background: var(--gray-2); transform: none; box-shadow: none; }
.qty-selector button[disabled] { opacity: 0.4; cursor: not-allowed; }
/* Owner Round 4 (Workstream D1): عتبة دنيا مرئية — السلوك (لا أثر عند 1)
   قائم أصلاً، هذا يجعله ظاهراً بصرياً فقط. aria-disabled لا disabled حقيقية
   كي لا تتعارض مع حالة "غير متوفر" (disabled فعلية، تُضبط مرّة عند الرسم). */
.qty-selector button.at-floor { opacity: 0.4; cursor: not-allowed; }

/* ===== تقليل الحركة — احترام prefers-reduced-motion (PRODUCT.md §الإتاحة) =====
   المستخدم الذي يطلب تقليل الحركة (نظام التشغيل) تصبح كل الانتقالات/الحركات
   لحظية فعلياً بدل إلغائها — لا تُفقد أي وظيفة، فقط تختفي الحركة. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ===== واصف المتغيّر: «المنتج — اللون» =====
   يظهر أسفل دوائر الألوان لا في العنوان: تغيير العنوان مع كل نقرة كان
   يُزحزح ارتفاع الكتلة ويهزّ الصفحة. المساحة محجوزة بارتفاع سطر ثابت
   (min-height) فلا يقفز شيء عند أول ظهور للنصّ. */
.variant-descriptor {
  margin-top: 10px;
  min-height: 1.5em;
  font-size: 14px;
  font-weight: 700;
  color: var(--navy);
}
.variant-descriptor:empty { min-height: 0; margin-top: 0; }
