/* Fonts (self-hosted, no third-party requests) */
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/static/fonts/inter-400.woff2") format("woff2");
}
@font-face {
  font-family: "Inter";
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url("/static/fonts/inter-italic-400.woff2") format("woff2");
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("/static/fonts/inter-600.woff2") format("woff2");
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("/static/fonts/inter-700.woff2") format("woff2");
}
@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/static/fonts/jbmono-400.woff2") format("woff2");
}
@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("/static/fonts/jbmono-700.woff2") format("woff2");
}

:root {
  --bg: #f7f8fa;
  --fg: #15181c;
  --muted: #5b6472;
  --border: #dee3e8;
  --accent: #1f6b4f;
  --code-bg: #eef1ee;
  --max-width: 980px;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #10141a;
    --fg: #e7ebee;
    --muted: #8993a1;
    --border: #262c36;
    --accent: #6fd7a3;
    --code-bg: #161c22;
  }
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  height: 100%;
}

@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
}

body {
  margin: 0;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.65;
}

a {
  color: var(--accent);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.wrap {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 20px;
}

/* Header */
header.site {
  border-bottom: 1px solid var(--border);
}

header.site .wrap {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding-top: 28px;
  padding-bottom: 28px;
}

.brand-group {
  display: flex;
  align-items: baseline;
  gap: 12px;
}

header.site a.brand {
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--fg);
  text-decoration: none;
}

header.site .prompt {
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--muted);
}

@media (max-width: 480px) {
  header.site .prompt {
    display: none;
  }
}

nav.site-nav a {
  font-family: var(--mono);
  color: var(--muted);
  text-decoration: none;
  margin-left: 20px;
  font-size: 0.88rem;
}

nav.site-nav a:hover {
  color: var(--accent);
}

/* Main */
main {
  flex: 1 0 auto;
}

/* Specificity note: .wrap's own padding (0,1,0) would otherwise beat a
   bare `main { padding }` (0,0,1) regardless of source order, silently
   dropping this. Scoping to main.wrap (0,1,1) wins correctly. */
main.wrap {
  padding: 1% 20px 96px;
}

h1, h2, h3, h4 {
  font-weight: 700;
  line-height: 1.3;
  scroll-margin-top: 20px;
}

h1 { font-size: 2rem; margin: 0 0 0.5em; }
h2 { font-size: 1.4rem; margin: 1.8em 0 0.6em; }
h3 { font-size: 1.15rem; margin: 1.6em 0 0.5em; }

p { margin: 0 0 1.1em; }

.lede {
  font-family: var(--mono);
  font-size: 0.92rem;
  color: var(--muted);
  margin: 0 0 2em;
}

.meta {
  font-family: var(--mono);
  color: var(--muted);
  font-size: 0.85rem;
  margin-bottom: 2em;
}

code, pre, kbd, samp {
  font-family: var(--mono);
}

code {
  background: var(--code-bg);
  padding: 0.15em 0.4em;
  border-radius: 4px;
  font-size: 0.88em;
}

pre {
  background: var(--code-bg);
  padding: 16px 18px;
  border-radius: 8px;
  overflow-x: auto;
  font-size: 0.88em;
  line-height: 1.55;
}

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

blockquote {
  margin: 1.5em 0;
  padding-left: 1em;
  border-left: 3px solid var(--border);
  color: var(--muted);
}

hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2.5em 0;
}

ul, ol {
  padding-left: 1.4em;
}

/* Post layout: article + side table of contents */
.post-layout {
  display: flex;
  align-items: flex-start;
  gap: 48px;
}

.post-layout > article {
  flex: 1 1 0%;
  min-width: 0;
  max-width: 700px;
}

/* Table of contents, styled as a small file tree */
nav.toc {
  font-family: var(--mono);
  font-size: 0.85rem;
}

nav.toc p.toc-title {
  margin: 0 0 0.7em;
  color: var(--muted);
}

nav.toc.side {
  flex: 0 0 220px;
  position: sticky;
  top: 24px;
  max-height: calc(100vh - 48px);
  overflow-y: auto;
}

@media (max-width: 860px) {
  .post-layout {
    flex-direction: column;
  }

  .post-layout > article {
    max-width: none;
  }

  nav.toc.side {
    position: static;
    width: 100%;
    flex-basis: auto;
    max-height: none;
    order: -1;
    border-bottom: 1px solid var(--border);
    padding-bottom: 1.5em;
    margin-bottom: 1.5em;
  }
}

nav.toc ul {
  list-style: none;
  padding-left: 0;
  margin: 0;
}

nav.toc li {
  margin: 0.3em 0;
}

/* Keep the nested lists for document structure, but let the generated
   `tree` prefixes own the visual indentation and connector columns. */
nav.toc li > ul {
  margin: 0;
  padding: 0;
}

nav.toc a {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  text-decoration: none;
  color: var(--fg);
}

nav.toc .toc-branch {
  color: var(--muted);
  white-space: pre;
}

nav.toc a:hover {
  color: var(--accent);
}

/* Post list */
.post-list {
  list-style: none;
  padding: 0;
  margin: 0;
  max-width: 700px;
}

.post-list li {
  display: grid;
  grid-template-columns: 110px 1fr;
  column-gap: 20px;
  padding: 18px 0;
  border-bottom: 1px solid var(--border);
}

.post-list li:first-child {
  padding-top: 0;
}

.post-list .date {
  grid-column: 1;
  grid-row: 1;
  font-family: var(--mono);
  color: var(--muted);
  font-size: 0.85rem;
  padding-top: 0.15em;
}

.post-list a.title {
  grid-column: 2;
  grid-row: 1;
  font-weight: 600;
  font-size: 1.1rem;
  text-decoration: none;
  color: var(--fg);
}

.post-list a.title:hover {
  color: var(--accent);
}

.post-list .desc {
  grid-column: 2;
  grid-row: 2;
  color: var(--muted);
  margin: 6px 0 0;
}

@media (max-width: 480px) {
  .post-list li {
    grid-template-columns: 1fr;
  }

  .post-list .date {
    grid-column: 1;
    grid-row: 1;
    margin-bottom: 4px;
  }

  .post-list a.title {
    grid-column: 1;
    grid-row: 2;
  }

  .post-list .desc {
    grid-column: 1;
    grid-row: 3;
  }
}
