/* "Book": one quiet reading column, serif text, system UI for chrome, one accent. */

@font-face {
  font-family: "Newsreader";
  font-style: normal;
  font-weight: 200 800;
  font-display: swap;
  src: url("/fonts/newsreader-latin-opsz-normal.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: "Newsreader";
  font-style: italic;
  font-weight: 200 800;
  font-display: swap;
  src: url("/fonts/newsreader-latin-opsz-italic.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;
}

:root {
  --measure: 38rem;
  --gutter: 1.25rem;
  --bg: #ffffff;
  --text: #26262a;
  --mute: #6e6e73;
  --rule: #e6e6e3;
  --code-bg: #f7f7f5; /* Pygments comments (#3d7b7b) need >= 4.5:1 on it */
  --accent: #c2410c;
  --serif: "Newsreader", Georgia, "Times New Roman", serif;
  --ui: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16161a;
    --text: #e7e5e0;
    --mute: #9b9a97;
    --rule: #2c2c31;
    --code-bg: #212126;
    --accent: #f2895a;
  }
}

@media (prefers-reduced-motion: no-preference) {
  @view-transition {
    navigation: auto;
  }
}

/* Base */

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--serif);
  font-size: 1.1875rem;
  line-height: 1.6;
  font-optical-sizing: auto;
  font-kerning: normal;
  text-rendering: optimizeLegibility;
  overflow-wrap: break-word;
}

.column {
  max-width: calc(var(--measure) + 2 * var(--gutter));
  margin: 0 auto;
  padding: 0 var(--gutter);
}

a {
  color: var(--accent);
  text-decoration-line: underline;
  text-decoration-thickness: 1px;
  text-decoration-color: color-mix(in srgb, var(--accent) 45%, transparent);
  text-underline-offset: 0.18em;
}

a:hover {
  text-decoration-color: var(--accent);
  text-decoration-thickness: 2px;
}

a:focus-visible,
input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

h1,
h2,
h3,
h4 {
  font-weight: 500;
  line-height: 1.15;
  letter-spacing: -0.01em;
  text-wrap: balance;
}

h1 {
  font-size: clamp(2.1rem, 1.5rem + 2.6vw, 2.9rem);
  margin: 0 0 0.75rem;
}

h1 a {
  color: inherit;
}

h1 a:hover {
  color: var(--accent);
}

h2 {
  font-size: 1.6rem;
  margin: 2.5rem 0 0.75rem;
}

h3 {
  font-size: 1.3rem;
  margin: 2rem 0 0.5rem;
}

p,
ul,
ol,
blockquote,
pre,
table {
  margin: 0 0 1.25rem;
}

blockquote {
  margin-left: 0;
  padding-left: 1.1rem;
  border-left: 2px solid var(--accent);
  font-style: italic;
}

hr {
  border: 0;
  border-top: 1px solid var(--rule);
  margin: 2.5rem 0;
}

code,
pre {
  font-family: var(--mono);
  font-size: 0.82em;
}

code {
  background: var(--code-bg);
  padding: 0.1em 0.3em;
  border-radius: 3px;
}

/* scroll shadows: the two cover gradients scroll with the content and hide the shadows at either end */
pre {
  font-style: normal;
  background:
    linear-gradient(to right, var(--code-bg) 30%, transparent) left / 2.5rem 100%,
    linear-gradient(to left, var(--code-bg) 30%, transparent) right / 2.5rem 100%,
    radial-gradient(farthest-side at 0 50%, rgb(0 0 0 / 0.18), transparent) left / 0.8rem 100%,
    radial-gradient(farthest-side at 100% 50%, rgb(0 0 0 / 0.18), transparent) right / 0.8rem 100%,
    var(--code-bg);
  background-repeat: no-repeat;
  background-attachment: local, local, scroll, scroll;
  padding: 1rem 1.1rem;
  border-radius: 4px;
  overflow-x: auto;
  line-height: 1.5;
}

