/* PILOT landing — first paint and script-aware typography (M1).
   Render-blocking: link it in <head> before the module script so the
   localisation gate is in force for the very first frame. Only tokens that
   style.css :root defines are referenced, each with a fallback. */

/* ── Localisation gate ────────────────────────────────────
   The HTML source is Chinese. With scripting, the copy that a visitor reads in
   the first viewport stays invisible (layout kept, no shift) until
   localizeStaticDocument() adds html.is-localized in the same task as the
   text swap. The photo is never gated: it paints first and is the LCP.
   If the module never runs, the failsafe reveals the source after 3 s.
   Without scripting this block does not apply and the source reads as is. */
@media (scripting: enabled) {
  html:not(.is-localized) :is(.hero-kicker, .hero-title, .hero-copy, .flight-log, .hero-deck, .desktop-nav, .header-actions) {
    visibility: hidden;
    animation: l10n-failsafe 0s 3s forwards !important;
  }
}
@keyframes l10n-failsafe { to { visibility: visible; } }

/* ── Line breaking ─────────────────────────────────────── */
h1, h2, h3 { text-wrap: balance; }
p { text-wrap: pretty; }
:lang(zh), :lang(ja) { line-break: strict; }
:is(h1, h2, h3):not(:lang(zh), :lang(ja), :lang(th), :lang(lo), :lang(km), :lang(my)) { hyphens: auto; }

/* Designed <br> breaks: typeset.js turns them into spaces outside Chinese and
   Japanese. CJK keeps them, except inside running paragraphs on phones, where
   the measure is too short for a fixed break to land well. */
@media (max-width: 640px) {
  html.is-cjk p br { display: none; }
}

/* ── Arabic and Hebrew ────────────────────────────────────
   Archivo stays first for Latin glyphs; the system faces behind it carry heavy
   weights, and weight synthesis is allowed where a face has none. */
:root:lang(ar) {
  --font-text: "Archivo", "Noto Sans Arabic", "Segoe UI", "Geeza Pro", "SF Arabic", Tahoma, var(--font-sys, system-ui, sans-serif);
  --font-display: "Archivo", "Noto Sans Arabic", "Segoe UI", "Geeza Pro", "SF Arabic", Tahoma, var(--font-sys, system-ui, sans-serif);
}
:root:lang(he) {
  --font-text: "Archivo", "Noto Sans Hebrew", "Segoe UI", "Arial Hebrew", var(--font-sys, system-ui, sans-serif);
  --font-display: "Archivo", "Noto Sans Hebrew", "Segoe UI", "Arial Hebrew", var(--font-sys, system-ui, sans-serif);
}
/* #hero-title is named so the rule outranks the hero's own font shorthand. */
:is(h1, h2, h3, #hero-title):is(:lang(ar), :lang(he)) {
  font-weight: 700;
  letter-spacing: 0;
  line-height: 1.22;
  font-synthesis-weight: auto;
}

/* ── CJK families ─────────────────────────────────────────
   Japanese and Traditional Chinese must not fall through to Simplified Chinese
   faces (the glyph shapes differ), and Korean needs Hangul faces first. */
:root:lang(ja) { --font-sys: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Yu Gothic", Meiryo, "Noto Sans CJK JP", "Noto Sans JP", system-ui, sans-serif; }
:root:lang(zh-Hant) { --font-sys: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang TC", "Microsoft JhengHei UI", "Microsoft JhengHei", "Noto Sans CJK TC", "Noto Sans TC", system-ui, sans-serif; }
:root:lang(ko) { --font-sys: -apple-system, BlinkMacSystemFont, "Segoe UI", "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans CJK KR", "Noto Sans KR", system-ui, sans-serif; }
/* Korean breaks between words, never inside them; Japanese headings break at phrase boundaries. */
:lang(ko) :is(h1, h2, h3, h4, p, li, .button) { word-break: keep-all; }
:lang(ja) :is(h1, h2, h3, strong, summary, .button) { word-break: auto-phrase; }

/* ── Tall scripts ─────────────────────────────────────────
   Thai, Lao, Khmer, Burmese, Devanagari, Bengali, Tamil, Telugu and Georgian
   stack marks above and below the line; tight display leading and negative
   tracking would collide or clip them. */
:is(h1, h2, h3, #hero-title):is(:lang(th), :lang(lo), :lang(km), :lang(my), :lang(hi), :lang(bn), :lang(ta), :lang(te), :lang(ka)) {
  line-height: 1.3;
  letter-spacing: 0;
}

/* ── Bidi ─────────────────────────────────────────────── */
.ltr-run { unicode-bidi: isolate; direction: ltr; }
/* The kicker's platform list is its own run, so an RTL kicker keeps "لـ Tinder" together. */
.hero-kicker :is(.kicker-sep, .kicker-platforms) { unicode-bidi: isolate; }
[dir=rtl] svg:has(> use[href="#i-arrow"]),
[dir=rtl] svg:has(> use[href="#i-arrow-up"]) { scale: -1 1; }

/* Khmer and Burmese set very tall, wide headlines: on phones a lower floor keeps
   the hero title below the faces in the photo (fit.js never goes under it). */
@media (max-width: 640px) {
  :is(:lang(km), :lang(my)) .hero-title { font-size: var(--fit, 32px); }
}
