/* ============================================================================
   Typography — the font stacks for the whole surface, and the reading layer for answers.

   Loaded last (SemantikHead), so it is the one place that decides fonts, answer text sizes and
   long-form rhythm. The earlier sheets size chrome only (labels, buttons, menus, the sidebar).

   Fonts — html[data-font] (SemantikThemeOptions.Font, set by the host; theme-boot.js resolves
   auto, the default, before paint, so only the two values below ever reach CSS)
     geist     The bundled Geist variable font, the product face (auto everywhere but Windows).
     system    The platform's UI face (Segoe UI Variable on Windows, SF Pro on Apple). auto picks it
               on Windows: Geist has almost no hinting, so at 100% scaling Chromium draws it soft,
               while Segoe UI is hinted for ClearType. Geist is then never downloaded.

   Reading — html[data-text-size] (compact | default | large; host default, user can change it in
   the Appearance panel)
     One size (--reading-size) drives the answer: headings, inline code, tables and code blocks are
     relative to it. Default is 16px, the long-form norm (ChatGPT, Gemini, Notion, GitHub).

   Column
     One reading column (--thread-width) holds the question, the answer, figures and the composer,
     as in ChatGPT and Claude: answer text fills it, about 90 characters a line at 16px. A narrower
     text cap inside a wider column was tried and left an empty strip beside every paragraph. The
     column grows a little with the text size so a line keeps about the same length.

   Rhythm
     Paragraphs and blocks are one text size apart, sections two; list items half; a heading sits
     close to the text it introduces. Inline code is a quiet tint, not a bordered chip, because
     technical answers carry many identifiers per line.

   Dark themes
     Body text is mixed 10% toward the background: near-white strokes on near-black glow on large
     screens. Geist is drawn a touch heavier there (420), as light-on-dark text reads thinner.
   ========================================================================= */

/* Geist 1.7.2 (Vercel, SIL OFL 1.1 — wwwroot/fonts/Geist-OFL.txt), self-hosted. A declared
   @font-face costs nothing until a rule uses the family, so data-font="system" never loads it. */
