/* ======================================================================
   كتبي PDF — تصميم المقالات
   يُحمَّل في صفحات الكتب والروايات والمؤلفين، وداخل محرر لوحة التحكم
   (نفس الملف = ما تراه في المحرر هو ما يظهر في الموقع).
   يعتمد على متغيرات الهوية في style.css ويدعم الوضع الليلي والنهاري.
   ====================================================================== */

/* ---------- الغلاف ---------- */
.art {
  position: relative;
  min-width: 0;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}
.art::before {
  content: "";
  position: absolute;
  inset-inline: 0;
  top: 0;
  height: 4px;
  background: var(--gradient-gold);
}
.art::after {
  content: "";
  position: absolute;
  top: -120px;
  inset-inline-end: -90px;
  width: 340px;
  height: 340px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--gold-dim), transparent 68%);
  opacity: .7;
  pointer-events: none;
}
.art > * { position: relative; z-index: 1; }

/* ---------- رأس المقال ---------- */
.art-head { padding: 52px 48px 10px; text-align: center; }
.art-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 18px;
  border-radius: var(--radius-pill);
  background: var(--gold-dim);
  color: var(--gold-light);
  font-size: 13.5px;
  font-weight: 800;
  box-shadow: inset 0 0 0 1px var(--border);
}
.art-title {
  margin: 20px auto 0;
  max-width: 820px;
  font-size: clamp(26px, 4.2vw, 40px);
  font-weight: 900;
  line-height: 1.55;
  color: var(--text);
  overflow-wrap: anywhere;
}
.art-title::after {
  content: "";
  display: block;
  width: 96px;
  height: 4px;
  margin: 22px auto 0;
  border-radius: 4px;
  background: var(--gradient-gold);
}
.art-meta { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 20px; }
.art-meta span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 700;
}
.art-meta svg { color: var(--gold); }

/* ---------- فهرس المقال ---------- */
.art-toc { max-width: 860px; margin: 26px auto 4px; padding: 0 48px; }
.art-toc details {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 4px 22px;
}
.art-toc summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 0;
  cursor: pointer;
  list-style: none;
  font-weight: 800;
  font-size: 16px;
  color: var(--text);
}
.art-toc summary::-webkit-details-marker { display: none; }
.art-toc summary::after { content: "−"; color: var(--gold); font-size: 22px; line-height: 1; }
.art-toc details:not([open]) summary::after { content: "+"; }
.art-toc ol { margin: 0; padding: 2px 0 16px; list-style: none; counter-reset: artoc; }
.art-toc li { margin: 0; padding: 6px 0; line-height: 1.8; }
.art-toc li.art-toc-2 { counter-increment: artoc; font-weight: 700; }
.art-toc li.art-toc-2::before {
  content: counter(artoc);
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  margin-inline-end: 10px;
  border-radius: 50%;
  background: var(--gold-dim);
  color: var(--gold-light);
  font-size: 13px;
  font-weight: 900;
}
.art-toc li.art-toc-3 { padding-inline-start: 38px; font-size: 14.5px; }
.art-toc li.art-toc-3::before { content: "◆"; margin-inline-end: 9px; color: var(--gold); font-size: 8px; vertical-align: middle; }
.art-toc a { color: var(--text-muted); transition: color var(--transition); }
.art-toc a:hover { color: var(--gold-light); }

/* ---------- جسم المقال ---------- */
.art-body {
  max-width: 860px;
  margin-inline: auto;
  padding: 26px 48px 52px;
  font-family: var(--font-body);
  font-size: 17.5px;
  line-height: 2.15;
  color: var(--text);
  counter-reset: art-h2;
  overflow-wrap: anywhere;
}
.art-body > :first-child { margin-top: 0; }
.art-body > :last-child { margin-bottom: 0; }

