/*
 * RTL / Persian typography layer for the Tradez WordPress theme + Elementor
 * -------------------------------------------------------------------------
 * Add this file AFTER the theme's CSS (style.css, bootstrap.css, spacing.css,
 * tradly-*.css, icon CSS) so these rules take precedence.
 *
 * Suggested enqueue (adjust the handle/path to match your theme):
 *
 * if ( is_rtl() ) {
 *     wp_enqueue_style(
 *         'tradez-rtl-persian',
 *         get_stylesheet_directory_uri() . '/css/rtl-persian.css',
 *         array( 'tradez-style' ),
 *         '1.1.0'
 *     );
 * }
 *
 * This stylesheet is scoped to RTL pages and content areas. It avoids changing
 * navigation/menu lists and other UI lists wherever possible.
 */

/* ==========================================================================
   1. RTL base and Persian-friendly fonts
   ========================================================================== */

html[dir="rtl"] body {
  direction: rtl;
  text-align: right;
  font-family: "Vazirmatn", "IRANSansX", Tahoma, var(--body-font, sans-serif);
}

html[dir="rtl"] h1,
html[dir="rtl"] h2,
html[dir="rtl"] h3,
html[dir="rtl"] h4,
html[dir="rtl"] h5,
html[dir="rtl"] h6,
html[dir="rtl"] .display-one,
html[dir="rtl"] .display-two,
html[dir="rtl"] .display-three,
html[dir="rtl"] .display-four,
html[dir="rtl"] .display-five,
html[dir="rtl"] .display-six,
html[dir="rtl"] .heading {
  font-family: "Vazirmatn", "IRANSansX", Tahoma, var(--head-font, sans-serif);
}

/* ==========================================================================
   2. Lists in Tradez post/page content, WordPress content, and Elementor
   ========================================================================== */

/* Content wrappers only: intentionally excludes site navigation and menus. */
html[dir="rtl"] .postbox__text ol,
html[dir="rtl"] .postbox__text ul,
html[dir="rtl"] .tp-page-content ol,
html[dir="rtl"] .tp-page-content ul,
html[dir="rtl"] .tp-blog-area ol,
html[dir="rtl"] .tp-blog-area ul,
html[dir="rtl"] .entry-content ol,
html[dir="rtl"] .entry-content ul,
html[dir="rtl"] .wp-block-list,
html[dir="rtl"] .elementor-widget-text-editor ol,
html[dir="rtl"] .elementor-widget-text-editor ul,
html[dir="rtl"] .elementor-widget-theme-post-content ol,
html[dir="rtl"] .elementor-widget-theme-post-content ul {
  direction: rtl !important;
  text-align: right !important;
  padding-inline-start: 2.75em !important;
  padding-inline-end: 0 !important;
  margin-inline-start: 0 !important;
  margin-inline-end: 0 !important;
  list-style-position: outside !important;  
}

/* Persian numerals + period marker for ordered lists. */
html[dir="rtl"] .postbox__text ol,
html[dir="rtl"] .tp-page-content ol,
html[dir="rtl"] .tp-blog-area ol,
html[dir="rtl"] .entry-content ol,
html[dir="rtl"] .elementor-widget-text-editor ol,
html[dir="rtl"] .elementor-widget-theme-post-content ol {
  list-style-type: persian !important;
}

/* Bullets for unordered lists. */
html[dir="rtl"] .postbox__text ul,
html[dir="rtl"] .tp-page-content ul,
html[dir="rtl"] .tp-blog-area ul,
html[dir="rtl"] .entry-content ul,
html[dir="rtl"] .elementor-widget-text-editor ul,
html[dir="rtl"] .elementor-widget-theme-post-content ul {
  list-style-type: disc !important;
}

/* A little breathing room between the marker and the text. */
html[dir="rtl"] .postbox__text li,
html[dir="rtl"] .tp-page-content li,
html[dir="rtl"] .tp-blog-area li,
html[dir="rtl"] .entry-content li,
html[dir="rtl"] .elementor-widget-text-editor li,
html[dir="rtl"] .elementor-widget-theme-post-content li {
  padding-inline-start: 0.35em;
  line-height: 2;
  margin-block-end: 0.35em;
}

