/* self-hosted fonts (static/fonts) — no CDN requests */
@font-face {
  font-family: "Source Sans 3";
  font-style: normal;
  font-weight: 200 900;
  font-display: swap;
  src: url("/fonts/source-sans-3-latin-wght-normal.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: "Source Sans 3";
  font-style: normal;
  font-weight: 200 900;
  font-display: swap;
  src: url("/fonts/source-sans-3-latin-ext-wght-normal.woff2") format("woff2");
  unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EA0-1EF9,U+1F00-1FFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF;
}

@font-face {
  font-family: "Source Sans 3";
  font-style: italic;
  font-weight: 200 900;
  font-display: swap;
  src: url("/fonts/source-sans-3-latin-wght-italic.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: "Source Sans 3";
  font-style: italic;
  font-weight: 200 900;
  font-display: swap;
  src: url("/fonts/source-sans-3-latin-ext-wght-italic.woff2") format("woff2");
  unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EA0-1EF9,U+1F00-1FFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF;
}

@font-face {
  font-family: "Bitter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("/fonts/bitter-latin-wght-normal.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: "Bitter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("/fonts/bitter-latin-ext-wght-normal.woff2") format("woff2");
  unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EA0-1EF9,U+1F00-1FFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF;
}

@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/fonts/jetbrains-mono-latin-400-normal.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;
  font-display: swap;
  src: url("/fonts/jetbrains-mono-latin-ext-400-normal.woff2") format("woff2");
  unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EA0-1EF9,U+1F00-1FFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF;
}

@font-face {
  font-family: "JetBrains Mono";
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url("/fonts/jetbrains-mono-latin-400-italic.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: italic;
  font-weight: 400;
  font-display: swap;
  src: url("/fonts/jetbrains-mono-latin-ext-400-italic.woff2") format("woff2");
  unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EA0-1EF9,U+1F00-1FFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF;
}

@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("/fonts/jetbrains-mono-latin-700-normal.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: 700;
  font-display: swap;
  src: url("/fonts/jetbrains-mono-latin-ext-700-normal.woff2") format("woff2");
  unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EA0-1EF9,U+1F00-1FFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF;
}

:root {
  color-scheme: light dark;

  /* single spacing scale (root 16px): xs 8px, sm 16px, md 28px, lg 36px, xl 48px */
  --space-xs: 0.5rem;
  --space-sm: 1rem;
  --space-md: 1.75rem;
  --space-lg: 2.25rem;
  --space-xl: 3rem;

  --measure: 85ch;

  --color-bg: #fff;
  --color-text: #474747;
  --color-link: #2440c9;
  --color-link-visited: #2440c9;
  --color-link-hover: #16277a;
  --color-code-bg: #f2f3f3;
  --color-code-inline-bg: #e5e7e7;
  --color-muted: #7e7e7e;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;

    --color-bg: #1d1e1e;
    --color-text: #e8e8e6;
    --color-link: #8aa8ff;
    --color-link-visited: #8aa8ff;
    --color-link-hover: #b9cbff;
    --color-code-bg: #262727;
    --color-code-inline-bg: #2b2c2c;
    --color-muted: #a6a6a3;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;

  --color-bg: #1d1e1e;
  --color-text: #e8e8e6;
  --color-link: #8aa8ff;
  --color-link-visited: #8aa8ff;
  --color-link-hover: #b9cbff;
  --color-code-bg: #262727;
  --color-code-inline-bg: #2b2c2c;
  --color-muted: #a6a6a3;
}

:root[data-theme="light"] {
  color-scheme: light;
}

html {
  background-color: var(--color-bg);
}

/* minimal reset: one source of truth, no UA ghost margins */
*,
*::before,
*::after {
  box-sizing: border-box;
}

body,
h1,
h2,
h3,
p,
ul,
ol,
figure {
  margin: 0;
}

ul,
ol {
  padding: 0;
}

body {
  background: var(--color-bg);
  color: var(--color-text);
  font-family: "Source Sans 3", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 18px;
  line-height: 1.6;
  text-align: justify;
  hyphens: auto;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  padding: var(--space-xl) var(--space-md) var(--space-lg);
}

a {
  color: var(--color-link);
  text-decoration: underline;
}

a:visited {
  color: var(--color-link-visited);
}

a:hover,
a:focus-visible {
  color: var(--color-link-hover);
}

img,
video {
  max-width: 100%;
}

pre {
  background: var(--color-code-bg);
  color: var(--color-text);
  padding: var(--space-sm);
  overflow-x: auto;
}

code {
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.8125em;
  background: var(--color-code-inline-bg);
  padding: 0.15em 0.3em;
  border-radius: 4px;
}

pre code {
  background: transparent;
  padding: 0;
}

/* skip-link block */
.skip-link {
  position: absolute;
  left: -9999px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.skip-link:focus {
  left: var(--space-sm);
  top: var(--space-sm);
  width: auto;
  height: auto;
  padding: 0.5em 1em;
  background: var(--color-bg);
  color: var(--color-text);
  z-index: 100;
}

/* site-header block (used on every page) */
.site-header {
  width: 100%;
  max-width: var(--measure);
  margin-inline: auto;
  margin-bottom: var(--space-md);
}

.site-header__title {
  font-family: "Bitter", Georgia, "Times New Roman", serif;
  font-size: 1.2em;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.site-header__back {
  font-size: 0.9em;
}

.site-header__nav {
  margin-top: var(--space-sm);
  text-transform: uppercase;
}

/* compact header: post view — plain title with back link below */
.site-header--compact {
  margin-bottom: var(--space-md);
}

.site-header--compact .site-header__nav {
  margin-top: var(--space-xs);
}

/* page main block */
.page__main {
  width: 100%;
  max-width: var(--measure);
  margin-inline: auto;
  flex: 1;
}

/* post block */
.post__header {
  margin-bottom: var(--space-md);
}

.post__title {
  font-family: "Bitter", Georgia, "Times New Roman", serif;
  font-size: 1.4em;
  font-weight: 650;
  letter-spacing: -0.015em;
  line-height: 1.3;
}

.post__meta {
  font-size: 0.85em;
  color: var(--color-muted);
  margin-top: var(--space-xs);
}

.post__meta-separator {
  margin-inline: 0.35em;
}

.post__content > * + * {
  margin-top: 0;
}

.post__content p {
  margin-bottom: var(--space-lg);
}

.post__content p:last-child {
  margin-bottom: 0;
}

.post__content h2,
.post__content h3 {
  font-family: "Bitter", Georgia, "Times New Roman", serif;
  font-weight: 650;
  letter-spacing: -0.01em;
  line-height: 1.35;
  color: var(--color-text);
  margin-top: var(--space-xl);
  margin-bottom: var(--space-sm);
}

.post__content h2 {
  font-size: 1.25em;
}

.post__content h3 {
  font-size: 1.1em;
}

.post__content pre {
  margin-bottom: var(--space-lg);
}

/* tables (GFM markdown; no wrapper element, so horizontal scroll
   comes from block display on the table itself) */
.post__content table {
  display: block;
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  border-collapse: collapse;
  font-size: 0.9em;
  text-align: left;
  margin-bottom: var(--space-lg);
}

.post__content th,
.post__content td {
  padding: var(--space-xs) var(--space-sm);
  vertical-align: top;
  border-bottom: 1px solid var(--color-code-inline-bg);
}

.post__content th {
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.85em;
  white-space: nowrap;
  border-bottom: 2px solid var(--color-muted);
}

.post__content tr:last-child td {
  border-bottom: 0;
}

/* post abstract block (opt-in via [extra] abstract) */
.post__abstract {
  font-size: 0.95em;
  font-style: italic;
  margin-top: var(--space-sm);
  padding-inline: var(--space-sm);
}

/* post TOC (opt-in via [extra] toc = true; rendered from page.toc) */
.post__toc {
  border: 1px solid var(--color-muted);
  padding: var(--space-sm);
  margin-bottom: var(--space-md);
}

.post__toc-title {
  font-size: 0.85em;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-muted);
  margin-bottom: var(--space-xs);
}

.post__toc-list,
.post__toc-list ul {
  list-style: none;
}

.post__toc-list ul {
  padding-left: var(--space-sm);
}

.post__toc-list li {
  margin-top: var(--space-xs);
}

/* numbered sections (opt-in via [extra] numbered_sections = true; h2 only) */
.post--numbered .post__content {
  counter-reset: section;
}

.post--numbered .post__content h2 {
  counter-increment: section;
}

.post--numbered .post__content h2::before {
  content: counter(section) ". ";
}

.post--numbered .post__toc-list {
  counter-reset: section;
}

.post--numbered .post__toc-list > li {
  counter-increment: section;
}

.post--numbered .post__toc-list > li::before {
  content: counter(section) ". ";
  margin-right: 0.25em;
}

/* footnotes (Zola renders [^n] to .footnote-reference/.footnote-definition;
   the sup floats into a fixed gutter so each note hangs cleanly) */
.post__content .footnote-reference {
  font-size: 0.75em;
  line-height: 0;
}

.post__content .footnote-definition {
  font-size: 0.85em;
  text-align: left;
}

.post__content .footnote-definition:first-of-type {
  border-top: 1px solid var(--color-muted);
  padding-top: var(--space-sm);
  margin-top: var(--space-lg);
}

.post__content .footnote-definition:first-of-type::before {
  content: "Notes";
  display: block;
  font-size: 0.85em;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-muted);
  margin-bottom: var(--space-xs);
}

.post__content .footnote-definition-label {
  float: left;
  width: 2em;
  font-weight: 700;
  color: var(--color-link);
}

.post__content .footnote-definition p {
  margin-bottom: var(--space-xs);
  margin-left: 2em;
  overflow: hidden;
}

/* writeups block (homepage list) */
.writeups__title {
  font-family: "Bitter", Georgia, "Times New Roman", serif;
  font-size: 1.2em;
  font-weight: 650;
  letter-spacing: -0.01em;
  margin-bottom: var(--space-sm);
}

.writeups__list {
  list-style: none;
}

.writeups__item + .writeups__item {
  margin-top: var(--space-xs);
}

.writeups__date {
  margin-left: var(--space-xs);
}

/* social block (homepage links) */
.social__list {
  list-style: none;
  display: flex;
  gap: var(--space-sm);
  margin-top: var(--space-sm);
}

/* site-footer block (every page) */
.site-footer {
  width: 100%;
  max-width: var(--measure);
  margin-inline: auto;
  margin-top: var(--space-xl);
}

.site-footer__text {
  margin: 0;
}

.site-footer__credit {
  margin: var(--space-xs) 0 0;
  font-size: 0.85em;
  color: var(--color-muted);
}

.theme-toggle[hidden] {
  display: none;
}

/* collapse empty wrappers while the toggle stays hidden (no-JS) */
.social__list > .social__item:has(> .theme-toggle[hidden]) {
  display: none;
}

.site-header__nav:has(> .theme-toggle[hidden]) > .post__meta-separator {
  display: none;
}
.theme-toggle {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  text-transform: uppercase;
  color: var(--color-link);
  text-decoration: underline;
  cursor: pointer;
}

.theme-toggle:visited {
  color: var(--color-link-visited);
}

.theme-toggle:hover,
.theme-toggle:focus-visible {
  color: var(--color-link-hover);
}

/* utility: visually hidden */
.u-visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media only screen and (max-width: 600px) {
  body {
    padding: var(--space-md) var(--space-sm) var(--space-md);
  }

  .site-header {
    margin-bottom: var(--space-md);
  }
}
