/* =========================================================
   Library Common CSS (پایه مشترک تمام کتاب‌ها و متون)
   ========================================================= */

.library-container {
    font-family: 'IRANYekan', Tahoma, sans-serif !important;
    background-color: #fcfcfc;
    border: 1px solid #eaeaea;
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 24px;
    /*white-space: pre-line;
    line-height: 1.1;*/
    direction: rtl;
}

/* مقدمه و نشان‌ها */
.library-intro {
    margin-bottom: 15px;
}

.library-badge {
    display: inline-block;
    font-weight: bold;
    font-family: 'IRANYekan', sans-serif;
    font-size: 1rem;
    line-height: 1.4;
    margin-bottom: 0.5rem;
}

.library-intro-text {
    font-family: 'IRANYekan', sans-serif;
    line-height: 2.5;
    font-size: 17px;
    color: #0f1e35;
    margin: 0;
}

.library-note {
    background-color: #f8fafc;
    border-right: 4px solid #94a3b8;
    color: #475569;
    padding: 15px 20px;
    margin: 20px 0;
    border-radius: 4px;
    font-size: 0.95rem;
    line-height: 1.8;
    font-style: italic;
}

/* متادیتا (تعداد بخش‌ها، شرح‌ها و غیره) */
.library-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 12px 0 18px;
}

.library-meta-badge {
    display: inline-block;
    padding: 6px 12px;
    background: #f1f5f9;
    color: #334155;
    border: 1px solid #e2e8f0;
    border-radius: 999px;
    font-size: 13px;
    line-height: 1.6;
}

/* =========================================================
   متن عربی و ترجمه فارسی (فونت و اندازه‌های یکسان پروژه)
   ========================================================= */
.library-arabic {
    font-family: 'IRANYekan', Tahoma, sans-serif !important;
    font-size: 28px;
    line-height: 2.2;
    color: #5e2901;
    text-align: justify;
    padding: 10px 0;
    margin-top: 15px;
    direction: rtl;
}

.library-persian {
    font-family: 'IRANYekan', Tahoma, sans-serif !important;
    font-size: 16px;
    line-height: 1.9;
    color: #484327;
    text-align: justify;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid #f1f5f9;
}

/* ردیف‌ها */
.library-row {
    margin-bottom: 30px;
    padding-bottom: 24px;
    border-bottom: 2px solid #f1f5f9;
}

/* =========================================================
   ابزارها و سوئیچرها (تب‌ها برای تغییر مترجم/شارح)
   ========================================================= */
.library-toolbar {
    margin-bottom: 18px;
}

.library-switcher {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    width: 100%;
    margin-top: 8px;
    margin-bottom: 16px;
}

.library-switcher-label {
    color: #475569;
    font-size: 14px;
    font-weight: 700;
}

