/* =============================================================================
   Corrections for scripts that are not Latin.

   Loaded only for those scripts -- see fg_assets(). A Latin page never
   downloads this file, and because it is the last stylesheet in, its plain
   selectors beat the tracked ones in main.css and atlas.css without a single
   !important.

   -------------------------------------------------------------------------
   WHY THIS FILE EXISTS AT ALL
   -------------------------------------------------------------------------

   The Latin typography on this site leans hard on two devices: negative
   tracking on the headings, and wide tracking plus uppercase on the small mono
   labels. Both are correct for Latin. Both are wrong -- one of them
   catastrophically -- for the scripts below.

   Arabic script is CURSIVE. Letters join, and the joins are part of the
   letterform, not a kerning nicety. `letter-spacing: .2em` on «ستون‌ها» does not
   space the word out; it pulls the connecting strokes apart and leaves a row of
   disconnected shapes, which to a Persian reader is not a style, it is broken
   text. Negative tracking is the same damage from the other direction. So the
   rule for the Arabic script is not "less tracking", it is NONE, everywhere.

   And there is no case in Arabic, Hebrew, Devanagari or CJK, so
   `text-transform: uppercase` is a no-op that silently leaves those labels with
   no visual differentiation at all -- the wide tracking was doing that job, and
   it has just been taken away.

   -------------------------------------------------------------------------
   WHAT REPLACES THEM
   -------------------------------------------------------------------------

   Weight, size and colour. The label tokens step up one weight so a Persian
   eyebrow still reads as an eyebrow, which is exactly why --w-label is a token
   rather than a number in nine rules.
   ========================================================================== */

/* -----------------------------------------------------------------------------
   Every script here: no tracking, no case.

   The universal selector is deliberate and is not the blunt instrument it looks
   like. The alternative is naming the twenty six tracked selectors across two
   stylesheets, which is a list that goes stale the first time someone adds a
   twenty seventh and does not know this file exists. A script level correction
   should apply to text that has not been written yet.
   -------------------------------------------------------------------------- */
/* THE DOUBLED ATTRIBUTE IS THE WHOLE POINT, and it is why this net now works.
   It used to read `body *`, which is one type selector and one universal --
   specificity (0,0,1). Every rule it was written to overrule is a class:
   `.fg-nav__item` is (0,1,0), `.fg-hero h1` is (0,1,1). A class beats a type
   selector no matter which stylesheet comes last, so this block has never once
   applied to the elements it names in its own comment. Persian shipped with
   1.43px of tracking on the masthead rail, 2.2px on every eyebrow and -1.32px
   on the hero -- the exact disconnected-letterform damage described above,
   live, on every non-Latin page.

   `body[class][class] *` is (0,2,1): comfortably over every component rule in
   main.css, atlas.css and reading.css, and still under this file's own
   per-component corrections at (0,2,0)... which it does not collide with
   anyway, since those set face, weight and size and never tracking. The
   attribute is doubled rather than a class being named because this file is
   enqueued ONLY for scripts that cannot take tracking -- so the correct scope
   is "everything on the page", and a hardcoded list of script classes would go
   stale the first time a locale is added. */
:root, body, body[class][class] * {
  letter-spacing: normal;
}

body[class][class] * {
  text-transform: none;
}

/* -----------------------------------------------------------------------------
   Arabic script: Persian and Arabic.
   -------------------------------------------------------------------------- */

.script-arabic, .script-persian {
  /* Persian sets deep below the baseline and carries marks above it, so the
     Latin leading crowds it. This is on the root so the whole scale moves. */
  line-height: 1.85;
}

.script-arabic h1, .script-persian h1,
.script-arabic h2, .script-persian h2,
.script-arabic h3, .script-persian h3,
.script-arabic h4, .script-persian h4 {
  line-height: 1.45;
}

/* The orb labels and the hero headline are set tight enough in Latin that the
   Persian descenders collide with the line below. */
.script-arabic .fg-hero h1, .script-persian .fg-hero h1 { line-height: 1.3; }
.script-arabic .fg-orb b, .script-persian .fg-orb b,
.script-arabic .fg-core-label b, .script-persian .fg-core-label b { line-height: 1.4; }

/* -----------------------------------------------------------------------------
   The label voice, rebuilt without uppercase or tracking.

   These are the elements that were mono + uppercase + .1..2em tracking. In
   Persian they get the text face one weight up, one step down in size, and the
   quiet ink -- which is the same three-part signal the Latin version sends, made
   out of the materials this script actually has.
   -------------------------------------------------------------------------- */
