/* ============================================================
   JAZEER — طبقة الصقل البصري
   يُحمَّل بعد كل ملفات CSS الأخرى ليتقدم عليها في التتالي.
   يعتمد على متغيرات القوالب الموجودة، فيعمل مع القوالب الخمسة.
   ============================================================ */

/* ---------- 1. نظام نسب الصور ----------
   صورك عمودية بنسب مختلطة (4:5 و 2:3). نثبّت النسبة مرة واحدة
   بدل الاعتماد على ارتفاعات ثابتة تختلف بين الملفات. */

.card-image {
  aspect-ratio: 4 / 5;
  height: auto !important;
  min-height: 0 !important;
  background: color-mix(in srgb, var(--cream) 70%, var(--line));
  display: grid;
  place-items: center;
}

.card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 42%;
}

/* البطاقة الأفقية في نمط الكتالوج تحتفظ بشكلها المربّع */
[data-products-layout="catalog"] .card-image {
  aspect-ratio: 1 / 1;
}

/* ---------- 2. إطار صورة المنتج ----------
   contain بدل cover: المنتج يظهر كاملاً، والإطار يمنحه
   هامشاً محترماً بدل أشرطة فارغة قبيحة. */

.detail-image {
  aspect-ratio: 4 / 5;
  min-height: 0 !important;
  background:
    radial-gradient(ellipse 60% 40% at 50% 88%,
      color-mix(in srgb, var(--ink) 9%, transparent), transparent 70%),
    linear-gradient(168deg, var(--white), color-mix(in srgb, var(--cream) 92%, var(--line)));
  border: 1px solid color-mix(in srgb, var(--line) 80%, transparent);
  padding: clamp(18px, 3vw, 40px);
  display: grid;
  place-items: center;
  overflow: hidden;
}

.detail-image img {
  width: 100%;
  height: 100%;
  object-fit: contain !important;
  filter: drop-shadow(0 18px 28px color-mix(in srgb, var(--ink) 16%, transparent));
  transition: transform .6s cubic-bezier(.16, .84, .44, 1);
}

/* تكبير هادئ بالمرور — لا يقص شيئاً لأن الإطار مبطّن */
.detail-image:hover img {
  transform: scale(1.05);
}

@media (max-width: 760px) {
  .detail-image {
    aspect-ratio: 1 / 1;
    padding: 16px;
  }
  .detail-image:hover img { transform: none; }
}

/* ---------- 3. هدوء الحركة ----------
   الانزلاق المتناوب يمنة ويسرة يشتّت العين ويوحي بقالب جاهز.
   نستبدله بظهور واحد صاعد وهادئ. */

.product-card {
  opacity: 0;
  transform: translateY(14px) !important;
  animation: cardRise .5s cubic-bezier(.22, .8, .3, 1) forwards;
  animation-delay: var(--delay);
}

.product-card:nth-child(even) {
  transform: translateY(14px) !important;
}

@keyframes cardRise {
  to { opacity: 1; transform: translateY(0) !important; }
}

.product-card:hover {
  transform: translateY(-5px) !important;
  box-shadow: 0 18px 40px color-mix(in srgb, var(--ink) 13%, transparent);
}

/* الشعار الوامض المستمر يرهق العين ويبدو هاوياً */
.logo-wrap img {
  animation: none !important;
  filter: none !important;
}

@media (prefers-reduced-motion: reduce) {
  .product-card {
    opacity: 1;
    transform: none !important;
    animation: none;
  }
  html { scroll-behavior: auto; }
  * { transition-duration: .01ms !important; }
}

/* ---------- 4. تسلسل السعر ----------
   السعر بعد الخصم هو المعلومة، والسعر القديم مرجع ثانوي. */

.card-bottom .price strong,
.detail-price strong {
  font-variant-numeric: tabular-nums;
  letter-spacing: -.01em;
}

.card-bottom .price del,
.detail-price del {
  opacity: .5;
  font-size: .82em;
  text-decoration-thickness: 1px;
}

/* ---------- 5. هياكل التحميل ----------
   بدل دوّارة مبهمة: أشكال بحجم البطاقة الحقيقي،
   فلا تقفز الصفحة عند وصول البيانات. */

.skeleton-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 22px;
}

.skeleton-card {
  border: 1px solid var(--line);
  background: var(--white);
  overflow: hidden;
}

