/* Typographic detail layer — the rules that make the page read as typeset
   rather than templated. Loaded LAST of the css/ set, after every surface file
   (tokens, base, chrome, feed, detail, states, media, cjk, responsive, ops), so
   it can correct the finished page instead of fighting it.

   Contract for every rule below:
     · no !important anywhere;
     · a property a surface file already sets is only restated through ONE extra
       ancestor, and the comment names the file and the reason;
     · colour, type size and rhythm come from tokens.css only;
     · everything is progressive: an unsupported declaration is dropped and the
       page keeps the surface file's behaviour.

   Sources executed 2026-11-07 (each rule cites the one it comes from):
     Apple HIG Typography — system faces carry continuous optical sizes, so
       glyph structure and spacing adapt to the point size.
       https://developer.apple.com/design/human-interface-guidelines/typography
     MDN text-wrap — balance is for headings and short blocks (Chromium caps it
       at 6 lines, Firefox at 10); pretty is for body copy and spends work on
       fewer orphans. https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/text-wrap
     MDN font-variant-numeric — tabular figures share one advance width (columns
       align); proportional figures keep the face's natural widths.
       https://developer.mozilla.org/en-US/docs/Web/CSS/font-variant-numeric
     MDN hyphens — manual breaks only at U+002D and soft hyphens; auto needs a
       language tag and a dictionary.
       https://developer.mozilla.org/en-US/docs/Web/CSS/hyphens
     Practical Typography, Hyphenation — headings are short, so hyphenating them
       causes more problems than it solves.
       https://practicaltypography.com/hyphenation.html
     Practical Typography, Alternate figures — tabular on a fixed width where
       numbers must align; proportional where they sit in prose.
       https://practicaltypography.com/alternate-figures.html
     Practical Typography, Hyphens and dashes — en dash for ranges, em dash for
       a break, never -- or ---.
       https://practicaltypography.com/hyphens-and-dashes.html
     Practical Typography, Straight and curly quotes — editorial copy uses the
       curly marks. https://practicaltypography.com/straight-and-curly-quotes.html
     MDN hanging-punctuation — first/last hang an opening/closing quote or
       bracket outside the line box; unsupported engines align normally.
       https://developer.mozilla.org/en-US/docs/Web/CSS/hanging-punctuation
     CSS Text Level 4 — text-wrap-style and hanging-punctuation definitions.
       https://drafts.csswg.org/css-text-4/
     W3C CLReq — Mainland zh-Hans sets double curly quotes first and single
       nested. https://www.w3.org/TR/clreq/
     MDN font-size-adjust — from-font keeps fallback faces on the first
       available face's x-height.
       https://developer.mozilla.org/en-US/docs/Web/CSS/font-size-adjust */

/* ======================================================== 1. optics =====
   One tracking curve for the serif display face, a linear function of the
   element's own font size:

       t(px) = (1em − 0.795rem) × −0.0367, clamped to [−0.03em, −0.008em]

   At the sizes this newsroom actually sets, that is:
     28px phone lead / article H1  → −0.020em  (matches responsive.css)
     40px desktop lead             → −0.025em
     44px desktop article H1       → −0.026em
   Larger type is always set tighter, and the clamp floor stops at −0.03em so no
   headline is ever crushed. The UI curve in §1b reaches zero at 15px and can
   never be negative below it, which is the "no negative tracking under 12px"
   rule stated as arithmetic instead of a list of exceptions.

   One extra ancestor is the only cascade lever used: it lets this file own the
   whole curve instead of five ad-hoc values in five surface files. */
:root {
  --track-display: clamp(-0.03em, calc((1em - 0.795rem) * -0.0367), -0.008em);
  --track-ui: clamp(-0.012em, calc((1em - 0.9375rem) * -0.05), 0em);
}