.script-arabic .eyebrow,        .script-persian .eyebrow,
.script-arabic .fg-index__label,.script-persian .fg-index__label,
.script-arabic .fg-index__hint, .script-persian .fg-index__hint,
.script-arabic .fg-idx__count,  .script-persian .fg-idx__count,
.script-arabic .fg-branch__count b, .script-persian .fg-branch__count b,
.script-arabic .fg-branch__count s, .script-persian .fg-branch__count s,
.script-arabic .fg-hero__meta s,.script-persian .fg-hero__meta s,
.script-arabic .fg-core-label span, .script-persian .fg-core-label span,
.script-arabic .foot__meta,     .script-persian .foot__meta,
.script-arabic .foot__up,       .script-persian .foot__up,
.script-arabic .foot__world,    .script-persian .foot__world,
.script-arabic .fgr-toc__head,  .script-persian .fgr-toc__head,
.script-arabic .fgr-toc__meta,  .script-persian .fgr-toc__meta,
.script-arabic .fg-nav__item,   .script-persian .fg-nav__item,
.script-arabic .fg-nav__meta,   .script-persian .fg-nav__meta,
.script-arabic .fg-nav__enter,  .script-persian .fg-nav__enter,
.script-arabic .fg-menu__more summary, .script-persian .fg-menu__more summary,
.script-arabic .fg-find__keys,  .script-persian .fg-find__keys,
.script-arabic .locale-switch__head, .script-persian .locale-switch__head {
  font-family: var(--f-text);
  font-weight: 500;
}

/* The masthead's row runs a step up for these scripts: 11.5px Latin mono
   tracked wide holds a line; 11.5px Persian with no tracking to help it
   disappears. */
.script-arabic .fg-nav__item, .script-persian .fg-nav__item,
.script-arabic .foot__world,  .script-persian .foot__world { font-size: 13px; }

/* The section ordinal follows the index ordinal's rule above: a coordinate,
   not a word, so it keeps the mono face and its tabular digits whatever
   numerals fg_num() wrote into it. */
.script-arabic .fgr-h__n, .script-persian .fgr-h__n {
  font-family: var(--f-mono);
  font-variant-numeric: tabular-nums;
}

/* Emphasis without slant. There is no italic tradition in the Arabic script --
   an oblique IRANYekanX is not emphasis, it is a rendering fault -- so <em>
   inside a body leans on weight and full ink instead, the same two materials
   the label voice above is rebuilt from. */
.script-arabic .node-body em, .script-persian .node-body em {
  font-style: normal;
  font-weight: 600;
  color: var(--ink);
}

/* The ordinal stays mono and stays Latin: it is a coordinate, not a word, and
   01..08 is legible to every reader on the site. Tabular so the column of them
   down the left of an index does not shift by a digit. */
.script-arabic .fg-idx__n, .script-persian .fg-idx__n {
  font-family: var(--f-mono);
  font-variant-numeric: tabular-nums;
}

/* -----------------------------------------------------------------------------
   CJK and Devanagari.

   Far less to correct -- neither has joins to break -- but the same two devices
   are still meaningless, and CJK wants its own leading. Kept here rather than in
   a third file: one stylesheet for "the Latin assumptions do not hold" is easier
   to reason about than one per script.
   -------------------------------------------------------------------------- */
.script-sc, .script-jp, .script-kr { line-height: 1.9; }
.script-sc h1, .script-jp h1, .script-kr h1,
.script-sc h2, .script-jp h2, .script-kr h2 { line-height: 1.4; }

/* -----------------------------------------------------------------------------
   Korean only: where a line is allowed to break.

   Browsers line-break Korean as CJK, which means a break is allowed between any
   two Hangul syllables. «검색엔진최적화» sets as «검색엔 / 진최적화» --
   a word cut in half, in a heading, with no hyphen to admit it. Measured against
   this theme's own stylesheets: the default splits that word at every container
   width from 40px up to 516px at the h1's 44.6px, up to 188px at body size, and
   up to 128px at the 11px label size. The front page h1 measures 382px and
   .fg-index__label measures 79px. Both are inside the band, so this is not an
   edge case waiting for a narrow viewport -- it is what a Korean page renders as.

   The rule stops at kr, and that is the point of not reusing the three-class
   selector above. Korean puts spaces between eojeol, so `keep-all` always has
   somewhere else to break and costs at most a raggeder right edge. Chinese and
   Japanese have no spaces at all: under `keep-all` a zh or jp paragraph has no
   break opportunity anywhere and sets as one line -- 357px and 419px measured in
   a 190px box. The same declaration is correct for one of these three scripts
   and catastrophic for the other two.

   `overflow-wrap` is in the same rule because `keep-all` on its own is a
   regression for any run that has no space in it either. The default could
   always break between syllables; `keep-all` takes that away and nothing
   replaces it, so an unspaced Korean compound overflowed its box by 59px,
   Korean glued to a Latin word by 93px, and a 120px ring label by 82px.
   `break-word` returns all three to the exact width the default produced, and
   costs nothing anywhere else -- it only ever fires on a line that would
   otherwise overflow, which is the same clause that lets a URL or a long
   identifier inside Korean prose still break rather than run off the page.

   `break-word` and never `anywhere`, for the reason atlas.css gives at
   .fg-label b: `anywhere` drops the intrinsic min-content width to one glyph and
   a flex item sized by its content then sets itself out one syllable per line.
   atlas.css already declares `overflow-wrap:break-word` on both ring labels, so
   what inherits from here is the value those rules were going to set anyway.
   -------------------------------------------------------------------------- */
.script-kr { word-break: keep-all; overflow-wrap: break-word; }

.script-devanagari { line-height: 1.9; }
.script-devanagari h1, .script-devanagari h2 { line-height: 1.5; }

/* Hebrew is not cursive and takes tracking, but has no case either. The
   universal reset above already handles it; nothing further is needed. */
