/* ============================================================================
   LuxeChain - GLOBAL TYPOGRAPHY TOKENS
   The single source of truth for the type system on every surface: marketing
   site, customer dashboard, admin panel, invoices, playground, emails.

   WHY THIS FILE EXISTS
   Six stylesheets previously each declared their own --font-sans, and they
   disagreed:
       luxechain.css       Instrument Sans   (never loaded - see note below)
       design-system.css   Plus Jakarta Sans
       marketing.css       Plus Jakarta Sans
       lc-light.css        Plus Jakarta Sans
       admin-light.css     Plus Jakarta Sans
   Whichever stylesheet loaded last won, so the face silently changed per page
   - and the public site asked for Instrument Sans, which is not vendored
   anywhere on this box, so it has been rendering as the fallback (Roboto) the
   whole time. That is the actual reason the site never had a coherent voice.
   All six now point at these tokens; none of them declare a face of their own.

   LOAD ORDER: this file must be imported LAST, after every other stylesheet,
   so its :root block wins on equal specificity. Each template already orders
   its <link> tags; the pages that only load a subset still get the tokens
   because this file is self-contained (it does not @import anything).

   SCALE: Apple's own HIG steps, expressed in rem against a 16px root.
   Display  34/40  -0.022em  600   page titles on marketing
   Title 1  28/34  -0.020em  600   admin/page headings
   Title 2  22/28  -0.018em  600   section headings
   Title 3  20/25  -0.016em  600   card headings
   Headline 17/22  -0.011em  600   emphasised body / KPI labels
   Body     17/25  -0.011em  400   (17px is Apple's default body; see the
                                   --text-body note below for why we use 16)
   Callout  16/21  -0.008em  400
   Subhead  15/20  -0.006em  400
   Footnote 13/18  -0.003em  400
   Caption  12/16   0em      400   uppercase micro-labels
   ============================================================================ */

:root {
  /* ---- the face stack -------------------------------------------------
     SF Pro is a system font: it is present on macOS/iOS and cannot be
     redistributed, so it is referenced through the Apple system aliases and
     never embedded. Inter is self-hosted and carries every other platform,
     which is what keeps Android and Windows from falling through to a much
     narrower generic sans. Detailed reasoning: css/fonts.css. */
  --font-sf: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text",
             "Helvetica Neue", "Segoe UI", "Inter", system-ui, Roboto,
             "Noto Sans", Arial, sans-serif;

  /* Display vs Text: SF Pro ships as two optical sizes. On Apple hardware the
     aliases pick the right one automatically; elsewhere both resolve to Inter,
     which is fine because Inter is one optical size designed to work at both.
     Kept as two tokens so the intent survives a future proper SF webfont. */
  --font-display: -apple-system, BlinkMacSystemFont, "SF Pro Display",
                  "Helvetica Neue", "Inter", system-ui, "Segoe UI", Roboto,
                  "Noto Sans", Arial, sans-serif;
  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Text",
               "Helvetica Neue", "Inter", system-ui, "Segoe UI", Roboto,
               "Noto Sans", Arial, sans-serif;
  --font-mono: "SF Mono", ui-monospace, "JetBrains Mono", "Menlo", "Consolas",
               "Liberation Mono", monospace;

  /* ---- weights --------------------------------------------------------
     Apple's scale is restrained: Regular 400, Medium 500, Semibold 600.
     Bold 700 is deliberately absent - the brief forbids excessive bold, and
     headings at 600 over 400 body text already give clear hierarchy. */
  --fw-regular: 400;
  --fw-medium: 500;
  --fw-semibold: 600;

  /* ---- size scale -----------------------------------------------------
     Body sits at 16px rather than Apple's 17px on purpose. 17px was tuned for
     iOS text views measured in points; in a desktop browser at 100% zoom on a
     dense admin table it inflates row height and halves how many rows fit
     without scrolling. 16px is the web-native equivalent of the same optical
     weight and matches the surrounding layout grid. */
  --text-display: 2.125rem;  /* 34 */
  --text-title1: 1.75rem;    /* 28 */
  --text-title2: 1.375rem;   /* 22 */
  --text-title3: 1.25rem;    /* 20 */
  --text-headline: 1.0625rem;/* 17 */
  --text-body: 1rem;         /* 16 */
  --text-callout: 0.9375rem; /* 15 */
  --text-subhead: 0.875rem;  /* 14 */
  --text-footnote: 0.8125rem;/* 13 */
  --text-caption: 0.75rem;   /* 12 */

  /* ---- line heights ---------------------------------------------------
     Tight on large text, generous on small. A single global line-height is
     the most common reason a "clean" type system still looks amateur: 1.5 on
     a 34px display heading reads as disconnected. */
  --lh-display: 1.18;
  --lh-title: 1.24;
  --lh-heading: 1.32;
  --lh-body: 1.5;
  --lh-tight: 1.35;

  /* ---- letter spacing -------------------------------------------------
     SF and Inter are both tightly fitted at large sizes, so display text
     needs negative tracking or it looks loose and generic. Small caps labels
     need positive tracking to stay legible. Nothing here is decorative. */
  --ls-display: -0.022em;
  --ls-title: -0.019em;
  --ls-heading: -0.014em;
  --ls-body: -0.006em;
  --ls-caption: 0.045em;
}