.art-body p {
  margin: 0 0 1.3em;
  color: var(--text-muted);
  color: color-mix(in srgb, var(--text) 86%, transparent);
}
.art-body strong, .art-body b { color: var(--text); font-weight: 800; }
.art-body em, .art-body i { font-style: normal; color: var(--gold-light); font-weight: 700; }
.art-body u { text-decoration: underline; text-decoration-color: var(--gold); text-decoration-thickness: 2px; text-underline-offset: 6px; }
.art-body s, .art-body del { color: var(--text-faint); }
.art-body sub, .art-body sup { font-size: .75em; line-height: 0; }
.art-body a {
  color: var(--gold-light);
  font-weight: 700;
  border-bottom: 1px dashed var(--border-strong);
  transition: color var(--transition), border-color var(--transition);
}
.art-body a:hover { color: var(--gold); border-bottom-color: var(--gold); }
.art-body mark {
  padding: 1px 8px;
  border-radius: 7px;
  background: var(--gold-dim);
  color: var(--gold-light);
  font-weight: 800;
}
.art-body .art-badge {
  display: inline-block;
  padding: 1px 12px;
  border-radius: var(--radius-pill);
  background: var(--gold-dim);
  border: 1px solid var(--border-strong);
  color: var(--gold-light);
  font-size: .85em;
  font-weight: 800;
  line-height: 1.9;
}
.art-body kbd {
  padding: 2px 9px;
  border-radius: 7px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-bottom-width: 3px;
  font: 700 .85em/1.6 ui-monospace, Menlo, Consolas, monospace;
  color: var(--text);
  direction: ltr;
  unicode-bidi: isolate;
}
.art-body abbr[title] { text-decoration: underline dotted var(--gold); cursor: help; }

/* الفقرات الخاصة */
.art-body p.art-lead {
  margin-bottom: 1.6em;
  padding-inline-start: 22px;
  border-inline-start: 4px solid var(--gold);
  font-size: 1.16em;
  font-weight: 600;
  line-height: 2.1;
  color: var(--text);
}
.art-body p.art-pull {
  margin: 2em 0;
  padding: 26px 14px;
  text-align: center;
  font-size: 1.4em;
  font-weight: 800;
  line-height: 1.9;
  color: var(--gold-light);
  border-block: 1px solid var(--border-strong);
}
.art-body p.art-pull::before {
  content: "\201C";
  display: block;
  height: .5em;
  font: 900 3.2em/1 Georgia, serif;
  color: var(--gold);
  opacity: .8;
}

/* ---------- العناوين ---------- */
.art-body h2, .art-body h3, .art-body h4 { scroll-margin-top: 96px; }
.art-body h2 {
  counter-increment: art-h2;
  position: relative;
  margin: 2.3em 0 .9em;
  padding-bottom: 16px;
  font-size: 1.62em;
  font-weight: 900;
  line-height: 1.55;
  color: var(--text);
  border-bottom: 1px solid var(--border);
}
.art-body h2::before {
  content: counter(art-h2);
  display: inline-grid;
  place-items: center;
  width: 1.55em;
  height: 1.55em;
  margin-inline-end: 14px;
  border-radius: 50%;
  background: var(--gradient-gold);
  color: #221a0d;
  font-size: .7em;
  font-weight: 900;
  vertical-align: middle;
  box-shadow: var(--shadow-gold);
}
.art-body h2::after {
  content: "";
  position: absolute;
  inset-inline-start: 0;
  bottom: -2px;
  width: 96px;
  height: 3px;
  border-radius: 3px;
  background: var(--gradient-gold);
}
.art-body h3 {
  margin: 2em 0 .7em;
  padding: 4px 18px 4px 0;
  padding-inline: 18px 0;
  border-inline-start: 4px solid var(--gold);
  font-size: 1.25em;
  font-weight: 800;
  line-height: 1.7;
  color: var(--text);
}
.art-body h4 {
  margin: 1.7em 0 .5em;
  font-size: 1.05em;
  font-weight: 800;
  color: var(--gold-light);
}
.art-body h4::before { content: "\2726"; margin-inline-end: 10px; color: var(--gold); }

