/* Limma documentation: the one stylesheet (mkdocs.yml, extra_css).
 *
 * White and black, in Limma's own type. Everything here works through
 * mkdocs-material's CSS variables and a few selectors on its markup.
 *
 * NOTHING IS LOADED FROM ANOTHER SITE. The fonts are files beside this
 * one (../fonts/, each with its SIL Open Font License), every url() is
 * relative, and the theme's own web font is off (theme.font: false):
 * the privacy policy promises the site loads nothing from elsewhere, and
 * tests/test_docs_hosted_pages.py holds the built site to it.
 *
 * Contents
 *   1. Fonts          4. Header and logo     7. Code
 *   2. Tokens         5. Navigation          8. Tables
 *   3. Material map   6. Type                9. Admonitions, footer, search
 */

/* 1. Fonts ------------------------------------------------------------ */

/* The latin subsets of the three variable fonts the Limma website uses.
 * unicode-range is the subset each file holds: a character outside it
 * (an arrow, a CJK name) is drawn by the fallback stack below. */

@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("../fonts/inter-latin-var.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193,
    U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Manrope";
  font-style: normal;
  font-weight: 500 800;
  font-display: swap;
  src: url("../fonts/manrope-latin-var.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193,
    U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  src: url("../fonts/jetbrains-mono-latin-var.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193,
    U+2212, U+2215, U+FEFF, U+FFFD;
}

/* 2. Tokens ----------------------------------------------------------- */

/* Light: a white page and near-black ink; greys only, no colour accent. */
:root,
[data-md-color-scheme="default"] {
  --limma-bg: #ffffff;
  --limma-ink: #111111;
  --limma-ink-2: #3d3d3d;      /* secondary text: nav links, captions */
  --limma-muted: #6b6b6b;      /* labels, the TOC, metadata */
  --limma-faint: #9a9a9a;      /* comments, placeholders */
  --limma-line: #e8e8e8;       /* hairlines */
  --limma-line-strong: #d2d2d2;
  --limma-surface: #f6f6f6;    /* code blocks, admonition titles */
  --limma-surface-2: #fafafa;  /* hover tints */
  --limma-underline: rgba(17, 17, 17, 0.32);
  --limma-select: rgba(17, 17, 17, 0.1);
}

/* Dark: black, with near-white text. */
[data-md-color-scheme="slate"] {
  --limma-bg: #0b0b0b;
  --limma-ink: #ededed;
  --limma-ink-2: #c8c8c8;
  --limma-muted: #9a9a9a;
  --limma-faint: #6e6e6e;
  --limma-line: #1f1f1f;
  --limma-line-strong: #333333;
  --limma-surface: #161616;
  --limma-surface-2: #121212;
  --limma-underline: rgba(237, 237, 237, 0.35);
  --limma-select: rgba(237, 237, 237, 0.16);
}

:root {
  --limma-font-body: "Inter", ui-sans-serif, system-ui, -apple-system,
    BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --limma-font-display: "Manrope", "Inter", ui-sans-serif, system-ui,
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
    Arial, sans-serif;
  --limma-font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo,
    Monaco, Consolas, "Liberation Mono", monospace;
  --limma-radius: 6px;
}

/* 3. Material's variables, mapped onto the tokens --------------------- */

/* Material declares its font stacks on body; this rule comes later in the
 * cascade with the same specificity, so it replaces them. */
body {
  --md-text-font-family: var(--limma-font-body);
  --md-code-font-family: var(--limma-font-mono);
}

:root,
[data-md-color-scheme="default"],
[data-md-color-scheme="slate"] {
  /* the page */
  --md-default-bg-color: var(--limma-bg);
  --md-default-bg-color--light: var(--limma-bg);
  --md-default-bg-color--lighter: var(--limma-bg);
  --md-default-bg-color--lightest: var(--limma-bg);
  --md-default-fg-color: var(--limma-ink);
  --md-default-fg-color--light: var(--limma-muted);
  --md-default-fg-color--lighter: var(--limma-faint);
  --md-default-fg-color--lightest: var(--limma-line);

  /* "primary" is the header: the page's own white (or black) */
  --md-primary-fg-color: var(--limma-bg);
  --md-primary-fg-color--light: var(--limma-bg);
  --md-primary-fg-color--dark: var(--limma-bg);
  --md-primary-bg-color: var(--limma-ink);
  --md-primary-bg-color--light: var(--limma-muted);

  /* "accent" is hover and focus: ink, never a colour */
  --md-accent-fg-color: var(--limma-ink);
  --md-accent-fg-color--transparent: var(--limma-select);
  --md-accent-bg-color: var(--limma-bg);
  --md-accent-bg-color--light: var(--limma-bg);

  /* text */
  --md-typeset-color: var(--limma-ink);
  --md-typeset-a-color: var(--limma-ink);
  --md-typeset-mark-color: var(--limma-select);
  --md-typeset-table-color: var(--limma-line);
  --md-typeset-table-color--light: var(--limma-surface-2);
  --md-typeset-kbd-color: var(--limma-surface);
  --md-typeset-kbd-accent-color: var(--limma-bg);
  --md-typeset-kbd-border-color: var(--limma-line-strong);

  /* admonitions and footer: the page's own colours */
  --md-admonition-fg-color: var(--limma-ink);
  --md-admonition-bg-color: var(--limma-bg);
  --md-footer-fg-color: var(--limma-ink);
  --md-footer-fg-color--light: var(--limma-muted);
  --md-footer-fg-color--lighter: var(--limma-faint);
  --md-footer-bg-color: var(--limma-bg);
  --md-footer-bg-color--dark: var(--limma-bg);

  /* no drop shadows: hairlines do that work */
  --md-shadow-z1: 0 0 0 1px var(--limma-line);
  --md-shadow-z2: 0 0 0 1px var(--limma-line);
  --md-shadow-z3: 0 0 0 1px var(--limma-line-strong);
}

::selection {
  background: var(--limma-select);
}

/* 4. Header and logo -------------------------------------------------- */

.md-header,
.md-header--shadow {
  box-shadow: none;
  border-bottom: 1px solid var(--limma-line);
}

/* The wordmark, with a small "Docs" beside it. The header never repeats
 * "Limma" as text: the site name stays in the page title, not here. */
.md-header__button.md-logo {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin: 0.2rem 0.4rem 0.2rem 0.2rem;
  padding: 0.4rem;
  opacity: 1;
}

.md-header__button.md-logo img {
  height: 0.95rem;
  width: auto;
}

.md-logo::after {
  content: "Docs";
  font-family: var(--limma-font-body);
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0;
  line-height: 1;
  color: var(--limma-muted);
  padding-left: 0.6rem;
  border-left: 1px solid var(--limma-line-strong);
}

/* Dark mode draws the white wordmark (logo-white.svg) in place of the
 * black one. A pseudo-element's background works in every browser. */
[data-md-color-scheme="slate"] .md-logo img {
  display: none;
}

[data-md-color-scheme="slate"] .md-logo::before {
  content: "";
  display: block;
  height: 0.95rem;
  aspect-ratio: 77.57 / 17.98;
  background: url("../brand/logo-white.svg") no-repeat left center / contain;
}

/* The site name ("Limma Documentation") is not shown beside the
 * wordmark; the slot shows the page's title once the page scrolls. */
.md-header__topic:first-child {
  visibility: hidden;
}

.md-header__title {
  margin-left: 0.4rem;
  font-family: var(--limma-font-display);
  font-weight: 600;
}

.md-header__topic + .md-header__topic {
  font-size: 0.75rem;
  color: var(--limma-ink-2);
}

/* Small screens: keep the wordmark in the header, after the menu button. */
@media screen and (max-width: 76.234375em) {
  .md-header__button.md-logo {
    display: flex;
    margin-left: 0;
  }

  .md-header__button[for="__drawer"] {
    order: -1;
  }
}

/* The palette toggle and search: ink on the page, no coloured field. */
.md-header__button.md-icon,
.md-header__option {
  color: var(--limma-ink-2);
}

.md-header__button.md-icon:hover,
.md-header__option:hover {
  color: var(--limma-ink);
  opacity: 1;
}

/* 5. Navigation ------------------------------------------------------- */

.md-nav {
  font-size: 0.7rem;
  line-height: 1.45;
}

.md-nav__link {
  margin-top: 0.5em;
  color: var(--limma-ink-2);
}

.md-nav__link:hover,
.md-nav__link:focus {
  color: var(--limma-ink);
}

/* the page being read: bold black */
.md-nav__item .md-nav__link--active,
.md-nav__item .md-nav__link--active code {
  color: var(--limma-ink);
  font-weight: 650;
}

/* "Start here", "Integrator", …: quiet section labels */
.md-nav__item--section > .md-nav__link {
  margin-top: 1.6em;
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--limma-muted);
}

.md-nav__item--section > .md-nav__link[for],
.md-nav__item--section > .md-nav__container > .md-nav__link:not(.md-nav__link--active) {
  color: var(--limma-muted);
}

/* a section with a page of its own ("Operator", "Window"): its label is that link */
.md-nav__item--section > .md-nav__container > .md-nav__link:hover {
  color: var(--limma-ink);
}

/* the sidebars' scrollbars: a hairline thumb */
.md-sidebar__scrollwrap {
  scrollbar-color: var(--limma-line-strong) transparent;
}

.md-sidebar__scrollwrap:hover {
  scrollbar-color: var(--limma-faint) transparent;
}

/* Wide screens: the header already says "Docs"; the sidebar does not repeat it. */
@media screen and (min-width: 76.25em) {
  .md-nav--primary > .md-nav__title {
    display: none;
  }
}

/* the drawer on small screens: "Docs" under the wordmark */
.md-nav--primary > .md-nav__title {
  font-size: 0;
  background: var(--limma-bg);
  color: var(--limma-ink);
  box-shadow: none;
  border-bottom: 1px solid var(--limma-line);
}

.md-nav--primary > .md-nav__title .md-logo img {
  height: 1.1rem;
}

.md-nav--primary > .md-nav__title::after {
  content: "Docs";
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--limma-muted);
}

