:root {
  --bg: #e8ece9;
  --ink: #1c2427;
  --muted: #5d696c;
  --line: #c9d0cd;
  --link: #2c5a63;
  --code-bg: #dde3e0;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", "URW Palladio L", P052, Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "DejaVu Sans Mono", monospace;
  --gutter: clamp(16px, 4vw, 48px);
  --page: 72rem;
  --text: 36rem;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12181a;
    --ink: #dde4e3;
    --muted: #8e9a9c;
    --line: #2a3437;
    --link: #8fc0c6;
    --code-bg: #1b2326;
  }
}

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.1875rem;
  line-height: 1.6;
  font-variant-numeric: oldstyle-nums;
}

img { display: block; max-width: 100%; height: auto; }

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

.skip {
  position: absolute; left: var(--gutter); top: -3rem;
  font-family: var(--sans); font-size: 0.95rem;
  background: var(--ink); color: var(--bg); padding: 0.4rem 0.8rem;
}
.skip:focus { top: 0.5rem; }

/* header */
.site-header {
  max-width: var(--page);
  margin: 0 auto;
  padding: 1.1rem var(--gutter);
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.4rem 1.5rem;
  font-family: var(--sans);
  font-size: 0.95rem;
}
.brand { color: var(--ink); text-decoration: none; font-family: var(--serif); font-size: 1.15rem; }
.site-nav { display: flex; gap: 1.25rem; }
.site-nav a { color: var(--muted); text-decoration: none; }
.site-nav a:hover { color: var(--ink); }
.site-nav a[aria-current="page"] { color: var(--ink); text-decoration: underline; text-underline-offset: 0.35em; }

/* home hero: the title is drawn in the page colour, so its foot dissolves into the page below the picture */
.hero { position: relative; margin: 0 0 clamp(1.5rem, 3vw, 2.5rem); }
.hero img {
  width: 100%;
  height: clamp(320px, 70vh, 780px);
  object-fit: cover;
  object-position: 50% 62%;
}
.hero h1 {
  position: absolute;
  left: calc(max(0px, (100% - var(--page)) / 2) + var(--gutter));
  right: var(--gutter);
  bottom: -0.13em;
  margin: 0;
  font-weight: 400;
  font-size: clamp(3.25rem, 10.5vw, 9.5rem);
  line-height: 0.86;
  letter-spacing: -0.015em;
  color: var(--bg);
}

@media (prefers-color-scheme: dark) {
  .hero h1 { color: #e8ece9; bottom: 0.18em; }
}

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

.intro { max-width: var(--text); font-size: 1.3rem; line-height: 1.5; margin: 0 0 3.5rem; }

h2 { font-weight: 400; font-size: 1.75rem; line-height: 1.2; margin: 0 0 1.25rem; }

/* note list */
.note-list { list-style: none; margin: 0 0 3rem; padding: 0; border-top: 1px solid var(--line); }
.note-list li { border-bottom: 1px solid var(--line); }
.note-item {
  display: grid;
  grid-template-columns: minmax(0, 15rem) minmax(0, 1fr);
  gap: 1.5rem;
  padding: 1.5rem 0;
  color: inherit;
  text-decoration: none;
}
.note-item img { aspect-ratio: 3 / 2; object-fit: cover; width: 100%; }
.note-item h3 { font-weight: 400; font-size: 1.45rem; line-height: 1.25; margin: 0 0 0.35rem; color: var(--link); }
.note-item:hover h3 { text-decoration: underline; text-underline-offset: 0.18em; }
.note-item p { margin: 0; max-width: 34rem; }
.meta { font-family: var(--sans); font-size: 0.85rem; color: var(--muted); margin: 0 0 0.5rem; font-variant-numeric: lining-nums; }

/* article */
.article { max-width: var(--text); margin: 0 auto; padding: 1.5rem var(--gutter) 0; box-sizing: content-box; }
.article h1 { font-weight: 400; font-size: clamp(2.2rem, 5vw, 3.2rem); line-height: 1.1; margin: 1rem 0 0.75rem; }
.article .lede { font-size: 1.3rem; line-height: 1.5; color: var(--muted); margin: 0 0 2rem; }
.article p { margin: 0 0 1.1rem; hyphens: auto; }
.article h2 { font-size: 1.45rem; margin: 2.5rem 0 0.75rem; }

figure { margin: 2.25rem 0; }
.wide { margin-left: calc(50% - min(50vw, 30rem)); margin-right: calc(50% - min(50vw, 30rem)); }
.wide figcaption { padding: 0 var(--gutter); }
@media (min-width: 64rem) { .wide figcaption { padding: 0; } }
figcaption { font-family: var(--sans); font-size: 0.85rem; line-height: 1.45; color: var(--muted); margin-top: 0.6rem; font-variant-numeric: lining-nums; }

pre {
  font-family: var(--mono);
  font-size: 0.82rem;
  line-height: 1.55;
  background: var(--code-bg);
  padding: 1rem 1.15rem;
  overflow-x: auto;
  border-radius: 4px;
  margin: 1.5rem 0;
}
code { font-family: var(--mono); font-size: 0.88em; }
p code { background: var(--code-bg); padding: 0.05em 0.3em; border-radius: 3px; }

.more { border-top: 1px solid var(--line); margin-top: 3rem; padding-top: 1.25rem; }
.more ul { margin: 0; padding-left: 1.1rem; }

/* gallery */
.page-head { max-width: var(--text); margin: 1.5rem 0 2.5rem; }
.page-head h1 { font-weight: 400; font-size: clamp(2.2rem, 5vw, 3.2rem); line-height: 1.1; margin: 1rem 0 0.75rem; }
.page-head p { margin: 0; }
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr));
  gap: 2.5rem 1.5rem;
  margin: 0 0 3rem;
}
.grid figure { margin: 0; }
.grid a { display: block; }
.grid img { aspect-ratio: 3 / 2; object-fit: cover; width: 100%; }
.grid figcaption b { font-family: var(--serif); font-weight: 400; font-size: 1.05rem; color: var(--ink); display: block; }
.grid .featured { grid-column: 1 / -1; }
.grid .featured figcaption b { font-size: 1.3rem; }

/* footer */
.site-footer {
  max-width: var(--page);
  margin: 4rem auto 0;
  padding: 0 var(--gutter) 2.5rem;
  font-family: var(--sans);
  font-size: 0.85rem;
  color: var(--muted);
}
.site-footer > div { border-top: 1px solid var(--line); padding-top: 1.5rem; }
.site-footer p { margin: 0; max-width: 40rem; }

/* 404 */
.lost { max-width: var(--text); margin: 0 auto; padding: 4rem var(--gutter) 2rem; box-sizing: content-box; }
.lost h1 { font-weight: 400; font-size: clamp(2.2rem, 5vw, 3.2rem); line-height: 1.1; margin: 0 0 1rem; }

@media (max-width: 40rem) {
  body { font-size: 1.0625rem; }
  .note-item { grid-template-columns: 1fr; gap: 0.9rem; }
  .intro { font-size: 1.15rem; }
  .hero { margin-bottom: 2.25rem; }
}
