/* DRIVE typography floor (2026-11-10 font QA). Loaded LAST from shared/_ui_theme_head.html, on every staff, guest, auth and
   ops page. Typography only: font stacks, language fallbacks, CJK line breaking and tracking, minimum readable sizes, number
   figures. It never moves anything; layout stays in the page templates and the layout stylesheets.

   Why this file exists (QA 2026-11-10, measured with Chromium CSS.getPlatformFontsForNode on the data copy):
   1. Every stack named "Apple SD Gothic Neo" (a Korean font that also carries 4,620 Korean-style hanja) BEFORE any Chinese
      font. On iPhone and Mac, Traditional and Simplified UI text was drawn half in the Korean font and half in PingFang,
      with different stroke weight and shapes inside one word (e.g. 全部 in Apple SD Gothic, 车辆 in PingFang). Simplified pages
      also got PingFang TC (Traditional forms) because no SC font was listed. Fixed by ordering the CJK fonts per html lang.
   2. No stack named the Windows fonts (Malgun Gothic, Microsoft JhengHei, Microsoft YaHei) or Android's Noto Sans CJK, so the
      Surface fell to DirectWrite's locale guess; an English UI with a Chinese customer name could land in a Japanese font
      (Yu Gothic / Meiryo), which lacks many Traditional characters. Fixed by naming them explicitly.
   3. Korean table headers lost word-break: keep-all (table-polish.css sets normal), and Chinese text inherited keep-all from
      Korean rules, which forbids line breaks between Chinese characters. Fixed per language below.
   4. Negative heading tracking (down to -.055em) and wide uppercase eyebrow tracking (.12em) were applied to Hangul and Han,
      which makes CJK glyphs touch or drift apart. Reset per language.
   5. On phones: pills 10.5px, section eyebrows 10.5px, bottom tabs 10px, chips 12px, table text 12.5px, hints 12px. Floors
      below: body-like text 13px, tap labels 14px (bottom tabs 12.5px), decorations 12px.
   6. Phone landscape (844px) is wider than the 840px mobile breakpoint, so inputs were 15px (selects 13px) and iOS Safari
      zoomed the page on focus. Fixed for every coarse-pointer device regardless of width.
   The web fonts themselves (Manrope, Inter Tight, Geist "$") are Latin only on purpose; Hangul and Han always come from the
   system fonts named here, so nothing is downloaded for them. */

/* ---------- 1. Font families ---------- */
:root {
  /* Latin / system UI, in platform order. "-apple-system" and BlinkMacSystemFont are SF on Apple, ignored elsewhere;
     Segoe UI is Windows; Roboto is Android. */
  --df-font-sys: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial;
  /* Symbol fonts last, for ::before / ::after glyphs (▾ ▴ ✓ › ·) that Manrope does not carry. */
  --df-font-sym: "Apple Symbols", "Segoe UI Symbol", "Noto Sans Symbols2", "Noto Sans Symbols";
  /* English pages: a Chinese name goes to a Chinese font, a Korean name to a Korean font. Chinese first because the Korean
     fonts also contain hanja and would catch Chinese characters with Korean-style shapes. */
  --df-font-cjk: "PingFang TC", "PingFang SC", "Microsoft JhengHei", "Microsoft YaHei", "Apple SD Gothic Neo", "Malgun Gothic",
                 "Noto Sans TC", "Noto Sans SC", "Noto Sans KR", "Noto Sans CJK TC", "Noto Sans CJK SC", "Noto Sans CJK KR";
  --df-font-ui: "Manrope UI", var(--df-font-sys), var(--df-font-cjk), var(--df-font-sym), sans-serif;
  --df-font-guest: "Manrope Guest Preview", "Manrope", var(--df-font-sys), var(--df-font-cjk), var(--df-font-sym), sans-serif;
}
:root:lang(ko) {
  --df-font-cjk: "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", "Noto Sans CJK KR",
                 "PingFang TC", "Microsoft JhengHei", "Noto Sans TC", "Noto Sans CJK TC";
}
:root:lang(zh-Hant) {
  --df-font-cjk: "PingFang TC", "PingFang HK", "Microsoft JhengHei", "Noto Sans TC", "Noto Sans CJK TC",
                 "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", "Noto Sans CJK KR";
}
:root:lang(zh-Hans) {
  --df-font-cjk: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", "Noto Sans CJK SC",
                 "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", "Noto Sans CJK KR";
}

/* Staff shell (base.html), auth pages, ops read-only pages: Manrope UI + the language stack above. Same selectors as
   app-theme.css / auth-theme.css / app.css so this later file wins without !important. */
