@font-face { font-family: "Libertinus Serif"; src: url("fonts/libertinus-serif-latin-400-normal.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Libertinus Serif"; src: url("fonts/libertinus-serif-latin-400-italic.woff2") format("woff2"); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: "Libertinus Serif"; src: url("fonts/libertinus-serif-latin-700-normal.woff2") format("woff2"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Libertinus Math"; src: url("fonts/libertinus-math-latin-400-normal.woff2") format("woff2"); font-display: swap; }
@font-face { font-family: "Caveat"; src: url("fonts/caveat-latin-500-normal.woff2") format("woff2"); font-weight: 500; font-display: swap; }

:root {
  --paper: #fdfcf7;
  --rule: #c5d6ec;          /* the blue lines */
  --margin-line: #eeb0ad;   /* the red margin line */
  --ink: #23262d;
  --ink-soft: #6a707c;
  --pen: #24408e;           /* ballpoint blue, for links */
  --postit: #fde96b;
  --line: 30px;             /* spacing of the ruled lines */
  --text: 39rem;            /* width of the text itself */
  --fade: 4.5rem;           /* how far the lines take to fade out beside the text */
  --note: 11.5rem;          /* post-it size */
  /* The red margin line slides in from 4.5rem as the window narrows, and the text always
     starts to the right of it, so the line is visible at every width. */
  --margin-x: clamp(1.6rem, 8vw, 4.5rem);
  --pad-l: max(var(--margin-x) + 1.05rem, (100% - var(--text)) / 2);   /* space left of the text */
  --pad-r: max(1.1rem, (100% - var(--text)) / 2);                      /* space right of it */
  --fade-l: min(var(--fade), var(--pad-l) - var(--margin-x) - 0.15rem);
  --fade-r: min(var(--fade), var(--pad-r));
  --serif: "Libertinus Serif", "Linux Libertine", Georgia, "Times New Roman", serif;
  --hand: "Caveat", "Segoe Print", "Bradley Hand", cursive;
}

* { box-sizing: border-box; }

html {
  background-color: var(--paper);
  /* red margin line, then the ruled lines; both scroll with the page */
  background-image:
    linear-gradient(90deg, transparent var(--margin-x), var(--margin-line) var(--margin-x), var(--margin-line) calc(var(--margin-x) + 1.5px), transparent calc(var(--margin-x) + 1.5px)),
    repeating-linear-gradient(transparent 0, transparent calc(var(--line) - 1px), var(--rule) calc(var(--line) - 1px), var(--rule) var(--line));
  background-position: 0 0, 0 1.5rem;
}

body {
  margin: 0;
  color: var(--ink);
  font: 1.19rem/1.55 var(--serif);
  text-rendering: optimizeLegibility;
  -webkit-text-size-adjust: 100%;
}

/* The blank strip down the middle: same paper, but the lines fade out before they reach the text. */
.sheet {
  min-height: 100vh;
  padding: 1.5rem var(--pad-r) 3rem var(--pad-l);
  background: linear-gradient(90deg,
    transparent calc(var(--pad-l) - var(--fade-l)),
    var(--paper) calc(var(--pad-l) - 0.3 * var(--fade-l)),
    var(--paper) calc(100% - var(--pad-r) + 0.3 * var(--fade-r)),
    transparent calc(100% - var(--pad-r) + var(--fade-r)));
  display: flex;
  flex-direction: column;
}
main { flex: 1; }
main::after { content: ""; display: block; clear: both; }

/* ---------- header / footer ---------- */
header.site {
  /* floats at the top of the window while the page scrolls underneath */
  position: sticky;
  top: 0;
  z-index: 10;
  margin-top: -1.5rem;
  padding: 0.7rem 0 0.45rem;
  background: var(--paper);
  border-bottom: 1px solid var(--rule);
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 3rem;
  font-family: var(--hand);
  font-size: 1.5rem;
  line-height: 1.2;
}
header.site a { color: var(--ink); text-decoration: none; }
header.site .name { font-size: 1.9rem; }
header.site nav { display: flex; gap: 1.25rem; }
header.site nav a { color: var(--pen); }
header.site a:hover { text-decoration: underline wavy 1.5px; text-underline-offset: 4px; }

footer.site {
  margin-top: 4rem;
  font-family: var(--hand);
  font-size: 1.2rem;
  color: var(--ink-soft);
  text-align: center;
}

/* ---------- text ---------- */
h1 {
  font: 500 3.1rem/1.05 var(--hand);
  margin: 0 0 0.5rem;
  text-wrap: balance;
}
h2, h3, h4 { font-family: var(--serif); line-height: 1.2; margin: 2.2rem 0 0.6rem; text-wrap: balance; }
h2 { font-size: 1.55rem; }
h3 { font-size: 1.25rem; font-style: italic; font-weight: 400; }
h4 { font-size: 1.05rem; }
p { margin: 0 0 1rem; }
.date { font-family: var(--hand); font-size: 1.35rem; color: var(--ink-soft); margin-bottom: 2rem; }

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

ul, ol { padding-left: 1.4rem; margin: 0 0 1rem; }
li { margin-bottom: 0.25rem; }
main ul, main ol { display: flow-root; }   /* lists sit beside a tucked-in post-it instead of running under it */
blockquote { margin: 1.25rem 0; padding-left: 1rem; border-left: 2px solid var(--rule); color: var(--ink-soft); font-style: italic; }
hr { border: 0; border-top: 1px solid var(--rule); margin: 2.5rem 0; }

code { font: 0.82em/1.5 ui-monospace, "SF Mono", Menlo, Consolas, monospace; }
:not(pre) > code { background: #eef2f8; padding: 0.1em 0.3em; border-radius: 3px; }
pre {
  overflow-x: auto;
  margin: 1.25rem 0;
  padding: 0.8rem 1rem;
  background: #f4f6fa;
  border: 1px solid #dfe6f0;
  border-radius: 3px;
}

math { font-family: "Libertinus Math", "STIX Two Math", "Cambria Math", math; font-size: 1.05em; }
math[display="block"] { margin: 1.25rem 0; overflow-x: auto; overflow-y: hidden; padding: 0.15rem 0; }

figure { margin: 1.5rem 0; text-align: center; }
figure > img, figure > svg { max-width: 100%; height: auto; margin: 0 auto; }
figcaption { font-size: 0.95rem; color: var(--ink-soft); margin-top: 0.5rem; }
table { border-collapse: collapse; margin: 0 auto; font-variant-numeric: tabular-nums; }
td, th { padding: 0.3rem 0.8rem; border-bottom: 1px solid var(--rule); text-align: left; }
main > img { max-width: 100%; height: auto; }

section[role="doc-endnotes"] { margin-top: 3rem; padding-top: 1rem; border-top: 1px solid var(--rule); font-size: 1rem; color: var(--ink-soft); }
section[role="doc-endnotes"] ol { padding: 0; }
section[role="doc-endnotes"] sup { margin-right: 0.4em; }

/* ---------- post list ---------- */
ul.posts { list-style: none; padding: 0; margin-top: 2rem; }
ul.posts li { display: grid; grid-template-columns: 1fr auto; column-gap: 1rem; align-items: baseline; margin-bottom: 1.5rem; }
ul.posts a { font-size: 1.35rem; text-decoration: none; }
ul.posts a:hover { text-decoration: underline wavy 1px; }
ul.posts time { font-family: var(--hand); font-size: 1.2rem; color: var(--ink-soft); white-space: nowrap; }
ul.posts p { grid-column: 1 / -1; margin: 0.15rem 0 0; color: var(--ink-soft); font-size: 1.05rem; }

/* ---------- post-its ---------- */
.postit {
  --tilt: 2deg;
  position: relative;
  width: var(--note);
  min-height: var(--note);
  padding: 1.1rem 0.75rem 0.7rem;
  /* a slightly darker band along the top, where the glue strip is */
  background: linear-gradient(rgba(170, 130, 0, 0.13), rgba(170, 130, 0, 0) 1.6rem), var(--postit);
  color: #2a2718;
  font: 500 1.3rem/1.15 var(--hand);
  text-align: center;
  transform: rotate(var(--tilt));
  /* tight shadow at the stuck top, looser at the bottom where the paper lifts */
  box-shadow: 0 1px 1px rgba(60, 50, 0, 0.18), 0 10px 9px -7px rgba(40, 35, 0, 0.42);
  border-bottom-right-radius: 3.5rem 0.4rem;
}
/* vary the crookedness so a page of notes doesn't look stamped */
.postit:nth-of-type(3n + 1) { --tilt: -2.5deg; }
.postit:nth-of-type(3n + 2) { --tilt: 1.5deg; }
.postit:nth-of-type(3n)     { --tilt: 3.5deg; }
.postit.left:nth-of-type(odd) { --tilt: -3.5deg; }

.postit img {
  display: block;
  width: 100%;
  height: auto;
  /* lets a scanned pen drawing on white sit straight on the yellow */
  mix-blend-mode: multiply;
}
.postit p { margin: 0.25rem 0 0; hyphens: none; }
.postit math { font-size: 0.85em; }

/* Small screens: the note sits in the flow, centred. */
.postit { margin: 1.75rem auto; }

/* Medium: tucked into the text, hanging a little over the edge. */
@media (min-width: 40rem) {
  .postit { --note: 10.5rem; margin: 0.4rem -2.5rem 1rem 1.5rem; float: right; clear: right; }
  .postit.left { margin: 0.4rem 1.5rem 1rem -2.5rem; float: left; clear: left; }
}

/* While notes are tucked into the text, a new section starts below them, not beside them. */
@media (min-width: 40rem) and (max-width: 77.99rem) { main h2, main h3 { clear: both; } }

/* Wide: stuck out on the lined paper beside the text. */
@media (min-width: 78rem) {
  .postit { --note: 11.5rem; margin: 0 calc(-1 * (var(--note) + var(--fade) + 1rem)) 1.5rem 0; }
  .postit.left { margin: 0 0 1.5rem calc(-1 * (var(--note) + var(--fade) + 1rem)); }
}

/* A big note sitting in the text itself, for diagrams. */
.postit svg { display: block; width: 100%; height: auto; }
.postit.wide, .postit.wide.wide {
  float: none; clear: both;
  width: min(100%, 27rem);
  min-height: 0;
  margin: 2.25rem auto;
  padding: 1.2rem 1rem 0.9rem;
  --tilt: -1.2deg;
}

/* Phones: slightly darker lines so the narrow notebook margin still reads. */
@media (max-width: 40rem) {
  html {
    background-image:
      linear-gradient(90deg, transparent var(--margin-x), var(--margin-line) var(--margin-x), var(--margin-line) calc(var(--margin-x) + 1.5px), transparent calc(var(--margin-x) + 1.5px)),
      repeating-linear-gradient(transparent 0, transparent calc(var(--line) - 1px), #b4c8e4 calc(var(--line) - 1px), #b4c8e4 var(--line));
  }
  body { font-size: 1.1rem; }
  h1 { font-size: 2.5rem; }
}

@media print {
  header.site { position: static; }
  html { background: none; }
  .sheet { background: none; }
}

/* ---------- landing page ---------- */
/* on the home page the big name is in the hero; the header copy fades in once that scrolls away */
body.home header.site .name { opacity: 0; visibility: hidden; transition: opacity 0.2s, visibility 0.2s; }
body.home.scrolled header.site .name { opacity: 1; visibility: visible; }
@media (prefers-reduced-motion: reduce) { body.home header.site .name { transition: none; } }
body.home header.site { margin-bottom: 1.5rem; }

.hero { margin-bottom: 1rem; }
.hero::after { content: ""; display: block; clear: both; }
.hero h1 { margin: 0 0 0.1rem; font-size: 3.4rem; }
.hero .tagline { font: 500 1.55rem/1.2 var(--hand); color: var(--ink-soft); margin-bottom: 1.4rem; }

/* a photo print stuck to the top corner of the page, by tape or a paperclip */
.portrait {
  position: relative;
  float: right;
  width: 11.5rem;
  margin: 0.6rem -2.75rem 1rem 2rem;
  padding: 0.5rem 0.5rem 0.55rem;
  background: #fff;
  box-shadow: 0 1px 2px rgba(30, 35, 50, 0.22), 0 12px 14px -9px rgba(30, 35, 50, 0.45);
  transform: rotate(3deg);
  transform-origin: 50% 0;
}
.portrait img { display: block; width: 100%; height: auto; aspect-ratio: 1; object-fit: cover; }
/* tape across the top edge; it is a button, and tapping it is an easter egg */
.portrait { z-index: 5; }
.tape-strip {
  position: absolute;
  top: -0.75rem; left: 50%;
  width: 5.5rem; height: 1.6rem;
  padding: 0; border: 0;
  transform: translateX(-50%) rotate(-3deg);
  background: rgba(238, 228, 190, 0.75);
  box-shadow: 0 1px 1px rgba(60, 50, 20, 0.18);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.tape-strip::after { content: ""; position: absolute; inset: -0.6rem; }   /* roomier tap target */
/* after the photo has dropped off the page: an empty spot and a note */
.portrait.fallen { background: none; box-shadow: none; transform: rotate(3deg); }
.portrait.fallen > * { visibility: hidden; }
.portrait.fallen::after {
  content: "oops.";
  position: absolute; inset: 0;
  display: grid; place-items: center;
  font: 500 1.6rem var(--hand); color: var(--ink-soft);
  animation: note-in 0.6s 0.2s both;
}
@keyframes note-in { from { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .portrait.fallen::after { animation: none; } }

/* The clip: only the front wire is drawn, so it reads as hooked over the print's top edge.
   The print's edge sits at y=26 of the 40x84 drawing. */
.portrait.clip::before {
  content: "";
  position: absolute;
  left: 1.6rem;
  top: -1.3rem;
  width: 2rem;
  height: 4.2rem;
  transform: rotate(-7deg);
  background: url("paperclip.svg") no-repeat center / contain;
  filter: drop-shadow(0 1.5px 1px rgba(20, 25, 40, 0.35));
  z-index: 1;
}

ul.links { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 0.3rem 1.4rem; }
ul.links li { margin: 0; }

/* section headings are jotted, like the rest of the handwriting on the page */
.home h3 { font: 500 2.1rem/1.1 var(--hand); margin: 2.75rem 0 0.8rem; clear: both; }

dl.timeline { display: grid; grid-template-columns: max-content 1fr; gap: 0.7rem 1.5rem; align-items: baseline; margin: 0; }
dl.timeline dt { font: 500 1.4rem/1.1 var(--hand); color: var(--pen); white-space: nowrap; }
dl.timeline dd { margin: 0; }
.home ul.posts { margin-top: 0; }
.home ul.posts li { margin-bottom: 1rem; }
.home ul.posts a { font-size: 1.19rem; }

@media (max-width: 40rem) {
  .portrait { width: 8.5rem; margin: 0.4rem -0.25rem 0.75rem 1rem; }
  .hero h1 { font-size: 2.7rem; }
  dl.timeline { grid-template-columns: 1fr; gap: 0.1rem; }
  dl.timeline dd { margin-bottom: 0.8rem; }
}

/* term lists (Typst `/ Term: description`), used for research interests */
main > dl:not(.timeline) dt { font-weight: 700; margin-top: 0.9rem; }
main > dl:not(.timeline) dd { margin: 0.1rem 0 0; }
html { scroll-padding-top: 4.5rem; }   /* so in-page links are not hidden under the floating header */

/* Until there is real margin on the right, right-hand notes and the photo barely overhang the text. */
@media (min-width: 40rem) and (max-width: 56.99rem) { .postit:not(.left):not(.wide), .hero .portrait { margin-right: -0.4rem; } }
