/* راست‌به‌چپ‌سازی راهنمای آنکی — RTL fixes for the Persian Anki manual */

/* فونت وزیرمتن (موجود در src/fonts) */
@font-face {
    font-family: 'Vazirmatn';
    src: url('../fonts/Vazirmatn-Regular.woff2') format('woff2');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Vazirmatn';
    src: url('../fonts/Vazirmatn-Medium.woff2') format('woff2');
    font-weight: 500;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Vazirmatn';
    src: url('../fonts/Vazirmatn-Bold.woff2') format('woff2');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

body {
    direction: rtl;
    font-family: 'Vazirmatn', 'Iranian Sans', Tahoma, sans-serif !important;
}

/* ============================================================
   RTL chrome: menu bar, page nav, sidebar, popups
   نوار منو: همبرگر و دکمه‌ها در سمت راست
   ============================================================ */

#menu-bar {
    direction: rtl;
}

/* پنجره انتخاب پوسته: به لبه راست چسبیده باشد */
.theme-popup {
    left: auto;
    right: 10px;
}
.theme-popup .theme {
    text-align: right;
}
.theme-selected::before {
    margin-left: 0;
    margin-right: -14px;
}

/* ناوبری صفحه: «بعدی» سمت چپ، «قبلی» سمت راست */
.nav-wide-wrapper {
    direction: rtl;
}
.nav-chapters.previous {
    float: none;
    left: auto;
    right: 0;
}
.nav-chapters.next {
    float: none;
    right: auto;
    left: 0;
}

.nav-wrapper {
    direction: rtl;
}
.mobile-nav-chapters.previous {
    float: right;
}
.mobile-nav-chapters.next {
    float: left;
}

/* نوار کناری (فهرست): سمت راست صفحه */
.sidebar {
    left: auto;
    right: 0;
}
.sidebar .sidebar-resize-handle {
    right: auto;
    left: 0;
}
.sidebar-hidden .sidebar {
    transform: translateX(var(--sidebar-width));
}
.sidebar-visible .page-wrapper {
    transform: translateX(calc(0px - var(--sidebar-width)));
}
@media only screen and (min-width: 620px) {
    .sidebar-visible .page-wrapper {
        transform: none;
        margin-left: 0;
        margin-right: var(--sidebar-width);
    }
}
.js:not(.sidebar-resizing) .page-wrapper {
    transition: margin-right 0.3s ease, transform 0.3s ease;
}

/* نشانگر پرش به سرفصل‌ها در سمت راست */
h1:target::before, h2:target::before, h3:target::before,
h4:target::before, h5:target::before, h6:target::before {
    content: "«";
    margin-left: 0;
    margin-right: -30px;
}

/* جست‌وجو */
#searchbar, #searchbar.searchbar input {
    direction: rtl;
    text-align: right;
}
ul#searchresults {
    padding-left: 0;
    padding-right: 20px;
}
.searchresults-header {
    padding: 18px 5px 0 0;
}

/* tooltipها */
.tooltiptext {
    left: auto;
    right: -8px;
    transform: translateX(50%);
}

/* ============================================================
   RTL content rules
   ============================================================ */

/* کدها همیشه چپ‌به‌راست می‌مانند */
code, pre, .playpen, pre > code {
    direction: ltr;
    font-family: var(--mono-font, ui-monospace, SFMono-Regular, Menlo, Consolas, monospace);
    text-align: left;
}
.hljs {
    unicode-bidi: plaintext;
}
pre {
    text-align: left;
}

/* جدول‌ها: ستون‌ها از راست خوانده می‌شوند، اما محتوای سلول‌های کد LTR می‌مانند */
td, th {
    direction: rtl;
}
td code, th code {
    direction: ltr;
    unicode-bidi: embed;
}

/* جعبه‌های admonish در چیدمان RTL */
.admonish {
    direction: rtl;
}
.admonish code {
    direction: ltr;
    unicode-bidi: embed;
}

/* اعداد و کلیدهای صفحه‌کلید داخل متن */
kbd {
    direction: ltr;
    unicode-bidi: embed;
    font-family: sans-serif;
}
