/*
 * SolaimanLipi -- the Bengali face used across the whole site.
 *
 * Ekushey SolaimanLipi, designed by Solaiman Karim, distributed free by
 * Ekushey. Served from this folder rather than a third party CDN so the site
 * is not one outage away from losing its Bengali type.
 *
 * =========================================================================
 * How this only affects Bengali
 * =========================================================================
 *
 * Every @font-face below carries a `unicode-range` covering the Bengali
 * block. A browser only downloads and applies a face for the characters in
 * its range, so naming SolaimanLipi *first* in a font stack means:
 *
 *     Bengali characters  -> SolaimanLipi
 *     everything else     -> the next family in the list, exactly as before
 *
 * That is why the stacks below end with the Latin families the site already
 * uses. Each context only loads its own: 'Plus Jakarta Sans' in the admin
 * panel, 'Inter' on the printable invoices, and the system stack on the
 * storefront. A family that is not loaded is skipped, so one stack serves all
 * three without changing any of their Latin type.
 *
 * Ranges covered:
 *   U+0980-09FF  Bengali block -- letters, digits, and the taka sign U+09F3
 *   U+200C-200D  ZWNJ / ZWJ, which control conjunct forms
 *   U+25CC       dotted circle, shown for an isolated combining mark
 * =========================================================================
 */

/*
 * Why 112%
 * --------
 * Bengali sits on a lower x-height than Latin at the same nominal size, so
 * SolaimanLipi at 13px reads noticeably smaller than Plus Jakarta Sans at
 * 13px beside it -- which is what made the admin tables hard to read.
 *
 * size-adjust scales the glyphs of this face only. It is the right tool
 * here because the face is already limited to the Bengali block: Latin
 * keeps its size, a heading that mixes the two still lines up, and no page
 * needs a rule of its own.
 */

@font-face {
    font-family: 'SolaimanLipi';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url('solaimanlipi-normal-v1.0.woff2') format('woff2'),
         url('solaimanlipi-normal-v1.0.ttf') format('truetype');
    size-adjust: 112%;
    unicode-range: U+0980-09FF, U+200C-200D, U+25CC;
}

/* 500 maps to the regular cut: SolaimanLipi ships no true mid weight, and a
   browser-synthesised one smears the conjuncts. */
@font-face {
    font-family: 'SolaimanLipi';
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url('solaimanlipi-normal-v1.0.woff2') format('woff2'),
         url('solaimanlipi-normal-v1.0.ttf') format('truetype');
    size-adjust: 112%;
    unicode-range: U+0980-09FF, U+200C-200D, U+25CC;
}

@font-face {
    font-family: 'SolaimanLipi';
    font-style: normal;
    font-weight: 600 900;
    font-display: swap;
    src: url('solaimanlipi-bold-v1.0.woff2') format('woff2'),
         url('solaimanlipi-bold-v1.0.ttf') format('truetype');
    size-adjust: 112%;
    unicode-range: U+0980-09FF, U+200C-200D, U+25CC;
}

/* Italic: SolaimanLipi has no italic cut and Bengali is not written slanted,
   so the upright face is used and synthesis switched off. */
@font-face {
    font-family: 'SolaimanLipi';
    font-style: italic;
    font-weight: 400 900;
    font-display: swap;
    src: url('solaimanlipi-normal-v1.0.woff2') format('woff2'),
         url('solaimanlipi-normal-v1.0.ttf') format('truetype');
    size-adjust: 112%;
    unicode-range: U+0980-09FF, U+200C-200D, U+25CC;
}

/*
 * The stack. `--bn-stack` is what everything below points at, so a site that
 * wants a different Latin face only has to change this one line.
 */
:root {
    --bn-stack: 'SolaimanLipi', 'Plus Jakarta Sans', 'Inter', system-ui,
                -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;

    /* Bootstrap 5 reads its body font from this variable, so setting it
       carries SolaimanLipi into every Bootstrap-styled element at once. */
    --bs-body-font-family: var(--bn-stack);
}

html,
body {
    font-family: var(--bn-stack);
}

/* Form controls never inherit the page font on their own, in any browser. */
button,
input,
optgroup,
select,
textarea {
    font-family: var(--bn-stack);
}

/*
 * jQuery UI hard-codes Arial on its own widgets, so its datepickers and
 * autocompletes would not inherit from body.
 */
.ui-widget,
.ui-widget input,
.ui-widget select,
.ui-widget textarea,
.ui-widget button {
    font-family: var(--bn-stack);
}

/*
 * Nothing else is listed on purpose.
 *
 * font-family is inherited, so every heading, cell, chip and button already
 * picks the stack up from body. Naming elements individually -- `span` and
 * `a` in particular -- would also hit icon elements, whose family is set by
 * Font Awesome / Material Icons / feather on the element itself. Overriding
 * that renders every icon on the site as a blank box, and `font-family:
 * revert` does not undo it either: revert drops to the user-agent origin,
 * discarding the icon library's own declaration along with ours.
 *
 * Leaving icons, <code> and <pre> to inherit-or-keep-their-own is both
 * simpler and correct.
 */

/* Bengali has no upper case and no true italic, so neither transform helps
   it -- they only ever produce a worse-looking line. */
:lang(bn) {
    font-style: normal;
    text-transform: none;
}
