/*
 * Typography Tokens
 */

:root {
  --sigvelo-font-sans:
    system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --sigvelo-font-heading: var(--sigvelo-font-sans);
  --sigvelo-font-mono:
    SFMono-Regular, Consolas, Menlo, Monaco, "liberation mono", "Courier New", monospace;
  --sigvelo-text-root: 16px;

  /*
   * Reading roles. Interface chrome, the assistant's prose, and the user's own
   * words are three different reading tasks, and products routinely want them
   * set differently — a serif response against a sans UI is the common one.
   * All three resolve to the sans face until a consumer says otherwise, so
   * nothing changes by default.
   */
  --sigvelo-font-ui: var(--sigvelo-font-sans);
  --sigvelo-font-response: var(--sigvelo-font-sans);
  --sigvelo-font-user-message: var(--sigvelo-font-sans);

  /* Named so [data-font="dyslexic"] has something to point at. The face is not
     bundled; a consumer that wants it self-hosts OpenDyslexic and the stack
     falls through to a wide-spaced serif everywhere else. */
  --sigvelo-font-dyslexic: "OpenDyslexic", "Comic Sans MS", Georgia, serif;

  /* Type scale */
  --sigvelo-text-3xs: 0.625rem;
  --sigvelo-text-2xs: 0.6875rem;
  --sigvelo-text-xs: 0.75rem;
  --sigvelo-text-compact: 0.8125rem;
  --sigvelo-text-sm: 0.875rem;
  --sigvelo-text-base: 1rem;
  --sigvelo-text-lg: 1.125rem;
  --sigvelo-text-xl: 1.25rem;
  --sigvelo-text-2xl: 1.5rem;
  --sigvelo-text-3xl: 1.75rem;
  --sigvelo-text-4xl: 2.25rem;
  --sigvelo-text-5xl: 3rem;

  /* Fluid type scale */
  --sigvelo-text-fluid-sm: clamp(0.8125rem, 0.75rem + 0.2vw, 0.875rem);
  --sigvelo-text-fluid-base: clamp(0.9375rem, 0.875rem + 0.2vw, 1rem);
  --sigvelo-text-fluid-lg: clamp(1.0625rem, 0.95rem + 0.35vw, 1.25rem);
  --sigvelo-text-fluid-xl: clamp(1.25rem, 1.1rem + 0.5vw, 1.5rem);
  --sigvelo-text-fluid-2xl: clamp(1.5rem, 1.25rem + 0.75vw, 2rem);
  --sigvelo-text-fluid-3xl: clamp(1.875rem, 1.5rem + 1.2vw, 2.75rem);

  --sigvelo-font-weight-normal: 400;
  --sigvelo-font-weight-semibold: 500;
  --sigvelo-font-weight-bold: 700;

  /*
   * Line heights.
   *
   * The ratio scale below is for prose, where leading should grow with the
   * reader's font size. For interface text, prefer the paired absolutes
   * further down: they are quantized to whole pixels, so a stack of labels,
   * rows, and icons lands on the same rhythm the spacing scale uses instead of
   * accumulating fractional drift.
   */
  --sigvelo-leading-none: 1;
  --sigvelo-leading-tight: 1.2;
  --sigvelo-leading-compact: 1.25;
  --sigvelo-leading-snug: 1.375;
  --sigvelo-leading-normal: 1.5;
  --sigvelo-leading-relaxed: 1.625;
  --sigvelo-leading-loose: 2;

  /*
   * One leading per type step. Setting a size and its partner keeps every
   * label of that size on the same baseline rhythm without anyone choosing a
   * ratio by eye. Small text takes a proportionally tighter measure and large
   * text a looser one, which is why these are not one multiplier.
   */
  --sigvelo-text-3xs-leading: 0.875rem; /* 14px */
  --sigvelo-text-2xs-leading: 1rem; /* 16px */
  --sigvelo-text-xs-leading: 1rem; /* 16px */
  --sigvelo-text-compact-leading: 1.125rem; /* 18px */
  --sigvelo-text-sm-leading: 1.25rem; /* 20px */
  --sigvelo-text-base-leading: 1.5rem; /* 24px */
  --sigvelo-text-lg-leading: 1.75rem; /* 28px */
  --sigvelo-text-xl-leading: 1.75rem; /* 28px */
  --sigvelo-text-2xl-leading: 2rem; /* 32px */
  --sigvelo-text-3xl-leading: 2.25rem; /* 36px */
  --sigvelo-text-4xl-leading: 2.5rem; /* 40px */
  --sigvelo-text-5xl-leading: 3rem; /* 48px */

  /* Letter spacing. Large type set at the default tracking looks loose, so
     display headings tighten as they grow. */
  --sigvelo-tracking-tighter: -0.03em;
  --sigvelo-tracking-tight: -0.015em;
  --sigvelo-tracking-normal: 0;
  --sigvelo-tracking-wide: 0.025em;
  --sigvelo-tracking-wider: 0.05em;

  /*
   * Measure. Line length is the readability control with the most evidence
   * behind it and the one nothing in the system could express, so long-form
   * agent output ran the full width of whatever panel it landed in. Character
   * units, not rem: the comfortable measure is a count of characters, and it
   * should follow the reader's font size rather than fight it.
   */
  --sigvelo-measure-prose: 68ch;
  /* Code, tables, and diagrams read worse when wrapped than when wide. */
  --sigvelo-measure-wide-block: 100ch;

  /*
   * Reading roles. Body text is one size across chat, markdown, activity, and
   * workspace. Activity stays that size and fades (Codex conversation-body);
   * headings and metadata are the only size exceptions.
   */
  --sigvelo-text-prose: var(--sigvelo-text-sm);
  --sigvelo-text-prose-leading: var(--sigvelo-text-sm-leading);
  --sigvelo-text-code: var(--sigvelo-text-prose);
  --sigvelo-text-code-leading: var(--sigvelo-text-prose-leading);
  --sigvelo-text-meta: var(--sigvelo-text-xs);
  --sigvelo-text-meta-leading: var(--sigvelo-text-xs-leading);

  /*
   * Reader text scale. Applied by .sigvelo-reader-text to prose only, never to
   * chrome: a reader who wants larger message text is not asking for taller
   * toolbars, and scaling both is how a side panel runs out of room. Controls
   * keep resolving through the rem type ramp.
   */
  --sigvelo-chat-font-scale: 1;
}

/*
 * Opt-in dyslexia-friendly face. Set on :root for the whole document or on any
 * subtree. Only the reading roles change — mono stays mono, because a
 * proportional face makes code worse for everyone.
 */
:root[data-font="dyslexic"],
[data-font="dyslexic"] {
  --sigvelo-font-ui: var(--sigvelo-font-dyslexic);
  --sigvelo-font-response: var(--sigvelo-font-dyslexic);
  --sigvelo-font-user-message: var(--sigvelo-font-dyslexic);
  --sigvelo-font-heading: var(--sigvelo-font-dyslexic);
}
