/* ============================================================
   styles-rtl.css — RTL + Arabic fixes for iqoptionsaudi.com
   Load AFTER styles.css
   ============================================================ */

/* ── Base font stack ── */
html[dir="rtl"] body {
  font-family: "Segoe UI", "Tahoma", "Arial", system-ui, sans-serif;
}

/* ══════════════════════════════════════════════════════════════
   OVERFLOW FIX — THREE ROOT CAUSES IDENTIFIED AND FIXED

   CULPRIT 1: .skip-link has `left: -9999px` in styles.css.
   In RTL this physical left:-9999px extends 9999px to the LEFT
   of the viewport = massive blank space on the RIGHT side.
   Fix: flip to right:-9999px in RTL so it hides off the
   logical end (right side) instead.

   CULPRIT 2: .sidebar-right has `grid-column: 2` at 980px.
   In our RTL grid we swap to (content | toc) = 2 columns.
   grid-column:2 forces sidebar into column 2 (the TOC column)
   AND order:99 tries to push it below — conflict creates an
   implicit 3rd track outside the template = horizontal overflow.
   Fix: reset grid-column to auto so auto-placement handles it.

   CULPRIT 3: `html[dir=rtl] * { max-width:100% }` from our
   previous attempt was too broad — it broke table layouts and
   other components that need intrinsic sizing. Removed.
   ══════════════════════════════════════════════════════════════ */

/* FIX 1 — skip-link */
html[dir="rtl"] .skip-link {
  left: auto;
  right: -9999px;
}
html[dir="rtl"] .skip-link:focus {
  right: 1rem;
  left: auto;
}

/* FIX 2 — sidebar-right grid-column conflict at 980px */
@media (min-width: 980px) {
  html[dir="rtl"] .sidebar-right {
    grid-column: auto;
  }
}
@media (min-width: 1200px) {
  html[dir="rtl"] .sidebar-right {
    grid-column: auto;
  }
}

/* FIX 3 — body/html containment (targeted, not blanket) */
html[dir="rtl"],
html[dir="rtl"] body {
  overflow-x: hidden;
  max-width: 100%;
}

/* ══════════════════════════════════════════════════════════════
   LAYOUT GRID — RTL column order
   Use order only — no grid-column overrides (that's the bug).
   ══════════════════════════════════════════════════════════════ */
@media (min-width: 980px) {
  html[dir="rtl"] .layout {
    grid-template-columns: minmax(0, 1fr) var(--toc-width);
  }
  html[dir="rtl"] .content      { order: 1; }
  html[dir="rtl"] .toc          { order: 2; }
  html[dir="rtl"] .sidebar-right { order: 99; }
}

@media (min-width: 1200px) {
  html[dir="rtl"] .layout {
    grid-template-columns: 220px minmax(0, 1fr) var(--toc-width);
  }
  html[dir="rtl"] .sidebar-right { order: 1; }
  html[dir="rtl"] .content       { order: 2; }
  html[dir="rtl"] .toc           { order: 3; }
}

/* ══════════════════════════════════════════════════════════════
   STARS FIX
   .stars::after uses `inset: 0 auto 0 0` (physical left).
   In RTL browsers remap this to inset-inline-start which
   becomes the visual RIGHT — gold fill clips from wrong end.
   Force direction:ltr on .stars to keep the fill correct.
   ══════════════════════════════════════════════════════════════ */
html[dir="rtl"] .stars {
  direction: ltr;
  display: inline-flex;
  unicode-bidi: embed;
}

/* ── TOC list padding ── */
html[dir="rtl"] .toc ol,
html[dir="rtl"] .mobile-bottom-toc__panel ol,
html[dir="rtl"] .footnotes ol {
  padding-right: 1.15rem;
  padding-left: 0;
}

html[dir="rtl"] .toc-links ul,
html[dir="rtl"] .mobile-useful-links ul {
  padding-right: 0;
  padding-left: 0;
}

/* toc-links: flip dot from ::before to ::after */
html[dir="rtl"] .toc-links a::before { content: none; }
html[dir="rtl"] .toc-links a::after {
  content: "";
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.45;
  flex-shrink: 0;
  order: 9;
}

/* ── Article lists ── */
html[dir="rtl"] article ul,
html[dir="rtl"] article ol {
  padding-right: 1.35rem;
  padding-left: 0;
}

/* ── Snapshot brand border ── */
@media (min-width: 760px) {
  html[dir="rtl"] .snapshot__brand {
    border-right: none;
    border-left: 1px solid var(--line);
    padding-right: 0;
    padding-left: 1rem;
  }
}

/* ── Snapshot feature list bullets ── */
html[dir="rtl"] .snapshot__feature-list li {
  padding-left: 0;
  padding-right: 1.3rem;
}
html[dir="rtl"] .snapshot__feature-list li::before {
  left: auto;
  right: 0;
}

/* ── Snapshot chips border direction ── */
html[dir="rtl"] .snapshot-chip {
  border-right: none;
  border-left: 1px solid rgba(29,78,137,0.1);
}
html[dir="rtl"] .snapshot-chip:last-child { border-left: 0; }