body,
body.app-shell,
body:has(> .auth-wrap),
body:has(> .bare-top) { font-family: var(--df-font-ui); }
.auth-wrap .auth-title,
body.app-shell .m-product-wordmark { font-family: var(--df-font-ui); }
/* Guest pages: guest.css builds --font per language already, but guest-detail-theme.css replaced it on every page that has
   a .topbar with a fixed Korean-first list. Put the language-ordered list back (the Manrope Guest Preview face stays first). */
:root { --font: var(--df-font-guest); }
body:has(> .topbar):not(.app-shell) { --font: var(--df-font-guest); font-family: var(--font); }
body:has(> .topbar):not(.app-shell) :is(button, input, select, textarea) { font-family: inherit; }

/* ---------- 2. Line breaking per language ---------- */
/* Korean: never split a word between syllables (Eugene 2026-10-30 "부 / 터"). Tables lost it to table-polish.css. */
:root:lang(ko) body { word-break: keep-all; overflow-wrap: break-word; }
:root:lang(ko) :is(th, th *, td, button, .btn, .chip, .pill, summary, label, dt, dd, li, p, h1, h2, h3, h4) { word-break: keep-all; }
:root:lang(ko) body.app-shell .main .tbl th { word-break: keep-all !important; overflow-wrap: break-word !important; }
/* Chinese breaks between any two characters; keep-all (inherited from Korean-minded rules) would forbid that and push long
   lines out of their cards. */
:root:is(:lang(zh-Hant), :lang(zh-Hans)) body :not(pre, code, textarea, input) { word-break: normal; }
:root:is(:lang(zh-Hant), :lang(zh-Hans)) body { line-break: auto; }

/* ---------- 3. Tracking on Hangul and Han ---------- */
/* Headings and names: at most -.01em (Latin headings elsewhere keep their tighter tracking). */
:root:is(:lang(ko), :lang(zh-Hant), :lang(zh-Hans)) :is(h1, h2, h3, h4, .page-head h1, .card h2, .m-title, .title, .nd-t, .vc-t,
  .sec h2, .st-gt, .count, .crow-name, .vrow-name, .deal-head h1, .dn h1, .ns-head h1, .ns-gt, .kpi .v, .stat .n, .sc-car,
  .auth-title, .pill, .badge, .tag, .vc-chip, .ot-t b) { letter-spacing: -.01em !important; }
/* Eyebrows / small caps labels: uppercase tracking (.09 to .13em) spreads CJK too far apart. */
:root:is(:lang(ko), :lang(zh-Hant), :lang(zh-Hans)) :is(.nav-h, .dash-zh, .dq-h, .map-layer, .eyebrow, .sl-kicker, .ey, .sl-sn,
  .sl-lbl, .who, .fl, .st-pv-l, .sub-h, .m-sheet-h, .kv dt, .rv-notet, .ss-live, .tc-ver, .tc-diff, .lbl, .fs-k, .fx-k,
  .gd-summary-note, .now, .ops-day) { letter-spacing: .03em !important; }

/* ---------- 4. Numbers ---------- */
/* Prices and counts line up in columns; the "$" keeps the demo rule (money-theme.css: Geist "$" at 1em, weight 600). */
body :is(td.num, .num, .tnum, .stat .n, .kpi .v, .vrow-price, .vrow-price-to, .price, .price-col, .pricebox, .pay, .fin,
  .df-money-v3, .sc-money, .sc-gross, .sc-num, .sl-value-n, .gd-summary-price, .vc-p, .dp-now, .ot-from, .td-num) {
  font-variant-numeric: tabular-nums;
}

/* ---------- 5. Minimum readable sizes on phones (and the folded Fold) ---------- */
/* Phone portrait (<= 840px, the app's mobile breakpoint), phone landscape (844px wide but under 520px tall) and any touch
   device: the floors are harmless on a large screen and essential on a small one. */
