/* =========================
   Print stylesheet (PDF-friendly, close to site look)
   ========================= */

@page{
  size: A4;
  margin: 8mm 8mm;
}

*{
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

*,*::before,*::after{
  animation: none !important;
  transition: none !important;
  box-shadow: none !important;
  text-shadow: none !important;
  filter: none !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}

/* Force light variables even لو الثيم داكن */
html, html[data-theme="dark"]{
  --bg: #ffffff;
  --panel: #ffffff;
  --card: #ffffff;
  --text: #111111;
  --muted: #444444;
  --soft: rgba(0,0,0,.03);
  --chip-border: rgba(0,0,0,.14);
  --shadow: none;
  --shadow-2: none;
  --shadow-3: none;
}

html,body{
  height: auto !important;
  overflow: visible !important;
  background: #fff !important;
  color: var(--text) !important;
}

body{
  direction: rtl !important;
  font-family: 'Mizan AR+LT','Tajawal','Inter',system-ui,-apple-system,'Segoe UI',Roboto,Arial,sans-serif !important;
}

/* استغلال أكبر لمساحة الورقة */
.page{
  padding: 0 !important;
  min-height: auto !important;
  justify-content: flex-start !important;
}

.shell{
  width: 100% !important;
}

/* ===== Topbar قريب من الموقع لكن بدون عناصر UI غير لازمة ===== */
.topbar{
  background: var(--panel) !important;
  border: 1px solid rgba(0,0,0,.12) !important;
  border-radius: 18px !important;
  padding: 10px 14px !important;
  margin: 0 0 12px !important;
}

.topbar .nav,
.topbar .nav__links,
.topbar .nav__actions,
.topbar .theme-toggle,
#themeToggle{
  display:none !important;
}

/* ===== Cards ===== */
.card{
  background: var(--panel) !important;
  border-radius: 22px !important;
}

main.card.post-surface{
  margin-top: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  background: transparent !important;
}

.post-page > .post-inner-card.card{
  margin-top: 0 !important;
  padding: 12px 12px 10px !important;
  border: 1px solid rgba(0,0,0,.14) !important;
  background: #fff !important;
}

/* ===== Article layout: single column + TOC on top ===== */
.post-layout{
  display:block !important;
  gap: 0 !important;
  padding: 0 !important;
}

.toc-side{
  position: static !important;
  width: auto !important;
  top: auto !important;
  margin: 0 0 14px !important;
}

.toc{
  max-height: none !important;
  overflow: visible !important;
  background: var(--soft) !important;
  border-color: rgba(0,0,0,.14) !important;
}

.toc__nav{
  overflow: visible !important;
}

/* اطبع المحتوى حتى لو كان details مغلق */
details.toc:not([open]) > :not(summary){
  display:block !important;
}

/* ===== Header داخل المقال ===== */
.post-head{
  margin-top: 6px !important;
}

.post-title{
  margin: 10px 0 8px !important;
}

.post-meta .pill{
  background: rgba(0,0,0,.05) !important;
  border-color: rgba(0,0,0,.14) !important;
  color: var(--text) !important;
}

/* صورة الغلاف: نفس الشكل لكن بدون ظل */
.post-hero{
  box-shadow: none !important;
  max-height: 95mm !important;
}

/* ===== Content ===== */
.post-surface .post-body{
  padding: 0 !important;
  font-size: 20px !important;
  line-height: 1.9 !important;
}

/* لا تطبع URL بجانب الروابط */
.post-body a[href]::after{
  content: '' !important;
  display:none !important;
}

a{
  color: var(--text) !important;
  text-decoration: underline !important;
}

/* عناصر قد تعلّق المعاينة */
.post-body iframe,
.post-body video{
  display:none !important;
}

.post-body img{
  max-width: 100% !important;
  height: auto !important;
  break-inside: avoid !important;
  page-break-inside: avoid !important;
}

/* Code */
.post-body pre{
  background: var(--soft) !important;
  border: 1px solid rgba(0,0,0,.12) !important;
  border-radius: 14px !important;
  padding: 10px 12px !important;
  white-space: pre-wrap !important;
  overflow: visible !important;
  break-inside: avoid !important;
}
.post-body code{
  word-break: break-word !important;
}

/* Tables */
.post-body table{
  width: 100% !important;
  border-collapse: collapse !important;
  table-layout: auto !important;
  font-size: 15.5px !important;
}
.post-body th,
.post-body td{
  border: 1px solid rgba(0,0,0,.22) !important;
  padding: 6px 8px !important;
  vertical-align: top !important;
}
.post-body th{
  background: rgba(0,0,0,.05) !important;
  font-weight: 900 !important;
}
.post-body thead{ display: table-header-group; }
.post-body tfoot{ display: table-footer-group; }

/* FAQ: اطبعها مفتوحة + نفس الإطار */
.post-body .rte-faq{
  box-shadow: none !important;
  backdrop-filter: none !important;
}
.post-body details.rte-faq__item:not([open]) > :not(summary){
  display:block !important;
}
.post-body .rte-faq__q::after{
  display:none !important;
}

/* تجنّب تقطيع عناصر كبيرة بشكل سيء */
.post-body blockquote,
.post-body pre,
.post-body table,
.post-body .rte-faq,
.post-body details.rte-faq__item{
  break-inside: avoid !important;
  page-break-inside: avoid !important;
}

h1,h2,h3,h4{
  break-after: avoid-page;
  page-break-after: avoid;
}

p,li{
  orphans: 3;
  widows: 3;
}

/* اخفاء عناصر UI غير مفيدة في PDF */
.read-progress,
.to-top,
.related-posts,
.site-footer,
footer,
.footer{
  display:none !important;
}
