/* ==========================================================================
   Product Description — Prestige-inspired elegant typography
   Targets .rte blocks inside product context across ALL product templates
   ========================================================================== */

/* --------------------------------------------------------------------------
   Scope: every .rte that lives inside a product layout or featured product
   -------------------------------------------------------------------------- */

.product-details .rte,
.product-information .rte,
.featured-product .rte,
.featured-product-information .rte,
rte-formatter.rte,
.text-block.rte {

  /* ── Core body typography ────────────────────────────────────────────── */
  font-size: clamp(0.875rem, 0.9375rem, 1rem);   /* 14–15px fluid */
  line-height: 1.85;
  letter-spacing: 0.012em;
  color: rgb(var(--color-foreground-rgb) / 0.82);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  word-spacing: 0.02em;

  /* ── Paragraphs ──────────────────────────────────────────────────────── */
  p {
    margin-block-start: 0;
    margin-block-end: 0.9em;
    font-size: inherit;
    line-height: inherit;
    color: inherit;
  }

  p:last-child {
    margin-block-end: 0;
  }

  /* ── Heading hierarchy inside description ─────────────────────────────── */

  /* H2 — Section title */
  h2 {
    font-family: var(--font-heading--family, var(--font-paragraph--family));
    font-size: 1rem;                   /* 16px — close to body, authoritative */
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    line-height: 1.4;
    margin-block-start: 1.8em;
    margin-block-end: 0.55em;
    color: rgb(var(--color-foreground-rgb) / 1);
    padding-block-end: 0.4em;
    border-block-end: 1px solid rgb(var(--color-foreground-rgb) / 0.12);
  }

  h2:first-child {
    margin-block-start: 0;
  }

  /* H3 — Sub-section */
  h3 {
    font-family: var(--font-heading--family, var(--font-paragraph--family));
    font-size: 0.875rem;               /* 14px */
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    line-height: 1.45;
    margin-block-start: 1.5em;
    margin-block-end: 0.4em;
    color: rgb(var(--color-foreground-rgb) / 0.9);
  }

  h3:first-child {
    margin-block-start: 0;
  }

  /* H4 — Label / feature heading */
  h4 {
    font-family: var(--font-paragraph--family);
    font-size: 0.8125rem;              /* 13px */
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    line-height: 1.4;
    margin-block-start: 1.3em;
    margin-block-end: 0.3em;
    color: rgb(var(--color-foreground-rgb) / 0.88);
  }

  h4:first-child {
    margin-block-start: 0;
  }

  /* H5 / H6 — Micro-labels */
  h5,
  h6 {
    font-family: var(--font-paragraph--family);
    font-size: 0.75rem;                /* 12px */
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    line-height: 1.4;
    margin-block-start: 1.1em;
    margin-block-end: 0.25em;
    color: rgb(var(--color-foreground-rgb) / 0.65);
  }

  h5:first-child,
  h6:first-child {
    margin-block-start: 0;
  }

  /* ── Unordered lists ─────────────────────────────────────────────────── */
  ul {
    margin-block-start: 0.35em;
    margin-block-end: 0.9em;
    padding-inline-start: 0;
    list-style: none;
  }

  ul li {
    position: relative;
    padding-inline-start: 1.3em;
    margin-block-end: 0.35em;
    line-height: 1.7;
    color: inherit;
  }

  /* Elegant dash bullet — Prestige style */
  ul li::before {
    content: "–";
    position: absolute;
    inset-inline-start: 0;
    color: rgb(var(--color-foreground-rgb) / 0.35);
    font-weight: 400;
  }

  ul li:last-child {
    margin-block-end: 0;
  }

  ul:last-child {
    margin-block-end: 0;
  }

  /* ── Ordered lists ───────────────────────────────────────────────────── */
  ol {
    margin-block-start: 0.35em;
    margin-block-end: 0.9em;
    padding-inline-start: 1.4em;
    counter-reset: ol-counter;
    list-style: none;
  }

  ol li {
    position: relative;
    padding-inline-start: 0.3em;
    margin-block-end: 0.35em;
    line-height: 1.7;
    color: inherit;
    counter-increment: ol-counter;
  }

  ol li::before {
    content: counter(ol-counter) ".";
    position: absolute;
    inset-inline-start: -1.4em;
    color: rgb(var(--color-foreground-rgb) / 0.45);
    font-weight: 500;
    font-size: 0.8125em;
    letter-spacing: 0.02em;
    top: 0.1em;
  }

  ol li:last-child {
    margin-block-end: 0;
  }

  ol:last-child {
    margin-block-end: 0;
  }

  /* Nested lists */
  ul ul,
  ol ol,
  ul ol,
  ol ul {
    margin-block-start: 0.25em;
    margin-block-end: 0.25em;
  }

  /* ── Horizontal rules ────────────────────────────────────────────────── */
  hr {
    border: none;
    border-block-start: 1px solid rgb(var(--color-foreground-rgb) / 0.1);
    margin-block: 1.5em;
  }

  /* ── Blockquotes ─────────────────────────────────────────────────────── */
  blockquote {
    margin-inline: 0;
    margin-block: 1.4em;
    padding-inline-start: 1.25em;
    border-inline-start: 2px solid rgb(var(--color-foreground-rgb) / 0.18);
    font-style: italic;
    font-size: 0.9375em;
    color: rgb(var(--color-foreground-rgb) / 0.65);
    line-height: 1.85;
  }

  blockquote p {
    margin-block-end: 0;
  }

  /* ── Inline elements ─────────────────────────────────────────────────── */
  strong,
  b {
    font-weight: 600;
    color: rgb(var(--color-foreground-rgb) / 0.95);
    letter-spacing: inherit;
  }

  em,
  i {
    font-style: italic;
    color: inherit;
  }

  /* ── Links inside description ────────────────────────────────────────── */
  a:not(.button, .button-secondary) {
    color: var(--color-foreground);
    text-decoration-color: rgb(var(--color-foreground-rgb) / 0.3);
    text-decoration-thickness: 0.06em;
    text-underline-offset: 0.2em;
    transition: text-decoration-color 0.2s ease, color 0.2s ease;
  }

  a:not(.button, .button-secondary):hover {
    color: var(--color-primary);
    text-decoration-color: rgb(var(--color-primary-rgb, var(--color-foreground-rgb)) / 0.5);
  }

  /* ── Tables ──────────────────────────────────────────────────────────── */
  table {
    width: 100% !important;
    border-collapse: collapse;
    font-size: 0.875em;
    margin-block: 1em;
  }

  thead,
  tr:not(:has(td)) {
    background-color: rgb(var(--color-foreground-rgb) / 0.04);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    font-size: 0.75em;
  }

  th {
    text-align: start;
    padding-inline: var(--padding-md);
    padding-block: var(--padding-sm);
    border-block-end: 1px solid rgb(var(--color-foreground-rgb) / 0.12);
    color: rgb(var(--color-foreground-rgb) / 0.7);
  }

  td {
    text-align: start;
    padding-inline: var(--padding-md);
    padding-block: var(--padding-sm);
    border-block-end: 1px solid rgb(var(--color-foreground-rgb) / 0.07);
    line-height: 1.6;
  }

  tr:last-child td {
    border-block-end: none;
  }

  /* ── Small / captions ────────────────────────────────────────────────── */
  small {
    font-size: 0.8125em;
    color: rgb(var(--color-foreground-rgb) / 0.55);
    letter-spacing: 0.02em;
  }

  /* ── Code ────────────────────────────────────────────────────────────── */
  code,
  pre {
    font-size: 0.8125em;
    background: rgb(var(--color-foreground-rgb) / 0.05);
    border-radius: 3px;
    padding-inline: 0.35em;
    padding-block: 0.1em;
    font-family: monospace;
  }
}

