/* Markdown presentation adapted from the supplied markdown.css and
   markdown-dark.css. Rules are scoped so the site chrome and specialized
   layouts retain their own styling. */

:is(.markdown-body, #markdown-content) {
  --md-base-font-size: 13pt;
  --md-line-height: 1.3;
  --md-font-serif: "Lora", "Palatino Linotype", "NewComputerModern10", Palatino, Georgia, serif;
  --md-font-mono: "Maple Mono NF", "Maple Mono", "FiraCode Nerd Font", "Fira Code", Consolas, "Courier New", monospace;
  --md-color-text: #333333;
  --md-color-heading: #000000;
  --md-color-muted: #777777;
  --md-color-link: #4183c4;
  --md-color-border: #cccccc;
  --md-color-border-light: #eaeaea;
  --md-color-surface: #f8f8f8;
  --md-color-table-border: #bfbfbf;
  --md-color-surface-alt: #f0f0f0;
  --md-color-bg: #ffffff;
  --md-color-quote-bar: #dddddd;

  color: var(--md-color-text);
  font-family: var(--md-font-serif);
  font-size: var(--md-base-font-size);
  line-height: var(--md-line-height);
}

html[data-theme="dark"] :is(.markdown-body, #markdown-content) {
  --md-color-text: #f0f0f0;
  --md-color-heading: #ffffff;
  --md-color-muted: #b4b4b4;
  --md-color-link: #6cb6ff;
  --md-color-border: #3c3c3c;
  --md-color-border-light: #3a3a3a;
  --md-color-surface: #252526;
  --md-color-table-border: #444444;
  --md-color-surface-alt: #2d2d30;
  --md-color-bg: #1e1e1e;
  --md-color-quote-bar: #4a4a4a;
}

/* High-contrast Rouge syntax palette, based on GitHub's light and dark
   code colors. These tokens intentionally follow markdown.css so they
   override the theme's light-only Pygments stylesheet in dark mode. */
:is(.markdown-body, #markdown-content) {
  --code-text: #24292f;
  --code-comment: #6e7781;
  --code-keyword: #cf222e;
  --code-string: #0a3069;
  --code-number: #0550ae;
  --code-function: #8250df;
  --code-class: #953800;
  --code-variable: #116329;
  --code-decorator: #8250df;
  --code-error: #cf222e;
  --code-error-bg: #ffebe9;
}

html[data-theme="dark"] :is(.markdown-body, #markdown-content) {
  --code-text: #e6edf3;
  --code-comment: #8b949e;
  --code-keyword: #ff7b72;
  --code-string: #a5d6ff;
  --code-number: #79c0ff;
  --code-function: #d2a8ff;
  --code-class: #ffa657;
  --code-variable: #7ee787;
  --code-decorator: #d2a8ff;
  --code-error: #ff7b72;
  --code-error-bg: #490202;
}

:is(.markdown-body, #markdown-content) a {
  color: var(--md-color-link);
  text-decoration: none;
}

:is(.markdown-body, #markdown-content) a.absent {
  color: #cc0000;
}

html[data-theme="dark"] :is(.markdown-body, #markdown-content) a.absent {
  color: #f78166;
}

