/* Anti-flash: hide body by default until i18n is applied.
   CSS is render-blocking, so this rule takes effect before <body> ever paints,
   even on slow networks. JS adds .i18n-ready once translation is done. */
html:not(.i18n-ready) body { visibility: hidden !important; }

/* Custom language switcher */
.lang-switcher { position: relative; margin-left: 16px; }
.lang-dropdown { position: relative; }
.lang-btn {
    background: #0044ff;
    color: #fff;
    border: none;
    border-radius: 20px;
    padding: 6px 14px;
    font-size: 14px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-family: 'Roboto', '宋体', sans-serif;
    line-height: 1.2;
    transition: background .2s;
}
.lang-btn:hover { background: #0033cc; }
.lang-btn svg { flex-shrink: 0; }
.lang-menu {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    list-style: none;
    padding: 6px 0;
    margin: 0;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
    min-width: 130px;
    display: none;
    z-index: 9999;
}
.lang-menu.open { display: block; }
.lang-menu li {
    padding: 8px 16px;
    cursor: pointer;
    font-size: 14px;
    color: #333;
    white-space: nowrap;
    transition: background .15s;
}
.lang-menu li:hover { background: #f0f4ff; color: #0044ff; }
.lang-menu li.active { color: #0044ff; font-weight: 600; }

/* RTL adjustments */
html[dir="rtl"] body { direction: rtl; text-align: right; }
html[dir="rtl"] .lang-switcher { margin-left: 0; margin-right: 16px; }
html[dir="rtl"] .lang-menu { right: auto; left: 0; }
html[dir="rtl"] .navbar-nav { padding-right: 0; }
html[dir="rtl"] .ml-auto { margin-left: 0 !important; margin-right: auto !important; }
html[dir="rtl"] .text-md-left { text-align: right !important; }
html[dir="rtl"] .text-left { text-align: right !important; }
/* Latin numerals/years should still flow LTR even in RTL context */
html[dir="rtl"] .intro_fslc_date,
html[dir="rtl"] .stat-card .num,
html[dir="rtl"] .feat-card .en,
html[dir="rtl"] .corp-intro .corp-en { direction: ltr; unicode-bidi: embed; }

/* Mobile */
@media (max-width: 991.98px) {
    .lang-switcher { margin: 8px 0 0 0; }
    html[dir="rtl"] .lang-switcher { margin: 8px 0 0 0; }
}
