/* Linnear's design system, mapped onto the Zensical (Material) theme.
 *
 * Every color below is copied from packages/tailwind-config/base.css and
 * commented with the token it comes from, so the two stay in step. The rules
 * that follow enforce docs/UI_DESIGN_STYLE.md: one accent, hairlines instead
 * of decoration, 0.5rem radii, minimal syntax color.
 *
 * Note on units: the theme sets `html { font-size: 125% }`, so `.05rem` is a
 * 1px hairline and `.4rem` is the 0.5rem base radius.
 */

/* The theme loads Space Grotesk at 300/400/500/700, but the type scale sets
   headings in 600, so that weight is requested here as well. */
@import url("https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&display=swap");

/* Light scheme ---------------------------------------------------------- */

:root,
[data-md-color-scheme="default"] {
  /* --primary */
  --md-primary-fg-color: oklch(0.546 0.245 264);
  --md-primary-fg-color--light: oklch(0.62 0.24 264);
  --md-primary-fg-color--dark: oklch(0.47 0.22 264);

  /* --primary-foreground */
  --md-primary-bg-color: oklch(0.985 0.005 264);
  --md-primary-bg-color--light: oklch(0.985 0.005 264 / 70%);

  /* Hover and focus stay the one accent, a shade darker than --primary */
  --md-accent-fg-color: oklch(0.47 0.22 264);
  --md-accent-bg-color: oklch(0.985 0.005 264);
  --md-accent-bg-color--light: oklch(0.985 0.005 264 / 70%);

  /* --accent, the hover tint on ghost and outline controls. The theme also
     fills the active navigation item with it, a tint rather than a bar. */
  --md-accent-fg-color--transparent: oklch(0.94 0.03 264);

  /* --foreground */
  --md-default-fg-color: oklch(0.278 0.033 256);

  /* --muted-foreground, the lightest text color allowed */
  --md-default-fg-color--light: oklch(0.53 0.02 256);

  /* Between --muted-foreground and --border: icons and scrollbars only */
  --md-default-fg-color--lighter: oklch(0.278 0.033 256 / 32%);

  /* --border, the main structural device: every hairline resolves to this */
  --md-default-fg-color--lightest: oklch(0.918 0.006 264);

  /* --background */
  --md-default-bg-color: oklch(1 0 0);
  --md-default-bg-color--light: oklch(1 0 0);
  --md-default-bg-color--lighter: oklch(1 0 0 / 30%);
  --md-default-bg-color--lightest: oklch(1 0 0 / 12%);

  /* --muted for the code surface, --foreground for the text in it */
  --md-code-bg-color: oklch(0.961 0.004 264);
  --md-code-bg-color--light: oklch(0.961 0.004 264 / 70%);
  --md-code-bg-color--lighter: oklch(0.961 0.004 264 / 40%);
  --md-code-fg-color: oklch(0.278 0.033 256);

  /* --primary at 15%, which is also the ::selection fill */
  --md-code-hl-color: oklch(0.546 0.245 264);
  --md-code-hl-color--light: oklch(0.546 0.245 264 / 15%);

  /* --primary for links */
  --md-typeset-a-color: oklch(0.546 0.245 264);

  /* --highlight for marked text */
  --md-typeset-mark-color: oklch(0.953 0.051 181);

  /* --border for table rules, --muted for the zebra fill */
  --md-typeset-table-color: oklch(0.918 0.006 264);
  --md-typeset-table-color--light: oklch(0.961 0.004 264);

  /* --muted and --border for keys */
  --md-typeset-kbd-color: oklch(0.961 0.004 264);
  --md-typeset-kbd-accent-color: oklch(1 0 0);
  --md-typeset-kbd-border-color: oklch(0.918 0.006 264);

  /* --destructive and --success at 10%, for diffs */
  --md-typeset-del-color: oklch(0.577 0.245 27 / 10%);
  --md-typeset-ins-color: oklch(0.5 0.154 150 / 10%);

  /* --background and --muted: the footer is flat, a hairline sets it apart */
  --md-footer-bg-color: oklch(1 0 0);
  --md-footer-bg-color--dark: oklch(0.961 0.004 264);

  /* --warning on its own 10% tint */
  --md-warning-fg-color: oklch(0.53 0.163 49);
  --md-warning-bg-color: oklch(0.53 0.163 49 / 10%);

  /* --destructive. The theme has no token of its own for it, and this one is
     used only by the danger, failure and bug admonition icons below. */
  --md-danger-fg-color: oklch(0.577 0.245 27);
}