/* Nested lists: keep their own indentation and avoid excess vertical gaps. */
html[dir="rtl"] .postbox__text li > ul,
html[dir="rtl"] .postbox__text li > ol,
html[dir="rtl"] .tp-page-content li > ul,
html[dir="rtl"] .tp-page-content li > ol,
html[dir="rtl"] .tp-blog-area li > ul,
html[dir="rtl"] .tp-blog-area li > ol,
html[dir="rtl"] .entry-content li > ul,
html[dir="rtl"] .entry-content li > ol,
html[dir="rtl"] .elementor-widget-text-editor li > ul,
html[dir="rtl"] .elementor-widget-text-editor li > ol,
html[dir="rtl"] .elementor-widget-theme-post-content li > ul,
html[dir="rtl"] .elementor-widget-theme-post-content li > ol {
  margin-block-start: 0.35em;
  margin-block-end: 0.35em;
  padding-inline-start: 1.5em !important;
}

/* WordPress Gutenberg list block can appear outside .entry-content. */
html[dir="rtl"] .wp-block-list {
  list-style-position: outside !important;
  padding-inline-start: 2.5em;
}
html[dir="rtl"] ol.wp-block-list {
  list-style-type: persian !important;
}
html[dir="rtl"] ul.wp-block-list {
  list-style-type: disc !important;
}

/* ==========================================================================
   3. Headings, paragraphs, and vertical rhythm in content
   ========================================================================== */

html[dir="rtl"] .postbox__text h1,
html[dir="rtl"] .postbox__text h2,
html[dir="rtl"] .postbox__text h3,
html[dir="rtl"] .postbox__text h4,
html[dir="rtl"] .tp-page-content h1,
html[dir="rtl"] .tp-page-content h2,
html[dir="rtl"] .tp-page-content h3,
html[dir="rtl"] .tp-page-content h4,
html[dir="rtl"] .tp-blog-area h1,
html[dir="rtl"] .tp-blog-area h2,
html[dir="rtl"] .tp-blog-area h3,
html[dir="rtl"] .tp-blog-area h4,
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"] .elementor-widget-text-editor h1,
html[dir="rtl"] .elementor-widget-text-editor h2,
html[dir="rtl"] .elementor-widget-text-editor h3,
html[dir="rtl"] .elementor-widget-text-editor h4,
html[dir="rtl"] .elementor-widget-theme-post-content h1,
html[dir="rtl"] .elementor-widget-theme-post-content h2,
html[dir="rtl"] .elementor-widget-theme-post-content h3,
html[dir="rtl"] .elementor-widget-theme-post-content h4 {
  line-height: 1.7;
  margin-block-start: 1.25em;
  margin-block-end: 0.55em;
}

html[dir="rtl"] .postbox__text p,
html[dir="rtl"] .tp-page-content p,
html[dir="rtl"] .tp-blog-area p,
html[dir="rtl"] .entry-content p,
html[dir="rtl"] .elementor-widget-text-editor p,
html[dir="rtl"] .elementor-widget-theme-post-content p {
  line-height: 2;
  margin-block-start: 0;
  margin-block-end: 0.9em;
}

/* Prevent a heading immediately followed by a paragraph/list from touching it. */
html[dir="rtl"] .postbox__text h1 + p,
html[dir="rtl"] .postbox__text h2 + p,
html[dir="rtl"] .postbox__text h3 + p,
html[dir="rtl"] .postbox__text h4 + p,
html[dir="rtl"] .tp-page-content h1 + p,
html[dir="rtl"] .tp-page-content h2 + p,
html[dir="rtl"] .tp-page-content h3 + p,
html[dir="rtl"] .tp-page-content h4 + p,
html[dir="rtl"] .tp-blog-area h1 + p,
html[dir="rtl"] .tp-blog-area h2 + p,
html[dir="rtl"] .tp-blog-area h3 + p,
html[dir="rtl"] .tp-blog-area h4 + p,
html[dir="rtl"] .entry-content h1 + p,
html[dir="rtl"] .entry-content h2 + p,
html[dir="rtl"] .entry-content h3 + p,
html[dir="rtl"] .entry-content h4 + p,
html[dir="rtl"] .elementor-widget-text-editor h1 + p,
html[dir="rtl"] .elementor-widget-text-editor h2 + p,
html[dir="rtl"] .elementor-widget-text-editor h3 + p,
html[dir="rtl"] .elementor-widget-text-editor h4 + p,
html[dir="rtl"] .elementor-widget-theme-post-content h1 + p,
html[dir="rtl"] .elementor-widget-theme-post-content h2 + p,
html[dir="rtl"] .elementor-widget-theme-post-content h3 + p,
html[dir="rtl"] .elementor-widget-theme-post-content h4 + p {
  margin-block-start: 0;
}