html[lang="en"] main .article__title,        /* feed.css: −0.022em; responsive.css: −0.02em at phone */
html[lang="en"] main .detail .detail__title, /* detail.css sets −0.022em under .detail .detail__title */
html[lang="en"] main .digest__headline,      /* feed.css: −0.022em */
html[lang="en"] main .state__title {         /* states.css sets none; the inherited −0.006em is too loose at 19-23px */
  letter-spacing: var(--track-display);
  font-optical-sizing: auto;    /* variable faces interpolate; a no-op on the static system serif */
  font-kerning: normal;
  font-size-adjust: from-font;  /* a fallback face keeps the primary face's x-height, so the
                                   tracking curve measures the same text on every OS */
}

/* 1b. The UI face. Zero-specificity :where(): any surface file that already
   sets tracking (chips −0.004em, labels 0, the wordmark −0.03em) keeps its own
   value untouched; this only supplies a direct value where the element was
   inheriting body's −0.006em computed at 17px as an absolute −0.102px. That
   inheritance is why 12-14px labels were silently carrying negative tracking:
   the fixed length does not re-resolve on the smaller element.

   The rule matches the English edition only, and the whole selector is inside
   :where() so its specificity is zero on both the language gate and the class
   list: a zh-Hans label keeps cjk.css's letter-spacing: 0 on its Han grid, and
   any English surface class that sets its own tracking still wins. */
:where(html[lang="en"]) :where(
  .masthead__kicker, .rail__inner, .boot, .feed-note, .status-note,
  .article__meta, .article__deck, .article__foot, .article__more,
  .article__bullets li,
  .card__meta, .card__deck, .card__snippet, .card__source,
  .digest__summary, .digest-item__meta, .digest-item__summary,
  .related__note, .related__reason, .related__empty,
  .detail__back, .detail__deck, .detail__notice, .detail__kicker,
  .section-label, .panel__label, .disclaimer, .plate__note,
  .market__asof, .market__sym, .market__price, .market__chg,
  .claim__text, .claim__span, .claim__num, .claim__conf, .compliance__riskrow,
  .entities, .entities__key, .entities__val,
  .state__body, .state__detail, .button,
  .colophon__note, .colophon__fine, .searchbar__input, .toolbar__link, .chip,
  .story-figure .badge, .story-figure .ai-label,
  .ops-note, .ops-stat__label, .ops-stat__sub,
  .feed-note--block, .section-head, .rail__clock, .filters__count
) {
  letter-spacing: var(--track-ui);
}

/* zh-Hans: base.css's body tracking is a Latin optical correction and cjk.css
   is explicit that Han characters stay on their fixed grid with zero tracking.
   One rule closes the gap between that intent and the inherited −0.006em that
   reaches body copy through body; every class in cjk.css keeps its own 0. */
html[lang="zh-Hans"] body {
  letter-spacing: 0;
}

/* ===================================================== 2. text-wrap =====
   Policy: balance on headlines that are four lines or fewer by design (the
   engine caps it at 6/10 lines and degrades to normal wrapping beyond), pretty
   on decks and body copy, and no `text-wrap` declaration of `nowrap` anywhere
   in this layer. (Chrome serialises a surface file's `white-space: nowrap`
   into a computed text-wrap-mode of nowrap on the clock, toolbar and source
   labels; that is intended one-line chrome owned by those files, not a wrap
   algorithm chosen here, and this layer leaves it alone.) The masthead
   logotype is a two-word inline-flex and needs neither.

   feed.css sets `pretty` on the two index-line titles below. They are one to
   three lines at every width — the block size MDN names for balance — so the
   layer restates the algorithm through `main`; `pretty` remains on the decks. */
main .card__title,
main .digest-item__title,
main .state__title {
  text-wrap: balance;
}
.detail__deck {           /* detail.css sets size and measure, never a wrap algorithm */
  text-wrap: pretty;
}
.prose :is(blockquote, figcaption) {
  text-wrap: pretty;
}

/* ====================================================== 3. hyphenation ===
   A newsroom does not hyphenate a headline. `manual` permits a break only at a
   real hyphen or an author-set soft hyphen and never inserts one; body copy
   inherits the same floor. Chinese has no hyphenation at all: `none` is stated
   explicitly so a later `auto` anywhere cannot leak into the zh edition. */