:is(.markdown-body, #markdown-content) h1,
:is(.markdown-body, #markdown-content) h2,
:is(.markdown-body, #markdown-content) h3,
:is(.markdown-body, #markdown-content) h4,
:is(.markdown-body, #markdown-content) h6 {
  position: relative;
  margin: 0 0 0.75em;
  padding: 0;
  color: var(--md-color-heading);
  font-family: var(--md-font-serif);
  font-weight: 700;
  line-height: 1.25;
  -webkit-font-smoothing: antialiased;
}

:is(.markdown-body, #markdown-content) h1 {
  padding-bottom: 0.2275em;
  margin-bottom: 0.7em !important;
  border-bottom: 1px solid var(--md-color-border);
  font-size: 2em;
}

:is(.markdown-body, #markdown-content) h2 {
  margin-top: 1.2em;
  padding-bottom: 0.3em;
  margin-bottom: 0.65em !important;
  border-bottom: 1px solid var(--md-color-border);
  font-size: 1.5em;
}

:is(.markdown-body, #markdown-content) h3 {
  margin-top: 1.2em;
  padding-bottom: 0.28em;
  margin-bottom: 0.6em !important;
  border-bottom: 1px solid var(--md-color-border);
  font-size: 1.15em;
}

:is(.markdown-body, #markdown-content) h4 {
  margin-top: 1.2em;
  padding-bottom: 0.25em;
  margin-bottom: 0.55em !important;
  border-bottom: 1px solid var(--md-color-border);
  font-size: 1.05em;
}


:is(.markdown-body, #markdown-content) h6 {
  margin-top: 1em;
  margin-bottom: 0;
  font-size: 1em;
}

:is(.markdown-body, #markdown-content) h6 {
  color: var(--md-color-muted);
}

:is(.markdown-body, #markdown-content) p {
  text-align: left;
}

:is(.markdown-body, #markdown-content) li {
  margin-top: 0;
  margin-bottom: 0;
  text-align: justify;
}

:is(.markdown-body, #markdown-content) hr {
  height: 1px;
  margin: 0.4em 0;
  padding: 0;
  border: 0;
  border-top: 1px solid var(--md-color-border);
}

:is(.markdown-body, #markdown-content) dl {
  padding: 0;
}

:is(.markdown-body, #markdown-content) dl dt {
  margin: 0.4em 0;
  padding: 0;
  font-size: 1em;
  font-style: italic;
  font-weight: 700;
}

:is(.markdown-body, #markdown-content) dl dd {
  margin: 0 0 1.15em;
  padding: 0 1.15em;
}

:is(.markdown-body, #markdown-content) blockquote {
  padding: 0 1.15em;
  border-left: 4px solid var(--md-color-quote-bar);
  color: var(--md-color-muted);
}

:is(.markdown-body, #markdown-content) blockquote > :first-child {
  margin-top: 0;
}

:is(.markdown-body, #markdown-content) blockquote > :last-child {
  margin-bottom: 0;
}

:is(.markdown-body, #markdown-content) table {
  width: 100%;
  max-width: 100%;
  padding: 0;
  border-collapse: collapse;
  table-layout: auto;
  font: inherit;
}

:is(.markdown-body, #markdown-content) table tr {
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--md-color-table-border);
  background-color: var(--md-color-bg);
}

:is(.markdown-body, #markdown-content) table tr:nth-child(2n) {
  background-color: var(--md-color-surface);
}

:is(.markdown-body, #markdown-content) table th,
:is(.markdown-body, #markdown-content) table td {
  min-width: 0;
  margin: 0;
  padding: 0.45em 1em;
  border: 1px solid var(--md-color-table-border);
  text-align: left;
  overflow-wrap: break-word;
  word-break: normal;
  hyphens: auto;
}

:is(.markdown-body, #markdown-content) table th {
  background-color: var(--md-color-surface-alt);
  font-weight: 700;
}

:is(.markdown-body, #markdown-content) img {
  width: 90%;
  max-width: 400px;
  margin-top: 1.15em;
  margin-bottom: 1.15em;
}

:is(.markdown-body, #markdown-content) span.frame {
  display: block;
  clear: both;
  overflow: hidden;
}

:is(.markdown-body, #markdown-content) span.float-right {
  display: block;
  float: right;
  margin-left: 1em;
  overflow: hidden;
}

:is(.markdown-body, #markdown-content) pre,
:is(.markdown-body, #markdown-content) .highlight pre {
  max-width: 100%;
  padding: 0.5em 0.8em;
  border: 1px solid var(--md-color-border);
  border-radius: 3px;
  background-color: var(--md-color-surface);
  font-family: var(--md-font-mono);
  font-size: 0.8em;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  tab-size: 4;
}

:is(.markdown-body, #markdown-content) pre :is(code, tt) {
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  font-size: inherit;
  white-space: inherit;
  overflow-wrap: inherit;
}

/* Rouge/Pygments token classes. Grouping related tokens keeps Python code
   legible without assigning a different color to every minor token type. */
:is(.markdown-body, #markdown-content) .highlight,
:is(.markdown-body, #markdown-content) .highlight pre,
:is(.markdown-body, #markdown-content) .highlight code {
  color: var(--code-text);
}

:is(.markdown-body, #markdown-content) .highlight :is(.c, .cm, .cp, .c1) {
  color: var(--code-comment);
  font-style: italic;
}

:is(.markdown-body, #markdown-content) .highlight :is(.k, .kn, .kt, .ow) {
  color: var(--code-keyword);
  font-weight: 600;
}

:is(.markdown-body, #markdown-content) .highlight :is(.s, .sa, .dl, .s1, .s2, .se, .sh, .si) {
  color: var(--code-string);
}

:is(.markdown-body, #markdown-content) .highlight :is(.m, .mf, .mh, .mi, .mo) {
  color: var(--code-number);
}

:is(.markdown-body, #markdown-content) .highlight :is(.nf) {
  color: var(--code-function);
  font-weight: 600;
}

:is(.markdown-body, #markdown-content) .highlight :is(.nc, .ne) {
  color: var(--code-class);
  font-weight: 600;
}

:is(.markdown-body, #markdown-content) .highlight :is(.nb, .bp, .no, .vi) {
  color: var(--code-variable);
}

:is(.markdown-body, #markdown-content) .highlight :is(.na, .nd, .ni, .nl) {
  color: var(--code-decorator);
}

:is(.markdown-body, #markdown-content) .highlight :is(.err, .gt) {
  color: var(--code-error);
}

:is(.markdown-body, #markdown-content) .highlight .err {
  background-color: var(--code-error-bg);
}

/* Optional ChatGPT Codex-inspired code theme. Enable it per post with
   `code_theme: codex` in the Markdown front matter. */
.post.code-theme-codex #markdown-content {
  --code-text: #24292f;
  --code-comment: #6e7781;
  --code-keyword: #a40e4c;
  --code-string: #2f6f44;
  --code-number: #9a4d00;
  --code-function: #335cbb;
  --code-class: #8a5a00;
  --code-variable: #26734d;
  --code-decorator: #7047a3;
  --code-error: #cf222e;
  --code-error-bg: #ffebe9;
}

.post.code-theme-codex #markdown-content .highlight,
.post.code-theme-codex #markdown-content .highlight pre {
  border-color: #d9d9de;
  background-color: #f7f7f8;
  box-shadow: 0 1px 2px rgb(0 0 0 / 8%);
}

.post.code-theme-codex #markdown-content .highlight code {
  background-color: transparent;
}

html[data-theme="dark"] .post.code-theme-codex #markdown-content {
  --code-text: #f4f4f5;
  --code-comment: #9aa4af;
  --code-keyword: #ff7ab2;
  --code-string: #a8cc8c;
  --code-number: #d19a66;
  --code-function: #82aaff;
  --code-class: #ffc777;
  --code-variable: #c3e88d;
  --code-decorator: #c792ea;
  --code-error: #ff6b6b;
  --code-error-bg: #4b1113;
}

html[data-theme="dark"] .post.code-theme-codex #markdown-content .highlight,
html[data-theme="dark"] .post.code-theme-codex #markdown-content .highlight pre {
  border-color: #343434;
  background-color: #171717;
  box-shadow: 0 1px 2px rgb(0 0 0 / 25%);
}

/* About-only icon sizing: 30% smaller than the theme's 4rem/3.2rem defaults. */
.social .about-contact-icons {
  font-size: 2.8rem;
}

.social .about-contact-icons a img {
  width: 2.24rem;
  height: 2.24rem;
  margin-bottom: 0.7rem;
}

@media (max-width: 700px) {
  :is(.markdown-body, #markdown-content) table th,
  :is(.markdown-body, #markdown-content) table td {
    padding: 0.4em 0.5em;
  }

  :is(.markdown-body, #markdown-content) pre,
  :is(.markdown-body, #markdown-content) .highlight pre {
    padding: 0.5em 0.6em;
  }

  :is(.markdown-body, #markdown-content) img {
    width: 100%;
  }
}

@media (max-width: 420px) {
  :is(.markdown-body, #markdown-content) {
    --md-base-font-size: 12pt;
  }

  :is(.markdown-body, #markdown-content) table th,
  :is(.markdown-body, #markdown-content) table td {
    padding: 0.35em 0.4em;
  }
}
