/*
 * Persian numerals, site-wide.
 *
 * The digit-only faces below map the ASCII digits (U+0030-0039) onto Persian
 * numeral glyphs, so every 0-9 the site prints renders as ۰-۹ without touching
 * the underlying text. Because they are declared under the *same* family names
 * the stylesheets already ask for, any rule that says `font-family: Peyda` (or
 * iranyekan, IRANSans, ...) picks them up automatically -- no per-element
 * `.fa-number` class needed, and JS-rendered numbers are covered too.
 *
 * The Peyda digits are cut from Peyda's own U+06F0-06F9 glyphs, so they match
 * the site typeface exactly. Loaded only when the locale is fa.
 *
 * Escape hatch: add class `en-number` to anything that must stay Latin.
 */

/* Peyda's own Persian digits, remapped onto 0-9 */
@font-face {
    font-family: 'PeydaFaDigits';
    src: url('/fonts/peyda/Peyda-Digits-FaNum.woff2') format('woff2');
    font-weight: 100 900;
    font-style: normal;
    font-display: block;
    unicode-range: U+0030-0039;
}

/* IranYekan FaNum digits, for the places still set in iranyekan */
@font-face {
    font-family: 'YekanFaDigits';
    src: url('/fonts/iranyekan-digits-fanum-regular.woff2') format('woff2');
    font-weight: 100 500;
    font-style: normal;
    font-display: block;
    unicode-range: U+0030-0039;
}
@font-face {
    font-family: 'YekanFaDigits';
    src: url('/fonts/iranyekan-digits-fanum-bold.woff2') format('woff2');
    font-weight: 600 900;
    font-style: normal;
    font-display: block;
    unicode-range: U+0030-0039;
}

/* Untouched Peyda, kept under a private name for the `en-number` escape hatch */
@font-face {
    font-family: 'PeydaLatinNum';
    src: url('/fonts/peyda/Peyda-Regular.woff2') format('woff2');
    font-weight: 100 900;
    font-style: normal;
    font-display: swap;
}

/* ---- Shadow the digit range of every family the site actually asks for ---- */

@font-face {
    font-family: 'Peyda';
    src: url('/fonts/peyda/Peyda-Digits-FaNum.woff2') format('woff2');
    font-weight: 100 900;
    font-style: normal;
    font-display: block;
    unicode-range: U+0030-0039;
}

@font-face {
    font-family: 'iranyekan';
    src: url('/fonts/iranyekan-digits-fanum-regular.woff2') format('woff2');
    font-weight: 100 500;
    font-style: normal;
    font-display: block;
    unicode-range: U+0030-0039;
}
@font-face {
    font-family: 'iranyekan';
    src: url('/fonts/iranyekan-digits-fanum-bold.woff2') format('woff2');
    font-weight: 600 900;
    font-style: normal;
    font-display: block;
    unicode-range: U+0030-0039;
}

@font-face {
    font-family: 'IRANSans';
    src: url('/fonts/iranyekan-digits-fanum-regular.woff2') format('woff2');
    font-weight: 100 500;
    font-style: normal;
    font-display: block;
    unicode-range: U+0030-0039;
}
@font-face {
    font-family: 'IRANSans';
    src: url('/fonts/iranyekan-digits-fanum-bold.woff2') format('woff2');
    font-weight: 600 900;
    font-style: normal;
    font-display: block;
    unicode-range: U+0030-0039;
}

@font-face {
    font-family: 'Vazirmatn';
    src: url('/fonts/peyda/Peyda-Digits-FaNum.woff2') format('woff2');
    font-weight: 100 900;
    font-style: normal;
    font-display: block;
    unicode-range: U+0030-0039;
}

@font-face {
    font-family: 'Nunito';
    src: url('/fonts/peyda/Peyda-Digits-FaNum.woff2') format('woff2');
    font-weight: 100 900;
    font-style: normal;
    font-display: block;
    unicode-range: U+0030-0039;
}

/* Last-resort system fallbacks: only the digit range is shadowed */
@font-face {
    font-family: 'Tahoma';
    src: url('/fonts/peyda/Peyda-Digits-FaNum.woff2') format('woff2');
    font-weight: 100 900;
    font-style: normal;
    font-display: block;
    unicode-range: U+0030-0039;
}
@font-face {
    font-family: 'Arial';
    src: url('/fonts/peyda/Peyda-Digits-FaNum.woff2') format('woff2');
    font-weight: 100 900;
    font-style: normal;
    font-display: block;
    unicode-range: U+0030-0039;
}

/* ---- Catch the elements no named family reaches ---- */

/* `sans-serif`/`system-ui` and unstyled elements inherit from body, which the
   site sets to Peyda; this makes the fallback explicit for anything that
   slipped through (e.g. ::placeholder, table cells in user HTML). */
html[lang="fa"] body,
html[lang="fa"] :not([type="email"]):not([type="password"]):not([type="url"])::placeholder,
html[lang="fa"] option,
html[lang="fa"] optgroup {
    font-family: 'PeydaFaDigits', 'Peyda', 'YekanFaDigits', 'iranyekan', Tahoma, sans-serif;
}

/* `.fa-number` used to be the per-element opt-in. Digits are Persian
   everywhere now, so let those elements keep the surrounding typeface instead
   of switching to IranYekan mid-sentence. */
html[lang="fa"] .fa-number {
    font-family: inherit !important;
}

/* ---- Escape hatch: keep Latin digits where they are actually Latin ---- */
/* Note the fallbacks: Tahoma/Arial are deliberately absent here, their digit
   range is shadowed above. */
html[lang="fa"] .en-number,
html[lang="fa"] .en-number *,
html[lang="fa"] input[type="email"],
html[lang="fa"] input[type="password"],
html[lang="fa"] input[type="url"] {
    font-family: 'PeydaLatinNum', system-ui, sans-serif !important;
}

html[lang="fa"] code,
html[lang="fa"] pre,
html[lang="fa"] kbd,
html[lang="fa"] samp {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace !important;
}
