/*
 * الأساسيات: إعادة الضبط، الطباعة، الحاويات، الشبكات.
 */

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--dm-header-h) + 20px);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--dm-font);
  font-size: var(--dm-fs-base);
  line-height: var(--dm-lh);
  color: var(--dm-text);
  background: var(--dm-bg);
  overflow-x: hidden;
}

body.dm-no-scroll {
  overflow: hidden;
}

/* ------------------------------------------------------------------ */
/* الطباعة وإعادة الضبط                                                */
/* ------------------------------------------------------------------ */

/*
 * الروابط بلا خط سفلي وبلا لون خاص: التصميم يميّزها بموضعها ولونها
 * في كل مكوّن على حدة (زر، رابط قائمة، رقم هاتف)، فلونٌ عام واحد
 * كان يصطدم بكل واحد منها. والخط السفلي يعود وحده عند التركيز
 * بلوحة المفاتيح وداخل نص المقالات، وهما الموضعان اللذان يحتاجانه.
 */
a {
  color: inherit;
  text-decoration: none;
}

a:hover,
a:focus {
  text-decoration: none;
}

/* داخل نص المحرّر الرابط لا يُميَّز إلا بالخط واللون، فيبقيان. */
.dm-prose a {
  color: var(--dm-primary);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.dm-prose a:hover {
  color: var(--dm-primary-dark);
}

/* الصور عناصر كتلية لا تتجاوز حاويتها أبدًا. */
img,
svg,
video,
canvas,
iframe {
  display: block;
  max-width: 100%;
}

img,
video {
  height: auto;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  margin: 0 0 14px;
  font-weight: 700;
  line-height: 1.35;
  color: var(--dm-dark);
}

h1 { font-size: clamp(1.9rem, 4vw, 2.9rem); }
h2 { font-size: clamp(1.5rem, 3vw, 2.2rem); }
h3 { font-size: clamp(1.2rem, 2.2vw, 1.5rem); }
h4 { font-size: 1.1rem; }
h5,
h6 { font-size: 1rem; }

p {
  margin: 0 0 14px;
}

p:last-child {
  margin-bottom: 0;
}

/* القوائم أداة بناء في هذا الثيم لا قوائم نقطية، فتُجرَّد افتراضيًا. */
ul,
ol {
  margin: 0;
  padding: 0;
  list-style: none;
}

/* وتعود نقاطها داخل نص المحرّر وحده. */
.dm-prose ul,
.dm-prose ol {
  margin: 0 0 16px;
  padding-inline-start: 22px;
  list-style: disc;
}

.dm-prose ol {
  list-style: decimal;
}

figure,
blockquote {
  margin: 0;
}

/* العناصر التفاعلية ترث خط الموقع بدل خط النظام. */
button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
}

table {
  width: 100%;
  border-collapse: collapse;
}

strong,
b {
  font-weight: 700;
}

/* ------------------------------------------------------------------ */
/* الحاوية والأقسام                                                    */
/* ------------------------------------------------------------------ */

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

.dm-container--narrow {
  max-width: 860px;
}

.dm-section {
  padding-block: var(--dm-section-y);
}

.dm-section--alt {
  background: var(--dm-bg-alt);
}

/*
 * الطابع الفاخر: خلفية ثابتة خلف الصفحة كلها، والأقسام المتبادلة
 * تصير شفافة فتظهر من خلالها بدل العاجي الباهت. الصنف dm-lux يُضاف
 * من PHP حين تُفعَّل من اللوحة، فلا تنقلب ألوان أي موقع بالصدفة.
 */
body.dm-lux::before,
body.dm-lux::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
}

body.dm-lux::before {
  background-image: var(--dm-body-bg, none);
  background-position: center;
  background-size: cover;
}

body.dm-lux::after {
  background: rgba(var(--dm-overlay-rgb), var(--dm-body-bg-overlay, 0.82));
}

/*
 * القسم العادي لم يكن يرسم خلفيته أصلًا لأن body كان أبيض تحته.
 * مع الخلفية الفاخرة صار «بلا خلفية» يعني «الصورة الداكنة تظهر من
 * خلاله» ونصُّه الداكن يختفي، فلا بد من طلائه صراحةً.
 */
body.dm-lux .dm-section:not(.dm-section--alt),
body.dm-lux .dm-page,
body.dm-lux .dm-menu-page {
  background: var(--dm-bg);
}

body.dm-lux .dm-section--alt {
  background: transparent;
  color: #fff;
}

body.dm-lux .dm-section--alt :is(h1, h2, h3, h4, h5, strong, em, li, td, th),
body.dm-lux .dm-section--alt .dm-sec-head__title {
  color: #fff;
}

body.dm-lux .dm-section--alt :is(p, .dm-sec-head__text, .dm-prose) {
  color: rgba(255, 255, 255, 0.78);
}

body.dm-lux .dm-section--alt .dm-sec-head__eyebrow {
  color: var(--dm-secondary);
  background: rgba(255, 255, 255, 0.1);
}

body.dm-lux .dm-section--alt .dm-sec-head__title span,
body.dm-lux .dm-section--alt .dm-stars {
  color: var(--dm-secondary);
}

/*
 * البطاقات العرضية داخل قسم داكن: زجاج بحافة ذهبية بدل الأبيض المصمت.
 */
