/* ==========================================================================
   Arabshop — التهيئة الأساسية والطباعة والأدوات المساعدة
   الاتجاه RTL افتراضي؛ كل التخطيط مبني على الخصائص المنطقية
   (margin-inline / inset-inline) لا على left/right.
   ========================================================================== */

*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: 6rem;
}

body {
  min-height: 100vh;
  background-color: var(--bg);
  color: var(--ink-900);
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

img, picture, svg, video { display: block; max-width: 100%; }
img { height: auto; }
input, button, textarea, select { font: inherit; color: inherit; background: none; border: 0; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; }
a { color: inherit; text-decoration: none; }
ul, ol { list-style: none; }
table { border-collapse: collapse; width: 100%; }

h1, h2, h3, h4, h5 {
  font-family: var(--font-display);
  font-weight: 800;
  line-height: var(--leading-tight);
  color: var(--ink-900);
  text-wrap: balance;
  overflow-wrap: break-word; /* a long word never pushes past a 360px screen */
}

h1 { font-size: var(--text-3xl); }
h2 { font-size: var(--text-2xl); }
h3 { font-size: var(--text-xl); }
h4 { font-size: var(--text-lg); }

p { text-wrap: pretty; }

:focus-visible {
  outline: 3px solid var(--brand-300);
  outline-offset: 2px;
  border-radius: var(--r-xs);
}

::selection { background: var(--brand-600); color: var(--on-primary); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--surface-muted); }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: var(--r-full); }
::-webkit-scrollbar-thumb:hover { background: var(--ink-300); }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ── الهيكل ───────────────────────────────────────────────────────────── */

.page { display: flex; min-height: 100vh; flex-direction: column; }
.page__main { flex: 1; }

.container {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.container--narrow { max-width: var(--container-narrow); }
.container--full { max-width: none; } /* "Full width" sections: edge to edge, keeping the side gutter */

/* المسافة بين الأقسام من الإعدادات (section_spacing)، ولكل قسم نسبة أعلى/أسفل (--pt/--pb من padding_top/padding_bottom) */
.section { padding-block: calc(var(--section-space) * 0.83 * var(--pt, 1)) calc(var(--section-space) * 0.83 * var(--pb, 1)); }
.section--tight { padding-block: calc(var(--section-space) * 0.66 * var(--pt, 1)) calc(var(--section-space) * 0.66 * var(--pb, 1)); }
.section--flush-top { padding-block-start: 0; }

@media (min-width: 1024px) {
  .section { padding-block: calc(var(--section-space) * 1.33 * var(--pt, 1)) calc(var(--section-space) * 1.33 * var(--pb, 1)); }
  .section--tight { padding-block: calc(var(--section-space) * 0.83 * var(--pt, 1)) calc(var(--section-space) * 0.83 * var(--pb, 1)); }
}

/* عنوان قسم مع رابط "عرض الكل": شبكة. السطر الصغير (eyebrow) في صفّ فوق العنوان، والرابط (والعدّاد) في صفّ العنوان
   نفسه، فيتوسّطان سطر العنوان لا كتلة العنوان كلها. حاوية العناوين تذوب في الشبكة (display: contents) إلا إذا كانت
   مخفية للقارئ فقط (sr-only). */
.section-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: "eyebrow eyebrow" "title more";
  align-items: center;
  column-gap: var(--space-4);
  margin-block-end: var(--space-6);
}

.section-head__titles { display: flex; flex-direction: column; gap: 0.25rem; }
.section-head > .section-head__titles { grid-area: title; }
.section-head > .section-head__titles:not(.sr-only) { display: contents; }
.section-head .section-head__eyebrow { grid-area: eyebrow; justify-self: start; margin-block-end: 0.25rem; }
.section-head .section-head__title { grid-area: title; }
.section-head .section-head__link { grid-area: more; }

.section-head__eyebrow {
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--brand-600);
}

.section-head__title { font-size: var(--text-xl); }

@media (min-width: 768px) {
  .section-head__title { font-size: var(--text-2xl); }
}

.section-head__link {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  flex-shrink: 0;
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--brand-600);
  transition: gap var(--t-fast) var(--ease);
}

.section-head__link:hover { gap: 0.625rem; }

/* عنوان قسم فيه عدّاد (flash-head): على الجوال وفي «تحت العنوان» العدّاد في صفّ ثالث تحت العنوان؛ من 640px
   «في المنتصف» (--tri) و«في الطرف» (flash-head--end) في صفّ العنوان نفسه */
.section-head .countdown { grid-area: cd; justify-self: start; margin-block-start: var(--space-3); }
.flash-head { grid-template-areas: "eyebrow eyebrow" "title more" "cd cd"; }
@media (min-width: 640px) {
  .section-head--tri, .flash-head--end { grid-template-areas: "eyebrow eyebrow eyebrow" "title cd more"; }
  .section-head--tri { grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); }
  .flash-head--end { grid-template-columns: minmax(0, 1fr) auto auto; }
  /* no "View all": the countdown takes its place at the very edge */
  .flash-head--end:not(:has(.section-head__link)) { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "eyebrow eyebrow" "title cd"; }
  .section-head--tri .countdown, .flash-head--end .countdown { margin-block-start: 0; }
  .section-head--tri .countdown { justify-self: center; }
  .section-head--tri .section-head__link { justify-self: end; }
}

/* ── الأدوات المساعدة ─────────────────────────────────────────────────── */

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute;
  inset-inline-start: 50%;
  top: -100px;
  z-index: 100;
  transform: translateX(50%);
  padding: 0.75rem 1.25rem;
  border-radius: 0 0 var(--r-md) var(--r-md);
  background: var(--brand-600);
  color: var(--on-primary);
  font-weight: 700;
  transition: top var(--t-base) var(--ease);
}