/* ---------- القوائم ---------- */
.art-body ul, .art-body ol { margin: 0 0 1.5em; padding: 0; list-style: none; }
.art-body li { position: relative; margin: 0 0 .6em; padding-inline-start: 32px; color: var(--text-muted); color: color-mix(in srgb, var(--text) 86%, transparent); }
.art-body li > p { margin: 0 0 .5em; }
.art-body li > ul, .art-body li > ol { margin: .6em 0 .2em; }
.art-body ul > li::before {
  content: "";
  position: absolute;
  inset-inline-start: 6px;
  top: .82em;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--gradient-gold);
  box-shadow: 0 0 0 4px var(--gold-dim);
}
.art-body ul ul > li::before { width: 8px; height: 8px; background: transparent; border: 2px solid var(--gold); box-shadow: none; }

.art-body ol { counter-reset: art-ol; }
.art-body ol[start="2"] { counter-reset: art-ol 1; }
.art-body ol[start="3"] { counter-reset: art-ol 2; }
.art-body ol[start="4"] { counter-reset: art-ol 3; }
.art-body ol[start="5"] { counter-reset: art-ol 4; }
.art-body ol[start="6"] { counter-reset: art-ol 5; }
.art-body ol > li { counter-increment: art-ol; padding-inline-start: 50px; }
.art-body ol > li::before {
  content: counter(art-ol);
  position: absolute;
  inset-inline-start: 0;
  top: .5em;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--gold-dim);
  border: 1px solid var(--gold);
  color: var(--gold-light);
  font-size: 15px;
  font-weight: 900;
  line-height: 1;
}
.art-body ol.art-steps > li {
  padding: 18px 70px 18px 22px;
  padding-inline: 22px 72px;
  margin-bottom: 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}
.art-body ol.art-steps > li::before {
  inset-inline-start: auto;
  inset-inline-end: 18px;
  top: 16px;
  width: 38px;
  height: 38px;
  border: 0;
  background: var(--gradient-gold);
  color: #221a0d;
  font-size: 17px;
  box-shadow: var(--shadow-gold);
}
.art-body ul.art-checks > li::before,
.art-body .art-keypoints ul > li::before {
  content: "\2713";
  top: .5em;
  inset-inline-start: 0;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 0;
  background: var(--teal-dim);
  color: var(--teal);
  box-shadow: none;
  font-size: 14px;
  font-weight: 900;
}
.art-body ul.art-checks > li, .art-body .art-keypoints ul > li { padding-inline-start: 40px; }