/* Dark scheme, from the .dark block of base.css ------------------------- */

[data-md-color-scheme="slate"] {
  /* --primary */
  --md-primary-fg-color: oklch(0.62 0.24 264);
  --md-primary-fg-color--light: oklch(0.7 0.21 264);
  --md-primary-fg-color--dark: oklch(0.546 0.245 264);

  /* --primary-foreground */
  --md-primary-bg-color: oklch(0.985 0.005 264);
  --md-primary-bg-color--light: oklch(0.985 0.005 264 / 70%);

  --md-accent-fg-color: oklch(0.7 0.21 264);
  --md-accent-bg-color: oklch(0.985 0.005 264);
  --md-accent-bg-color--light: oklch(0.985 0.005 264 / 70%);

  /* --accent */
  --md-accent-fg-color--transparent: oklch(0.32 0.04 264);

  /* --foreground */
  --md-default-fg-color: oklch(0.961 0.004 264);

  /* --muted-foreground */
  --md-default-fg-color--light: oklch(0.65 0.015 256);

  --md-default-fg-color--lighter: oklch(0.961 0.004 264 / 32%);

  /* --border */
  --md-default-fg-color--lightest: oklch(1 0 0 / 12%);

  /* --background, with --card as the raised step */
  --md-default-bg-color: oklch(0.178 0.025 256);
  --md-default-bg-color--light: oklch(0.178 0.025 256);
  --md-default-bg-color--lighter: oklch(0.178 0.025 256 / 30%);
  --md-default-bg-color--lightest: oklch(0.178 0.025 256 / 12%);

  /* --muted and --foreground */
  --md-code-bg-color: oklch(0.3 0.025 256);
  --md-code-bg-color--light: oklch(0.3 0.025 256 / 70%);
  --md-code-bg-color--lighter: oklch(0.3 0.025 256 / 40%);
  --md-code-fg-color: oklch(0.961 0.004 264);

  /* --primary at 15% */
  --md-code-hl-color: oklch(0.62 0.24 264);
  --md-code-hl-color--light: oklch(0.62 0.24 264 / 15%);

  /* --primary */
  --md-typeset-a-color: oklch(0.62 0.24 264);

  /* --highlight */
  --md-typeset-mark-color: oklch(0.277 0.046 193);

  /* --border and --muted */
  --md-typeset-table-color: oklch(1 0 0 / 12%);
  --md-typeset-table-color--light: oklch(0.3 0.025 256 / 50%);

  /* --muted, --card and --border */
  --md-typeset-kbd-color: oklch(0.3 0.025 256);
  --md-typeset-kbd-accent-color: oklch(0.228 0.028 256);
  --md-typeset-kbd-border-color: oklch(1 0 0 / 12%);

  /* --destructive and --success at 15% */
  --md-typeset-del-color: oklch(0.65 0.22 25 / 15%);
  --md-typeset-ins-color: oklch(0.723 0.19 150 / 15%);

  /* --background and --card */
  --md-footer-bg-color: oklch(0.178 0.025 256);
  --md-footer-bg-color--dark: oklch(0.228 0.028 256);

  /* --warning */
  --md-warning-fg-color: oklch(0.769 0.17 70);
  --md-warning-bg-color: oklch(0.769 0.17 70 / 15%);

  /* --destructive */
  --md-danger-fg-color: oklch(0.65 0.22 25);
}

/* Syntax highlighting ---------------------------------------------------- */

/* Code carries no syntax rainbow: --foreground, --muted-foreground and
   --primary for the keywords that say what the code does. */

