/* ---------------------------------------------------------------------------
   A research notebook, not a startup landing page.
   Two typefaces, one accent per screen. Brick is reserved for the
   counterfactual branch in diagrams and for the "safe" tag.
--------------------------------------------------------------------------- */

@font-face {
  font-family: "Source Serif 4";
  src: url("../fonts/source-serif-4-latin-400-normal.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Source Serif 4";
  src: url("../fonts/source-serif-4-latin-400-italic.woff2") format("woff2");
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: "Source Serif 4";
  src: url("../fonts/source-serif-4-latin-600-normal.woff2") format("woff2");
  font-weight: 600;
  font-style: normal;
  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-style: normal;
  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-style: normal;
  font-display: swap;
}

:root {
  --paper: #FAF8F3;
  --tint: #F4F1EA;
  --ink: #1C1B19;
  --muted: #6B6A65;
  --rule: #D9D5CC;
  --blue: #2B4C7E;
  --brick: #9A4A3A;

  --serif: "Source Serif 4", "Source Serif Pro", Georgia, "Times New Roman", serif;
  --mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;

  --measure: 33rem; /* roughly 70 characters of body text */
  --gutter: 1.25rem;

  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #1C1B19;
    --tint: #262522;
    --ink: #ECE9E2;
    --muted: #A19F98;
    --rule: #3B3935;
    --blue: #93B3E2;
    --brick: #DB8F7D;
  }
}

@media print {
  :root {
    --paper: #FFFFFF;
  }
  .site-header nav,
  .site-footer,
  .skip {
    display: none;
  }
}

/* Base ------------------------------------------------------------------- */

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

html {
  font-size: 106.25%; /* 17px */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

@media (min-width: 40em) {
  html {
    font-size: 118.75%; /* 19px */
  }
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-weight: 400;
  line-height: 1.6;
  font-kerning: normal;
  font-variant-numeric: oldstyle-nums;
  text-rendering: optimizeLegibility;
}

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

main.wrap {
  padding-block: 3.5rem 5rem;
}

a {
  color: var(--blue);
  text-decoration-line: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}

a:hover {
  text-decoration-thickness: 2px;
}

:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 3px;
}

h1,
h2,
h3,
h4 {
  font-weight: 600;
  line-height: 1.2;
  text-wrap: balance;
  margin: 2.4em 0 0.6em;
}

h1 {
  font-size: 2rem;
  letter-spacing: -0.012em;
  margin-top: 0;
}

h2 {
  font-size: 1.4rem;
}

h3 {
  font-size: 1.15rem;
}

h4 {
  font-size: 1rem;
}

p,
ul,
ol,
blockquote,
pre,
table,
figure {
  margin: 0 0 1.15em;
}

strong,
b {
  font-weight: 600;
}

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

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

.skip {
  position: absolute;
  left: -999px;
  top: 0.5rem;
  padding: 0.4rem 0.8rem;
  background: var(--paper);
  font-family: var(--mono);
  font-size: 0.75rem;
}

.skip:focus {
  left: 0.5rem;
}

/* Labels, dates and tags: the monospace voice ---------------------------- */

.label,
.meta,
.site-header nav,
.site-footer,
.posts time,
.tag {
  font-family: var(--mono);
  font-variant-numeric: normal;
}

.label {
  margin: 3.75rem 0 1.4rem;
  padding-bottom: 0.55rem;
  border-bottom: 1px solid var(--rule);
  color: var(--blue);
  font-size: 0.7rem;
  font-weight: 500;
  line-height: 1.4;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.meta {
  margin-bottom: 1rem;
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0.04em;
}

.meta .tag {
  margin-left: 0.6em;
}

.tag {
  display: inline-block;
  padding: 0.1em 0.55em;
  border: 1px solid currentColor;
  border-radius: 2px;
  font-size: 0.6rem;
  font-weight: 500;
  line-height: 1.5;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  vertical-align: 0.15em;
  white-space: nowrap;
}

.tag--super {
  color: var(--blue);
}

.tag--safe {
  color: var(--brick);
}

/* Header and footer ------------------------------------------------------ */

.site-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1.5rem;
  padding-block: 1.6rem 1.2rem;
  border-bottom: 1px solid var(--rule);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--ink);
  font-weight: 600;
  text-decoration: none;
}

.monogram {
  flex: none;
  width: 1.55rem;
  height: 1.55rem;
}

