/* BuildMesh blog: lab notebook. Cool paper, blue ink, yellow highlighter,
   a faint grid at the top of the page. No JavaScript. */

@font-face {
  font-family: "Source Serif 4";
  src: url("/fonts/source-serif-4-latin-standard-normal.woff2") format("woff2-variations");
  font-weight: 200 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Source Serif 4";
  src: url("/fonts/source-serif-4-latin-standard-italic.woff2") format("woff2-variations");
  font-weight: 200 900;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("/fonts/ibm-plex-mono-latin-400-normal.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("/fonts/ibm-plex-mono-latin-500-normal.woff2") format("woff2");
  font-weight: 500;
  font-display: swap;
}

:root {
  --bg: #f6f7f5;
  --surface: #eaecea;
  --text: #1b1e23;
  --muted: #5b626b;
  --rule: #d8dcd9;
  --accent: #2348a8;
  --accent-soft: rgba(35, 72, 168, 0.12);
  --grid: rgba(35, 72, 168, 0.075);
  --highlight: #ffe86b;
  --marker: #fff1a6;
  --marker-text: #463a00;

  --serif: "Source Serif 4", "Iowan Old Style", "Charter", Georgia, serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --measure: 40rem;
  --gutter: clamp(1rem, 4vw, 2rem);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161a;
    --surface: #1e2126;
    --text: #e3e6ea;
    --muted: #9aa2ad;
    --rule: #2b3037;
    --accent: #8eb0ff;
    --accent-soft: rgba(142, 176, 255, 0.16);
    --grid: rgba(142, 176, 255, 0.06);
    --highlight: rgba(255, 220, 80, 0.32);
    --marker: #4a4214;
    --marker-text: #f7eaa8;
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

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

body {
  position: relative;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--serif);
  font-size: clamp(1.0625rem, 0.98rem + 0.35vw, 1.1875rem);
  line-height: 1.65;
  font-optical-sizing: auto;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

body::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 30rem;
  z-index: -1;
  pointer-events: none;
  background-image: linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 24px 24px;
  background-position: center top;
  -webkit-mask-image: linear-gradient(to bottom, #000 35%, transparent);
  mask-image: linear-gradient(to bottom, #000 35%, transparent);
}

a {
  color: inherit;
  text-decoration-color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}
a:hover {
  color: var(--accent);
}
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 2px;
}

::selection {
  background: var(--highlight);
  color: inherit;
}

/* Highlighter stroke over the lower part of the text. */
.hl {
  color: inherit;
  background: linear-gradient(transparent 52%, var(--highlight) 52%, var(--highlight) 90%, transparent 90%);
  padding-inline: 0.08em;
  margin-inline: -0.08em;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}

/* ---------- Frame ---------- */

.site-header,
main,
.site-footer {
  max-width: calc(var(--measure) + 2 * var(--gutter));
  margin: 0 auto;
  padding-inline: var(--gutter);
}

.preview-bar {
  background: var(--marker);
  color: var(--marker-text);
  font: 500 0.75rem/1 var(--mono);
  text-align: center;
  padding: 0.6rem var(--gutter);
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-block: 1.75rem;
}

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font: 500 1rem/1 var(--mono);
  text-decoration: none;
  letter-spacing: -0.01em;
}
.wordmark .logo {
  width: 1.4rem;
  height: 1.4rem;
  color: var(--accent);
}
.wordmark-sub {
  color: var(--muted);
  margin-left: -0.5rem;
}

.site-header nav {
  display: flex;
  gap: 1.25rem;
  font: 0.85rem/1 var(--mono);
}
.site-header nav a {
  color: var(--muted);
  text-decoration: none;
}
.site-header nav a:hover {
  color: var(--accent);
}

main {
  padding-block: 1.5rem 4rem;
}

.site-footer {
  padding-block: 0 3rem;
  color: var(--muted);
  font: 0.8rem/1.6 var(--mono);
}
.site-footer > div {
  padding-top: 2rem;
  border-top: 1px solid var(--rule);
}
.site-footer p {
  margin: 0;
}

/* ---------- Shared bits ---------- */

.meta,
.eyebrow,
.section-label,
.post-item-meta {
  font-family: var(--mono);
  font-size: 0.78rem;
  font-weight: 400;
  color: var(--muted);
  letter-spacing: 0;
}

.eyebrow {
  margin: 0 0 1rem;
  color: var(--accent);
  font-weight: 500;
}

.badge {
  display: inline-block;
  padding: 0.15em 0.55em;
  border-radius: 999px;
  background: var(--marker);
  color: var(--marker-text);
  font: 500 0.7rem/1.4 var(--mono);
}

h1,
h2,
h3 {
  font-family: var(--serif);
  line-height: 1.2;
  letter-spacing: -0.015em;
  text-wrap: balance;
}

/* ---------- Home ---------- */

.intro {
  padding-block: 2.5rem 3rem;
}
.intro h1 {
  margin: 0 0 1rem;
  font-size: clamp(2rem, 1.4rem + 2.6vw, 2.9rem);
  font-weight: 600;
  line-height: 1.1;
}
/* The home intro describes the site, so it's set lighter than post titles:
   regular weight, no meta line above it. */
.home-intro {
  padding-block: 2rem 2.75rem;
}
.home-intro h1 {
  font-size: clamp(1.75rem, 1.35rem + 1.7vw, 2.3rem);
  font-weight: 400;
  line-height: 1.15;
  letter-spacing: -0.01em;
}
.home-intro .lede {
  font-size: 1em;
}

.lede {
  margin: 0;
  max-width: 34rem;
  color: var(--muted);
  font-size: 1.1em;
}
.not-found {
  padding-block: 4rem 6rem;
}

.section-label {
  margin: 0 0 0.5rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--rule);
}