:root,
[data-md-color-scheme="default"],
[data-md-color-scheme="slate"] {
  --md-code-hl-keyword-color: var(--md-primary-fg-color);
  --md-code-hl-special-color: var(--md-primary-fg-color);

  --md-code-hl-name-color: var(--md-code-fg-color);
  --md-code-hl-function-color: var(--md-code-fg-color);
  --md-code-hl-constant-color: var(--md-code-fg-color);
  --md-code-hl-string-color: var(--md-code-fg-color);
  --md-code-hl-number-color: var(--md-code-fg-color);

  --md-code-hl-comment-color: var(--md-default-fg-color--light);
  --md-code-hl-operator-color: var(--md-default-fg-color--light);
  --md-code-hl-punctuation-color: var(--md-default-fg-color--light);
  --md-code-hl-variable-color: var(--md-default-fg-color--light);
  --md-code-hl-generic-color: var(--md-default-fg-color--light);
}

/* Header and footer ------------------------------------------------------ */

/* The header is the page color with one hairline under it, not a blue bar:
   blue is reserved for links, focus and the active state. */
.md-header {
  background-color: var(--md-default-bg-color);
  border-bottom: 0.05rem solid var(--md-default-fg-color--lightest);
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}

/* The hairline already separates the header, so the scroll shadow comes off */
.md-header--shadow {
  box-shadow: none;
}

.md-header__title {
  font-weight: 600;
  letter-spacing: -0.015em;
}

/* The theme fills the footer's bottom bar with --md-default-fg-color--lightest,
   which is --border here and too dark for a surface, so it takes --muted. */
.md-footer-meta {
  background-color: var(--md-footer-bg-color--dark);
}

/* Typography ------------------------------------------------------------- */

/* 400 for body, 500 for controls and labels, 600 for headings, 700 only for
   <strong>, with the type scale's tracking per level. */

.md-typeset h1 {
  font-weight: 600;
  letter-spacing: -0.035em;
}

.md-typeset h2 {
  font-weight: 600;
  letter-spacing: -0.025em;
}

.md-typeset h3,
.md-typeset h4,
.md-typeset h5,
.md-typeset h6 {
  font-weight: 600;
  letter-spacing: -0.015em;
}

.md-typeset b,
.md-typeset strong {
  font-weight: 700;
}

/* The theme sets these titles in 700 as well. They are headings, so 600. */
.md-header__topic:first-child,
.md-nav--secondary .md-nav__title,
.md-nav .md-nav__title[for="__drawer"],
.md-typeset .admonition-title,
.md-typeset summary {
  font-weight: 600;
}

/* A citation marker is mono, like the footnotes on the marketing site's
   statistics, at the weight the theme's 700 replaced. */
.md-typeset .footnote-ref {
  font-family: var(--md-code-font-family);
  font-weight: 400;
}

/* Article text keeps to about 65 characters a line. Code, tables, figures and
   admonitions span the full column so they never scroll the page sideways. */
.md-typeset h1,
.md-typeset h2,
.md-typeset h3,
.md-typeset h4,
.md-typeset p,
.md-typeset ul,
.md-typeset ol,
.md-typeset dl,
.md-typeset blockquote {
  max-width: 65ch;
}

::selection {
  background: var(--md-code-hl-color--light);
}

/* Shape ------------------------------------------------------------------ */

/* 0.5rem is the base radius: code blocks, admonitions, tabs and cards all
   take it, and nothing is rounder. */

.md-typeset .admonition,
.md-typeset details {
  border: 0.05rem solid var(--md-default-fg-color--lightest);
  border-radius: 0.4rem;
}

/* An admonition is a framed block in the page color whatever its type: the
   type shows in the icon and the title, not in a colored fill. The theme sets
   the fill per type, as `.md-typeset .admonition.note`, so the attribute
   selector here is what matches that specificity. */
.md-typeset .admonition[class],
.md-typeset details[class] {
  background-color: var(--md-default-bg-color);
}