.skip-link:focus { top: 0; }
[dir="ltr"] .skip-link { transform: translateX(-50%); }

.clamp-1, .clamp-2, .clamp-3 {
  display: -webkit-box; -webkit-box-orient: vertical; overflow: hidden;
}
.clamp-1 { -webkit-line-clamp: 1; line-clamp: 1; }
.clamp-2 { -webkit-line-clamp: 2; line-clamp: 2; }
.clamp-3 { -webkit-line-clamp: 3; line-clamp: 3; }

.muted   { color: var(--ink-500); }
.muted-2 { color: var(--ink-400); }
.strong  { font-weight: 700; }

.text-xs { font-size: var(--text-xs); }
.text-sm { font-size: var(--text-sm); }
.text-lg { font-size: var(--text-lg); }

.stack   { display: flex; flex-direction: column; }
.stack-2 { gap: var(--space-2); }
.stack-3 { gap: var(--space-3); }
.stack-4 { gap: var(--space-4); }
.stack-6 { gap: var(--space-6); }

.row { display: flex; align-items: center; gap: var(--space-3); }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); }
.row-wrap { flex-wrap: wrap; }

.divider { height: 1px; background: var(--border); border: 0; }
.divider--v { width: 1px; height: 1.5rem; background: var(--border); }

[hidden] { display: none !important; }
.is-hidden { display: none !important; }

.grow { flex: 1; }
.center { text-align: center; }

/* ── الأيقونات ────────────────────────────────────────────────────────── */

.icon {
  display: inline-block;
  flex-shrink: 0;
  width: 1.25rem;
  height: 1.25rem;
  stroke-width: 1.75;
  vertical-align: middle;
}

.icon--xs { width: 0.875rem; height: 0.875rem; }
.icon--sm { width: 1rem;     height: 1rem; }
.icon--md { width: 1.125rem; height: 1.125rem; }
.icon--lg { width: 1.5rem;   height: 1.5rem; }
.icon--xl { width: 2rem;     height: 2rem; }
.icon--2xl{ width: 2.75rem;  height: 2.75rem; }

/* الأسهم والشيفرونات مرسومة لاتجاه العربية (الأمام = يسار)، وتنعكس في الإنجليزية */
[dir="ltr"] .icon--flip { transform: scaleX(-1); }

.spin { animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── الأرقام والأسعار ─────────────────────────────────────────────────── */

/* الأرقام تبقى بالاتجاه اللاتيني داخل النص العربي */
.num {
  font-variant-numeric: tabular-nums;
  unicode-bidi: plaintext;
}

.price {
  display: inline-flex;
  align-items: baseline;
  gap: 0.25rem;
  font-weight: 800;
  color: var(--ink-900);
  unicode-bidi: plaintext;
}

.price__currency { font-size: 0.75em; font-weight: 600; color: var(--ink-500); }
.price--lg { font-size: var(--text-xl); }
.price--xl { font-size: var(--text-2xl); }

.price-was {
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--ink-400);
  text-decoration: line-through;
  unicode-bidi: plaintext;
}

/* ── الزخرفة الهندسية ─────────────────────────────────────────────────── */

/* نجمة ثمانية متكررة مستوحاة من الزخرفة الإسلامية — تُستخدم كطبقة خفيفة */
.pattern {
  background-image: url('../images/pattern.svg');
  background-size: 132px;
  background-repeat: repeat;
}

.pattern--fade {
  -webkit-mask-image: linear-gradient(to bottom, var(--ink), transparent);
  mask-image: linear-gradient(to bottom, var(--ink), transparent);
}

/* محاذاة عنوان القسم (title_align) */
.section-head--center { grid-template-columns: auto auto; grid-template-areas: "eyebrow ." "title more"; justify-content: center; text-align: center; }
.section-head--center .section-head__titles { align-items: center; }
.section-head--center .section-head__eyebrow { justify-self: center; }
/* centred with a countdown: one column in the middle (title, countdown, link) */
.section-head--center.flash-head, .section-head--center.flash-head--end, .section-head--center.section-head--tri {
  grid-template-columns: auto; grid-template-areas: "eyebrow" "title" "cd" "more"; justify-items: center;
}
.section-head--center.flash-head .countdown { justify-self: center; margin-block-start: var(--space-3); }
.section-head--center.flash-head .section-head__link { margin-block-start: var(--space-3); }
.section-title { margin-block-end: var(--space-5); }
.section-title--center { text-align: center; }

/* Theme editor preview only: what an empty section needs (request.design_mode) */
.editor-hint { display: flex; align-items: center; gap: var(--space-2); margin-block: var(--space-4); padding: var(--space-4); border: 1px dashed var(--border-strong); border-radius: var(--r-md); color: var(--ink-500); font-size: var(--text-sm); background: var(--surface-muted); }

/* page to page: a soft cross-fade instead of a white flash (browsers with cross-document view transitions;
   others navigate as before). Not with reduced motion. */
@media (prefers-reduced-motion: no-preference) {
  @view-transition { navigation: auto; }
  ::view-transition-old(root), ::view-transition-new(root) { animation-duration: 180ms; }
}

/* A section shown on one kind of device only (show_on, UI/own-colors); phones = below 900px like the product page. */
@media (min-width: 900px) { .only-phone { display: none !important; } }
@media (max-width: 899px) { .only-desktop { display: none !important; } }
