/*
 * پشتیبانی چندزبانه/چندجهته -- بخش و، معماری زبان بالادست.
 * این فایل additive است: هیچ رفتار پیش‌فرض RTL/فارسی را حذف نمی‌کند،
 * فقط برای زبان‌های LTR (لاتین/چینی/ژاپنی و ...) رفتار درست را روی
 * چند نقطهٔ شناخته‌شدهٔ هاردکد-شدهٔ RTL در کد قدیمی اعمال می‌کند.
 *
 * Multi-language/multi-direction support -- بخش و, upstream language
 * architecture. Additive only: does not remove any RTL/Persian default
 * behavior, only corrects a handful of known hardcoded-RTL spots in the
 * legacy code for LTR languages (Latin scripts, Chinese, Japanese, ...).
 */

/* --- جهت‌دهی پایه --- Base direction --- */
html[dir="ltr"] body {
    direction: ltr;
    text-align: left;
}
html[dir="rtl"] body {
    direction: rtl;
    text-align: right;
}

/*
 * چند بخش قدیمی (header_template/*, snippets.blade.php) مقدار
 * "direction: rtl" را مستقیم در استایل خط تزریق می‌کنند، مستقل از
 * زبان انتخاب‌شده -- این‌ها با ویرایش کوچک به شرط زبان مشروط شدند
 * (بخش و)؛ این بلوک فقط یک لایهٔ دفاعی دوم additive است.
 * A few legacy partials hardcode "direction: rtl" inline regardless of
 * the selected language -- those were made conditional at the source
 * (بخش و); this block is just an additive second line of defense.
 */
html[dir="ltr"] .header-search {
    direction: ltr !important;
}
html[dir="ltr"] .lang-box {
    direction: ltr !important;
}

/* آیکون/عکس‌های جهت‌دار (فلش/چوروم) که باید در LTR آینه شوند */
/* Direction-sensitive icons/arrows that must mirror under LTR */
html[dir="ltr"] .rtl-mirror,
html[dir="ltr"] .bi-chevron-right,
html[dir="ltr"] .fa-chevron-right {
    transform: scaleX(-1);
}
html[dir="ltr"] .bi-chevron-left,
html[dir="ltr"] .fa-chevron-left {
    transform: scaleX(-1);
}

/*
 * فونت مناسب هر خانوادهٔ زبانی -- پشتیبانی چینی/ژاپنی/کره‌ای (CJK)
 * علاوه بر لاتین -- بدون حذف فونت فارسی پیش‌فرض برای زبان‌های راست‌چین.
 * Script-appropriate font stacks -- adds CJK support alongside Latin,
 * without removing the default Persian font for RTL languages.
 */
:lang(zh) body, html[lang^="zh"] body {
    font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", "Heiti SC", sans-serif;
}
:lang(ja) body, html[lang="ja"] body {
    font-family: "Hiragino Sans", "Yu Gothic", "Noto Sans JP", "Meiryo", sans-serif;
}
:lang(ko) body, html[lang="ko"] body {
    font-family: "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", sans-serif;
}
html[dir="ltr"]:not([lang^="zh"]):not([lang="ja"]):not([lang="ko"]) body {
    font-family: "Segoe UI", Roboto, Arial, "OpenSans", sans-serif;
}

/* پنل‌های مدیریت (استور/مدیا) -- همان منطق برای دراپ‌داون زبان مشترک */
/* Admin panels (store/media) -- same logic for the shared language switcher */
.panel-lang-switcher select {
    border-radius: 8px;
}

/*
 * سلسله‌مراتب تایپوگرافی -- برای هر محتوای جدیدی که در بخش و ساخته
 * می‌شود (صفحات/زبان‌های جدید). مقادیر پایه‌اند (specificity معمولی، نه
 * !important) تا استایل‌های اختصاصی هر سکشن که از قبل تعریف شده‌اند
 * (styles.blade.php و غیره) دست‌نخورده بمانند -- این فقط یک پیش‌فرض
 * حرفه‌ای برای عنوان/زیرعنوان/متنی‌ست که هنوز استایل اختصاصی ندارد.
 * فارسی به‌خاطر پیچیدگی بصری بیشتر حروف، line-height بزرگ‌تری می‌گیرد.
 *
 * Typographic hierarchy -- for any new content created in بخش و
 * (new pages/languages). Base-specificity values (not !important) so
 * per-section styles already defined elsewhere (styles.blade.php etc.)
 * remain untouched -- this is only a professional default for
 * headings/subheadings/body text that don't yet have dedicated styling.
 * Persian gets a taller line-height due to its visually denser script.
 */
h1, .type-h1 {
    font-size: 2.75rem;
    font-weight: 700;
    line-height: 1.25;
    margin-bottom: 0.6em;
}
h2, .type-h2 {
    font-size: 2.125rem;
    font-weight: 700;
    line-height: 1.3;
    margin-bottom: 0.55em;
}
h3, .type-h3 {
    font-size: 1.625rem;
    font-weight: 600;
    line-height: 1.35;
    margin-bottom: 0.5em;
}
h4, .type-h4 {
    font-size: 1.25rem;
    font-weight: 600;
    line-height: 1.4;
    margin-bottom: 0.5em;
}
p, .type-body {
    font-size: 1rem;
    line-height: 1.7;
}
html[dir="rtl"] h1, html[dir="rtl"] .type-h1 { line-height: 1.35; }
html[dir="rtl"] h2, html[dir="rtl"] .type-h2 { line-height: 1.4; }
html[dir="rtl"] h3, html[dir="rtl"] .type-h3 { line-height: 1.45; }
html[dir="rtl"] p, html[dir="rtl"] .type-body { line-height: 1.85; }

@media (max-width: 767px) {
    h1, .type-h1 { font-size: 1.875rem; }
    h2, .type-h2 { font-size: 1.5rem; }
    h3, .type-h3 { font-size: 1.25rem; }
    h4, .type-h4 { font-size: 1.1rem; }
}
