/* =========================================================
   Local Shabnam Font - Loaded from mdBook fonts directory
   ========================================================= */
@font-face {
    font-family: 'Shabnam';
    src: url('../fonts/Shabnam-540d3f4e.woff2') format('woff2');
    font-weight: normal;
    font-style: normal;
    font-display: block;
}

@font-face {
    font-family: 'Shabnam';
    src: url('../fonts/Shabnam-Medium-fd5931f5.woff2') format('woff2');
    font-weight: 500;
    font-style: normal;
    font-display: block;
}

@font-face {
    font-family: 'Shabnam';
    src: url('../fonts/Shabnam-Bold-1ff187f5.woff2') format('woff2');
    font-weight: bold;
    font-style: normal;
    font-display: block;
}

:root {
    --content-max-width: 950px;
}

/* =========================================================
   Base Body Typography - Local Shabnam
   ========================================================= */
body, .content main {
    font-family: 'Shabnam', sans-serif !important;
    direction: rtl;
    text-align: justify;
    font-size: 20px !important;
    font-weight: normal !important;
    line-height: 2.2 !important;
    color: var(--fg) !important;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Paragraphs */
.content main p {
    font-family: 'Shabnam', sans-serif !important;
    font-size: 20px !important;
    line-height: 2.2 !important;
    margin-top: 22px !important;
    margin-bottom: 22px !important;
    color: var(--fg) !important;
}

/* Headings */
.content main h1 {
    font-family: 'Shabnam', sans-serif !important;
    font-size: 34px !important;
    font-weight: bold !important;
    line-height: 1.5 !important;
    margin-top: 36px !important;
    margin-bottom: 20px !important;
    color: var(--fg) !important;
}

.content main h2 {
    font-family: 'Shabnam', sans-serif !important;
    font-size: 27px !important;
    font-weight: bold !important;
    line-height: 1.5 !important;
    margin-top: 32px !important;
    margin-bottom: 18px !important;
    color: var(--fg) !important;
}

.content main h3 {
    font-family: 'Shabnam', sans-serif !important;
    font-size: 22px !important;
    font-weight: bold !important;
    line-height: 1.5 !important;
    margin-top: 26px !important;
    margin-bottom: 14px !important;
    color: var(--fg) !important;
}

.content main h4 {
    font-family: 'Shabnam', sans-serif !important;
    font-size: 20px !important;
    font-weight: bold !important;
    margin-top: 20px !important;
    margin-bottom: 10px !important;
    color: var(--fg) !important;
}

/* Lists */
.content main li {
    font-family: 'Shabnam', sans-serif !important;
    font-size: 19px !important;
    line-height: 2.1 !important;
    margin-top: 10px !important;
    margin-bottom: 10px !important;
    color: var(--fg) !important;
}

/* Strong bold keywords */
.content main strong,
.content main b {
    font-weight: bold !important;
    color: var(--fg) !important;
}

/* =========================================================
   Sidebar Typography
   ========================================================= */
.sidebar {
    font-family: 'Shabnam', sans-serif !important;
    direction: rtl !important;
    text-align: right !important;
    font-size: 18px !important;
}

.sidebar-brand-header {
    padding: 16px 12px 12px 12px !important;
    margin-bottom: 8px !important;
    border-bottom: 1px solid var(--sidebar-spacer, rgba(255, 255, 255, 0.12)) !important;
    direction: rtl !important;
    text-align: right !important;
}

.sidebar-brand-link {
    font-family: 'Shabnam', sans-serif !important;
    font-size: 22px !important;
    font-weight: bold !important;
    color: var(--sidebar-fg, #ffffff) !important;
    text-decoration: none !important;
    display: inline-block !important;
}

.sidebar-brand-link:hover {
    color: var(--sidebar-active, #38bdf8) !important;
}

.sidebar .part-title {
    font-family: 'Shabnam', sans-serif !important;
    font-size: 19px !important;
    font-weight: bold !important;
    color: var(--sidebar-active, #60a5fa) !important;
    padding: 18px 8px 8px 8px !important;
    border-bottom: 1px solid var(--sidebar-spacer, rgba(255, 255, 255, 0.15)) !important;
    margin-bottom: 8px !important;
}

.sidebar ol.chapter {
    padding-right: 0 !important;
    margin-right: 0 !important;
}

.sidebar li.chapter-item {
    line-height: 1.7 !important;
    margin: 6px 0 !important;
}

.sidebar li.chapter-item a {
    font-family: 'Shabnam', sans-serif !important;
    display: block;
    padding: 8px 10px !important;
    border-radius: 6px;
    font-size: 18px !important;
    font-weight: normal !important;
    color: var(--sidebar-fg) !important;
    transition: background 0.15s ease, color 0.15s ease;
}

.sidebar li.chapter-item a:hover {
    background-color: var(--theme-hover) !important;
    color: var(--sidebar-active) !important;
}

.sidebar li.chapter-item.active > a,
.sidebar li.chapter-item a.active {
    background-color: rgba(56, 189, 248, 0.18) !important;
    color: var(--sidebar-active) !important;
    font-weight: bold !important;
}

.sidebar li.chapter-item a strong {
    font-family: 'Shabnam', sans-serif !important;
    margin-left: 8px !important;
    font-weight: bold !important;
    font-size: 19px !important;
    color: var(--sidebar-active, #38bdf8) !important;
}

/* mdBook On-This-Page in Sidebar */
.on-this-page {
    margin-left: 0 !important;
    margin-right: 18px !important;
    margin-top: 8px !important;
    margin-bottom: 14px !important;
    border-inline-start: none !important;
    border-right: 3px solid var(--sidebar-active, #38bdf8) !important;
    padding-left: 0 !important;
    padding-right: 12px !important;
}

.on-this-page > ol {
    padding-right: 0 !important;
    padding-left: 0 !important;
    list-style: none !important;
}

.on-this-page li.header-item {
    margin-block-end: 6px !important;
    line-height: 1.6em !important;
}

.on-this-page li.header-item a {
    font-family: 'Shabnam', sans-serif !important;
    font-size: 17px !important;
    color: var(--sidebar-fg) !important;
    opacity: 0.82 !important;
    padding: 4px 8px !important;
    border-radius: 4px;
    transition: all 0.15s ease;
}

.on-this-page li.header-item a:hover {
    color: var(--sidebar-active) !important;
    opacity: 1 !important;
    background-color: var(--theme-hover) !important;
}

.chapter a.current-header,
.on-this-page a.current-header {
    color: var(--sidebar-active) !important;
    opacity: 1 !important;
    font-weight: bold !important;
    background-color: rgba(56, 189, 248, 0.15) !important;
}

/* Callout / Note Boxes */
.callout {
    margin: 26px 0 !important;
    padding: 18px 22px !important;
    border-radius: 8px;
    border-right: 5px solid var(--links, #38bdf8);
    background-color: var(--quote-bg, rgba(30, 41, 59, 0.7));
    font-size: 19px !important;
    line-height: 2.1 !important;
    color: var(--fg) !important;
}

.callout-title {
    font-family: 'Shabnam', sans-serif !important;
    font-weight: bold !important;
    margin-bottom: 10px !important;
    color: var(--links, #38bdf8);
    font-size: 21px !important;
    line-height: 1.5 !important;
}

.callout p {
    font-family: 'Shabnam', sans-serif !important;
    font-size: 19px !important;
    line-height: 2.1 !important;
    margin: 8px 0 !important;
    color: var(--fg) !important;
}

.callout-warning, .callout-caution {
    border-right-color: var(--blockquote-warning-color, #f59e0b);
    background-color: var(--quote-bg, rgba(180, 83, 9, 0.2));
}
.callout-warning .callout-title, .callout-caution .callout-title {
    color: var(--blockquote-warning-color, #d97706);
}

.callout-important {
    border-right-color: var(--blockquote-important-color, #a855f7);
    background-color: var(--quote-bg, rgba(126, 34, 206, 0.2));
}
.callout-important .callout-title {
    color: var(--blockquote-important-color, #9333ea);
}

.callout-tip {
    border-right-color: var(--blockquote-tip-color, #10b981);
    background-color: var(--quote-bg, rgba(4, 120, 87, 0.2));
}
.callout-tip .callout-title {
    color: var(--blockquote-tip-color, #059669);
}

/* Math formatting */
.katex-display, .MathJax_Display {
    direction: ltr !important;
    text-align: center !important;
    margin: 20px 0 !important;
}

.katex, .MathJax {
    direction: ltr !important;
}

/* Navigation arrows */
.nav-chapters {
    direction: ltr;
}

/* RTL Sidebar drag handle */
[dir=rtl] .sidebar .sidebar-resize-handle,
.sidebar-resize-handle {
    cursor: col-resize !important;
    width: 10px !important;
}
html.sidebar-resizing,
html.sidebar-resizing * {
    cursor: col-resize !important;
    user-select: none !important;
}

/* =========================================================
   Mobile Responsiveness & Fluid Typography
   ========================================================= */
@media only screen and (max-width: 768px) {
    body, .content main {
        font-size: 16.5px !important;
        line-height: 1.95 !important;
        text-align: right !important; /* Avoid unnatural Persian justification on small screens */
    }

    .content main p {
        font-size: 16.5px !important;
        line-height: 1.95 !important;
        margin-top: 14px !important;
        margin-bottom: 14px !important;
    }

    .content main h1 {
        font-size: 24px !important;
        line-height: 1.4 !important;
        margin-top: 22px !important;
        margin-bottom: 14px !important;
    }

    .content main h2 {
        font-size: 20px !important;
        line-height: 1.4 !important;
        margin-top: 20px !important;
        margin-bottom: 12px !important;
    }

    .content main h3 {
        font-size: 18px !important;
        line-height: 1.4 !important;
        margin-top: 18px !important;
        margin-bottom: 10px !important;
    }

    .content main h4 {
        font-size: 16.5px !important;
        margin-top: 14px !important;
        margin-bottom: 8px !important;
    }

    .content main li {
        font-size: 16px !important;
        line-height: 1.85 !important;
        margin-top: 8px !important;
        margin-bottom: 8px !important;
    }

    .callout {
        padding: 12px 14px !important;
        margin: 16px 0 !important;
    }

    .callout-title {
        font-size: 17px !important;
        margin-bottom: 6px !important;
    }

    .callout p {
        font-size: 15.5px !important;
        line-height: 1.85 !important;
        margin: 6px 0 !important;
    }

    .sidebar {
        font-size: 16px !important;
    }

    .sidebar-brand-link {
        font-size: 19px !important;
    }

    .sidebar .part-title {
        font-size: 16.5px !important;
        padding: 14px 6px 6px 6px !important;
    }

    .sidebar li.chapter-item {
        font-size: 15.5px !important;
        line-height: 1.6 !important;
    }

    /* Math sizing on mobile to prevent overflow */
    .katex {
        font-size: 1.05em !important;
    }

    .katex-display {
        overflow-x: auto !important;
        overflow-y: hidden !important;
        padding: 6px 0 !important;
        margin: 14px 0 !important;
    }
}

