/* One Paper a Day, "Lab notebook". Every color, font and size is a token in :root, so a
   redesign is a CSS change. Mobile first: phone, then 48rem (tablet), then 64rem (the rail). */

@font-face { font-family: "IBM Plex Mono"; font-style: normal; font-weight: 400; font-display: swap;
  src: url(fonts/IBMPlexMono-400.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: "IBM Plex Mono"; font-style: normal; font-weight: 500; font-display: swap;
  src: url(fonts/IBMPlexMono-500.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: "Instrument Sans"; font-style: normal; font-weight: 600; font-display: swap;
  src: url(fonts/InstrumentSans-600.woff2) format("woff2"); }
@font-face { font-family: "Instrument Sans"; font-style: normal; font-weight: 700; font-display: swap;
  src: url(fonts/InstrumentSans-700.woff2) format("woff2"); }
@font-face { font-family: "Source Serif 4"; font-style: normal; font-weight: 400; font-display: swap;
  src: url(fonts/SourceSerif4-Text-400.woff2) format("woff2"); }
@font-face { font-family: "Source Serif 4"; font-style: italic; font-weight: 400; font-display: swap;
  src: url(fonts/SourceSerif4-Text-400-Italic.woff2) format("woff2"); }
@font-face { font-family: "Source Serif 4"; font-style: normal; font-weight: 600; font-display: swap;
  src: url(fonts/SourceSerif4-Text-600.woff2) format("woff2"); }

:root {
  --font-mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --font-sans: "Instrument Sans", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --font-serif: "Source Serif 4", "Iowan Old Style", Georgia, serif;

  --ground: #F3F4F1;       /* page */
  --grid: #E6E8E3;         /* the notebook's square grid */
  --ink: #16181A;
  --ink-2: #4A4F54;        /* secondary text: paper titles */
  --muted: #5C6166;        /* labels and metadata */
  --card: #FBFBF9;         /* the TL;DR box and buttons */
  --rule: #16181A;         /* every border */
  --accent: #B23A0B;       /* hover, numbers, labels */
  --selection: #F2CDBB;
  --block-bg: #16181A;     /* the subscribe block */
  --block-ink: #F3F4F1;
  --block-label: #B9BEC2;
  --block-accent: #F08A5D;
  --field-bg: #23262A;
  --field-border: #6E747A; /* the design's #5C6166, lifted to 3:1 against the field */
  --button-bg: #B23A0B;
  --button-hover: #8F2E08;
  --button-ink: #FFFFFF;

  --grid-size: 24px;
  --gutter: 20px;
  --page: 1024px;          /* the archive and the rail layout */
  --measure: 700px;        /* the reading column */
  --rail: 240px;
  --rail-gap: 72px;

  --text-body: 1.125rem;   /* 18px, 19px from 48rem */
  --leading-body: 1.62;
  --text-tldr: 1.125rem;
  --text-h1: 2.25rem;
  --text-label: 0.75rem;   /* mono labels and metadata */
  --text-small: 0.8125rem;
  --text-ui: 0.875rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ground: #121416;
    --grid: #1C1F22;
    --ink: #E8EAE6;
    --ink-2: #C2C7CB;
    --muted: #9AA0A6;
    --card: #1A1D20;
    --rule: rgb(232 234 230 / 0.6);
    --accent: #F08A5D;
    --selection: #5B3424;
    /* The subscribe block inverts: ink ground, ground ink, as it does in the light theme. */
    --block-bg: #E8EAE6;
    --block-ink: #16181A;
    --block-label: #4A4F54;
    --block-accent: #B23A0B;
    --field-bg: #F7F8F5;
    --field-border: #5C6166;
    --button-bg: #B23A0B;
    --button-hover: #8F2E08;
    --button-ink: #FFFFFF;
  }
}

@media (min-width: 48rem) {
  :root {
    --grid-size: 32px;
    --gutter: 32px;
    --text-body: 1.1875rem;
    --leading-body: 1.66;
    --text-tldr: 1.3125rem;
    --text-h1: clamp(2.75rem, 1.4rem + 2.6vw, 3.375rem);
    --text-label: 0.8125rem;
  }
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html {
  color-scheme: light dark;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  background-color: var(--ground);
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: var(--grid-size) var(--grid-size);
  color: var(--ink);
  font-family: var(--font-serif);
  font-size: var(--text-body);
  line-height: var(--leading-body);
  font-kerning: normal;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-wrap: break-word;
}

::selection { background: var(--selection); color: var(--ink); }

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

.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}
.skip {
  position: absolute; left: 16px; top: -4rem; z-index: 1; padding: 8px 12px;
  background: var(--ink); color: var(--ground);
  font: 500 var(--text-small) / 1.4 var(--font-mono); text-decoration: none;
}
.skip:focus { top: 16px; }

/* Site header */
.site-header {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 16px var(--gutter);
  background: var(--ground);
  border-bottom: 1px solid var(--rule);
  font-family: var(--font-mono); font-size: var(--text-small); line-height: 1.4;
}
.brand { padding-block: 13px; font-weight: 500; text-decoration: none; white-space: nowrap; }
.brand-name { text-transform: uppercase; }
.brand-slash { color: var(--accent); }
.nav { display: flex; gap: 20px; }
.nav a { padding-block: 13px; text-decoration: none; }
.nav a[aria-current="page"], .nav-subscribe { color: var(--accent); }
.nav a:hover { color: var(--accent); }
@media (max-width: 47.99rem) { .nav-wide { display: none; } }
@media (min-width: 48rem) {
  .nav:has([aria-current="page"]) .nav-subscribe:not(:hover) { color: var(--ink); }
  /* 64px as designed at 1280; narrower screens line the brand up with the content */
  .site-header {
    padding: 24px clamp(var(--gutter), (100% - var(--page)) / 2, 64px);
    font-size: var(--text-ui); line-height: 1.3;
  }
  .brand { padding-block: 0; letter-spacing: 0.04em; }
  .nav { gap: 28px; }
  .nav a { padding-block: 0; }
}

/* Post page: the metadata rail and the reading column */
.post-layout { padding: 30px var(--gutter) 0; background: var(--ground); }
.rail {
  font-family: var(--font-mono); font-size: var(--text-label); line-height: 1.5; color: var(--muted);
}
.rail dl { margin: 0; display: flex; flex-wrap: wrap; gap: 4px 16px; }
.rail dt {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}
.rail dd { margin: 0; }
.rail a { color: var(--ink); }
.rail a:hover { color: var(--accent); }
.rail-status dd { color: var(--accent); }
.rail-wide { display: none; }
.rail-links { display: flex; flex-wrap: wrap; gap: 4px 14px; }

.post h1 {
  margin: 14px 0 0;
  font-family: var(--font-sans); font-weight: 700; font-size: var(--text-h1);
  line-height: 1.05; letter-spacing: -0.02em; text-wrap: balance;
}
.paper-title {
  margin: 12px 0 0;
  font-style: italic; font-size: 1rem; line-height: 1.45; color: var(--ink-2); text-wrap: pretty;
}
.prose { margin-top: 24px; }

@media (min-width: 48rem) {
  .post-layout {
    width: min(var(--measure), 100% - 2 * var(--gutter)); margin-inline: auto;
    padding: 64px 0 0; background: none;
  }
  .post-col { background: var(--ground); }
  .post h1 { margin-top: 16px; }
  .paper-title { font-size: 1.0625rem; }
  .prose { margin-top: 32px; }
}
@media (min-width: 64rem) {
  .post-layout {
    display: grid; grid-template-columns: var(--rail) minmax(0, 1fr); column-gap: var(--rail-gap);
    width: min(var(--page), 100% - 2 * var(--gutter)); padding-top: 88px;
  }
  .post-col { max-width: var(--measure); }
  .rail {
    align-self: start; position: sticky; top: 32px;
    padding-top: 12px; font-size: var(--text-small); color: var(--ink);
  }
  .rail dl { flex-direction: column; flex-wrap: nowrap; gap: 22px; }
  .rail dl > div { display: flex; flex-direction: column; gap: 4px; }
  .rail dt {
    position: static; width: auto; height: auto; overflow: visible;
    clip: auto; clip-path: none; white-space: normal;
    color: var(--muted); text-transform: uppercase;
  }
  .post h1 { margin-top: 0; line-height: 1.04; letter-spacing: -0.025em; }
}

/* Post body */
.prose p { margin: 0; text-wrap: pretty; }
.prose p + p { margin-top: 1em; }
.prose .tldr {
  padding: 18px; border: 1px solid var(--rule); background: var(--card);
  font-size: var(--text-tldr); line-height: 1.5;
}
.tldr-label {
  display: block; margin-bottom: 8px;
  font-family: var(--font-mono); font-size: 0.75rem; font-weight: 500; line-height: 1.4;
  color: var(--accent);
}
.prose h2 {
  margin: 36px 0 10px;
  font-family: var(--font-mono); font-size: var(--text-label); font-weight: 500;
  line-height: 1.3; letter-spacing: 0.06em; text-transform: uppercase;
}
.prose .tldr + h2 { margin-top: 40px; }
.sec-no { color: var(--accent); }
.prose strong { font-weight: 600; }
.prose em { font-style: italic; }

.prose .results {
  list-style: none; margin: 0; padding: 0; border-bottom: 1px solid var(--rule);
}
.prose .results li {
  position: relative; margin: 0; padding: 14px 0 14px 36px;
  border-top: 1px solid var(--rule); line-height: 1.58;
}
.r-no {
  position: absolute; left: 0; top: 19px;
  font-family: var(--font-mono); font-size: var(--text-small); line-height: 1.4; color: var(--accent);
}

/* The code-generated Links section: a mono row (the rail shows these links from 64rem) */
.prose h2#links + ul {
  list-style: none; margin: 0; padding: 0;
  display: flex; flex-wrap: wrap; gap: 6px 18px;
  font-family: var(--font-mono); font-size: var(--text-small); line-height: 1.5;
}
.prose h2#links + ul li { margin: 0; }