.monogram .node {
  fill: var(--ink);
}

.monogram .edge {
  fill: none;
  stroke: var(--blue);
  stroke-width: 1.6;
  stroke-linecap: round;
}

.monogram .edge--cf {
  stroke: var(--brick);
  stroke-dasharray: 2.4 2;
}

.site-header nav {
  display: flex;
  gap: 1.5rem;
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

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

.site-header nav a:hover,
.site-header nav a[aria-current="page"] {
  color: var(--blue);
}

.site-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.5rem 1.5rem;
  padding-block: 1.4rem 3rem;
  border-top: 1px solid var(--rule);
  color: var(--muted);
  font-size: 0.68rem;
  letter-spacing: 0.04em;
}

.site-footer a {
  color: inherit;
  text-decoration: none;
}

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

.site-footer ul {
  display: flex;
  gap: 1.25rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

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

.hero {
  margin: 1.5rem 0 2.75rem;
  color: var(--blue);
  font-size: clamp(1.9rem, 6.2vw, 2.7rem);
  line-height: 1.14;
  letter-spacing: -0.018em;
}

.thesis,
blockquote {
  padding: 1.4rem 1.6rem;
  background: var(--tint);
}

.thesis > :last-child,
blockquote > :last-child {
  margin-bottom: 0;
}

.thesis .tag {
  margin-right: 0.35em;
}

.thesis figure {
  margin-top: 1.6rem;
}

.links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.5rem;
  padding: 0;
  list-style: none;
}

.more {
  margin-top: 1.5rem;
}

.about {
  display: flex;
  align-items: flex-start;
  gap: 1.25rem;
}

.about p {
  margin-top: 0;
}

.avatar {
  flex: none;
  width: 5.5rem;
  height: 5.5rem;
  border: 1px solid var(--rule);
  border-radius: 50%;
  object-fit: cover;
}

@media (max-width: 30em) {
  .about {
    flex-direction: column;
  }
}

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

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

.posts li {
  display: grid;
  grid-template-columns: 5.6rem 1fr;
  gap: 0 1rem;
  align-items: baseline;
  padding-block: 0.5rem;
}

.posts time {
  color: var(--muted);
  font-size: 0.7rem;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.posts a {
  color: var(--ink);
  text-decoration: none;
}

.posts a:hover {
  color: var(--blue);
  text-decoration: underline;
  text-decoration-thickness: 1px;
}

.posts .tag {
  margin-left: 0.5em;
}

@media (max-width: 30em) {
  .posts li {
    grid-template-columns: 1fr;
    padding-block: 0.6rem;
  }
}

/* Posts and pages -------------------------------------------------------- */

.post-header {
  margin-bottom: 2.25rem;
}

.post-header h1 {
  margin-bottom: 0.9rem;
}

.origin {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  font-style: italic;
}

.post-footer {
  margin-top: 3.5rem;
  padding-top: 1.2rem;
  border-top: 1px solid var(--rule);
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.04em;
}

.post-footer a {
  text-decoration: none;
}

.prose img {
  display: block;
  margin: 2rem auto 0.9rem;
}

.prose li {
  margin-bottom: 0.4em;
}

.prose li > p {
  margin-bottom: 0.4em;
}

figure {
  margin-block: 2rem;
}

figure img {
  display: block;
  margin: 0 auto;
}

figcaption {
  margin-top: 0.8rem;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.5;
}

code,
kbd,
pre {
  font-family: var(--mono);
  font-size: 0.84em;
  font-variant-numeric: normal;
}

pre {
  padding: 1rem 1.2rem;
  overflow-x: auto;
  background: var(--tint);
  line-height: 1.5;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  font-variant-numeric: lining-nums tabular-nums;
}

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

th {
  font-family: var(--mono);
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

/* Causal diagrams -------------------------------------------------------- */

.dag {
  display: block;
  margin-inline: auto;
}

.dag .node {
  fill: var(--ink);
}

.dag .edge {
  fill: none;
  stroke: var(--blue);
  stroke-width: 1.25;
}

.dag .edge--cf {
  stroke: var(--brick);
  stroke-dasharray: 5 4;
}

.dag .head {
  fill: var(--blue);
}

.dag .head--cf {
  fill: var(--brick);
}

.dag text {
  fill: var(--ink);
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.06em;
}
