/* the site is light-mode only: diagrams and screenshots are authored once,
   against this background, so the page has to meet them there */
:root {
  --bg: #fbfaf8;
  --fg: #222222;
  --muted: #777777;

  /* surfaces and rules are the grey diluted into the background, so the whole
     palette moves when --muted does */
  --code-bg: color-mix(in srgb, var(--muted) 10%, var(--bg));
  --border: color-mix(in srgb, var(--muted) 22%, var(--bg));
}

body {
  font-family: system-ui, sans-serif;
  line-height: 1.4;
  max-width: 640px;
  margin: 4rem auto;
  padding: 0 1rem;
  color: var(--fg);
  background: var(--bg);
}

header {
  margin-bottom: 2rem;
  font-weight: 600;
}

header a {
  color: inherit;
  text-decoration: none;
}

header a:hover {
  text-decoration: underline;
}

/* size and space both descend with depth, so nesting reads correctly */
h1 {
  font-size: 1.7rem;
  margin-bottom: 0.5rem;
}

h2 {
  font-size: 1.3rem;
  margin-top: 2.5rem;
  margin-bottom: 0.75rem;
}

h3 {
  font-size: 1.05rem;
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
}

p,
ul,
ol {
  margin: 1rem 0;
}

.toc {
  margin: 1.5rem 0 2.5rem;
  font-size: 0.95rem;
}

.toc ol {
  margin: 0.25rem 0;
  padding-left: 1.5rem;
}

.toc li + li {
  margin-top: 0.25rem;
}

/* headings aren't flush against the viewport edge when jumped to */
h2[id],
h3[id] {
  scroll-margin-top: 1rem;
}

/* space between sibling bullets, but not inside a single wrapped one */
li + li {
  margin-top: 0.5rem;
}

/* a nested list sits closer to its parent than to the next bullet */
li > ul,
li > ol {
  margin: 0.5rem 0;
}

.dates {
  color: var(--muted);
  font-size: 0.9rem;
  margin-top: 0;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-size: 0.95rem;
  /* fixed layout ignores cell content, so every table shares these widths */
  table-layout: fixed;
}

th:nth-child(1) { width: 22%; }
th:nth-child(2) { width: 25%; }
th:nth-child(3) { width: 53%; }

/* border-collapse merges each shared edge into a single rule, so asking
   every cell for all four borders draws the grid and closes the outer box */
th,
td {
  text-align: left;
  vertical-align: top;
  padding: 0.5rem 0.75rem;
  border: 1.5px solid var(--border);
  overflow-wrap: break-word;
}

th {
  font-weight: 600;
}

/* the header detaches from the data by weight, not by a second colour */
thead th {
  border-bottom-width: 2.5px;
}

figure {
  margin: 1.5rem 0;
}

/* tables and figures share one caption treatment: below, centered, and
   back at body size because captions read as prose */
caption,
figcaption {
  caption-side: bottom;
  text-align: center;
  padding-top: 0.6rem;
  font-size: 1rem;
}

/* a line lifted out of the prose it interrupts -- the markdown has to leave
   blank lines inside the div, or markdown-it passes the content through raw */
.center {
  text-align: center;
}

/* the intrinsic width/height attributes reserve the row's height before the
   file loads, so the text below doesn't jump */
figure img,
figure video {
  display: block;
  /* the border has to sit inside the 100%, or the figure outdents the column */
  box-sizing: border-box;
  width: 100%;
  height: auto;
  border: 1px solid var(--border);
  border-radius: 6px;
}

/* video, unlike an image, shows a placeholder box until the poster arrives */
figure video {
  background: var(--code-bg);
}

/* two stacks sit side by side until the column gets too narrow for both */
.stacks {
  display: flex;
  gap: 1rem;
}

.stack {
  flex: 1;
  min-width: 0;
}

.stack-title {
  margin: 0 0 0.5rem;
  font-weight: 600;
  font-size: 0.95rem;
}

.stack-layers {
  list-style: none;
  margin: 0;
  padding: 0;
}

.stack-layers li {
  display: flex;
  gap: 0.6rem;
  padding: 0.6rem 0.75rem;
  border: 1.5px solid var(--border);
  background: var(--code-bg);
  font-size: 0.95rem;
}

/* layers pull up onto each other so a shared edge is drawn once, not twice --
   this also overrides the li + li spacing that separates prose bullets */
.stack-layers li + li {
  margin-top: -1.5px;
}

/* only the outer corners round, so the three boxes read as one stack */
.stack-layers li:first-child {
  border-radius: 6px 6px 0 0;
}

.stack-layers li:last-child {
  border-radius: 0 0 6px 6px;
}

/* the level number is a fixed-width gutter, so the labels line up */
.stack-level {
  flex: 0 0 auto;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

pre {
  overflow-x: auto;
  padding: 1rem;
  background: var(--code-bg);
}

.entries {
  list-style: none;
  padding: 0;
  margin: 0;
}

.entries li + li {
  margin-top: 0.75rem;
}

/* the intro and the entry cards share one box treatment */
.intro,
.entry {
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.intro {
  margin: 0 0 1.5rem;
}

.entry {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  color: inherit;
  text-decoration: none;
}

.entry:hover {
  border-color: var(--muted);
}

.entry-thumb {
  flex: 0 0 88px;
  width: 88px;
  height: 88px;
  object-fit: cover;
  border-radius: 6px;
  background: var(--code-bg);
}

.entry-body {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 0;
}

.entry-title {
  font-weight: 600;
}

.entry-dates {
  color: var(--muted);
  font-size: 0.8rem;
}

.entry-snippet {
  color: var(--muted);
  font-size: 0.9rem;
}

@media (max-width: 480px) {
  .stacks {
    flex-direction: column;
  }

  .entry {
    flex-direction: column;
  }

  .entry-thumb {
    width: 100%;
    height: 140px;
  }
}