body.dm-lux .dm-section--alt :is(.dm-review, .dm-branch, .dm-feature) {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(var(--dm-secondary-rgb), 0.28);
  color: #fff;
}

body.dm-lux .dm-section--alt :is(.dm-review, .dm-branch, .dm-feature) :is(h2, h3, h4, strong) {
  color: #fff;
}

/*
 * أما الأسطح الوظيفية — النماذج والحقول وبطاقات التواصل وكروت
 * الأصناف — فتبقى بيضاء لأن قراءتها أهم من انسجامها، ولذلك تستعيد
 * لون نصها الداكن صراحةً. بغير هذه القاعدة ترث الأبيضَ من القسم
 * فيصير نصٌ أبيض على بطاقة بيضاء.
 */
body.dm-lux .dm-section--alt :is(
  .dm-contact-card, .dm-contact-app, .dm-dish, .dm-post, .dm-qr,
  .dm-form, .dm-field, .dm-book__aside, .dm-book__hours,
  .dm-menu-page__search, .dm-menu-nav, .dm-tabs__nav--pills, .dm-tabs__btn
) {
  color: var(--dm-text);
}

body.dm-lux .dm-section--alt :is(
  .dm-contact-card, .dm-contact-app, .dm-dish, .dm-post, .dm-qr,
  .dm-form, .dm-book__aside, .dm-book__hours
) :is(h1, h2, h3, h4, h5, strong, em, li, p, span, label) {
  color: inherit;
}

/*
 * التبديل التلقائي (dm_section_class) يضمن ألا يتجاور قسمان بنفس
 * الخلفية، لكن القاعدة تبقى شبكة أمان لو طُبع قسم خارج هذا النظام:
 * بلا حدّ لوني يصير الحشوان فراغًا واحدًا ضعف المعتاد.
 */
.dm-section:not(.dm-section--alt) + .dm-section:not(.dm-section--alt),
.dm-section--alt + .dm-section--alt {
  padding-top: calc(var(--dm-section-y) * 0.5);
}

.dm-main {
  min-height: 40vh;
}

.dm-anchor {
  display: block;
  height: 0;
}

/* ------------------------------------------------------------------ */
/* الشبكات                                                             */
/* ------------------------------------------------------------------ */

.dm-grid {
  display: grid;
  gap: clamp(16px, 2vw, 28px);
}

.dm-grid--2 { grid-template-columns: repeat(2, 1fr); }
.dm-grid--3 { grid-template-columns: repeat(3, 1fr); }
.dm-grid--4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 1024px) {
  .dm-grid--4 { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 860px) {
  .dm-grid--3,
  .dm-grid--4 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 560px) {
  .dm-grid--2,
  .dm-grid--3,
  .dm-grid--4 { grid-template-columns: 1fr; }
}

/* ------------------------------------------------------------------ */
/* عناصر مساعدة                                                        */
/* ------------------------------------------------------------------ */

/*
 * الإخفاء بـ inset-inline-start: -9999px يعمل في ltr لكنه في rtl يدفع
 * العنصر إلى يمين المستند فيمدّده آلاف البكسلات ويخلق تمدّدًا أفقيًا.
 * القصّ إلى مربّع بلا أبعاد يخفيه بصريًا في الاتجاهين ويُبقيه متاحًا
 * لقارئ الشاشة، ويعود كاملًا عند التركيز بلوحة المفاتيح.
 */
.dm-skip {
  position: absolute;
  top: 0;
  inset-inline-start: 0;
  z-index: 999;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  padding: 12px 20px;
  background: var(--dm-primary);
  color: #fff;
}

.dm-skip:focus {
  width: auto;
  height: auto;
  clip-path: none;
}

.dm-empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--dm-text-muted);
  background: var(--dm-bg-alt);
  border-radius: var(--dm-radius);
}

/* صورة بديلة عند غياب الصورة، بدل مربع فارغ */
.dm-img-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: 100%;
  min-height: 140px;
  color: rgba(var(--dm-dark-rgb), 0.28);
  font-size: 2rem;
  background:
    repeating-linear-gradient(
      45deg,
      rgba(var(--dm-dark-rgb), 0.04) 0 10px,
      rgba(var(--dm-dark-rgb), 0.07) 10px 20px
    );
}

.dm-img-placeholder em {
  font-size: 0.75rem;
  font-style: normal;
}

.dm-prose {
  color: var(--dm-text-soft);
}

.dm-prose h2,
.dm-prose h3 {
  margin-top: 1.4em;
}

.dm-prose ul {
  margin: 0 0 1em;
  padding-inline-start: 1.2em;
  list-style: disc;
}

.dm-prose img {
  border-radius: var(--dm-radius);
}

/* ترقيم الصفحات */
.dm-section .navigation.pagination {
  margin-top: 48px;
}

.dm-section .nav-links {
  display: flex;
  justify-content: center;
  gap: 8px;
}

.dm-section .page-numbers {
  display: grid;
  place-items: center;
  min-width: 42px;
  height: 42px;
  padding-inline: 10px;
  border: 1px solid var(--dm-border);
  border-radius: var(--dm-radius-sm);
  font-weight: 600;
  background: #fff;
}

.dm-section .page-numbers.current,
.dm-section .page-numbers:hover {
  color: #fff;
  background: var(--dm-primary);
  border-color: var(--dm-primary);
}

.screen-reader-text {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(1px, 1px, 1px, 1px);
  white-space: nowrap;
}