/* ============================================================================
   ELEMENT DEFAULTS
   Applied globally so no page has to opt in. Component rules that set their
   own size still win - this only fixes the base voice.
   ============================================================================ */
html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  /* Stops iOS Safari from inflating body text in landscape, which silently
     breaks every measured layout on the phone. */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  font-family: var(--font-sans);
  font-size: var(--text-body);
  font-weight: var(--fw-regular);
  line-height: var(--lh-body);
  letter-spacing: var(--ls-body);
  font-variant-numeric: tabular-nums;
}

/* Tabular figures everywhere numbers are compared column-to-column. Without
   this, KPI cards and price tables jitter horizontally as values change. */
table, .kpi .v, .num, .mono-sm, .tabular {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1, "cv05" 1;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: var(--fw-semibold);
  line-height: var(--lh-heading);
  letter-spacing: var(--ls-heading);
  /* Balance prevents a lone word on the last line of a heading, which is
     disproportionately visible at display sizes. */
  text-wrap: balance;
}

h1 {
  font-size: var(--text-title1);
  letter-spacing: var(--ls-title);
  line-height: var(--lh-title);
}

h2 {
  font-size: var(--text-title2);
  letter-spacing: var(--ls-title);
  line-height: var(--lh-title);
}

h3 { font-size: var(--text-title3); }
h4 { font-size: var(--text-headline); }
h5 { font-size: var(--text-callout); }
h6 {
  font-size: var(--text-caption);
  letter-spacing: var(--ls-caption);
  text-transform: uppercase;
}

p, li, dd, dt, figcaption {
  font-family: var(--font-sans);
  letter-spacing: var(--ls-body);
  /* Long tokens (an API key, a model id, an email) must not force a horizontal
     scrollbar on a 390px phone. `break-word` only splits when it has to. */
  overflow-wrap: break-word;
}

/* Buttons and navigation: Medium 500, never bold. Bold buttons read as chunky
   and dated; 500 is what Apple uses for every control surface. */
button, input, select, textarea, optgroup {
  font-family: var(--font-sans);
  font-size: var(--text-body);
  font-weight: var(--fw-regular);
  letter-spacing: var(--ls-body);
}

button, .btn, .nav-links a, nav a, [role="button"] {
  font-weight: var(--fw-medium);
  letter-spacing: -0.003em;
}

label, th, .label {
  font-weight: var(--fw-medium);
  letter-spacing: -0.002em;
}

code, kbd, samp, pre, .mono {
  font-family: var(--font-mono);
  font-size: 0.9em;
  letter-spacing: 0;
  font-variant-ligatures: none;
}

small, .small, .tiny, .caption, figcaption {
  font-size: var(--text-footnote);
  letter-spacing: 0;
}

/* ============================================================================
   UTILITY CLASSES
   Available on every page so new components do not invent another size.
   ============================================================================ */
.t-display { font-family: var(--font-display); font-size: var(--text-display);
             font-weight: var(--fw-semibold); line-height: var(--lh-display);
             letter-spacing: var(--ls-display); }
.t-title1  { font-family: var(--font-display); font-size: var(--text-title1);
             font-weight: var(--fw-semibold); line-height: var(--lh-title);
             letter-spacing: var(--ls-title); }
.t-title2  { font-family: var(--font-display); font-size: var(--text-title2);
             font-weight: var(--fw-semibold); line-height: var(--lh-title);
             letter-spacing: var(--ls-title); }
.t-title3  { font-family: var(--font-display); font-size: var(--text-title3);
             font-weight: var(--fw-semibold); line-height: var(--lh-heading);
             letter-spacing: var(--ls-heading); }
.t-headline{ font-size: var(--text-headline); font-weight: var(--fw-semibold);
             line-height: var(--lh-tight); letter-spacing: -0.011em; }
.t-body    { font-size: var(--text-body); font-weight: var(--fw-regular);
             line-height: var(--lh-body); letter-spacing: var(--ls-body); }
.t-callout { font-size: var(--text-callout); line-height: var(--lh-body); }
.t-subhead { font-size: var(--text-subhead); line-height: var(--lh-body); }
.t-footnote{ font-size: var(--text-footnote); line-height: var(--lh-tight); }
.t-caption { font-size: var(--text-caption); letter-spacing: var(--ls-caption);
             text-transform: uppercase; font-weight: var(--fw-medium); }
.t-mono    { font-family: var(--font-mono); letter-spacing: 0; }

/* Indices/superscript line-height collapses in some browsers; normalise. */
sub, sup { font-size: 0.72em; line-height: 0; position: relative; }
sup { top: -0.5em; }
sub { bottom: -0.25em; }