pre code {
  background: none;
  padding: 0;
  font-size: inherit;
}

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

picture,
.content > img,
.content p > img {
  display: block;
  margin: 2rem auto;
}

picture img {
  display: block;
  width: 100%;
}

.table-wrap {
  overflow-x: auto;
  margin: 0 0 1.25rem;
}

.table-wrap > table {
  margin: 0;
}

table {
  border-collapse: collapse;
  font-size: 0.95em;
}

th,
td {
  border-bottom: 1px solid var(--rule);
  padding: 0.4rem 0.75rem 0.4rem 0;
  text-align: left;
}

mark {
  background: color-mix(in srgb, var(--accent) 22%, transparent);
  color: inherit;
}

sup {
  line-height: 0;
}

.footnotes {
  font-size: 0.9em;
  color: var(--mute);
}

.footnotes-list {
  padding-left: 1.25rem;
}

/* cap height of Newsreader, standing on the baseline */
.icon {
  width: 0.8em;
  height: 0.8em;
  vertical-align: -0.08em;
  fill: currentColor;
}

/* icon-only links: quiet like the chrome, accent on hover; inline padding widens the hit area
   without moving the line; the label is the accessible name and tooltip */
.icon-link {
  padding: 0.3em 0.25em;
  color: var(--mute);
  text-decoration: none;
}

.icon-link:hover {
  color: var(--accent);
}

.project-index {
  margin: 0 0 1rem;
}

.project-index .post-list li {
  margin-bottom: 0.6rem;
  font-size: 1.02rem;
  line-height: 1.5;
}

.project-index .post-list .title {
  display: inline;
  font-size: inherit;
  font-weight: 500;
}

.project-index .description {
  color: var(--mute);
}

/* Chrome: system UI, quiet */

.skip-link {
  position: absolute;
  left: var(--gutter);
  top: 0.5rem;
  z-index: 1;
  transform: translateY(-200%);
  font-family: var(--ui);
  font-size: 0.9rem;
  background: var(--bg);
  padding: 0.5rem 0.75rem;
}

.skip-link:focus {
  transform: none;
}

.site-header {
  font-family: var(--ui);
  font-size: 0.9rem;
  padding-top: 1.75rem;
  padding-bottom: 3rem;
}

/* Links get ~44px tap height from padding; the negative margin keeps the visual spacing. */
.site-header nav {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0 1.1rem;
  margin: -0.7rem 0;
}

.site-header nav a {
  padding-block: 0.7rem;
}

.nav-links {
  display: contents;
}

/* Narrow screens: the name on its own line, the seven links in one row that scrolls sideways
   (they need ~450px); the fade at the right edge says there is more. No script involved. */
@media (max-width: 37.99rem) {
  .site-header {
    padding-top: 1.25rem;
    padding-bottom: 1.75rem;
  }

  .site-header .site-name {
    flex-basis: 100%;
    padding-block: 0.4rem;
  }

  .nav-links {
    display: flex;
    flex-wrap: nowrap;
    gap: 0 1.1rem;
    max-width: 100%;
    overflow-x: auto;
    scrollbar-width: none;
    mask-image: linear-gradient(to right, #000 calc(100% - 2.5rem), transparent);
    padding-right: 2.5rem; /* the last link can scroll clear of the fade */
  }

  .nav-links::-webkit-scrollbar {
    display: none;
  }

  .nav-links a {
    flex: none;
  }
}

.site-header a {
  color: var(--mute);
  text-decoration: none;
}

.site-header a:hover,
.site-header a[aria-current] {
  color: var(--accent);
}

.site-header .site-name {
  margin-right: auto;
  color: var(--text);
  font-family: var(--serif);
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: -0.005em;
}

.site-footer {
  font-family: var(--ui);
  font-size: 0.8rem;
  color: var(--mute);
  margin-top: 5rem;
  padding-top: 0.5rem;
  padding-bottom: 2.25rem;
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0 1.1rem;
}

/* the rule spans the text column, not the gutters around it */
.site-footer::before {
  content: "";
  position: absolute;
  top: 0;
  left: var(--gutter);
  right: var(--gutter);
  border-top: 1px solid var(--rule);
}

.site-footer a {
  padding-block: 0.75rem;
  color: var(--mute);
  text-decoration: none;
}

.site-footer a:hover {
  color: var(--accent);
}

.meta {
  font-family: var(--ui);
  font-size: 0.85rem;
  color: var(--mute);
  margin: 0 0 0.25rem;
}

.lede {
  color: var(--mute);
}

/* Onward navigation at the end of a note */

.note-nav {
  margin-top: 4rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--rule);
  display: grid;
  gap: 1.25rem;
}

