/* EB Garamond, one file per style; each file holds every weight from 400 to 800. */
@font-face {
  font-family: "EB Garamond";
  src: url("/fonts/EBGaramond.woff2") format("woff2");
  font-weight: 400 800;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "EB Garamond";
  src: url("/fonts/EBGaramond-Italic.woff2") format("woff2");
  font-weight: 400 800;
  font-style: italic;
  font-display: swap;
}

:root {
  --bg: #ffffff;
  --text: #000000;
  --muted: #6e6e6e;
  --rule: #e0e0e0;
  --accent: #000000;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1f1f1f;
    --text: #e6e6e6;
    --muted: #9a9a9a;
    --rule: #3a3a3a;
    --accent: #e6e6e6;
  }
}

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

/* Every size on the site is in rem, so this one number scales the whole page.
   Garamond is a small face: 19px on phones, 21px on wider screens. */
html {
  font-size: 118.75%;
  -webkit-text-size-adjust: 100%;
}

@media (min-width: 40rem) {
  html { font-size: 131.25%; }
}

body {
  margin: 0 auto;
  max-width: 31rem;
  padding: 2rem 1rem 3rem;
  background: var(--bg);
  color: var(--text);
  font-family: "EB Garamond", Garamond, Georgia, "Times New Roman", serif;
  font-size: 1rem;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-variant-numeric: oldstyle-nums;
  font-kerning: normal;
  overflow-wrap: break-word;
}

@media (min-width: 40rem) {
  body { padding: 3rem 1.25rem 4rem; }
}

/* Nothing may be wider than the text column, so the page never scrolls sideways. */
img, svg, video, canvas, iframe {
  max-width: 100%;
}

h1, h2, h3 {
  line-height: 1.25;
  letter-spacing: 0;
}

h1 {
  font-size: 1.9rem;
  font-weight: 600;
  line-height: 1.15;
  margin: 0 0 1rem;
  text-wrap: balance;
}

h2 {
  font-size: 1.3rem;
  font-weight: 600;
  margin: 2.5rem 0 0.75rem;
}

p {
  margin: 0 0 1.1rem;
}

/* Running text: words hyphenated to keep the lines even, and no short last line left on its own. */
main p,
article ol li {
  hyphens: auto;
  hyphenate-limit-chars: 6 3 3;
  text-wrap: pretty;
}

/* Phone lines are too short to justify without gaps between words, so only wider screens get it. */
@media (min-width: 40rem) {
  main p,
  article ol li {
    text-align: justify;
  }
}

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

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

/* Nav */
header {
  margin-bottom: 2.5rem;
}

nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.25rem;
}

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

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

/* Lists of posts */
ul {
  padding: 0;
  list-style: none;
}

li {
  padding: 0.35rem 0;
}

li small {
  display: block;
  color: var(--muted);
  font-size: 0.85rem;
}

li small + small {
  opacity: 0.75;
}

li {
  padding: 0.5rem 0;
}

h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--muted);
  margin: 1.5rem 0 0.25rem;
}

time {
  margin-right: 1rem;
  color: var(--muted);
  font-variant-numeric: lining-nums tabular-nums;
  white-space: nowrap;
}

/* Projects */
section {
  padding: 1.5rem 0;
  border-top: 1px solid var(--rule);
}

section h2 {
  margin-top: 0;
}

/* Blog post */
article > h1 + p {
  margin-top: -0.5rem;
  margin-bottom: 2rem;
}

/* Figures */
:root {
  --hand: #d93025;
  --hand-bg: #fdeceb;
  --learned: #000000;
  --learned-bg: #f2f2f2;
  --learned-line: #c4c4c4;
}

@media (prefers-color-scheme: dark) {
  :root {
    --hand: #ff6b62;
    --hand-bg: #3a1d1b;
    --learned: #e6e6e6;
    --learned-bg: #2b2b2b;
    --learned-line: #555555;
  }
}

figure {
  margin: 2.5rem 0;
  /* Labels inside figures and widgets are set small, in px. Garamond's letters are
     low for their size, so draw them as tall as a sans-serif's at the same size. */
  font-size-adjust: 0.48;
  font-variant-numeric: lining-nums;
}

figure > figcaption {
  font-size-adjust: none;
}

.dag-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}

.dag {
  text-align: center;
}

.dag svg {
  display: block;
  width: 100%;
  max-width: 150px;
  height: auto;
  margin: 0 auto;
  overflow: visible;
}

.dag .io {
  fill: var(--muted);
  font-size: 11px;
  text-anchor: middle;
}

.dag .edge {
  fill: none;
  stroke: var(--learned-line);
  stroke-width: 1.25;
  vector-effect: non-scaling-stroke;
}

.dag .node {
  stroke-width: 1.5;
  vector-effect: non-scaling-stroke;
}

.dag .node.hand { fill: var(--hand-bg); stroke: var(--hand); }
.dag .node.learned { fill: var(--learned-bg); stroke: var(--learned-line); }

.spectrum-axis {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 1rem;
  font-size: 0.85rem;
  white-space: nowrap;
}

.spectrum-axis .axis-line {
  position: relative;
  flex: 1;
  height: 1.5px;
  background: var(--learned-line);
}

.spectrum-axis .axis-line::after {
  content: "";
  position: absolute;
  right: -1px;
  top: 50%;
  width: 7px;
  height: 7px;
  border-top: 1.5px solid var(--learned-line);
  border-right: 1.5px solid var(--learned-line);
  transform: translateY(-50%) rotate(45deg);
}