/* ---------- الصناديق ---------- */
.art-body .art-callout {
  --c: var(--gold);
  --cd: var(--gold-dim);
  position: relative;
  margin: 1.9em 0;
  padding: 18px 24px 8px;
  border-radius: var(--radius-md);
  background: var(--cd);
  border: 1px solid var(--border-strong);
  border-inline-start: 4px solid var(--c);
}
.art-body .art-callout::before {
  content: "\0645\0639\0644\0648\0645\0629";
  display: block;
  width: max-content;
  margin-bottom: 10px;
  padding: 2px 14px;
  border-radius: var(--radius-pill);
  background: var(--c);
  color: #14110a;
  font-size: 13px;
  font-weight: 900;
  line-height: 1.9;
}
html[data-theme="light"] .art-body .art-callout::before { color: #fff; }
.art-body .art-callout p { color: var(--text); }
.art-body .art-callout li { color: var(--text); }
.art-body .art-note { --c: var(--teal); --cd: var(--teal-dim); }
.art-body .art-note::before { content: "\0645\0644\0627\062D\0638\0629"; }
.art-body .art-tip { --c: var(--gold); --cd: var(--gold-dim); }
.art-body .art-tip::before { content: "\0646\0635\064A\062D\0629"; }
.art-body .art-info { --c: var(--violet); --cd: var(--violet-dim); }
.art-body .art-info::before { content: "\0645\0639\0644\0648\0645\0629"; }
html[data-theme="dark"] .art-body .art-info::before { color: #fff; }
.art-body .art-warn { --c: var(--rose); --cd: var(--rose-dim); }
.art-body .art-warn::before { content: "\062A\0646\0628\064A\0647"; }

.art-body .art-keypoints {
  position: relative;
  margin: 2em 0;
  padding: 26px 28px 12px;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, var(--gold-dim), transparent 70%), var(--bg-elevated);
  border: 1px solid var(--gold);
  box-shadow: var(--shadow-sm);
}
.art-body .art-keypoints::before {
  content: "\2726  \0623\0647\0645  \0627\0644\0646\0642\0627\0637";
  display: block;
  margin-bottom: 14px;
  font-size: 1.1em;
  font-weight: 900;
  color: var(--gold-light);
}
.art-body .art-keypoints p { color: var(--text); }

/* ---------- الاقتباس ---------- */
.art-body blockquote {
  position: relative;
  margin: 2em 0;
  padding: 28px 32px 22px;
  border-radius: var(--radius-lg);
  background: linear-gradient(120deg, var(--gold-dim), transparent 80%), var(--bg-elevated);
  border: 1px solid var(--border);
  border-inline-start: 4px solid var(--gold);
  font-size: 1.1em;
  font-weight: 600;
  line-height: 2.1;
}
.art-body blockquote::before {
  content: "\201D";
  position: absolute;
  top: 6px;
  inset-inline-end: 20px;
  font: 900 76px/1 Georgia, serif;
  color: var(--gold);
  opacity: .3;
  pointer-events: none;
}
.art-body blockquote p { margin: 0 0 .7em; color: var(--text); }
.art-body blockquote > :last-child { margin-bottom: 0; }
.art-body cite { display: block; margin-top: 12px; font-size: 14px; font-style: normal; font-weight: 800; color: var(--gold-light); }
.art-body cite::before { content: "\2014  "; }

/* ---------- الفاصل ---------- */
.art-body hr {
  position: relative;
  height: 1px;
  margin: 2.8em 0;
  border: 0;
  overflow: visible;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
}
.art-body hr::after {
  content: "\2726";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  padding: 0 16px;
  background: var(--surface);
  color: var(--gold);
  font-size: 15px;
  line-height: 1;
}

/* ---------- الجداول ---------- */
.art-body .art-table-wrap {
  margin: 2em 0;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}
.art-body table { width: 100%; border-collapse: collapse; font-size: .92em; line-height: 1.9; }
.art-body .art-table-wrap table { min-width: 480px; }
.art-body th, .art-body td {
  padding: 12px 18px;
  border: 0;
  border-bottom: 1px solid var(--border);
  text-align: start;
  vertical-align: top;
  color: var(--text-muted);
}
.art-body th {
  background: var(--gold-dim);
  color: var(--gold-light);
  font-weight: 800;
  border-bottom: 1px solid var(--border-strong);
}
.art-body tr:last-child > td { border-bottom: 0; }
.art-body table.art-striped tbody tr:nth-child(even) { background: var(--bg-elevated); }
.art-body caption { caption-side: bottom; padding: 12px; font-size: 13.5px; color: var(--text-faint); }
.art-body > table { margin: 2em 0; border: 1px solid var(--border); }

/* ---------- الصور والوسائط ---------- */
.art-body img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 2em auto;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
}
.art-body img.art-img-wide { width: 100%; }
.art-body img.art-img-small { max-width: 320px; }
.art-body figure { margin: 2.2em 0; text-align: center; }
.art-body figure img { margin: 0 auto; }
.art-body figcaption { margin-top: 14px; font-size: 14px; line-height: 1.8; color: var(--text-faint); }
.art-body iframe {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  height: auto;
  margin: 2em 0;
  border: 0;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  background: #000;
}

/* ---------- الكود ---------- */
.art-body code {
  padding: 2px 9px;
  border-radius: 7px;
  background: var(--gold-dim);
  color: var(--gold-light);
  font: 600 .86em/1.7 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  direction: ltr;
  unicode-bidi: isolate;
}
.art-body pre {
  margin: 2em 0;
  padding: 20px 22px;
  overflow-x: auto;
  direction: ltr;
  text-align: left;
  background: #0b0e14;
  color: #e8e6df;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  font: 500 14px/1.85 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.art-body pre code { padding: 0; background: none; color: inherit; font: inherit; }

/* ---------- التفاصيل القابلة للطي ---------- */
.art-body details {
  margin: 1.4em 0;
  padding: 0 20px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition: border-color var(--transition);
}
.art-body details[open] { border-color: var(--gold); }
.art-body summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 0;
  cursor: pointer;
  list-style: none;
  font-weight: 800;
  color: var(--text);
}
.art-body summary::-webkit-details-marker { display: none; }
.art-body summary::after { content: "+"; color: var(--gold); font-size: 24px; line-height: 1; }
.art-body details[open] > summary::after { content: "\2212"; }
.art-body details > :not(summary):last-child { margin-bottom: 18px; }