.library-chip {
    flex-shrink: 0;
    padding: 6px 12px;
    background: #eff6ff;
    color: #1d4ed8;
    border: 1px solid #dbeafe;
    border-radius: 999px;
    font-family: 'IRANYekan', Tahoma, sans-serif;
    font-size: 14px;
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.library-chip:hover {
    background: #dbeafe;
}

.library-chip.is-active {
    background: #1d4ed8;
    color: #fff;
    border-color: #1d4ed8;
}

/* =========================================================
   جعبه شرح‌ها (Commentary Box)
   ========================================================= */
.library-commentary-box {
    margin-top: 20px;
    padding: 16px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
}

.library-commentary-toggle {
    padding: 8px 14px;
    background: #f8fafc;
    color: #0f172a;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-family: 'IRANYekan', Tahoma, sans-serif;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
}

.library-commentary-toggle:hover {
    background: #e2e8f0;
}

.library-commentary-panel {
    margin-top: 12px;
    padding-top: 8px;
}

/* =========================================================
   واژه‌نامه / Glossary
   ========================================================= */
.library-vocab {
    direction: rtl;
    margin-top: 28px;
    padding: 20px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
}

.library-vocab h4 {
    display: inline-block;
    margin-top: 0;
    margin-bottom: 15px;
    padding-bottom: 6px;
    color: #0f172a;
    border-bottom: 2px solid #3b82f6;
    font-size: 16px;
    font-weight: 700;
}

.library-vocab > div {
    margin-bottom: 18px;
    padding-bottom: 12px;
    border-bottom: 1px dashed #e2e8f0;
}

.library-vocab > div:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.library-vocab h5 {
    margin: 0 0 10px;
    color: #2563eb;
    font-size: 14px;
    font-weight: 700;
}

.library-vocab ul {
    margin: 0;
    padding-right: 20px;
    list-style-type: disc;
}

.library-vocab li {
    margin-bottom: 6px;
    color: #334155;
    font-size: 14px;
    line-height: 1.8;
}

/* =========================================================
   ناوبری (Navigation)
   ========================================================= */
.library-nav {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-top: 24px;
}

.library-nav a {
    color: #1d4ed8;
    text-decoration: none;
    font-weight: 700;
}

.library-nav a:hover {
    text-decoration: underline;
}

/* =========================================================
   بخش ریسپانسیو و اسکرول موبایل تب‌ها
   ========================================================= */
@media (max-width: 768px) {
    .library-container {
        padding: 15px;
    }
    
    .library-arabic {
        font-size: 22px;
    }
    
    .library-persian {
        font-size: 15px;
    }

    .library-switcher {
        flex-wrap: nowrap;
        overflow-x: auto;
        padding-bottom: 8px;
        -webkit-overflow-scrolling: touch;
    }

    .library-switcher::-webkit-scrollbar {
        height: 4px;
    }

    .library-switcher::-webkit-scrollbar-track {
        background: #f1f5f9;
    }

    .library-switcher::-webkit-scrollbar-thumb {
        background: #cbd5e1;
        border-radius: 4px;
    }

    .library-switcher-label {
        position: sticky;
        right: 0;
        z-index: 2;
        padding-left: 8px;
        background: #fcfcfc;
        white-space: nowrap;
    }

    .library-chip {
        white-space: nowrap;
    }

    .library-nav {
        flex-direction: column;
    }
}
.library-section {
    scroll-margin-top: 90px;
}


/* =========================================================
   نوع محتوا: جلسه / درس
   ========================================================= */

.library-container--lesson {
    border-top: 4px solid #7c3f12;
}

/* =========================================================
   متادیتای درس
   پیشنهاد ساختار: هر آیتم شامل label و value باشد
   ========================================================= */

.library-meta {
    align-items: stretch;
}

.library-meta-date,
.library-meta-teacher,
.library-meta-location {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 38px;
    padding: 7px 12px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    color: #334155;
    font-family: 'IRANYekan', Tahoma, sans-serif;
    font-size: 13px;
    line-height: 1.7;
}

/* آیکن‌ها بدون نیاز به کتابخانه آیکن */
.library-meta-date::before {
    content: "📅";
    font-size: 14px;
}

.library-meta-teacher::before {
    content: "👤";
    font-size: 14px;
}

.library-meta-location::before {
    content: "⌖";
    font-size: 17px;
    line-height: 1;
    color: #7c3f12;
}

/* وقتی ساختار label/value را اضافه کردید */
.library-meta-label {
    color: #64748b;
    font-weight: 700;
    white-space: nowrap;
}

.library-meta-value {
    color: #0f172a;
    font-weight: 500;
}

/* =========================================================
   بدنه محتوای درس
   ========================================================= */

.library-content {
    margin-top: 18px;
    color: #1e293b;
    font-size: 16px;
    line-height: 2.15;
}

.library-content > :first-child {
    margin-top: 0;
}

.library-content > :last-child {
    margin-bottom: 0;
}

/* پاراگراف‌های عادی که کلاس ویژه ندارند */
.library-content p {
    margin: 0 0 18px;
    text-align: justify;
}

/* لینک‌های درون محتوا */
.library-content a:not(.library-footnote-ref) {
    color: #1d4ed8;
    text-decoration: underline;
    text-decoration-color: #bfdbfe;
    text-underline-offset: 3px;
}

.library-content a:not(.library-footnote-ref):hover {
    color: #1e40af;
    text-decoration-color: currentColor;
}

/* =========================================================
   عنوان‌های میانی درس
   برای حفظ استقلال از استایل کلی قالب، divها نیز پشتیبانی شده‌اند
   ========================================================= */

.library-title-h3,
.library-content h3 {
    position: relative;
    margin: 38px 0 18px;
    padding: 10px 14px 10px 0;
    color: #3f1d08;
    border-right: 4px solid #9a5a23;
    border-bottom: 1px solid #eadfD6;
    font-family: 'IRANYekan', Tahoma, sans-serif;
    font-size: 21px;
    font-weight: 800;
    line-height: 1.8;
}

.library-title-h4,
.library-content h4 {
    margin: 28px 0 14px;
    padding-right: 10px;
    color: #5e2901;
    border-right: 3px solid #d6a36d;
    font-family: 'IRANYekan', Tahoma, sans-serif;
    font-size: 18px;
    font-weight: 700;
    line-height: 1.9;
}

/* =========================================================
   پاورقی‌های ارجاعی داخل متن
   ========================================================= */

.library-footnote-ref {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 21px;
    height: 21px;
    margin: 0 2px;
    padding: 0 4px;
    background: #fff7ed;
    border: 1px solid #fed7aa;
    border-radius: 999px;
    color: #9a3412;
    font-family: Tahoma, sans-serif;
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
    text-decoration: none;
    vertical-align: text-top;
    transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.library-footnote-ref:hover,
.library-footnote-ref:focus {
    background: #9a3412;
    border-color: #9a3412;
    color: #ffffff;
    outline: none;
}

.library-footnote-ref:focus-visible {
    outline: 3px solid rgba(154, 52, 18, 0.25);
    outline-offset: 2px;
}

/* =========================================================
   باکس فهرست پاورقی‌ها
   ========================================================= */

.library-footnotes {
    margin-top: 32px;
    padding: 18px 20px;
    background: #fffcf8;
    border: 1px solid #f1e4d6;
    border-right: 4px solid #c08045;
    border-radius: 10px;
    color: #4a3322;
}

.library-footnotes__title {
    margin: 0 0 14px;
    color: #5e2901;
    font-family: 'IRANYekan', Tahoma, sans-serif;
    font-size: 16px;
    font-weight: 800;
    line-height: 1.7;
}

.library-footnotes__list {
    margin: 0;
    padding-right: 24px;
}

.library-footnotes__item {
    margin-bottom: 10px;
    padding-bottom: 10px;
    border-bottom: 1px dashed #ead7c3;
    color: #5b4a3b;
    font-size: 14px;
    line-height: 2;
}

.library-footnotes__item:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: 0;
}

/* هدف لینک پاورقی را در مرورگر مشخص‌تر می‌کند */
.library-footnotes__item:target {
    background: #fff3df;
    box-shadow: 0 0 0 5px #fff3df;
    border-radius: 4px;
}

/* =========================================================
   بهبود نمایش در موبایل
   ========================================================= */

@media (max-width: 768px) {
    .library-meta {
        display: grid;
        grid-template-columns: 1fr;
        gap: 7px;
    }

    .library-meta-date,
    .library-meta-teacher,
    .library-meta-location {
        width: 100%;
    }

    .library-content {
        font-size: 15px;
        line-height: 2.1;
    }

    .library-title-h3,
    .library-content h3 {
        margin-top: 30px;
        font-size: 19px;
    }

    .library-title-h4,
    .library-content h4 {
        font-size: 17px;
    }

    .library-footnotes {
        padding: 15px;
    }
}

.library-footnote-back {
    display: inline-block;
    margin-right: 6px;
    color: #9a3412;
    font-size: 14px;
    text-decoration: none;
}

.library-footnote-back:hover {
    color: #5e2901;
}


.library-quote {
    margin: 22px 0;
    padding: 14px 18px;
    background: #f8fafc;
    border-right: 4px solid #64748b;
    border-radius: 8px;
    color: #334155;
    font-size: 16px;
    line-height: 2.1;
}

.library-verse {
    margin: 22px 0;
    padding: 16px;
    background: #fffdf5;
    border: 1px solid #f3e5ab;
    border-radius: 8px;
    color: #5e2901;
    font-size: 22px;
    line-height: 2.2;
    text-align: center;
}

.library-lecture-note {
    margin: 20px 0;
    padding: 16px;
    background: #f0f7ff;
    border: 1px solid #cfe3fb;
    border-right: 4px solid #2563eb;
    border-radius: 8px;
}

.library-lecture-note__label {
    display: block;
    margin-bottom: 8px;
    color: #1d4ed8;
    font-size: 13px;
    font-weight: 800;
}

.library-quote blockquote {
    margin: 0;
}

.library-quote p {
    margin: 0;
}

.library-quote figcaption {
    margin-top: 10px;
    color: #64748b;
    font-size: 13px;
    font-style: normal;
    line-height: 1.9;
}

/* =========================================================
   اجزای داخلی آیه
   ========================================================= */

.library-verse blockquote,
.library-verse p {
    margin: 0;
}

.library-verse__arabic {
    font-family: 'IRANYekan', Tahoma, sans-serif;
    font-size: 24px;
    font-weight: 700;
    line-height: 2.2;
}

.library-verse__translation {
    margin-top: 12px !important;
    color: #6b5a20;
    font-size: 15px;
    font-weight: 400;
    line-height: 2;
}

.library-verse__reference {
    margin-top: 10px;
    color: #8a6b14;
    font-size: 13px;
    font-weight: 700;
    line-height: 1.8;
}

/* اگر متن آیه علاوه بر library-verse، کلاس library-arabic هم داشته باشد */
.library-verse .library-arabic {
    margin: 0;
    padding: 0;
    text-align: center;
}

/* =========================================================
   اجزای داخلی تقریر / توضیح استاد
   ========================================================= */

.library-lecture-note p {
    margin: 0 0 12px;
    color: #1e3a5f;
    font-size: 15px;
    line-height: 2.1;
    text-align: justify;
}

.library-lecture-note p:last-child {
    margin-bottom: 0;
}

/* در صورتی که label را با h4 بسازید، نه span */
.library-lecture-note h4.library-lecture-note__label {
    margin-top: 0;
}

