/*
 * Persian right-to-left layer — Nilades Catalogue Repair
 *
 * Every rule is prefixed with `body.ncr-fa`, a class added only on the Persian
 * catalogue screen. The English page never matches any selector in this file,
 * so it cannot be affected.
 *
 * `!important` is used deliberately and only where the parent theme or
 * ArcPrime's own layers already set the same property with `!important`. Where
 * no conflict exists, plain declarations are used.
 *
 * What is *not* done here: no `transform: scaleX(-1)` on any container, so
 * photographs, product renders and tile faces are never mirrored. Only text
 * flow, box direction and directional spacing change.
 */

/* ===========================================================================
   1. Document and section flow
   ======================================================================== */

body.ncr-fa .aps-catalogue,
body.ncr-fa .aps-catalogue-body,
body.ncr-fa .aps-page-head,
body.ncr-fa .aps-page-head-copy,
body.ncr-fa .aps-results,
body.ncr-fa .aps-filter-sidebar {
  direction: rtl !important;
  text-align: right !important;
}

/* ---------------------------------------------------------------------------
   2. The heading block: eyebrow, title and standfirst
   "مجموعه‌های ما" / "محصولات" / the description paragraph.
   ------------------------------------------------------------------------ */

body.ncr-fa .aps-page-head-copy > *,
body.ncr-fa .aps-page-head-copy > span,
body.ncr-fa .aps-page-head-copy h1,
body.ncr-fa .aps-page-head-copy h1 em,
body.ncr-fa .aps-page-head-copy p {
  direction: rtl !important;
  text-align: right !important;
  margin-right: 0 !important;
  margin-left: auto !important;
}

/* The eyebrow is letter-spaced for Latin capitals; Persian needs none. */
body.ncr-fa .aps-page-head-copy > span {
  letter-spacing: 0 !important;
  display: block;
}

/* Persian sits better with a slightly looser measure and more leading. */
body.ncr-fa .aps-page-head-copy p {
  max-width: 62ch;
  line-height: 2;
  margin-inline: 0 auto !important;
}

body.ncr-fa .aps-page-head h1 {
  letter-spacing: 0 !important;
  line-height: 1.25;
}

/* The dotted decoration sits at the start of the line, which is now the right,
   so it moves to the left to stay behind the text rather than over it. */
body.ncr-fa .aps-page-head::after {
  right: auto !important;
  left: 10%;
}

@media (max-width: 640px) {
  body.ncr-fa .aps-page-head::after {
    right: auto !important;
    left: 0;
  }
}

/* The counter block is separated by a rule; the rule belongs on the side that
   faces the text, which in RTL is the right. */
body.ncr-fa .aps-page-head-mark {
  padding-left: 0 !important;
  padding-right: 30px;
  border-left: 0 !important;
  border-right: 1px solid var(--aps-line);
  text-align: right;
}

/* ---------------------------------------------------------------------------
   3. Product grid: visual order right to left
   `direction` on the grid container reverses the *placement* of items only.
   The DOM order, and therefore the semantic order, tab order and everything
   the AJAX handler and paginator rely on, is untouched.
   ------------------------------------------------------------------------ */

body.ncr-fa .aps-results,
body.ncr-fa .aps-results .aps-grid {
  direction: rtl !important;
}

body.ncr-fa .aps-results .aps-card,
body.ncr-fa .aps-results .aps-card-copy,
body.ncr-fa .aps-results .aps-card-top {
  direction: rtl !important;
  text-align: right !important;
}

/* Keep the media box itself in normal flow: the image must not be mirrored. */
body.ncr-fa .aps-card-media,
body.ncr-fa .aps-card-media img {
  direction: ltr;
  transform: none;
}

/* The card index sits in the leading corner, which is now the right. */
body.ncr-fa .aps-card::before {
  left: auto !important;
  right: 18px !important;
}

/* The CTA arrow points along the reading direction. */
body.ncr-fa .aps-card-arrow {
  transform: scaleX(-1);
}

body.ncr-fa .aps-card-top {
  flex-direction: row-reverse;
}

body.ncr-fa .aps-tags {
  justify-content: flex-start;
}

/* Product codes, dimensions and prices are Latin: let the bidi algorithm
   isolate them so "60 × 120 cm" does not reorder inside Persian text. */
body.ncr-fa .aps-card-price,
body.ncr-fa .aps-counter,
body.ncr-fa .aps-spec-table b,
body.ncr-fa .aps-modular-table b {
  unicode-bidi: plaintext;
}

/* ---------------------------------------------------------------------------
   4. Filter sidebar
   ------------------------------------------------------------------------ */

body.ncr-fa .aps-filter-heading,
body.ncr-fa .aps-filters,
body.ncr-fa .aps-filter-bar,
body.ncr-fa .aps-filter-accordion,
body.ncr-fa .aps-filter-options,
body.ncr-fa .aps-filter-option,
body.ncr-fa .aps-filter-status,
body.ncr-fa .aps-filter-sidebar summary {
  direction: rtl !important;
  text-align: right !important;
}

body.ncr-fa .aps-filter-sidebar summary {
  flex-direction: row !important;
}

body.ncr-fa .aps-filter-bar select {
  direction: rtl !important;
  text-align: right !important;
}

/* Filter cards keep their exact box: same size, same crop, same hover. Only
   the row direction changes so the swatch leads on the right. */
body.ncr-fa .aps-filter-option {
  flex-direction: row;
}

body.ncr-fa .aps-option-visual,
body.ncr-fa .aps-collection-thumb,
body.ncr-fa .ncr-term-thumb {
  transform: none;
  background-position: center center;
  background-size: cover;
}

/* Size diagrams carry their own caption; keep the SVG in LTR so the numerals
   read 60 × 120 rather than 120 × 60. */
body.ncr-fa .aps-size-diagram,
body.ncr-fa .aps-size-diagram svg {
  direction: ltr;
}

/* ---------------------------------------------------------------------------
   5. Pagination
   Numbers count from the right, matching the grid.
   ------------------------------------------------------------------------ */

body.ncr-fa .aps-pagination,
body.ncr-fa .aps-pagination ul {
  direction: rtl !important;
}

body.ncr-fa .aps-pagination ul {
  flex-direction: row-reverse;
}

/* ---------------------------------------------------------------------------
   6. Empty state stays centred in both languages.
   ------------------------------------------------------------------------ */

body.ncr-fa .aps-empty {
  text-align: center !important;
}

/* ---------------------------------------------------------------------------
   7. Typography
   Persian faces first, with ArcPrime's stack retained as the fallback so a
   missing web font never changes the layout metrics.
   ------------------------------------------------------------------------ */

body.ncr-fa .aps-catalogue,
body.ncr-fa .aps-filter-sidebar,
body.ncr-fa .aps-results {
  font-family: "Vazirmatn", "Vazir", "IRANSansX", "IRANSans", "Shabnam",
    "Yekan Bakh", "Noto Naskh Arabic", "Segoe UI", Tahoma, sans-serif;
}

body.ncr-fa .aps-catalogue p,
body.ncr-fa .aps-catalogue li {
  line-height: 2.05;
}

/* ---------------------------------------------------------------------------
   8. Reduced motion is respected by the parent stylesheet; nothing added here
   introduces motion, so there is nothing to opt out of.
   ------------------------------------------------------------------------ */