.md-nav--primary > .md-nav__title .md-logo::after {
  content: none;
}

[data-md-color-scheme="slate"] .md-nav__title .md-logo::before {
  height: 1.1rem;
}

/* the table of contents, right */
.md-nav--secondary .md-nav__title {
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--limma-muted);
  background: var(--limma-bg);
  box-shadow: none;
}

.md-nav--secondary .md-nav__link {
  color: var(--limma-muted);
}

.md-nav--secondary .md-nav__link--active,
.md-nav--secondary .md-nav__link:hover {
  color: var(--limma-ink);
}

/* 6. Type ------------------------------------------------------------- */

.md-typeset {
  font-size: 0.8rem;
  line-height: 1.7;
  font-feature-settings: "kern", "liga", "calt";
}

.md-typeset h1,
.md-typeset h2,
.md-typeset h3,
.md-typeset h4,
.md-typeset h5,
.md-typeset h6 {
  font-family: var(--limma-font-display);
  color: var(--limma-ink);
}

.md-typeset h1 {
  font-size: 2.05em;
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.2;
  margin: 0.4em 0 0.9em;
}

.md-typeset h2 {
  font-size: 1.45em;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.3;
  margin: 2.4em 0 0.7em;
}

.md-typeset h3 {
  font-size: 1.15em;
  font-weight: 650;
  letter-spacing: -0.01em;
  line-height: 1.4;
  margin: 2em 0 0.6em;
}

