/* Phyein Usul in German and Arabic: the few rules a translated page needs on top of the house styles.
   Loaded last by every page that tools/i18n/build.py writes into de/ and ar/ (the English pages load it for the language switch).
   German uses the house fonts unchanged. Arabic keeps the house fonts for Latin letters, digits and maths and takes its Arabic
   letters from the self-hosted faces in fonts/arabic.css: Amiri in the titles (where English has Instrument Serif or IBM Plex
   Serif), Noto Naskh Arabic in the text and the labels (where English has IBM Plex Sans and Mono). Left and right are exchanged
   on Arabic pages by mirrored copies of the house stylesheets (styles/*.rtl.css, made by the generator with rtlcss). */

/* ---------- the language switch ---------- */
.lang-switch { font: 12px/1.4 var(--mono, 'IBM Plex Mono', monospace); letter-spacing: 0.04em; color: var(--muted, #8b8079); white-space: nowrap; }
.lang-switch a { color: var(--ink-3, #5a504b); text-decoration: none; }
.lang-switch a:hover { color: var(--accent, #7a1f2b); }
.lang-switch a[aria-current='page'] { color: var(--accent, #7a1f2b); font-weight: 600; }
.lang-switch a[lang='ar'] { font-family: 'Noto Naskh Arabic', var(--sans, sans-serif); letter-spacing: 0; font-size: 13px; }
.cat-top .lang-switch { margin-inline-start: 10px; padding-inline-start: 18px; border-inline-start: 1px solid var(--rule, #d9d0c2); }
.lang-switch--top { position: absolute; top: 14px; inset-inline-end: 24px; z-index: 5; }
@media (max-width: 560px) { .lang-switch--top { top: 10px; inset-inline-end: 16px; } }

/* a piece whose English changed after it was translated: the English shows, with this small mark, until the translation follows */
.i18n-pending { display: inline-block; width: 6px; height: 6px; margin-inline-start: 4px; border-radius: 50%; background: #c9a227; vertical-align: middle; }

/* ---------- Arabic ---------- */
html[lang='ar'] {
  --serif: 'Instrument Serif', 'Amiri', Georgia, serif;
  --sans: 'IBM Plex Sans', 'Noto Naskh Arabic', system-ui, sans-serif;
  --mono: 'IBM Plex Mono', 'Noto Naskh Arabic', ui-monospace, monospace;
  --tex: 'Latin Modern Roman', 'Noto Naskh Arabic', 'KaTeX_Math', serif;
}
html[lang='ar'] body { line-height: 1.85; }
/* the home page sets its titles in IBM Plex Serif; in Arabic they take Amiri */
html[lang='ar'] .hero__name, html[lang='ar'] h1, html[lang='ar'] h2, html[lang='ar'] h3 { font-family: 'IBM Plex Serif', 'Amiri', Georgia, serif; }
html[lang='ar'] .cat h1, html[lang='ar'] .cat h2, html[lang='ar'] .cat h3, html[lang='ar'] .pf h1, html[lang='ar'] .pf h2, html[lang='ar'] .pf h3 { font-family: var(--serif); }
/* Arabic letters join: spacing between letters breaks the words, and capitals do not exist */
html[lang='ar'] body *:not(.katex):not(.katex *):not(code):not(code *) { letter-spacing: 0 !important; }
html[lang='ar'] :is(h1, h2, h3, h4, .hero__name) { line-height: 1.35; }
/* maths, code, addresses and numbers with units read left to right inside the right-to-left text */
html[lang='ar'] .katex, html[lang='ar'] code, html[lang='ar'] pre, html[lang='ar'] kbd, html[lang='ar'] .ltr { direction: ltr; unicode-bidi: isolate; }
html[lang='ar'] .katex-display { direction: ltr; }
html[lang='ar'] input[type='search'] { text-align: right; }
/* arrows drawn as characters point the way the text runs */
html[lang='ar'] .flip { display: inline-block; transform: scaleX(-1); }
/* Arabic has no italic: the Arabic faces have none, and a slanted copy of a naskh letter is not italic but damage. Latin words
   inside keep their italic face. */
html[lang='ar'] { font-synthesis-style: none; }
/* key figures such as "6 / 14 min" keep their left-to-right order */
html[dir='rtl'] .proj__tally dt { direction: ltr; unicode-bidi: isolate; text-align: right; }
/* figures read left to right in every language: canvas text inherits the canvas element's direction, SVG text its own, and the
   simulation pages set inline maths in spans of class "m"; legends, slider values ("24 px") and readout values are maths too */
html[dir='rtl'] canvas, html[dir='rtl'] svg, html[dir='rtl'] .stage__canvas, html[dir='rtl'] .legend, html[dir='rtl'] .m,
html[dir='rtl'] output, html[dir='rtl'] .readouts b { direction: ltr; unicode-bidi: isolate; }
/* the parameter curve's status line (scripts/curve.js) is a row of symbols, numbers and units, like a readout: kept left to right */
html[dir='rtl'] .curve__st { direction: ltr; unicode-bidi: isolate; text-align: left; }
.sim-top .lang-switch { margin-inline-start: 14px; }

/* ---------- moving between pages (scripts/flip.js names the kind: "page" or "lang") ---------- */
@view-transition { navigation: auto; }
::view-transition { background: var(--paper, #f5f1ea); }
::view-transition-group(root) { animation-duration: var(--dur, .75s); }
/* a link to another page: the old page settles back and fades while the new one rises into place, about 0.7 s in all, on the
   site's ease-out (styles/motion.css): it moves at once and comes to rest slowly */
::view-transition-old(root) { animation: page-out calc(var(--dur, .75s) * .4) var(--ease, ease) both; transform-origin: 50% 30%; }
::view-transition-new(root) { animation: page-in calc(var(--dur, .75s) * .7) var(--ease-out, ease-out) calc(var(--dur, .75s) * .2) both; }
@keyframes page-out { from { opacity: 1; transform: scale(1); } to { opacity: 0; transform: scale(.985); } }
@keyframes page-in { from { opacity: 0; transform: translateY(var(--rise, 14px)); } to { opacity: 1; transform: none; } }
/* a change of language turns the page over: half a turn out, half a turn in, together one --dur */
:root:active-view-transition-type(lang)::view-transition-group(root) { animation-duration: var(--dur, .75s); }
:root:active-view-transition-type(lang)::view-transition-old(root) { animation: lang-turn-out calc(var(--dur, .75s) / 2) cubic-bezier(.55, 0, 1, .45) both; transform-origin: 50% 50%; backface-visibility: hidden; }
:root:active-view-transition-type(lang)::view-transition-new(root) { animation: lang-turn-in calc(var(--dur, .75s) / 2) cubic-bezier(0, .55, .45, 1) calc(var(--dur, .75s) / 2) both; transform-origin: 50% 50%; backface-visibility: hidden; }
@keyframes lang-turn-out { from { transform: perspective(1800px) rotateY(0deg); } to { transform: perspective(1800px) rotateY(90deg); } }
@keyframes lang-turn-in { from { transform: perspective(1800px) rotateY(-90deg); } to { transform: perspective(1800px) rotateY(0deg); } }
/* the arriving page has moved in already: its own entrance animations would be a second motion. The figure keeps its fade
   (sim.css): it is still drawing its first frame when the page arrives, and fading in hides the empty grid before it */
.vt-arrive .sim__head, .vt-arrive .panel, .vt-arrive .hero__name, .vt-arrive .hero__tag, .vt-arrive .hero__meta,
.vt-arrive .hero__cta, .vt-arrive .figure { animation: none; }
.vt-arriving .reveal { transition: none; }   /* what is on the first screen shows with the page, not after it */
@media (prefers-reduced-motion: reduce) { @view-transition { navigation: none; } }