/* Anything else a body might hold */
.prose ul:not(.results), .prose ol:not(.results) { margin: 0; padding-left: 1.2em; }
.prose h2#links + ul { padding-left: 0; }
.prose li { margin-block: 0.4em; }
.prose h3 { font-family: var(--font-sans); font-weight: 600; font-size: 1.05em; margin: 1.6em 0 0.4em; }
.prose blockquote { margin: 1em 0; padding-left: 16px; border-left: 1px solid var(--rule); color: var(--ink-2); }
.prose code { font-family: var(--font-mono); font-size: 0.85em; }
.prose hr { border: 0; border-top: 1px solid var(--rule); margin: 32px 0; }

@media (min-width: 48rem) {
  .prose .tldr { padding: 24px 28px; }
  .tldr-label { margin-bottom: 10px; }
  .prose h2 { margin: 48px 0 14px; }
  .prose .tldr + h2 { margin-top: 60px; }
  .prose .results li { padding: 18px 0 18px 40px; line-height: 1.6; }
  .r-no { top: 23px; font-size: var(--text-ui); }
}
@media (min-width: 64rem) {
  .prose h2#links, .prose h2#links + ul { display: none; }
}

/* Share row */
.share {
  margin-top: 40px;
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  font-family: var(--font-mono); font-size: var(--text-ui); line-height: 1.2;
}
.share-label { flex-basis: 100%; color: var(--muted); }
.share a, .share button {
  display: inline-flex; align-items: center; min-height: 44px; padding: 11px 14px; border: 1px solid var(--rule); border-radius: 0; background: var(--card);
  font: inherit; color: var(--ink); text-decoration: none; cursor: pointer;
}
.share a:hover, .share button:hover { color: var(--accent); }
@media (min-width: 30rem) { .share-label { flex-basis: auto; margin-right: 6px; } }
@media (min-width: 48rem) { .share { margin-top: 56px; } }