html[lang="en"] :where(
  h1, h2, h3, h4,
  .article__title, .detail__title, .digest__headline,
  .card__title, .digest-item__title, .state__title
) {
  hyphens: manual;
  -webkit-hyphens: manual;
}
html[lang="zh-Hans"] {
  hyphens: none;
  -webkit-hyphens: none;
}

/* ================================================ 4. hanging punctuation ==
   first/last hang an opening quote or bracket and a closing one outside the
   measure, so the prose edge stays optically straight. Safari implements this;
   Chromium and Firefox drop the declaration and align the glyph inside the
   measure — identical text, normal alignment, no layout dependency. */
.prose {
  hanging-punctuation: first last;
}

/* ======================================================== 5. numerals ===
   Tabular wherever a reader compares numbers down a line or across refreshes:
   clocks, datelines, tickers, market rows, counts, claim indices, tables.
   Proportional everywhere else, so a figure inside a sentence keeps the face's
   own rhythm. The tabular list uses :where() (zero specificity) so every
   surface rule that already asks for tabular keeps its declaration and any new
   surface element inherits the policy without editing that file. */
:where(
  time,
  .rail__clock, .filters__count, .article__index, .article__foot, .article__time,
  .section-head span:last-child,
  .ticker, .market__row, .market__price, .market__chg, .market__asof,
  .claim__num, .claim__conf, .compliance__riskrow,
  .digest__day, .digest__counts
) {
  font-variant-numeric: tabular-nums;
}
.prose {
  font-variant-numeric: proportional-nums;
}
.prose :is(table, td, th) {
  font-variant-numeric: tabular-nums;
}

/* =========================================================== 6. prose ===
   detail.css owns the reading face, size and measure. This block owns the
   rhythm INSIDE that measure. Lead-in rule: slightly larger first paragraph,
   never a drop cap — an illuminated initial is a magazine device, not a
   newsroom one. */
main .prose {
  text-align: start;          /* ragged right, never justified: we do not hyphenate body copy */
  font-kerning: normal;
  font-size-adjust: from-font;
}

/* The lead-in is scoped to the English edition: the zh body runs its own 1.9
   leading on a Han grid, and a size bump there would break the grid. */
html[lang="en"] main .prose > p:first-of-type {
  font-size: 1.06em;
  letter-spacing: -0.002em;
}

/* Lists inside editorial copy get real vertical air; base.css's global reset
   is for layout lists, not for prose. Markers take the faint ink and ordered
   numbers take tabular figures so a list of ten never shifts its text edge. */
.prose :is(ul, ol) {
  margin: 1.15em 0;
  padding-left: 1.35em;
}
.prose li + li {
  margin-top: 0.45em;
}
.prose li::marker {
  color: var(--ink-faint);
}
.prose ol > li::marker {
  font-variant-numeric: tabular-nums;
}

/* An editorial quote: display face, italic, one hairline in the strong rule
   colour, and a citation line back in the UI face. */
.prose blockquote {
  margin: 1.8em 0;
  padding-left: 1.15em;
  border-left: 1px solid var(--rule-strong);
  font-size: 1.1em;
  line-height: 1.55;
  color: var(--ink);
}
/* Latin copy takes the italic cut and a touch of optical tightening; a Han
   blockquote keeps the upright Songti on its own zero tracking. */
html[lang="en"] .prose blockquote {
  font-style: italic;
  letter-spacing: -0.004em;
}
.prose blockquote cite {
  display: block;
  margin-top: 0.6em;
  font-family: var(--font-ui);
  font-style: normal;
  font-size: var(--fs-label);
  letter-spacing: 0;
  color: var(--ink-faint);
}

/* A pull quote is the one display-size block inside the measure: display face,
   balanced lines, one hairline above, no box and no tint. */