.md-typeset h4 {
  font-size: 1em;
  font-weight: 650;
  letter-spacing: 0;
  margin: 1.8em 0 0.5em;
}

.md-typeset h5,
.md-typeset h6 {
  font-size: 0.9em;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: none;
  color: var(--limma-ink-2);
}

.md-typeset p,
.md-typeset ul,
.md-typeset ol,
.md-typeset dl {
  margin-bottom: 1.1em;
}

.md-typeset li {
  margin-bottom: 0.35em;
}

.md-typeset strong {
  font-weight: 650;
}

/* links: black, underlined; the underline darkens on hover */
.md-typeset a {
  color: var(--limma-ink);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
  text-decoration-color: var(--limma-underline);
  transition: text-decoration-color 0.15s;
}

.md-typeset a:hover,
.md-typeset a:focus {
  color: var(--limma-ink);
  text-decoration-color: currentcolor;
}

/* the heading permalinks (the pilcrow) are not underlined */
.md-typeset .headerlink {
  text-decoration: none;
  color: var(--limma-faint);
}

.md-typeset .headerlink:hover,
.md-typeset :target > .headerlink {
  color: var(--limma-ink);
}

.md-typeset blockquote {
  border-left: 2px solid var(--limma-line-strong);
  color: var(--limma-ink-2);
  padding-left: 1em;
}