/* Previous / next */
.pager { margin-top: 40px; display: grid; gap: 10px; }
.pager a {
  display: block; padding: 16px 18px;
  border: 1px solid var(--rule); background: var(--card); text-decoration: none;
}
.pager small {
  display: block; margin-bottom: 6px;
  font-family: var(--font-mono); font-size: var(--text-label); line-height: 1.4;
  letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted);
}
.pager small span { color: var(--accent); }
.pager-title {
  display: block;
  font-family: var(--font-sans); font-weight: 600; font-size: 1.125rem; line-height: 1.25;
  letter-spacing: -0.01em; color: var(--ink); text-wrap: pretty;
}
.pager a:hover .pager-title { color: var(--accent); }
@media (min-width: 40rem) {
  .pager { grid-template-columns: 1fr 1fr; }
  .pager .older { grid-column: 1; }
  .pager .newer { grid-column: 2; text-align: right; }
}
@media (min-width: 48rem) { .pager { margin-top: 48px; } }

/* Subscribe block */
.subscribe {
  margin-top: 56px; padding: 28px 22px;
  display: flex; flex-direction: column; gap: 18px;
  background: var(--block-bg); color: var(--block-ink);
}
.subscribe-kicker {
  margin: 0 0 10px;
  font-family: var(--font-mono); font-size: 0.75rem; line-height: 1.4;
  text-transform: uppercase; color: var(--block-accent);
}
.subscribe h2 {
  margin: 0;
  font-family: var(--font-sans); font-weight: 700; font-size: 1.5rem; line-height: 1.15;
  letter-spacing: -0.015em; text-wrap: balance;
}
.subscribe form {
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; font-family: var(--font-mono);
}
.subscribe label {
  flex: 1 1 14rem; display: flex; flex-direction: column; gap: 6px;
  font-size: 0.75rem; line-height: 1.4; color: var(--block-label);
}
.subscribe input[type="email"] {
  min-width: 0; width: 100%; padding: 13px 14px;
  font: inherit; font-size: 0.9375rem; line-height: 1.3; color: var(--block-ink);
  background: var(--field-bg); border: 1px solid var(--field-border); border-radius: 0;
  -webkit-appearance: none; appearance: none;
}
.subscribe input[type="email"]::placeholder { color: var(--block-label); opacity: 1; }
.subscribe button {
  padding: 14px 22px;
  font: inherit; font-size: 0.9375rem; font-weight: 500; line-height: 1.3;
  color: var(--button-ink); background: var(--button-bg); border: 0; border-radius: 0; cursor: pointer;
}
.subscribe button:hover { background: var(--button-hover); }
.subscribe :focus-visible { outline-color: var(--block-accent); }
.subscribe input[type="email"]:focus-visible { outline-offset: 0; }
.subscribe .fine {
  margin: 12px 0 0;
  font-family: var(--font-mono); font-size: 0.75rem; line-height: 1.5; color: var(--block-label);
}
.subscribe a { color: var(--block-ink); }
.subscribe a:hover { color: var(--block-accent); }
@media (max-width: 29.99rem) { .subscribe button { flex-basis: 100%; } }
@media (min-width: 48rem) {
  .subscribe { margin-top: 64px; padding: 36px 40px; }
  .subscribe h2 { font-size: 1.875rem; text-wrap: pretty; }
}
@media (min-width: 64rem) {
  .subscribe-wide {
    margin-top: 72px; padding: 30px 36px;
    flex-direction: row; justify-content: space-between; align-items: flex-end; gap: 32px;
  }
  .subscribe-wide h2 { font-size: 1.5rem; line-height: 1.2; letter-spacing: 0; }
  .subscribe-wide .subscribe-action { flex: 0 0 auto; }
  .subscribe-wide form { flex-wrap: nowrap; }
  .subscribe-wide label { flex: 0 0 auto; }
  .subscribe-wide input[type="email"] { width: 270px; } /* the design's 240px content box */
}

