/* Load a tiny JetBrains Mono subset containing only the Unicode
   box-drawing characters used by freq() / cross_tab() / table_*()
   output. IBM Plex Mono (loaded by bslib) does not ship these glyphs
   in its Google Fonts subsets, so without this the browser picks
   them up from whichever system font happens to have them, producing
   inconsistent metrics and misaligned junctions. Google Fonts'
   text= parameter returns a custom ~1 KB subset containing only the
   listed characters: ─ │ ┌ ┐ └ ┘ ├ ┤ ┬ ┴ ┼ ╌. The last one
   (U+254C, light double dash) is used as the group separator rule
   in table_categorical() / table_continuous() when several row
   variables are stacked, and must be served from the same font as
   │ and ┼ so the junction on the dashed rule stays aligned with
   the solid │ column above and below. Must stay above other rules:
   @import is only valid at the top of a CSS file. */
@import url("https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400&display=swap&text=%E2%94%80%E2%94%82%E2%94%8C%E2%94%90%E2%94%94%E2%94%98%E2%94%9C%E2%94%A4%E2%94%AC%E2%94%B4%E2%94%BC%E2%95%8C");

body,
.navbar,
.dropdown-menu,
table,
.table,
.gt_table,
.tinytable,
.ft_table {
  font-feature-settings: "zero" 1;
}

code,
pre,
kbd,
samp,
.sourceCode,
.inline-codex {
  font-feature-settings: "zero" 1, "tnum" 1;
}

/* Keep IBM Plex Mono as the primary code font (identical look to the
   pre-fix site), and list JetBrains Mono only as a fallback — the
   browser automatically uses it for the box-drawing characters that
   IBM Plex Mono does not cover, so all │ / ─ / ┼ glyphs come from a
   single consistent source and align correctly. */
pre,
pre code,
code,
kbd,
samp,
.sourceCode,
.sourceCode pre,
.sourceCode pre code {
  font-family:
    "IBM Plex Mono",
    "JetBrains Mono",
    ui-monospace,
    SFMono-Regular,
    Menlo,
    Consolas,
    monospace;
}

/* pkgdown / downlit render R output lines (the ones starting with #>)
   inside <span class="co"> because they share the "comment" highlight
   class. In dark mode the bslib theme applies font-style: italic to
   those spans via the selector
   [data-bs-theme="dark"] pre code span.co
   which has specificity (0, 2, 3) — higher than any class-only
   override — so we use !important to keep ASCII output upright in
   both light and dark themes. */
.sourceCode .co,
pre .co,
code .co {
  font-style: normal !important;
}

/* IBM Plex Sans has a lower x-height (~520/1000) than IBM Plex Mono
   (~554/1000), so at identical nominal size the body text reads
   visually smaller than code blocks. Bumping body to 17px and
   line-height to 1.6 rebalances the two and improves readability
   for long-form documentation. The font-family fallback covers
   the brief swap moment plus offline / CSP-restricted contexts;
   bslib's default rule sets only "IBM Plex Sans" without a
   fallback. */
:root {
  --bs-body-font-size: 1.0625rem;
  --bs-body-line-height: 1.6;
  --bs-body-font-family:
    "IBM Plex Sans",
    system-ui,
    -apple-system,
    "Segoe UI",
    Roboto,
    "Helvetica Neue",
    sans-serif;
}

/* Cap the article main column at 78ch on large screens so prose
   lines stay within a comfortable reading length. Code blocks,
   wide ASCII tables, and rich tables (gt / tinytable / flextable)
   sit inside this column and remain free to overflow horizontally
   on their own when needed; we do not constrain them individually. */
@media (min-width: 992px) {
  .template-article main {
    max-width: 78ch;
  }
}

/* Soft background and rounding for inline `code` so it stands out
   from prose without competing with block code (already styled by
   the syntax highlighter). The :not(pre) > code selector excludes
   highlighted blocks, which always live under <pre>. */
:not(pre) > code {
  background-color: rgba(135, 131, 120, 0.12);
  padding: 0.125em 0.35em;
  border-radius: 0.25rem;
}
[data-bs-theme="dark"] :not(pre) > code {
  background-color: rgba(255, 255, 255, 0.08);
}

/* Bootstrap's default top-margin on headings is too tight for
   long-form articles; section breaks need clearer vertical
   breathing room. */
.template-article h2 { margin-top: 2.5rem; }
.template-article h3 { margin-top: 2rem; }
.template-article h4 { margin-top: 1.5rem; }

/* knitr-rendered Markdown tables ship without gt/tinytable/flextable
   classes and inherit Bootstrap's tight cell padding. Loosen rows
   without touching the styled table engines (which carry their own
   spacing). */
.template-article table:not(.gt_table):not(.tinytable):not(.tabwid) th,
.template-article table:not(.gt_table):not(.tinytable):not(.tabwid) td {
  padding: 0.5rem 0.75rem;
}

/* Respect users with vestibular sensitivity who request reduced
   motion via OS / browser settings. Disables animations and
   transitions package-wide, including any added by Bootstrap or
   pkgdown JS components. */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
