/* webrun.ai in Simplified Chinese: type and line breaking. includes/header.php links this file on
   /zh/ pages (lang.php on the /zh/ 404 too), after the page stylesheets. It also links it on
   English-only pages for visitors with the Chinese language cookie: there the header, the footer
   and the template library's own text carry lang="zh-Hans", so the general rules below select
   [lang|="zh"] as well as html:lang(zh). English without the cookie never loads it.

   Fonts. The brand faces (Inter, Instrument Serif) have no Chinese glyphs, and no Chinese font is
   downloaded: Chinese characters come from the reader's own system font for Simplified Chinese
   (PingFang SC on Apple devices, Microsoft YaHei on Windows, Noto Sans CJK SC on Android), which
   the browser picks from lang="zh-Hans". Headings set in Instrument Serif fall back to the
   system's Song face, as the Japanese headings use a Mincho face. Latin letters, digits and
   prices stay in Inter and Instrument Serif. */

/* Mono panels with Chinese text: Latin stays monospace, Chinese comes from the system sans. */
:is(html:lang(zh), [lang|="zh"]) :is(.flow-badge, .flow-param, .flow-match, .policy-result, .ap-flow-status,
  .ap-rule-match-text, .ap-rule-check, .ap-propose-action, .ap-enforce-val, .rule-dim,
  .log-label, .log-blocked, .log-guardrail, .log-allowed, .speed-vs-value, .rc-policy-badge,
  .mono, .ap-cap-preview, .ap-rule-entry-row, .ap-role-instruction-content,
  .env-zoom-terminal-lines, .env-pol-badge),
:is(html:lang(zh), [lang|="zh"]) :is([class*="ap-"], [class*="env-"]) :is(pre, code) {
  font-family: 'SF Mono', 'Fira Code', Consolas, 'PingFang SC', 'Microsoft YaHei', 'Noto Sans SC', 'Noto Sans CJK SC', monospace;
}

/* Line breaking: strict rules (no closing punctuation such as ，。、？ at the start of a line).
   A long Latin string (URL, file name) breaks only when it cannot fit. */
html:lang(zh) body,
[lang|="zh"] {
  line-break: strict;
  overflow-wrap: break-word;
}

/* Chinese has no italic: browsers would slant the glyphs. */
:is(html:lang(zh), [lang|="zh"]) :is(em, i, cite, blockquote, figcaption, .flow-match, .ap-rule-match-text,
  .template-caption, .env-tl-ongoing) {
  font-style: normal;
}

/* Display headings: Chinese leading and no negative tracking (the English values are set for
   Instrument Serif and Inter Latin, and pull Chinese characters into each other). */
:is(html:lang(zh), [lang|="zh"]) :is(h1, h2) {
  line-height: 1.3;
  letter-spacing: 0;
}
/* Even lines instead of a last line of one or two characters (Chrome 114+, Safari 17.5+,
   Firefox 121+; older browsers fill each line). */
:is(html:lang(zh), [lang|="zh"]) :is(h1, h2, h3) {
  text-wrap: balance;
}
html:lang(zh) body.page-workflows .wf-hero h1,
html:lang(zh) body.page-partnership .pt-hero h1,
html:lang(zh) body.page-press .pr-hero h1 {
  line-height: 1.25;
  letter-spacing: 0;
}
html:lang(zh) :is(.page-home .hero h1, .dvh h1) {
  letter-spacing: 0;
  line-height: 1.2;
}

/* The colour word: upright and bold, so it reads at a glance next to the thin Song strokes of
   the serif headings. The sans headlines (home and developer heroes, 600) keep their weight. */
:is(html:lang(zh), [lang|="zh"]) :is(h1, h2, h3, h4) :is(em, i) {
  font-style: normal;
  font-weight: 700;
}
html:lang(zh) :is(.page-home .hero h1, .dvh h1) :is(em, i) {
  font-weight: inherit;
}

:is(html:lang(zh), [lang|="zh"]) p {
  text-wrap: pretty;
}

/* Template library (English-only pages, read with the Chinese cookie): the first item of each
   filter group ("{name}（全部）") may wrap instead of ending in an ellipsis. */
.agl-browse:lang(zh) .agl-mega-sub-all { white-space: normal; }


/* Environments dashboard, file panel (product editor, 2 Nov). The Chinese dashboard keeps to its
   grid, where the English one runs past it (821 px), so the Chinese file panel was 336 px wide
   against 516 px in English, and the two long mock file names (voice-2026-02-26-161046.ogg)
   ended in an ellipsis. A wider right-hand column shows them in full from 1200 px up. The left
   panels come out at 292 px, the English width (291 px). Measured at 1200 to 1920: nothing clipped
   or overflowing. Below 1200 the names may still end in an ellipsis, as the file list intends. */
@media (min-width: 1200px) {
  html:lang(zh) .env-dash-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); }
}


/* Half-width space where a placeholder puts a Latin name next to Chinese (sales editor, 2 Nov).
   The template library prints "{name}的自动化模板", "专为{name}打造" and "全部{name}" for 707
   category and 30 industry names; about 77 start or end in Latin (Oracle MICROS POS, PEO 人事外包,
   运营与 IT), and one template cannot add ZH-STYLE's space only next to those. CSS Text 4
   text-autospace adds it at render time where a Chinese character meets a Latin letter or digit;
   an existing space is not doubled, and a browser without the property ignores the rule (as
   Chromium 92, the measuring browser, does). */
:is(html:lang(zh), [lang|="zh"]) { text-autospace: normal; }