/* ---------- الجوال ---------- */
@media (max-width: 720px) {
  .art-head { padding: 36px 20px 4px; }
  .art-toc { padding: 0 16px; }
  .art-toc details { padding: 2px 16px; }
  .art-body { padding: 20px 20px 36px; font-size: 16.5px; line-height: 2.05; }
  .art-body h2 { font-size: 1.45em; }
  .art-body blockquote { padding: 24px 20px 18px; }
  .art-body .art-keypoints { padding: 22px 18px 8px; }
  .art-body ol.art-steps > li { padding: 16px 16px 16px 60px; padding-inline: 16px 60px; }
  .art-body ol.art-steps > li::before { inset-inline-end: 12px; }
}
@media print {
  .art { box-shadow: none; border-color: #ccc; }
  .art::after { display: none; }
}

/* ---------- داخل المحرر (TinyMCE) ---------- */
body.art-body.art-editing {
  max-width: none;
  margin: 0;
  padding: 26px 36px 60px;
  background: var(--surface);
  overflow-x: hidden;
}
body.art-editing .art-callout, body.art-editing .art-keypoints { min-height: 3em; }

/* ---------- أزرار المقال (زر «إدراج زر» في المحرر) ---------- */
.art-body p.art-btn-row { text-align: center; margin: 24px 0; }
.art-body a.art-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 28px;
  border: 0;
  border-radius: 999px;
  background: var(--gradient-gold);
  color: #221a0d;
  font-weight: 800;
  font-size: 16px;
  line-height: 1.5;
  text-decoration: none;
  box-shadow: 0 10px 24px -12px rgba(217, 177, 106, .75);
  transition: transform var(--transition), box-shadow var(--transition), filter var(--transition);
}
.art-body a.art-btn:hover { color: #221a0d; border: 0; transform: translateY(-2px); filter: brightness(1.06); box-shadow: 0 14px 28px -12px rgba(217, 177, 106, .9); }
.art-body a.art-btn-teal { background: linear-gradient(135deg, #7be8da, #1b9a8c); color: #05211e; box-shadow: 0 10px 24px -12px rgba(27, 154, 140, .7); }
.art-body a.art-btn-violet { background: linear-gradient(135deg, #a597ff, #5b47d6); color: #fff; box-shadow: 0 10px 24px -12px rgba(111, 92, 224, .7); }
.art-body a.art-btn-rose { background: linear-gradient(135deg, #f3a3b9, #c8466c); color: #fff; box-shadow: 0 10px 24px -12px rgba(210, 88, 124, .7); }
.art-body a.art-btn-dark { background: linear-gradient(135deg, #3a4560, #151b29); color: #f3f1ea; box-shadow: 0 10px 24px -12px rgba(0, 0, 0, .6); }
.art-body a.art-btn-outline { background: transparent; color: var(--gold-light); box-shadow: inset 0 0 0 2px var(--gold); }
.art-body a.art-btn-teal:hover { color: #05211e; }
.art-body a.art-btn-violet:hover, .art-body a.art-btn-rose:hover { color: #fff; }
.art-body a.art-btn-dark:hover { color: #f3f1ea; }
.art-body a.art-btn-outline:hover { color: var(--gold); box-shadow: inset 0 0 0 2px var(--gold); }
.art-body a.art-btn-sm { padding: 7px 18px; font-size: 14px; }
.art-body a.art-btn-lg { padding: 15px 38px; font-size: 18px; }
.art-body a.art-btn-block { display: flex; width: 100%; }
.art-body a.art-btn-arrow::after { content: "←"; font-weight: 900; }

/* ---------- فيديو مرفوع من اللوحة ---------- */
.art-body video, .art-body video.art-video {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  margin: 22px auto;
  border-radius: 16px;
  background: #000;
  box-shadow: var(--shadow-md);
}