/* Archive, 404 and the empty home page */
.page { padding: 36px var(--gutter) 0; background: var(--ground); }
.page-head {
  display: flex; justify-content: space-between; align-items: baseline; gap: 16px;
  padding-bottom: 14px; border-bottom: 1px solid var(--rule); background: var(--ground);
}
.page-head h1 {
  margin: 0;
  font-family: var(--font-sans); font-weight: 700; font-size: 2.375rem; line-height: 1;
  letter-spacing: -0.02em;
}
.page-count {
  font-family: var(--font-mono); font-size: var(--text-label); color: var(--muted); white-space: nowrap;
}
.wide-only { display: none; }
.page-lede {
  /* full-width ground behind a 36em measure */
  margin: 0; padding: 28px max(0px, 100% - 36em) 0 0; font-size: 1.1875rem; line-height: 1.6;
  background: var(--ground);
}
.page-links {
  margin: 0; padding-top: 24px; display: flex; flex-wrap: wrap; gap: 10px;
  font-family: var(--font-mono); font-size: var(--text-ui); line-height: 1.2;
  background: var(--ground);
}
.page-links a {
  display: inline-flex; align-items: center; min-height: 44px; padding: 11px 14px; border: 1px solid var(--rule); background: var(--card); text-decoration: none;
}

