/* 0x2A — one stylesheet, no build step. Colours follow the OS light/dark setting. */

@font-face {
  font-family: "JetBrains Mono";
  src: url("/fonts/jetbrains-mono-normal.woff2") format("woff2");
  font-weight: 100 800;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url("/fonts/jetbrains-mono-italic.woff2") format("woff2");
  font-weight: 100 800;
  font-style: italic;
  font-display: swap;
}

:root {
  color-scheme: light dark; /* native scrollbars/controls follow the theme */
  --bg: #fdfdfc;
  --fg: #1a1a1a;
  --muted: #6b6b6b;
  --border: #e4e4e2;
  --code-bg: #f5f5f3;
  --link: #3548cf;
  --visited: #8f0075;
  --target: #dae5ec;

  /* syntax */
  --sx-k: #0b5cad; /* keyword / type */
  --sx-o: #c2185b; /* operator */
  --sx-m: #7c3aed; /* number */
  --sx-s: #8a5a00; /* string */
  --sx-f: #2e7d32; /* function / name */
  --sx-c: #8a8a8a; /* comment */
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0c0c0c;
    --fg: #e6e6e6;
    --muted: #8c8c8c;
    --border: #262626;
    --code-bg: #141414;
    --link: #a855f7;
    --visited: #d8b4fe;
    --target: #2f3849;

    /* monokai, like the old theme */
    --sx-k: #66d9ef;
    --sx-o: #f92672;
    --sx-m: #ae81ff;
    --sx-s: #e6db74;
    --sx-f: #a6e22e;
    --sx-c: #75715e;
  }
}

/* ---------- base ---------- */

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

body {
  background: var(--bg);
  color: var(--fg);
  font-family: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 16px;
  line-height: 1.7;
  margin: 0;
  min-height: 100%;
  overflow-wrap: break-word;
  font-variant-ligatures: none; /* keeps "C++", "->", "!=" as typed */
  -webkit-font-smoothing: antialiased;
}

.w { max-width: 680px; margin: 0 auto; padding: 4rem 1.5rem 6rem; }
/* homepage lines are short: shrink the column to its content so the block sits truly centered */
.home { width: fit-content; }

/* ---------- type ---------- */

h1, h2, h3, h4, h5, h6 { line-height: 1.3; letter-spacing: -0.01em; }
h1 { font-size: 1.6rem; font-weight: 700; margin: 0 0 2rem; }
h2 { font-size: 1.2rem; font-weight: 700; margin: 2.75rem 0 0.75rem; }
h3 { font-size: 1.05rem; font-weight: 600; margin: 2.25rem 0 0.5rem; }
h4, h5, h6 { font-size: 1rem; font-weight: 600; margin: 1.75rem 0 0.5rem; }

/* markdown-style markers on article headings */
article h2::before { content: "## "; color: var(--muted); font-weight: 400; }
article h3::before { content: "### "; color: var(--muted); font-weight: 400; }

p { margin: 0 0 1.25rem; }
strong { font-weight: 700; }

ul, ol { padding-left: 1.5rem; margin: 0 0 1.25rem; }
li { margin: 0.35rem 0; }
li > p { margin: 0 0 0.5rem; }
li::marker { color: var(--muted); }

a { color: var(--link); text-decoration: none; }
a:visited { color: var(--visited); }
a:hover { text-decoration: underline; text-underline-offset: 0.2em; text-decoration-thickness: 1px; }

*:target { background: var(--target); color: var(--fg); }

::selection { background: var(--link); color: var(--bg); }

hr { text-align: center; border: 0; margin: 2.5rem 0; color: var(--muted); }
hr::before { content: "/////"; }
hr::after { content: attr(data-content) "/////"; }

img { max-width: 100%; display: block; margin: 0 auto; border-radius: 6px; }
figure { margin: 1.5rem 0; }
figcaption { text-align: center; color: var(--muted); font-size: 0.875rem; margin-top: 0.5rem; }

blockquote { margin: 1.5rem 0; padding: 0.25rem 0 0.25rem 1.25rem; border-left: 2px solid var(--border); color: var(--muted); }
blockquote p { margin: 0.5rem 0; }

table { width: 100%; border-collapse: collapse; margin: 1.5rem 0; font-size: 0.9rem; }
th, td { border: 1px solid var(--border); padding: 0.4rem 0.6rem; text-align: left; }
th { background: var(--code-bg); }

details { border: 1px solid var(--border); border-radius: 6px; padding: 0.75rem 1rem; margin: 1.5rem 0; }
details summary { cursor: pointer; }
details[open] summary { border-bottom: 1px solid var(--border); margin-bottom: 0.75em; padding-bottom: 0.75em; }

/* ---------- code ---------- */

code, pre { font-family: inherit; }

:not(pre) > code {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.05em 0.35em;
  font-size: 0.875em;
}

pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  margin: 0 0 1.5rem;
  padding: 1rem 1.1rem;
  overflow-x: auto;
  font-size: 0.85rem;
  line-height: 1.6;
  tab-size: 4;
}

/* header bar added by /code.js: language label */
.code { margin: 0 0 1.5rem; }
.code > pre { margin: 0; border-top: 0; border-top-left-radius: 0; border-top-right-radius: 0; }
.code-head {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-bottom: 1px dashed var(--border);
  border-radius: 6px 6px 0 0;
  padding: 0.35rem 1.1rem;
  font-size: 0.75rem;
  color: var(--muted);
}

/* syntax tokens */
.k { color: var(--sx-k); }
.o { color: var(--sx-o); }
.m { color: var(--sx-m); }
.s { color: var(--sx-s); }
.f { color: var(--sx-f); }
.c { color: var(--sx-c); font-style: italic; }

/* ---------- layout bits ---------- */

/* homepage post list: muted year column */
.posts span { color: var(--muted); font-variant-numeric: tabular-nums; margin-right: 0.5rem; }

/* post header: "take me back!" ... year */
.post-meta { display: flex; justify-content: space-between; align-items: center; margin-bottom: 2.5rem; color: var(--muted); }
.post-meta p { margin: 0; }