@font-face {
  font-family: "Geist";
  src: url("fonts/Geist-Variable.woff2") format("woff2-variations"), url("fonts/Geist-Variable.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --font-system: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont,
    "Helvetica Neue", Roboto, "Noto Sans", Arial, sans-serif;
  --font-heading: var(--font-sans);
  /* GitHub's stack: SF Mono on Apple, Consolas on Windows. Consolas is narrower and lighter than
     Cascadia, which keeps identifier-heavy sentences from turning into blocks of code. */
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Cascadia Mono",
    "Liberation Mono", monospace;

  /* Reading tokens (default text size). */
  --reading-size: 1rem;
  --reading-leading: 1.7;
  --thread-width: 44rem;
  --turn-gap: 2rem;
}

/* With an external theme the interface face is the host's (external-tokens.css has a fallback). The
   default carries no specificity, so html[data-font="system"] below always wins over it. */
:where(:root:not([data-sm-theme="external"])) { --font-sans: "Geist", var(--font-system); }
html[data-font="system"] { --font-sans: var(--font-system); }

/* A host that keeps the chat's colour families (data-sm-palette) takes its font as well: these
   outrank a host's own font tokens (for example Blueprint's [data-bb-font]). */
html[data-sm-palette][data-font="geist"] { --font-sans: "Geist", var(--font-system); }
html[data-sm-palette][data-font="system"] { --font-sans: var(--font-system); }

html[data-text-size="compact"] { --reading-size: 0.9375rem; --reading-leading: 1.6; --thread-width: 42rem; }
html[data-text-size="large"] { --reading-size: 1.0625rem; --reading-leading: 1.7; --thread-width: 46rem; }

:where(.sm-root, .sm-scope) { font-family: var(--font-sans); font-kerning: normal; }

/* ── Turns ────────────────────────────────────────────────────────────── */

.sm-thread__inner { gap: var(--turn-gap); }

.sm-message__body {
  font-size: var(--reading-size);
  line-height: var(--reading-leading);
  letter-spacing: normal;
}

/* Light text on a dark ground glows and reads thinner: soften it a little, and give Geist (unhinted)
   a touch more weight. Headings, links and emphasis keep their own colours. */
html.dark .sm-message__body { color: color-mix(in srgb, var(--foreground) 90%, var(--background)); }
html.dark[data-font="geist"] .sm-message__body { font-weight: 420; }

.sm-bubble-user { font-size: var(--reading-size); line-height: 1.6; letter-spacing: normal; }
.sm-bubble-user--code { font-size: calc(var(--reading-size) * 0.875); }

/* 16px on small screens: below it mobile browsers zoom into a focused field. */
.sm-composer__input { font-size: var(--reading-size); }
@media (max-width: 768px) { .sm-composer__input { font-size: max(1rem, var(--reading-size)); } }

/* ── Prose: block rhythm ──────────────────────────────────────────────── */

.sm-prose { overflow-wrap: break-word; }
.sm-prose p,
.sm-prose li { text-wrap: pretty; }

.sm-prose > * + * { margin-top: var(--reading-size); }

/* Sections: a heading opens space above and stays close to its text. */
.sm-prose > h2 { margin-top: calc(var(--reading-size) * 2); }
.sm-prose > :is(h3, h4) { margin-top: calc(var(--reading-size) * 1.5); }
.sm-prose > :is(h2, h3, h4) + * { margin-top: calc(var(--reading-size) * 0.5); }

/* Framed blocks (tables, code, diagrams, files, images, display maths) get a little more air than
   a paragraph, so they read as figures rather than as the next line of text. */
.sm-prose > :is(.sm-prose__table-wrap, .sm-code, .sm-mermaid, .sm-artifact, .sm-file, .sm-image,
                .sm-gallery-block, .sm-gallery-strip, .sm-math--display) {
  margin-block: calc(var(--reading-size) * 1.25);
}

.sm-prose > hr { margin-block: calc(var(--reading-size) * 2); }

/* Nothing pushes the first block of a segment away from what precedes it. */
.sm-prose > :first-child { margin-top: 0; }

/* ── Prose: headings and emphasis ─────────────────────────────────────── */

.sm-prose :is(h2, h3, h4) {
  font-family: var(--font-heading);
  font-weight: 600;
  color: var(--foreground);
  text-wrap: balance;
}
.sm-prose h2 { font-size: 1.25em; line-height: 1.35; letter-spacing: -0.015em; }
.sm-prose h3 { font-size: 1.0625em; line-height: 1.45; letter-spacing: -0.01em; }
.sm-prose h4 { font-size: 1em; line-height: var(--reading-leading); font-weight: 500; }

.sm-prose strong { font-weight: 600; }

/* ── Prose: lists ─────────────────────────────────────────────────────── */

.sm-prose :is(ul, ol) { display: block; padding-left: 1.375em; }
.sm-prose li { padding-left: 0.2em; }
.sm-prose li + li { margin-top: 0.5em; }
.sm-prose li > :is(ul, ol) { margin-top: 0.5em; }
.sm-prose li::marker { color: var(--muted-foreground); }
.sm-prose ol > li::marker { font-variant-numeric: tabular-nums; }

/* ── Prose: inline code ───────────────────────────────────────────────── */

/* A tint of the text colour (so it works on every theme and mode) with no border: identifiers
   stay distinguishable without turning a sentence into a row of chips. */
.sm-prose :not(pre) > code {
  padding: 0.1em 0.3em;
  border: 0;
  border-radius: 0.25em;
  background: color-mix(in srgb, var(--foreground) 7%, transparent);
  color: var(--foreground);
  font-family: var(--font-mono);
  font-size: 0.875em;
  font-weight: 400;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}
.sm-prose a > code { color: inherit; }

/* ── Prose: quotes, tables, code blocks ───────────────────────────────── */

.sm-prose blockquote {
  padding: 0 0 0 1em;
  border-left: 3px solid var(--border);
  border-radius: 0;
  background: none;
  color: var(--muted-foreground);
}

.sm-prose table { font-size: 0.875em; line-height: 1.5; }
.sm-prose :is(th, td) { padding: 0.625em 0.875em; }
.sm-prose th { font-weight: 600; }
.sm-prose table :not(pre) > code { font-size: 0.9em; }

.sm-message__body .sm-code pre { font-size: calc(var(--reading-size) * 0.875); line-height: 1.6; }

/* ── Small screens ────────────────────────────────────────────────────── */

@media (max-width: 560px) {
  .sm-thread__inner { gap: calc(var(--turn-gap) * 0.75); }
}