.archive-list { list-style: none; margin: 0; padding: 0; background: var(--ground); }
.archive-list li {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px 0;
  padding: 22px 0; border-bottom: 1px solid var(--rule);
}
.a-date, .a-sep, .a-id {
  font-family: var(--font-mono); font-size: var(--text-label); line-height: 1.5; color: var(--muted);
}
.a-date { order: 1; }
.a-sep { order: 2; margin-inline: 0.6em; }
.a-id { order: 3; }
.a-main { order: 4; flex: 1 1 100%; display: flex; flex-direction: column; gap: 8px; }
.a-title {
  font-family: var(--font-sans); font-weight: 600; font-size: 1.375rem; line-height: 1.2;
  text-decoration: none; text-wrap: pretty;
}
.a-paper { margin: 0; font-style: italic; font-size: 1rem; line-height: 1.45; color: var(--ink-2); }

@media (min-width: 48rem) {
  .page { width: min(var(--page), 100% - 2 * var(--gutter)); margin-inline: auto; padding: 80px 0 0; background: none; }
  .page-head { padding-bottom: 20px; }
  .page-head h1 { font-size: 3.375rem; letter-spacing: -0.025em; }
  .wide-only { display: inline; }
  .a-title { font-size: 1.5rem; letter-spacing: -0.01em; }
}
@media (min-width: 64rem) {
  .archive-list li {
    display: grid; grid-template-columns: 150px minmax(0, 1fr) 170px; column-gap: 32px;
    padding: 28px 0;
  }
  .a-date { grid-column: 1; grid-row: 1; font-size: var(--text-ui); color: var(--ink); }
  .a-main { grid-column: 2; grid-row: 1; }
  .a-sep { display: none; }
  .a-id { grid-column: 3; grid-row: 1; text-align: right; }
  .a-title { font-size: 1.625rem; }
  .a-paper { font-size: 1.0625rem; }
}

/* Site footer */
.site-footer {
  margin: 72px var(--gutter) 0; padding: 24px 0 32px;
  border-top: 1px solid var(--rule); background: var(--ground);
  font-family: var(--font-mono);
}
.footer-row {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px 22px;
  font-size: var(--text-small); line-height: 1.5;
}
.footer-row nav { display: flex; gap: 22px; }
.footer-name { text-transform: lowercase; text-decoration: none; }
.footer-about { margin: 12px 0 0; max-width: 64ch; font-size: 0.75rem; line-height: 1.6; color: var(--muted); }
@media (min-width: 48rem) {
  .site-footer { width: min(var(--page), 100% - 2 * var(--gutter)); margin: 88px auto 0; padding-bottom: 40px; }
}

/* Touch-size screens: small inline links get a 44px-tall hit area without moving anything.
   The padding grows the box and the same negative margin takes it back out of the layout. */
@media (max-width: 63.99rem) {
  .rail a, .prose h2#links + ul a, .footer-row a, .subscribe .fine a {
    display: inline-block; padding: 13px 8px; margin: -13px -8px;
  }
  .a-title { padding-block: 9px; margin-block: -9px; } /* a one-line title is 26px */
}

@media print {
  .site-header nav, .share, .pager, .subscribe, .site-footer nav, .skip { display: none; }
  body { background: #fff; color: #000; }
  .rail-wide { display: flex; }
}
