/* Persian typography -------------------------------------------------------
   Vazirmatn variable webfont is used for Persian glyphs, loaded from the public
   jsDelivr CDN (the project ships no font file). An optional self-hosted copy at
   fonts/fa/Vazirmatn-Variable.woff2 is used if the CDN cannot be reached.
   Latin brand names, emails and codes continue to fall back to Inter/system. */
@font-face {
    font-family: 'Vazirmatn';
    src: url('https://cdn.jsdelivr.net/npm/vazirmatn@33.0.3/fonts/webfonts/Vazirmatn%5Bwght%5D.woff2') format('woff2'),
         url('fonts/fa/Vazirmatn-Variable.woff2') format('woff2');
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
    unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+200C-200F, U+202A-202E, U+2066-2069, U+FB50-FDFF, U+FE70-FEFF;
}

html[lang="fa"] body,
html[lang="fa"] input,
html[lang="fa"] textarea,
html[lang="fa"] select,
html[lang="fa"] button {
    font-family: 'Vazirmatn', 'Inter', Tahoma, Arial, sans-serif;
}

html[lang="fa"] body {
    line-height: 1.8;
}

html[lang="fa"] h1,
html[lang="fa"] h2,
html[lang="fa"] h3,
html[lang="fa"] h4,
html[lang="fa"] h5,
html[lang="fa"] h6 {
    line-height: 1.55;
    letter-spacing: 0;
}

/* Persian letters join to their neighbours; any tracking, positive or negative, breaks the joins.
   Labels styled as spaced capitals in Spanish and English therefore lose their tracking here. */
html[lang="fa"] body * {
    letter-spacing: 0 !important;
}

html[lang="fa"] h1,
html[lang="fa"] h2,
html[lang="fa"] h3,
html[lang="fa"] h4,
html[lang="fa"] h5,
html[lang="fa"] h6,
html[lang="fa"] strong,
html[lang="fa"] b,
html[lang="fa"] .btn-primary,
html[lang="fa"] .btn-secondary,
html[lang="fa"] .portal-button {
    font-weight: 700;
}

/* CBSP trilingual support: Persian RTL + compact language controls */
html[dir="rtl"] body {
    direction: rtl;
    text-align: right;
}

html[dir="rtl"] input,
html[dir="rtl"] textarea,
html[dir="rtl"] select,
html[dir="rtl"] button {
    font-family: inherit;
}

html[dir="rtl"] input[type="email"],
html[dir="rtl"] input[type="tel"],
html[dir="rtl"] input[type="url"],
html[dir="rtl"] .footer-contact-email,
html[dir="rtl"] [dir="ltr"],
html[dir="rtl"] code {
    direction: ltr;
    text-align: left;
    unicode-bidi: plaintext;
}

html[dir="rtl"] .header-inner,
html[dir="rtl"] .nav,
html[dir="rtl"] .footer-contact-row,
html[dir="rtl"] .footer-whatsapp-card,
html[dir="rtl"] .product-hero-meta,
html[dir="rtl"] .portal-topbar,
html[dir="rtl"] .portal-topbar-actions,
html[dir="rtl"] .portal-sidebar-brand,
html[dir="rtl"] .portal-sidebar-user,
html[dir="rtl"] .portal-nav-button,
html[dir="rtl"] .auth-brand-top {
    direction: rtl;
}

html[dir="rtl"] .breadcrumb,
html[dir="rtl"] .product-detail-toc-links,
html[dir="rtl"] .product-quick-facts,
html[dir="rtl"] .cards-grid,
html[dir="rtl"] .insurance-grid,
html[dir="rtl"] .complements-grid,
html[dir="rtl"] .footer-grid {
    direction: rtl;
}

html[dir="rtl"] ul:not(.portal-nav),
html[dir="rtl"] ol {
    padding-inline-start: 0;
    padding-inline-end: 1.4rem;
}

html[dir="rtl"] .mobile-nav-toggle,
html[dir="rtl"] .portal-mobile-menu {
    direction: ltr;
}

.lang-switcher .lang-btn,
.portal-language-switcher .portal-language-button {
    white-space: nowrap;
}

.site-language-floating {
    position: fixed;
    top: max(12px, env(safe-area-inset-top));
    right: max(12px, env(safe-area-inset-right));
    z-index: 1200;
    display: inline-flex;
    overflow: hidden;
    border: 1px solid #0877bd;
    border-radius: 8px;
    background: rgba(255,255,255,0.96);
    box-shadow: 0 8px 28px rgba(15, 23, 42, 0.14);
    backdrop-filter: blur(8px);
}

html[dir="rtl"] .site-language-floating {
    right: auto;
    left: max(12px, env(safe-area-inset-left));
}

.site-language-floating button {
    min-width: 44px;
    min-height: 36px;
    padding: 0.35rem 0.65rem;
    border: 0;
    border-inline-end: 1px solid rgba(8,119,189,0.2);
    background: transparent;
    color: #075f98;
    font: 700 0.78rem/1 Inter, Arial, sans-serif;
    cursor: pointer;
}

.site-language-floating button:last-child { border-inline-end: 0; }
.site-language-floating button.active,
.site-language-floating button.is-active {
    background: #0877bd;
    color: #fff;
}


@media (max-width: 900px) {
    .header .lang-switcher {
        width: min(100%, 190px);
    }
    .header .lang-btn {
        flex: 1 1 0;
        min-width: 0 !important;
        padding-inline: 0.6rem;
    }
    html[dir="rtl"] .header .nav-link {
        text-align: center;
        justify-content: center;
    }
}

@media (max-width: 520px) {
    .site-language-floating {
        top: max(8px, env(safe-area-inset-top));
        right: max(8px, env(safe-area-inset-right));
    }
    html[dir="rtl"] .site-language-floating {
        right: auto;
        left: max(8px, env(safe-area-inset-left));
    }
    .site-language-floating button {
        min-width: 40px;
        min-height: 34px;
        padding-inline: 0.5rem;
    }
}

/* Phone numbers keep their left-to-right order inside Persian pages ("+34 677 377 710"). */
html[dir="rtl"] a[href^="tel:"] strong {
    direction: ltr;
    unicode-bidi: isolate;
    text-align: right;
}

/* The footer WhatsApp card points the way Persian reads. */
html[dir="rtl"] .footer-whatsapp-arrow {
    display: inline-block;
    transform: scaleX(-1);
}

html[dir="rtl"] .footer-whatsapp-card:hover .footer-whatsapp-arrow {
    transform: scaleX(-1) translateX(3px);
}