.dags figcaption {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  margin-top: 1.25rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.dags figcaption span {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.dags .swatch {
  display: inline-block;
  width: 0.8rem;
  height: 0.8rem;
  border-radius: 50%;
  border: 1.5px solid;
}

.dags .swatch.hand { background: var(--hand-bg); border-color: var(--hand); }
.dags .swatch.learned { background: var(--learned-bg); border-color: var(--learned-line); }

.curves svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

.curves .axis {
  fill: none;
  stroke: var(--learned-line);
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

.curves .label {
  fill: var(--muted);
  font-size: 13px;
}

.curves .line {
  fill: none;
  stroke-width: 2.5;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
}

#curve-fe { vector-effect: non-scaling-stroke; }

.curves .line.hand { stroke: var(--hand); }
.curves .line.learned { stroke: var(--learned); }
.curves .line.dashed { stroke-dasharray: 9 9; stroke-linecap: butt; }

.curves figcaption {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.5rem;
  margin-top: 1.25rem;
  font-size: 0.8rem;
}

.curves figcaption span {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.curves .swatch {
  display: inline-block;
  width: 1.5rem;
  height: 2.5px;
  border-radius: 2px;
}

.curves .swatch.hand { background: var(--hand); }
.curves .swatch.learned { background: var(--learned); }
.curves .swatch.mixed {
  background: repeating-linear-gradient(90deg, var(--hand) 0 6px, var(--learned) 6px 12px);
}

@media (max-width: 30rem) {
  .curves .label { font-size: 18px; }

  .dag-row { gap: 0.5rem; }
  .spectrum-axis { font-size: 0.75rem; gap: 0.5rem; }

}

/* Numbered lists in posts, such as the references. Long links break instead of running off the screen. */
article ol {
  margin: 0 0 1.1rem;
  padding-left: 1.6rem;
  list-style: decimal;
  font-size: 0.9rem;
}

article ol li {
  padding: 0.25rem 0;
  overflow-wrap: anywhere;
}

/* Lists inside posts */
.points {
  margin: 0 0 1.1rem;
  padding-left: 1.25rem;
  list-style: disc;
}

ol.points {
  list-style: decimal;
}

.points li {
  padding: 0.2rem 0;
}

/* Verbatim prompts and model outputs */
pre.transcript {
  margin: 0 0 1.1rem;
  padding: 0.75rem 1rem;
  background: var(--learned-bg);
  border-left: 2px solid var(--learned-line);
  font-family: inherit;
  font-size: 0.8rem;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* Draft notes (post-it) */
.note {
  margin: 1.5rem 0;
  padding: 0.75rem 1rem;
  background: #fff4a8;
  color: #3d3500;
  font-size: 0.8rem;
  line-height: 1.5;
  border-radius: 2px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08), 0 4px 10px rgba(0, 0, 0, 0.06);
  transform: rotate(-0.4deg);
}

.note p { margin: 0 0 0.5rem; }
.note p:last-child { margin-bottom: 0; }

.note ul {
  margin: 0 0 0.5rem;
  padding-left: 1.1rem;
  list-style: disc;
}

.note li { padding: 0.1rem 0; }

@media (prefers-color-scheme: dark) {
  .note {
    background: #4a4214;
    color: #f5eaa8;
  }
}

/* Footer */
footer {
  margin-top: 5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--rule);
  color: var(--muted);
  font-size: 0.875rem;
}

/* Citations: underlined text; hover shows the reference; multiple references open a numbered list on click */
.cite {
  position: relative;
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
  cursor: pointer;
}

.cite:hover,
.cite.open {
  text-decoration-thickness: 2px;
}

.cite-multi:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.cite-pop {
  display: none;
  position: absolute;
  left: 0;
  top: calc(100% + 6px);
  z-index: 10;
  width: max-content;
  max-width: min(24rem, calc(100vw - 2rem));
  padding: 0.55rem 0.75rem;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--rule);
  border-radius: 4px;
  box-shadow: 0 4px 16px rgb(0 0 0 / 0.12);
  font-size: 0.8rem;
  line-height: 1.45;
  white-space: normal;
  text-align: left;
  cursor: auto;
}

/* Invisible bridge so the pointer can move from the text into the popover */
.cite-pop::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: -7px;
  height: 7px;
}

.cite:hover > .cite-pop,
.cite:focus-visible > .cite-pop,
.cite.open > .cite-pop {
  display: block;
}

.cite-ref {
  display: block;
}

.cite-url {
  display: block;
  margin-top: 0.2rem;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.cite-list {
  display: block;
  counter-reset: cite;
}

.cite-item {
  display: block;
  counter-increment: cite;
  padding-left: 1.6em;
  text-indent: -1.6em;
}

.cite-item + .cite-item {
  margin-top: 0.35rem;
}

.cite-item::before {
  content: counter(cite) ". ";
  display: inline-block;
  width: 1.6em;
  text-indent: 0;
  color: var(--muted);
}

/* Two-by-two tables */
table.quad {
  border-collapse: collapse;
  width: 100%;
  margin: 1.5rem 0;
  font-size: 0.9em;
}
table.quad th,
table.quad td {
  border: 1px solid var(--rule);
  padding: 0.5rem 0.6rem;
  text-align: left;
  vertical-align: top;
}
table.quad thead th,
table.quad tbody th {
  color: var(--muted);
  font-weight: normal;
}