html[dir="rtl"] .postbox__text h1 + ol,
html[dir="rtl"] .postbox__text h2 + ol,
html[dir="rtl"] .postbox__text h3 + ol,
html[dir="rtl"] .postbox__text h4 + ol,
html[dir="rtl"] .postbox__text h1 + ul,
html[dir="rtl"] .postbox__text h2 + ul,
html[dir="rtl"] .postbox__text h3 + ul,
html[dir="rtl"] .postbox__text h4 + ul,
html[dir="rtl"] .tp-page-content h1 + ol,
html[dir="rtl"] .tp-page-content h2 + ol,
html[dir="rtl"] .tp-page-content h3 + ol,
html[dir="rtl"] .tp-page-content h4 + ol,
html[dir="rtl"] .tp-page-content h1 + ul,
html[dir="rtl"] .tp-page-content h2 + ul,
html[dir="rtl"] .tp-page-content h3 + ul,
html[dir="rtl"] .tp-page-content h4 + ul,
html[dir="rtl"] .entry-content h1 + ol,
html[dir="rtl"] .entry-content h2 + ol,
html[dir="rtl"] .entry-content h3 + ol,
html[dir="rtl"] .entry-content h4 + ol,
html[dir="rtl"] .entry-content h1 + ul,
html[dir="rtl"] .entry-content h2 + ul,
html[dir="rtl"] .entry-content h3 + ul,
html[dir="rtl"] .entry-content h4 + ul {
  margin-block-start: 0.65em;
}

/* ==========================================================================
   4. WordPress core alignment classes (mirrored for RTL)
   ========================================================================== */

html[dir="rtl"] .alignleft {
  float: right;
  margin-inline-start: 0;
  margin-inline-end: 1.5em !important;
}

html[dir="rtl"] .alignright {
  float: left;
  margin-inline-start: 1.5em !important;
  margin-inline-end: 0;
}

/* ==========================================================================
   5. Checkbox / radio custom controls
   ========================================================================== */

html[dir="rtl"] .checkbox-single,
html[dir="rtl"] .single-radio {
  padding-left: 0;
  padding-right: 28px;
  padding-inline-start: 2.5em;
}

html[dir="rtl"] .checkbox-single .checkmark,
html[dir="rtl"] .single-radio .checkmark {
  left: auto;
  right: 0;
}

/* ==========================================================================
   6. Blockquotes
   ========================================================================== */

html[dir="rtl"] blockquote,
html[dir="rtl"] .tp-blog-area blockquote {
  text-align: right;
}

html[dir="rtl"] blockquote cite::before {
  margin-right: 0;
  margin-left: 10px;
}

html[dir="rtl"] .wp-block-quote.has-text-align-right {
  border-right: 0;
  border-left: 0;
}

/* ==========================================================================
   7. Comment avatars and threaded replies
   ========================================================================== */

html[dir="rtl"] .comments-avatar {
  float: right;
}

html[dir="rtl"] .comments-avatar img {
  margin-right: 0;
  margin-left: 15px;
}

/* ==========================================================================
   8. Tag chips and page-links pagination spacing
   ========================================================================== */

html[dir="rtl"] .tp-post-tag span,
html[dir="rtl"] .tp-post-tag a,
html[dir="rtl"] .postbox__text .wp-block-tag-cloud a {
  margin-right: 0;
  margin-left: 8px;
}

html[dir="rtl"] .page-links a,
html[dir="rtl"] .page-links > span {
  margin-left: 2px;
  margin-right: 3px;
}

/* ==========================================================================
   9. Latin numbers, prices, tickers, and percentages inside Persian text
   ==========================================================================
   Optional wrapper for values that should remain LTR, e.g. 12.45, $1,204,
   +3.2%, ETH/USDT. Example:
   <span class="ltr-num">12.45 USDT</span>
   ========================================================================== */

html[dir="rtl"] .ltr-num {
  direction: ltr;
  unicode-bidi: isolate;
  display: inline-block;
}