.md-typeset hr {
  border-bottom: 1px solid var(--limma-line);
}

/* 7. Code ------------------------------------------------------------- */

/* light grey on light, dark grey on dark; syntax in shades of the ink */
:root,
[data-md-color-scheme="default"] {
  --md-code-fg-color: #1f1f1f;
  --md-code-bg-color: var(--limma-surface);
  --md-code-hl-color: #111111;
  --md-code-hl-color--light: rgba(17, 17, 17, 0.07);
  --md-code-hl-keyword-color: #111111;
  --md-code-hl-function-color: #111111;
  --md-code-hl-name-color: #1f1f1f;
  --md-code-hl-string-color: #555555;
  --md-code-hl-number-color: #3d3d3d;
  --md-code-hl-constant-color: #3d3d3d;
  --md-code-hl-special-color: #3d3d3d;
  --md-code-hl-operator-color: #6b6b6b;
  --md-code-hl-punctuation-color: #6b6b6b;
  --md-code-hl-comment-color: #8a8a8a;
  --md-code-hl-generic-color: #6b6b6b;
  --md-code-hl-variable-color: #3d3d3d;
}

[data-md-color-scheme="slate"] {
  --md-code-fg-color: #e2e2e2;
  --md-code-bg-color: var(--limma-surface);
  --md-code-hl-color: #ededed;
  --md-code-hl-color--light: rgba(237, 237, 237, 0.08);
  --md-code-hl-keyword-color: #ffffff;
  --md-code-hl-function-color: #ffffff;
  --md-code-hl-name-color: #e2e2e2;
  --md-code-hl-string-color: #b0b0b0;
  --md-code-hl-number-color: #cfcfcf;
  --md-code-hl-constant-color: #cfcfcf;
  --md-code-hl-special-color: #cfcfcf;
  --md-code-hl-operator-color: #9a9a9a;
  --md-code-hl-punctuation-color: #9a9a9a;
  --md-code-hl-comment-color: #777777;
  --md-code-hl-generic-color: #9a9a9a;
  --md-code-hl-variable-color: #cfcfcf;
}

.md-typeset code,
.md-typeset kbd,
.md-typeset pre {
  font-variant-ligatures: none;
}

/* inline code */
.md-typeset code {
  font-size: 0.85em;
  padding: 0.1em 0.35em;
  border-radius: 4px;
  word-break: normal;
}

.md-typeset a code {
  color: inherit;
}

/* blocks */
.md-typeset pre > code {
  font-size: 0.82em;
  line-height: 1.65;
  padding: 1em 1.2em;
  border: 1px solid var(--limma-line);
  border-radius: var(--limma-radius);
}