.note-nav a {
  text-decoration: none;
}

.note-nav .meta {
  display: block;
}

.note-nav .title {
  display: block;
  font-size: 1.15rem;
  line-height: 1.3;
  color: var(--text);
}

.note-nav a:hover .title {
  color: var(--accent);
}

.note-nav .back {
  color: var(--accent);
  padding-block: 0.7rem;
}

/* Listings */

.section-label {
  font-family: var(--ui);
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--mute);
  margin: 3rem 0 1rem;
}

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

.post-list li {
  margin: 0 0 1.6rem;
}

.post-list .title {
  display: block;
  font-size: 1.3rem;
  line-height: 1.3;
  color: var(--text);
  text-decoration: none;
}

.post-list .title:hover {
  color: var(--accent);
}

.post-list p {
  margin: 0.3rem 0 0;
  color: var(--mute);
  font-size: 1.02rem;
  line-height: 1.5;
}

.archive-list li {
  display: grid;
  grid-template-columns: 6.5rem 1fr;
  gap: 1rem;
  margin: 0 0 0.6rem;
}

.archive-list a,
.publication h2 a {
  color: var(--text);
  text-decoration: none;
}

.archive-list a:hover,
.publication h2 a:hover {
  color: var(--accent);
}

.archive-list time {
  font-family: var(--ui);
  font-size: 0.85rem;
  color: var(--mute);
  padding-top: 0.2rem;
}

@media (max-width: 30rem) {
  .archive-list li {
    grid-template-columns: 1fr;
    gap: 0;
  }
}

.project,
.publication {
  border-top: 1px solid var(--rule);
  padding-top: 2rem;
  margin-top: 2rem;
}

.project h2,
.publication h2 {
  margin-top: 0;
}

/* Search */

.search label {
  display: block;
  font-family: var(--ui);
  font-size: 0.85rem;
  color: var(--mute);
  margin-bottom: 0.4rem;
}

.search input {
  width: 100%;
  font: inherit;
  font-size: 1.2rem;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--mute);
  border-radius: 4px;
  padding: 0.6rem 0.8rem;
  accent-color: var(--accent);
}

.search input::-webkit-search-cancel-button {
  -webkit-appearance: none;
  appearance: none;
  width: 1rem;
  height: 1rem;
  background-color: var(--mute);
  -webkit-mask: url("/icons/search-clear.svg") center / contain no-repeat;
  mask: url("/icons/search-clear.svg") center / contain no-repeat;
  cursor: pointer;
}

.search input::-webkit-search-cancel-button:hover {
  background-color: var(--accent);
}

#search-more {
  font: inherit;
  font-family: var(--ui);
  font-size: 0.9rem;
  color: var(--accent);
  background: none;
  border: 1px solid var(--mute);
  border-radius: 4px;
  padding: 0.5rem 1rem;
  cursor: pointer;
}

#search-more:hover {
  border-color: var(--accent);
}

#search-more[hidden],
#search-hint[hidden] {
  display: none;
}

#search-status {
  font-family: var(--ui);
  font-size: 0.9rem;
  color: var(--mute);
}