@media (max-width: 760px) {
  html[dir="rtl"] .snapshot-chip {
    border-left: 0;
    border-bottom: 1px solid rgba(29,78,137,0.1);
  }
  html[dir="rtl"] .snapshot-chip:last-child { border-bottom: 0; }
}

/* ── Tables ── */
html[dir="rtl"] th,
html[dir="rtl"] td { text-align: right; }

/* ── Disclosure bar ── */
html[dir="rtl"] .disclosure {
  border-left: none;
  border-right: 3px solid var(--accent);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

/* ── FAQ toggle: + floats to left in RTL ── */
html[dir="rtl"] details.faq-item summary::after { float: left; }

/* ── Pros/cons bullets ── */
html[dir="rtl"] .pc-card ul { padding: 0; }
html[dir="rtl"] .pc-card li { padding-left: 0; padding-right: 1.4rem; }
html[dir="rtl"] .pc-card li::before { left: auto; right: 0; }

/* ══════════════════════════════════════════════════════════════
   DEMO BANNER — RTL fix
   styles.css at 979px makes the banner a 2-col grid (icon|text,
   text-align:left). Fighting that grid with RTL grid-column
   integers breaks layout. Cleanest fix: override to flex-column
   (same as the 480px LTR layout) so RTL reads top-to-bottom
   naturally with right-aligned text. Works on all mobile widths.
   ══════════════════════════════════════════════════════════════ */

/* Badge: absolute top-right in LTR → flip to top-left in RTL */
html[dir="rtl"] .demo-banner__badge {
  right: auto;
  left: 8px;
}

@media (max-width: 979px) {
  /* Override the grid to simple flex column */
  html[dir="rtl"] .demo-banner {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: right;
    gap: 0;
  }
  /* Reset any grid placement — irrelevant in flex */
  html[dir="rtl"] .demo-banner__icon,
  html[dir="rtl"] .demo-banner__title,
  html[dir="rtl"] .demo-banner__text,
  html[dir="rtl"] .demo-banner__perks,
  html[dir="rtl"] .demo-banner__cta,
  html[dir="rtl"] .demo-banner__fine {
    grid-column: auto;
    grid-row: auto;
    width: 100%;
    max-width: 100%;
  }
  html[dir="rtl"] .demo-banner__icon {
    width: auto;
    margin-bottom: 0.75rem;
    align-self: center;
  }
  html[dir="rtl"] .demo-banner__perks {
    text-align: right;
    margin-bottom: 0.75rem;
  }
  html[dir="rtl"] .demo-banner__perks li {
    flex-direction: row-reverse;
    justify-content: flex-end;
    flex: none;
    border-bottom: 1px solid var(--line);
    padding: 0.3rem 0;
  }
  html[dir="rtl"] .demo-banner__perks li:last-child {
    border-bottom: none;
  }
  html[dir="rtl"] .demo-banner__perks li::before {
    order: 9;
  }
  html[dir="rtl"] .demo-banner__cta {
    max-width: 100%;
  }
  html[dir="rtl"] .demo-banner__badge {
    right: auto;
    left: 16px;
  }
}

@media (max-width: 480px) {
  /* Already flex-column from above — just ensure alignment */
  html[dir="rtl"] .demo-banner {
    text-align: right;
    align-items: center;
  }
}

/* ── Mobile bottom TOC ── */
@media (max-width: 979px) {
  html[dir="rtl"] .mobile-bottom-toc__panel ol {
    padding-right: 1.15rem;
    padding-left: 0;
  }
  html[dir="rtl"] .mobile-bottom-toc > summary { text-align: center; }
}

/* ── Pay-cards (mobile) ── */
@media (max-width: 720px) {
  html[dir="rtl"] .pay-card-head { flex-direction: row-reverse; }
  html[dir="rtl"] .pay-kv:nth-child(even) {
    border-right: 1px solid var(--line);
    border-left: none;
  }
  html[dir="rtl"] .pay-kv:nth-child(odd) { border-right: none; }
}

/* ── Author block ── */
@media (max-width: 760px) {
  html[dir="rtl"] .author-block { flex-direction: column; }
}

/* ── Verdict ── */
html[dir="rtl"] .verdict__top {
  flex-direction: row-reverse;
  justify-content: flex-end;
}

/* ══════════════════════════════════════════════════════════════
   BACK TO TOP
   Physical right = bottom-right corner of screen.
   Green #00c853 matches .demo-banner__cta exactly.
   ══════════════════════════════════════════════════════════════ */
#back-to-top {
  position: fixed;
  bottom: calc(5.5rem + env(safe-area-inset-bottom));
  right: 1.25rem;
  left: auto;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #00c853;
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(0,200,83,0.45), 0 2px 6px rgba(0,0,0,0.12);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s, visibility 0.25s, transform 0.2s, box-shadow 0.2s;
  z-index: 50;
  padding: 0;
}

#back-to-top svg {
  width: 22px;
  height: 22px;
  stroke: #fff;
  fill: none;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  display: block;
  flex-shrink: 0;
  direction: ltr;
}

#back-to-top.visible  { opacity: 1; visibility: visible; }
#back-to-top:hover    { background: #00a844; transform: translateY(-3px); }
#back-to-top:active   { transform: translateY(-1px); }

@media (min-width: 980px) {
  #back-to-top { bottom: 2rem; right: 2rem; }
}