.prose :is(.pullquote, .pull-quote) {
  margin: 2.1em 0;
  padding-top: 0.85em;
  border-top: 1px solid var(--rule);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.34em;
  line-height: 1.32;
  color: var(--ink);
  text-wrap: balance;
  hanging-punctuation: first last;
}
html[lang="en"] .prose :is(.pullquote, .pull-quote) {
  letter-spacing: -0.016em;   /* the same curve as the display tier, at 1.34em */
}

/* Figures: image, then a caption in the UI face at label size, never wider than
   a comfortable caption measure. */
.prose figure {
  margin: 1.9em 0;
}
.prose figure img {
  width: 100%;
  height: auto;
}
.prose figcaption {
  margin-top: 0.55em;
  max-width: 60ch;
  font-family: var(--font-ui);
  font-size: var(--fs-label);
  line-height: 1.5;
  letter-spacing: 0;
  color: var(--ink-faint);
}

/* A scene break is a short centred hairline, never a full-width band. */
.prose hr {
  width: 3rem;
  height: 1px;
  margin: 2.4em auto;
  border: 0;
  background: var(--rule-strong);
}

/* One extra ancestor over detail.css's `.prose a` so this layer owns the
   underline pair: a little more offset at 17-19px, a hair thicker than 1px on
   the dark ground, and skip-ink so descenders stay clean. The colour remains
   the accent token (5.0:1 on --paper, 7.3:1 on the dark ground), so the rule
   never disappears on either theme. */
main .prose a {
  text-decoration-thickness: max(1px, 0.06em);
  text-underline-offset: 0.16em;
  text-decoration-skip-ink: auto;
}
main .prose a:hover {
  text-decoration-thickness: max(1px, 0.1em);
}

/* ============================================== 7. selection & markers ===
   base.css sets an opaque accent-soft fill on the universal selection pseudo.
   A 22% accent wash keeps the selected text's own ink and lets the ground show
   through, which reads as a tint on both themes instead of a sticker; the
   opaque token pair stays as the fallback for engines without color-mix. */
html ::selection {
  background: var(--accent-soft);
  color: var(--ink);
}
@supports (background: color-mix(in srgb, red 20%, transparent)) {
  html ::selection {
    background: color-mix(in srgb, var(--accent) 22%, transparent);
  }
}

/* Editorial quote pairs: curly, never the typewriter marks. Mainland zh-Hans
   uses the same double-first, single-nested codepoints (W3C CLReq), so one
   declaration serves both editions. detail.css keeps its own pair for the
   single-level claim span. */
:root {
  quotes: "\201C" "\201D" "\2018" "\2019";
}

/* ==================================== 8. the headline sits on its ink =====
   A font box is bigger than the letters in it: every face reserves half-leading
   above the capitals and below the baseline so adjacent lines do not touch.
   On a 17px paragraph that air is welcome. On a 40px headline that opens a feed
   under a hairline it is a visible gap between the rule and the first letter —
   which is why the identity lane hand-tuned leading and nudged margins to close
   it, and why the masthead glyph carries a `-0.12em` optical nudge.

   `text-box` makes that air removable instead of eye-balled: `trim-both` drops
   the half-leading at both ends of the block and `cap alphabetic` says WHERE to
   cut — the top of the capitals and the baseline. The headline's box is then
   its ink, and the space around it is the space the stylesheet declared, not a
   number a face chose. It ships in current Chromium and Safari, but not yet in
   every engine, so it is behind a feature query: engines without it keep
   exactly today's layout, and this rule is inert, not a fallback.

   LATIN ONLY, deliberately. `cap` measures Latin capitals; a Han glyph fills
   its em with no cap height and no baseline the same way, so trimming to them
   would misalign the zh edition — which cjk.css already leads at the ink box
   by setting its own 1.46 line-height on these same selectors. The language
   gate keeps that work untouched. */
@supports (text-box: trim-both cap alphabetic) {
  html[lang="en"] :is(
    main .article__title,
    main .detail .detail__title,
    main .digest__headline,
    main .card--lead .card__title,
    main .card--secondary .card__title,
    main .state__title
  ) {
    text-box: trim-both cap alphabetic;
  }
}