/* An admonition's icon is neutral: blue means "act here", and a note isn't
   something to act on. Only the status types below take a color, and each of
   those carries its own icon and title alongside it. The theme colors each
   type as `.md-typeset .note > .admonition-title::before`, hence `[class]`. */
.md-typeset .admonition[class] > .admonition-title::before,
.md-typeset details[class] > summary::before {
  background-color: var(--md-default-fg-color--light);
}

.md-typeset .admonition.warning .admonition-title::before,
.md-typeset details.warning > summary::before {
  background-color: var(--md-warning-fg-color);
}

.md-typeset .admonition.danger .admonition-title::before,
.md-typeset .admonition.failure .admonition-title::before,
.md-typeset .admonition.bug .admonition-title::before,
.md-typeset details.danger > summary::before,
.md-typeset details.failure > summary::before,
.md-typeset details.bug > summary::before {
  background-color: var(--md-danger-fg-color);
}

/* A code block is --muted with a hairline around it, the same as a terminal
   block in the apps. */
.md-typeset pre > code {
  border: 0.05rem solid var(--md-default-fg-color--lightest);
  border-radius: 0.4rem;
}

/* Inline code reads as a chip */
.md-typeset code {
  border-radius: 0.2rem;
}

/* An admonition spans the column like a code block, so the text in it does
   too, rather than stopping at the paragraph measure and leaving a gap. */
.md-typeset .admonition p,
.md-typeset details p {
  max-width: none;
}

/* Publications ----------------------------------------------------------- */

/* The byline from overrides/partials/byline.html: authors and date in the
   caption style, --muted-foreground at text-sm, close under the title it
   belongs to and further from the text that follows. The `ul` in the
   selectors matches the specificity of the theme's list rules, as
   `.md-typeset ul:not([hidden])` and `[dir=ltr] .md-typeset ul li`. */
.md-typeset h1:has(+ .md-byline),
.md-typeset h2:has(+ .md-byline) {
  margin-bottom: 0.6rem;
}

.md-typeset ul.md-byline {
  display: flex;
  flex-wrap: wrap;
  padding: 0;
  margin: 0 0 1.6rem;
  font-size: 0.7rem;
  color: var(--md-default-fg-color--light);
  list-style: none;
}

.md-typeset ul.md-byline > li {
  margin: 0;
}

/* In the list, the excerpt follows its byline as closely as the byline
   follows the title, and the list starts a section's gap below the intro. */
.md-post--excerpt .md-typeset ul.md-byline {
  margin-bottom: 0.6rem;
}

.md-content__inner > header.md-typeset {
  margin-bottom: 2.4rem;
}

/* In the list a title is a heading that links, in --foreground, and turns
   blue only on hover, like the navigation. */
.md-post--excerpt .md-post__content > h2:first-child a {
  color: var(--md-default-fg-color);
  transition: color 150ms;
}

.md-post--excerpt .md-post__content > h2:first-child a:is(:hover, :focus) {
  color: var(--md-accent-fg-color);
}

/* A draft is a status, so it is a labeled badge in --warning rather than the
   theme's red block. Drafts only render under `zensical serve`. */
.md-draft {
  padding: 0 0.4rem;
  font-weight: 500;
  color: var(--md-warning-fg-color);
  background-color: var(--md-warning-bg-color);
  border-radius: 9999px;
}

/* overrides/blog-post.html keeps only the way back in the post's sidebar, so
   the theme's hairline under it would separate it from nothing. */
.md-sidebar--post .md-post__back {
  border-bottom: none;
}

/* Contents --------------------------------------------------------------- */

/* Below 60em the theme turns the contents into a button floating over the
   article, where it covers code and footnotes. It comes off: a phone reader
   scrolls instead. */
.md-sidebar--secondary .md-sidebar-button__wrapper {
  display: none;
}

/* overrides/main.html puts the contents sidebar after the article, and the
   theme's gap between the two only matched the old order. This is the same
   gap, selected from the article's side. */
@media screen and (min-width: 45em) {
  .md-content:has(~ .md-sidebar--secondary:not([hidden])) > .md-content__inner {
    margin-right: 1.2rem;
  }
}