.post-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.post-item {
  display: grid;
  grid-template-columns: 7.5rem 1fr;
  gap: 1.5rem;
  padding-block: 1.75rem;
  border-bottom: 1px solid var(--rule);
}
.post-item:last-child {
  border-bottom: 0;
}
.post-item-meta {
  padding-top: 0.45rem;
}
.post-item h2 {
  margin: 0 0 0.4rem;
  font-size: 1.45rem;
  font-weight: 600;
}
.post-item h2 a {
  text-decoration: none;
}
.post-item p {
  margin: 0 0 0.6rem;
  color: var(--muted);
}
.empty {
  padding-block: 2rem;
  color: var(--muted);
  font-style: italic;
}

@media (max-width: 36rem) {
  .post-item {
    grid-template-columns: 1fr;
    gap: 0.35rem;
  }
  .post-item-meta {
    padding-top: 0;
  }
}

/* ---------- Post ---------- */

.post-header {
  padding-block: 2rem 1rem;
}
.post-header h1 {
  margin: 0.75rem 0 0;
  font-size: clamp(2rem, 1.35rem + 2.8vw, 3rem);
  font-weight: 650;
  line-height: 1.08;
}
.post-header .meta {
  margin: 0;
}

.prose {
  overflow-wrap: break-word;
}
.prose > * + * {
  margin-top: 1.25em;
}
.prose p {
  margin-block: 0;
}
.prose p + p {
  margin-top: 1.1em;
}
.prose > :first-child {
  margin-top: 1.5rem;
}

.prose h2 {
  margin: 2.4em 0 0.6em;
  font-size: 1.55em;
  font-weight: 620;
}
.prose h3 {
  margin: 2em 0 0.5em;
  font-size: 1.22em;
  font-weight: 620;
}
.prose .anchor {
  float: left;
  margin-left: -1.1em;
  width: 1.1em;
  color: var(--muted);
  text-decoration: none;
  font-weight: 400;
  opacity: 0;
}
.prose h2:hover .anchor,
.prose h3:hover .anchor,
.prose .anchor:focus-visible {
  opacity: 1;
}

.prose a {
  text-decoration-color: color-mix(in srgb, var(--accent) 70%, transparent);
}

.prose blockquote {
  margin-inline: 0;
  padding-left: 1.25em;
  border-left: 3px solid var(--accent);
  color: var(--muted);
  font-style: italic;
}

.prose ul,
.prose ol {
  padding-left: 1.4em;
}
.prose li + li {
  margin-top: 0.4em;
}
.prose li::marker {
  color: var(--muted);
}

.prose code {
  font-family: var(--mono);
  font-size: 0.84em;
  padding: 0.12em 0.35em;
  border-radius: 4px;
  background: var(--surface);
}
.prose pre {
  margin-inline: calc(-1 * min(var(--gutter), 1.25rem));
  padding: 1rem 1.25rem;
  overflow-x: auto;
  border-radius: 8px;
  background: var(--surface);
  line-height: 1.55;
}
.prose pre code {
  padding: 0;
  background: none;
  font-size: 0.8em;
}

.prose img {
  display: block;
  max-width: 100%;
  height: auto;
  border-radius: 6px;
}

.prose hr {
  margin-block: 2.5em;
  border: 0;
  text-align: center;
}
.prose hr::after {
  content: "· · ·";
  color: var(--muted);
  letter-spacing: 0.5em;
}

.prose table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9em;
}
.prose th,
.prose td {
  padding: 0.5em 0.75em;
  border-bottom: 1px solid var(--rule);
  text-align: left;
}

/* Editorial markers, only visible in draft previews. */
.marker {
  padding: 0.1em 0.3em;
  border-radius: 3px;
  background: var(--marker);
  color: var(--marker-text);
  font-size: 0.9em;
}
.marker b {
  font: 500 0.75em var(--mono);
  margin-right: 0.4em;
}

.post-footer {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 3.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--rule);
  font: 0.85rem/1.4 var(--mono);
}
.post-footer a {
  text-decoration: none;
  color: var(--muted);
}
.post-footer a:hover {
  color: var(--accent);
}
