/**
 * OSHIDA — typography.
 *
 * Font faces, element defaults and Persian digit handling.
 *
 * The design file names the family "Estedad-FD". There is no separate FD
 * binary: FD is Estedad with the OpenType feature `ss20` ("Latin to Farsi
 * Digits") enabled, which swaps U+0030-0039 for the Persian shapes. We ship one
 * variable woff2 and expose FD as an opt-in class, so phone numbers keep their
 * Latin digits (design-tokens.md: Persian digits in counters and dates, Latin
 * digits in phone numbers).
 *
 * Owner: work package A1.
 */

/* --------------------------------------------------------------------------
 * 1. The real font.
 *
 * assets/fonts/estedad-var.woff2 — Estedad v8.5 variable (wght 100..900),
 * SIL OFL 1.1 (assets/fonts/OFL.txt), subset with pyftsubset to:
 *   U+0020-007E  Basic Latin
 *   U+00A0 U+00A9 U+00AB U+00B7 U+00BB U+00D7
 *   U+0600-06FF  Arabic block, including Arabic-Indic digits U+06F0-06F9
 *   U+061C U+200C-200F  ALM, ZWNJ (critical for Persian), ZWJ, LRM, RLM
 *   U+2010-2015 U+2018 U+2019 U+201C U+201D U+2022 U+2026 U+2039 U+203A
 * Layout features kept: ccmp locl init medi fina isol rlig liga calt mark mkmk
 * kern rvrn ss20. 58 588 bytes.
 *
 * Arabic Presentation Forms-A/B are deliberately NOT included: the font shapes
 * Persian through init/medi/fina/isol on the Arabic block, and no node in the
 * design uses a presentation-form codepoint. Including U+FB50-FBFF and
 * U+FE70-FEFF was measured at +1 688 bytes for zero rendering difference.
 * -------------------------------------------------------------------------- */

@font-face {
	font-family: "Estedad";
	src: url("../../fonts/estedad-var.woff2") format("woff2");
	font-weight: 100 900;
	font-style: normal;
	font-display: swap;
	unicode-range:
		U+0020-007E, U+00A0, U+00A9, U+00AB, U+00B7, U+00BB, U+00D7, U+061C,
		U+0600-06FF, U+200C-200F, U+2010-2015, U+2018, U+2019, U+201C, U+201D,
		U+2022, U+2026, U+2039, U+203A;
}

/* --------------------------------------------------------------------------
 * 2. Metric-matched fallback.
 *
 * Measured, not guessed. Estedad v8.5: unitsPerEm 1000, typoAscender 1025,
 * typoDescender -500, typoLineGap 0, USE_TYPO_METRICS set. Average advance
 * width over the actual Persian copy in the design (nav, hero, why-partner,
 * accordion, footer) is 0.49285 em for Estedad against 0.53193 em for Tahoma.
 *
 *   size-adjust       = 0.49285 / 0.53193            = 92.65%
 *   ascent-override   = (1025 / 1000) / 0.9265       = 110.63%
 *   descent-override  = ( 500 / 1000) / 0.9265       =  53.96%
 *   line-gap-override = 0                            =   0%
 *
 * With these, the swap from the fallback to Estedad changes neither the line
 * box nor the measured text advance, so CLS from the font swap is zero.
 * -------------------------------------------------------------------------- */

@font-face {
	font-family: "Estedad Fallback";
	src:
		local("Tahoma"),
		local("Segoe UI"),
		local("Noto Sans Arabic"),
		local("Arial");
	size-adjust: 92.65%;
	ascent-override: 110.63%;
	descent-override: 53.96%;
	line-gap-override: 0%;
	font-display: swap;
}

/* --------------------------------------------------------------------------
 * 3. Element defaults
 * -------------------------------------------------------------------------- */

html {
	font-family: var(--o-font);
	font-size: 100%;
	font-synthesis-weight: none;
	text-size-adjust: 100%;
}

body {
	color: var(--o-text);
	font-size: var(--o-fs-body);
	font-weight: var(--o-fw-extralight);
	line-height: var(--o-lh-body);
	letter-spacing: var(--o-track-micro);
	text-align: start;
	font-kerning: normal;
	font-optical-sizing: auto;
}

h1,
h2,
h3,
h4,
h5,
h6 {
	font-weight: var(--o-fw-black);
	line-height: var(--o-lh-heading);
	text-wrap: balance;
}

h1 {
	font-size: var(--o-fs-h1);
	letter-spacing: var(--o-track-snug);
}

h2 {
	font-size: var(--o-fs-h2);
	letter-spacing: var(--o-track-tight);
}

h3 {
	font-size: var(--o-fs-h3);
	font-weight: var(--o-fw-semibold);
	letter-spacing: var(--o-track-tight);
}

h4 {
	font-size: var(--o-fs-h4);
	letter-spacing: var(--o-track-micro);
}

h5 {
	font-size: var(--o-fs-lg);
	letter-spacing: var(--o-track-tight);
}

h6 {
	font-size: var(--o-fs-md);
	letter-spacing: var(--o-track-tight);
}

p {
	text-wrap: pretty;
}

small {
	font-size: var(--o-fs-xs);
}

strong,
b {
	font-weight: var(--o-fw-black);
}

a {
	color: inherit;
	text-decoration-thickness: 1px;
	text-underline-offset: 0.22em;
}

code,
kbd,
samp,
pre {
	font-family: ui-monospace, "SF Mono", "Cascadia Mono", monospace;
	font-size: 0.9em;
}

/* --------------------------------------------------------------------------
 * 4. Persian digits
 *
 * Content authors write real Persian digits (۰۱۲۳) wherever the design shows
 * them, so nothing is enabled globally. `.o-fa-digits` turns Latin digits into
 * Persian shapes for values that arrive as Latin from PHP (post counts, dates
 * out of `date_i18n`, step indices). `.o-latin-digits` forces them back — use
 * it on phone numbers, emails and any copyable identifier.
 * -------------------------------------------------------------------------- */

.o-fa-digits {
	font-feature-settings: "ss20" 1;
}

.o-latin-digits {
	font-feature-settings: "ss20" 0;
	direction: ltr;
	unicode-bidi: isolate;
}

/* Numeric runs inside RTL prose (phone numbers, years) must not be reordered
 * by the bidi algorithm. */
.o-num {
	direction: ltr;
	unicode-bidi: isolate;
	white-space: nowrap;
}