.md-typeset .highlight .k,
.md-typeset .highlight .kn,
.md-typeset .highlight .kd,
.md-typeset .highlight .kc,
.md-typeset .highlight .nf {
  font-weight: 600;
}

.md-typeset .highlight .c,
.md-typeset .highlight .c1,
.md-typeset .highlight .cm {
  font-style: italic;
}

.md-clipboard {
  color: var(--limma-faint);
}

.md-clipboard:hover,
.md-clipboard:focus {
  color: var(--limma-ink);
}

/* 8. Tables: hairline rules, no box -------------------------------- */

.md-typeset table:not([class]) {
  font-size: 0.7rem;
  line-height: 1.55;
  border: none;
  border-radius: 0;
  box-shadow: none;
  background: transparent;
}

.md-typeset table:not([class]) th {
  font-weight: 600;
  color: var(--limma-ink);
  background: transparent;
  border-bottom: 1px solid var(--limma-line-strong);
  padding: 0.7em 1.1em 0.7em 0;
  min-width: 4rem;
}

.md-typeset table:not([class]) td {
  border-top: 1px solid var(--limma-line);
  padding: 0.7em 1.1em 0.7em 0;
}

.md-typeset table:not([class]) tbody tr:first-child td {
  border-top: none;
}

.md-typeset table:not([class]) tbody tr:hover {
  background: transparent;
  box-shadow: none;
}

.md-typeset table:not([class]) code {
  font-size: 0.9em;
}

/* 9. Admonitions, footer, search -------------------------------------- */

/* Every admonition type is one monochrome box. These selectors match
 * Material's per-type rules in specificity and come later, so they win
 * for every type (note, warning, danger, tip, …) without naming each. */
.md-typeset .admonition.admonition,
.md-typeset details[class] {
  border: 1px solid var(--limma-line-strong);
  border-radius: var(--limma-radius);
  box-shadow: none;
  font-size: 0.75rem;
  background: var(--limma-bg);
}

.md-typeset .admonition > .admonition-title,
.md-typeset details[class] > summary {
  background: var(--limma-surface);
  border-bottom: 1px solid var(--limma-line);
  font-weight: 600;
  color: var(--limma-ink);
}

.md-typeset .admonition > .admonition-title::before,
.md-typeset details[class] > summary::before {
  background-color: var(--limma-ink);
}

.md-typeset details[class] > summary::after {
  color: var(--limma-muted);
}

.md-footer {
  border-top: 1px solid var(--limma-line);
}

.md-footer__link {
  color: var(--limma-ink);
}

.md-footer__title {
  font-family: var(--limma-font-display);
  font-weight: 600;
}

.md-footer__direction {
  color: var(--limma-muted);
}

.md-footer-meta {
  border-top: 1px solid var(--limma-line);
  color: var(--limma-muted);
}

.md-copyright {
  color: var(--limma-muted);
}

/* the search field: a hairline box on the page, not a tinted bar */
.md-search__form {
  background: var(--limma-bg);
  border: 1px solid var(--limma-line-strong);
  border-radius: var(--limma-radius);
  box-shadow: none;
}

.md-search__form:hover {
  background: var(--limma-surface-2);
}

.md-search__input,
.md-search__input::placeholder,
.md-search__icon {
  color: var(--limma-muted);
}

[data-md-toggle="search"]:checked ~ .md-header .md-search__form {
  border-radius: var(--limma-radius) var(--limma-radius) 0 0;
  background: var(--limma-bg);
}

.md-search__input {
  color: var(--limma-ink);
}

.md-search-result mark {
  color: var(--limma-ink);
  background: var(--limma-select);
}

.md-search-result__meta {
  background: var(--limma-surface);
  color: var(--limma-muted);
}

/* back to top */
.md-top {
  background: var(--limma-bg);
  color: var(--limma-ink);
  border: 1px solid var(--limma-line-strong);
  box-shadow: none;
}
