/* Basic RTL overrides for Arabic locales */
html[dir="rtl"], body.rtl {
  direction: rtl;
  unicode-bidi: embed;
}

/* Flip common margins/paddings */
.ml-1 { margin-left: 0.25rem; margin-right: 0; }
.mr-1 { margin-right: 0.25rem; }
.ml-2 { margin-left: 0.5rem; margin-right: 0; }
.mr-2 { margin-right: 0.5rem; }
.ml-3 { margin-left: 1rem; margin-right: 0; }
.mr-3 { margin-right: 1rem; }
.ml-4 { margin-left: 1.5rem; margin-right: 0; }
.mr-4 { margin-right: 1.5rem; }

.text-start { text-align: right !important; }
.text-end { text-align: left !important; }

/* Navigation menu arrows */
.menu-sub-icon { transform: scaleX(-1); }

/* Breadcrumbs (RTL) */
.breadcrumb {
  direction: rtl;
  display: flex;
  justify-content: flex-start; /* main-start is right in row-reverse */
  --bs-breadcrumb-divider: '‹';
}
/* Remove LTR divider placement */
.breadcrumb .breadcrumb-item + .breadcrumb-item::before { content: none; }
/* Add divider after each item except the last visually (which is DOM first-child) */
.breadcrumb .breadcrumb-item::after {
  content: var(--bs-breadcrumb-divider, "/");
  color: var(--bs-breadcrumb-divider-color);
  display: inline-block;
  margin: 0 .5rem;
}
.breadcrumb .breadcrumb-item + .breadcrumb-item { padding-right: var(--bs-breadcrumb-item-padding-x); padding-left: 0; }
.breadcrumb .breadcrumb-item:last-child::after { content: none; margin: 0; }
/* Zero left/right padding in RTL */
#breadcrumb .breadcrumb { padding-right: 0; padding-left: 0; }

/* Aesthetic tweaks */
#breadcrumb .breadcrumb .breadcrumb-item { display: inline-flex; align-items: center; }
#breadcrumb .breadcrumb .breadcrumb-item a { color: var(--pk-c-sub); text-decoration: none; }
#breadcrumb .breadcrumb .breadcrumb-item a:hover { color: var(--pk-c-primary); }
#breadcrumb .breadcrumb .breadcrumb-item.active { color: var(--pk-c-sub); font-weight: 500; }

/* Forms */
label { text-align: right; }
input, textarea, select { direction: rtl; }

/* Pagination */
.pagination { justify-content: flex-end; }

/* Utility */
.puock-links { direction: rtl; }
.list-group { direction: rtl; }

/* Arabic article typography improvements */
html[dir="rtl"] .entry-content,
.rtl .entry-content {
  /* Enable Arabic ligatures and smoother rendering */
  font-feature-settings: "rlig" 1, "calt" 1;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  line-height: 1.9;
  letter-spacing: 0; /* avoid weird spacing for Arabic */
  word-spacing: 0.02em;
}

/* Paragraphs: readable rhythm and justified lines (common in Arabic typesetting) */
html[dir="rtl"] .entry-content p,
.rtl .entry-content p {
  margin: 0 0 1em;
  text-align: justify;
  text-justify: inter-word;
  hyphens: none;
  white-space: normal;
  word-break: normal;
  overflow-wrap: break-word; /* allow long tokens (e.g., URLs) to wrap */
}

/* Headings spacing inside articles */
html[dir="rtl"] .entry-content h1,
html[dir="rtl"] .entry-content h2,
html[dir="rtl"] .entry-content h3,
html[dir="rtl"] .entry-content h4,
html[dir="rtl"] .entry-content h5,
html[dir="rtl"] .entry-content h6,
.rtl .entry-content h1,
.rtl .entry-content h2,
.rtl .entry-content h3,
.rtl .entry-content h4,
.rtl .entry-content h5,
.rtl .entry-content h6 {
  line-height: 1.6;
  margin: 1.25rem 0 .75rem;
}

/* Lists: proper indentation and marker placement on the right */
html[dir="rtl"] .entry-content ul,
html[dir="rtl"] .entry-content ol,
.rtl .entry-content ul,
.rtl .entry-content ol {
  padding-right: 1.25rem;
  padding-left: 0;
  margin: 0 0 1rem;
}
html[dir="rtl"] .entry-content ul,
.rtl .entry-content ul { list-style: disc inside; }
html[dir="rtl"] .entry-content ol,
.rtl .entry-content ol { list-style: decimal inside; }
html[dir="rtl"] .entry-content li,
.rtl .entry-content li { margin: 0 0 .4em; }

/* Blockquotes: flip border to the right and soften appearance */
html[dir="rtl"] .entry-content blockquote,
.rtl .entry-content blockquote {
  border-right: 3px solid var(--pk-c-primary);
  border-left: 0;
  margin: 1rem 0;
  padding: .5rem 1rem .5rem 0;
  color: var(--pk-c-sub);
  background: rgba(0,0,0,.03);
}

/* Code and pre blocks should remain LTR to preserve syntax readability */
html[dir="rtl"] .entry-content pre,
html[dir="rtl"] .entry-content code,
html[dir="rtl"] .entry-content kbd,
html[dir="rtl"] .entry-content samp,
.rtl .entry-content pre,
.rtl .entry-content code,
.rtl .entry-content kbd,
.rtl .entry-content samp {
  direction: ltr;
  unicode-bidi: plaintext;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, "Cascadia Mono", "Segoe UI Mono", Consolas, "Liberation Mono", "DejaVu Sans Mono", monospace;
  white-space: pre-wrap;
  overflow-x: auto;
}

/* Images and figures */
html[dir="rtl"] .entry-content img,
.rtl .entry-content img { max-width: 100%; height: auto; border-radius: .375rem; }
html[dir="rtl"] .entry-content figure,
.rtl .entry-content figure { margin: 1rem 0; }
html[dir="rtl"] .entry-content figcaption,
.rtl .entry-content figcaption { text-align: center; font-size: .875rem; color: var(--pk-c-sub); }

/* Links inside content: allow long URLs to wrap without breaking Arabic words globally */
html[dir="rtl"] .entry-content a,
.rtl .entry-content a { overflow-wrap: anywhere; word-break: break-word; }

/* Post title wrapping for Arabic */
html[dir="rtl"] #post-title,
.rtl #post-title {
  white-space: normal !important;
  word-break: normal !important;
  overflow-wrap: break-word;
}