/* --------------------------------------------------------------------------
   Mobile — slightly tighter on small screens
   -------------------------------------------------------------------------- */

@media screen and (max-width: 749px) {
  .product-details .rte,
  .product-information .rte,
  .featured-product .rte,
  .featured-product-information .rte,
  rte-formatter.rte,
  .text-block.rte {
    font-size: 0.875rem;     /* 14px on mobile */
    line-height: 1.78;

    h2 {
      font-size: 0.9375rem;
      letter-spacing: 0.07em;
    }

    h3 {
      font-size: 0.8125rem;
    }
  }
}

/* --------------------------------------------------------------------------
   RTL — Arabic product description: explicit direction + full overrides
   -------------------------------------------------------------------------- */

[dir="rtl"] .product-details .rte,
[dir="rtl"] .product-information .rte,
[dir="rtl"] .featured-product .rte,
[dir="rtl"] .featured-product-information .rte,
[dir="rtl"] rte-formatter.rte,
[dir="rtl"] .text-block.rte {

  /* ── Core RTL direction ───────────────────────────────────────────────── */
  direction: rtl;
  text-align: right;
  unicode-bidi: embed;

  /* ── Arabic typography ───────────────────────────────────────────────── */
  letter-spacing: 0;          /* Arabic script never uses letter-spacing     */
  word-spacing: 0.05em;
  line-height: 2;             /* Arabic needs more vertical breathing room   */

  /* ── Paragraphs ─────────────────────────────────────────────────────── */
  p {
    direction: rtl;
    text-align: right;
    margin-block-end: 1em;
  }

  /* ── All headings — remove uppercase + letter-spacing (Arabic N/A) ──── */
  h2 {
    direction: rtl;
    text-align: right;
    text-transform: none;
    letter-spacing: 0;
    line-height: 1.6;
    font-size: 1.0625rem;
  }

  h3 {
    direction: rtl;
    text-align: right;
    text-transform: none;
    letter-spacing: 0;
    line-height: 1.6;
  }

  h4 {
    direction: rtl;
    text-align: right;
    text-transform: none;
    letter-spacing: 0;
    line-height: 1.55;
  }

  h5,
  h6 {
    direction: rtl;
    text-align: right;
    text-transform: none;
    letter-spacing: 0;
    line-height: 1.55;
  }

  /* ── Bullet lists — bullet on the RIGHT side ─────────────────────────── */
  ul {
    direction: rtl;
    text-align: right;
    padding-inline-start: 0;
    padding-inline-end: 0;
  }

  ul li {
    direction: rtl;
    text-align: right;
    padding-inline-start: 0;
    padding-inline-end: 1.3em;   /* push text away from the right-side bullet */
    line-height: 2;
  }

  ul li::before {
    inset-inline-start: auto;    /* cancel LTR left position                 */
    inset-inline-end: 0;         /* anchor dash to the right edge            */
  }

  /* ── Ordered lists ────────────────────────────────────────────────────── */
  ol {
    direction: rtl;
    text-align: right;
    padding-inline-start: 0;
    padding-inline-end: 1.4em;
  }

  ol li {
    direction: rtl;
    text-align: right;
    padding-inline-start: 0;
    padding-inline-end: 0.3em;
    line-height: 2;
  }

  ol li::before {
    inset-inline-start: auto;
    inset-inline-end: -1.4em;
    letter-spacing: 0;
  }

  /* ── Blockquote — border on RIGHT side ───────────────────────────────── */
  blockquote {
    direction: rtl;
    text-align: right;
    padding-inline-start: 0;
    padding-inline-end: 1.25em;
    border-inline-start: none;
    border-inline-end: 2px solid rgb(var(--color-foreground-rgb) / 0.18);
    line-height: 2;
  }

  /* ── Tables ──────────────────────────────────────────────────────────── */
  table,
  th,
  td {
    direction: rtl;
    text-align: right;
    letter-spacing: 0;
  }

  thead,
  tr:not(:has(td)) {
    text-transform: none;
    letter-spacing: 0;
  }

  /* ── Strong / small ──────────────────────────────────────────────────── */
  strong,
  b {
    letter-spacing: 0;
  }

  small {
    letter-spacing: 0;
  }
}

/* --------------------------------------------------------------------------
   Force RTL on inline content injected by Shopify rich text editor
   (handles cases where editor injects style="text-align: left")
   -------------------------------------------------------------------------- */

[dir="rtl"] .product-details .rte *,
[dir="rtl"] .product-information .rte *,
[dir="rtl"] .featured-product .rte *,
[dir="rtl"] .featured-product-information .rte *,
[dir="rtl"] rte-formatter.rte *,
[dir="rtl"] .text-block.rte * {
  /* Only override alignment that the editor forces to left */
  unicode-bidi: plaintext;
}