.skeleton-card i {
  display: block;
  aspect-ratio: 4 / 5;
  background: linear-gradient(100deg,
    color-mix(in srgb, var(--line) 45%, var(--white)) 30%,
    color-mix(in srgb, var(--line) 80%, var(--white)) 50%,
    color-mix(in srgb, var(--line) 45%, var(--white)) 70%);
  background-size: 220% 100%;
  animation: shimmer 1.3s linear infinite;
}

.skeleton-card b,
.skeleton-card s {
  display: block;
  height: 11px;
  margin: 14px 16px;
  border-radius: 3px;
  background: color-mix(in srgb, var(--line) 60%, var(--white));
}

.skeleton-card s { width: 55%; }

@keyframes shimmer {
  to { background-position: -220% 0; }
}

@media (max-width: 1100px) { .skeleton-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 760px)  { .skeleton-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; } }

@media (prefers-reduced-motion: reduce) {
  .skeleton-card i { animation: none; }
}

/* ---------- 6. قسم المنتجات المقترحة ---------- */

.related-section {
  width: min(1400px, 88vw);
  margin: clamp(48px, 7vw, 96px) auto 0;
  padding-top: clamp(32px, 5vw, 56px);
  border-top: 1px solid var(--line);
}

.related-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: clamp(20px, 3vw, 32px);
}

.related-head span {
  display: block;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .16em;
  color: var(--orange);
  margin-bottom: 8px;
}

.related-head h2 {
  margin: 0;
  font-size: clamp(21px, 2.4vw, 30px);
  font-weight: 700;
  letter-spacing: -.02em;
}

.related-head a {
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
  white-space: nowrap;
  border-bottom: 1px solid transparent;
  transition: .2s;
}

.related-head a:hover {
  color: var(--ink);
  border-bottom-color: var(--orange);
}

.related-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 22px;
}

@media (max-width: 1100px) { .related-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 760px) {
  .related-section { width: 92vw; }
  .related-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
}

/* ---------- 7. شريط الطلب الثابت على الموبايل ----------
   في متجر يعتمد على واتساب، زر الطلب هو الواجهة كلها.
   لا يجوز أن يختفي عند التمرير. */

.order-bar {
  position: fixed;
  inset-inline: 0;
  bottom: 0;
  z-index: 40;
  display: none;
  align-items: center;
  gap: 14px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--white) 92%, transparent);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  box-shadow: 0 -8px 30px color-mix(in srgb, var(--ink) 12%, transparent);
}

.order-bar .bar-price {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}

.order-bar .bar-price strong {
  font-size: 19px;
  font-variant-numeric: tabular-nums;
}

.order-bar .bar-price del {
  font-size: 12px;
  opacity: .5;
}

.order-bar .buy-button {
  margin: 0 0 0 auto;
  flex: 1;
  max-width: 62%;
  text-align: center;
}

@media (max-width: 760px) {
  .order-bar { display: flex; }
  body.has-order-bar .detail-main { padding-bottom: 96px; }
  /* زر الطلب داخل البطاقة صار مكرراً */
  .detail-info > .buy-button { display: none; }
}

/* ---------- 8. تركيز لوحة المفاتيح ----------
   كان غائباً تماماً. شرط أساسي لأي واجهة جادة. */

a:focus-visible,
button:focus-visible,
input:focus-visible,
.product-card:focus-visible {
  outline: 2px solid var(--orange);
  outline-offset: 3px;
  border-radius: 2px;
}

.category[aria-pressed="true"] {
  border-color: var(--orange);
}

/* ---------- 9. إصلاح خط القالب الفاخر ----------
   signature-theme.css يفرض Arial فيلغي الخط العربي. */

[data-theme="signature"],
[data-theme="signature"] body,
[data-theme="signature"] h1,
[data-theme="signature"] h2,
[data-theme="signature"] h3 {
  font-family: 'Readex Pro', 'Tajawal', Tahoma, sans-serif !important;
}

/* ---------- 10. سلّم الطباعة ----------
   عناوين أكثر إحكاماً، ونص أسهل قراءة بالعربية. */

h1, h2, h3, .card-body h3 {
  letter-spacing: -.02em;
  text-wrap: balance;
}

.description,
.card-body p {
  line-height: 1.85;
  text-wrap: pretty;
}

.card-body h3 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 2.6em;
}