@media (max-width: 840px), (max-height: 520px), (pointer: coarse) {
  /* body-like text: 13px floor */
  body.app-shell :is(.small, .hint, .fld-help, .lbl, label.fld .lbl, .page-sub, .vrow-facts, .vrow-sub, .crow-sub, .step-desc,
    .step-sub, .note, .nav-t, .fs-k, .fx-k, .qstock, .qarr, .rv-addh, .rv-addt, .ss-fold-k, .ss-fold-d, .ss-chg-k, .user-chip,
    .brand-dealer.txt, .sb, .lb, .hbt, .att-chk, .fb-name, .g-more, .vrow-pay, .trim) { font-size: 13px !important; }
  body.app-shell .tbl, body.app-shell .tbl :is(th, td) { font-size: 13px !important; }
  body.app-shell :is(.tbl .pill, .vrow-pills .pill, .veh-tags .pill, .sort-arr) { font-size: 12px !important; }
  /* labels and decorations: 12px floor */
  body.app-shell :is(.pill:not(a), .dash-zh, .dq-h, .nav-h, .m-sheet-h, .map-layer, .stat .l, .stat .l + .l, .ss-name, .ss-time,
    .rv-notet, .st-pv-l, .owner-dot.tag, .ad-score, .sc-sfx, .seg-n, .cnt, .rv-cnt, .who, .ops-day, .g-type,
    .map-legend li) { font-size: 12px !important; }
  body.app-shell .pill { height: auto; min-height: 22px; line-height: 1.2; padding-block: 2px; }
  body.app-shell :is(.badge, .user-dot, .owner-dot) { font-size: 11.5px !important; }
  /* tap labels: 14px (bottom tab bar 12.5px: five tabs share 390px); a pill that is a link is a tap target too */
  body.app-shell :is(.btn, .btn.small, .chip, .seg a, .seg button, .mseg a, .m-row, .m-title, .sib-chip, .vtog button,
    .lang-btn, .filebtn .fb-face, summary, .card-head summary, .acct-s, .more, .rv-s, .rv-t,
    button:not(.m-tab)) { font-size: 14px !important; }
  body.app-shell a.pill { font-size: 13px !important; }
  body.app-shell .m-tab { font-size: 12.5px !important; }

  /* guest pages */
  body:has(> .topbar):not(.app-shell) :is(.ey, .fl, .vc-chip, .vc-pick, .stk, .kv dt, .gd-summary-note, .note, .tc-note, .tc-ver,
    .tc-diff, .vkr, .src, .sl-lbl, .sl-sn, .sl-kicker, .sub-h, .tag, .badge, .eyebrow, .gal-n, .chip .n, .g-disc, .g-disc-full,
    .std, .tc-msrp span, .tc-legend span, .wrap > div[style*="font-size:11px"]) { font-size: 12.5px !important; }
  body:has(> .topbar):not(.app-shell) :is(.base-l span, .cov-nm, .cov-nm span, .cov-v em, .doc-btn em, .cov-note, .demo-note,
    .df-salesperson-label) { font-size: 13px !important; }
  body:has(> .topbar):not(.app-shell) :is(.more, .gd-summary-label, .df-seller-action-name, .vs-l, .chip, .g-visit-go, .tb-lang-now,
    .nc-link, .drive-view-switch a, .drive-view-switch span) { font-size: 14px !important; }
  body:has(> .topbar):not(.app-shell) :is(.vc-chip, .vc-pick, .badge, .tag) { height: auto; min-height: 22px; line-height: 1.2; }
  /* scorecard month pill */
  body.app-shell .sc-months .now { font-size: 12px !important; }
  /* guest labels that sit outside the .topbar pages too: trim-exclusive tag, MSRP label (trims and new-car detail),
     rep tracker's "unsubscribed" / placeholder marks */
  body :is(.feat-l .only, .tc-msrp span, .tcf-msrp span, .row .pl, .bd .uns) { font-size: 12.5px !important; }
}

/* ---------- 6. Form controls never trigger the iOS focus zoom ---------- */
/* Any touch device, any width (phone landscape is 844px, wider than the 840px mobile breakpoint). 16px is the Safari threshold.
   The PIN field (22px) and the down-payment field (17px) stay larger. */
@media (pointer: coarse), (max-width: 840px), (max-height: 520px) {
  body :is(input:not([type=checkbox], [type=radio], [type=range], [type=hidden], [type=file], [type=color]), select, textarea) {
    font-size: 16px !important;
  }
  body .auth-card input.pin { font-size: 22px !important; }
  body .dp-in input { font-size: 17px !important; }
}

/* ---------- 7. Weight hygiene ---------- */
/* Manrope is a 200..800 variable font; 850 / 900 requests clamp to 800 (no faux bold). The system CJK fonts named above all
   ship a true bold (PingFang Semibold, Apple SD Gothic Neo Bold, Malgun Gothic Bold, Microsoft JhengHei/YaHei Bold, Noto Sans
   CJK Bold), so no synthetic bold appears on any of the four device families. Synthesis stays allowed for unknown fonts. */
