* { box-sizing: border-box; }
[id] { scroll-margin-top: 1rem; }
::selection { background: var(--selection); }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: var(--font-text); line-height: var(--leading-body);
  font-variant-numeric: oldstyle-nums proportional-nums; font-kerning: normal;
}
.wrap { max-width: var(--measure); margin: 0 auto; padding: 0 var(--gutter) 96px; }
a { color: var(--red); text-decoration: none; }
a:hover { color: var(--red-hover); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }
/* Links inside running prose carry an underline, so color is not the only cue. Links that
   stand alone (the masthead name, list titles, "more" links) don't. The contact line's
   links are set upright in its italic line instead. */
p:not(.contact, .name, .entry, .more) a:not(sup a):not(.anchor), .ex li > span a, .answers li > span a {
  text-decoration: underline; text-decoration-color: var(--link-line); text-decoration-thickness: 1px; text-underline-offset: 3px;
}
p a:hover { text-decoration-color: currentColor; }
.sc { font-family: var(--font-sc); font-weight: 500; }

/* Skip link: hidden until focused */
.skip { position: absolute; left: -999px; top: 0.5rem; z-index: 10; background: var(--bg); padding: 0.3rem 0.7rem; font-family: var(--font-sc); font-weight: 500; letter-spacing: 0.06em; }
.skip:focus { left: var(--gutter); }

/* Title-page masthead: a double rule above, a single rule below */
.masthead { text-align: center; margin-top: 2.4rem; padding: 1.1rem 0 0.9rem; border-top: var(--rule-double); border-bottom: var(--rule-single); }
.masthead .name { margin: 0; font-family: var(--font-sc); font-size: var(--size-name); font-weight: 500; letter-spacing: 0.1em; line-height: var(--leading-tight); }
.masthead .name a { color: var(--text); }
.masthead .name a:hover { text-decoration: none; color: var(--text); }
/* No indent: off the home page the name is a p, so "p + p" below would indent the motto
   and push it 0.7em right of center. On the home page the name is an h1. */
.masthead .motto { margin: 0.1rem 0 0.5rem; font-style: italic; color: var(--muted); text-indent: 0; }
.masthead nav { display: flex; flex-wrap: wrap; justify-content: center; gap: 0 0.2rem; font-family: var(--font-sc); font-weight: 500; letter-spacing: 0.06em; }
.masthead nav a { color: var(--text); padding: 0 0.3rem; }
.masthead nav a:hover, .masthead nav a[aria-current] { color: var(--red); text-decoration: none; }
.masthead nav a + a::before { content: "\00B7"; color: var(--red); margin-right: 0.6rem; display: inline-block; }
@media (max-width: 640px) { .masthead nav { gap: 0 0.7rem; } .masthead nav a + a::before { display: none; } }


/* Paragraphs: book indents, better line breaks, no hyphens in short words */
p { margin: 0; hyphens: auto; text-wrap: pretty; hyphenate-limit-chars: 7 3 3; }
p + p { text-indent: var(--indent); }
.dropcap::first-letter { float: left; font-size: var(--size-initial); line-height: 0.82; padding: 0.06em 0.1em 0 0; color: var(--red); font-weight: 500; }

/* The recruiter line under the home intro */
.contact { margin-top: var(--space-3); font-style: italic; color: var(--muted); }
p + p.contact { text-indent: 0; }
.contact .sep { color: var(--red); font-style: normal; margin: 0 0.45em; }
.contact a { font-style: normal; }

h2 { font-family: var(--font-sc); font-weight: 500; font-size: var(--size-h2); letter-spacing: 0.06em; color: var(--red); margin: var(--space-5) 0 var(--space-2); line-height: 1.3; }
h2 .n { margin-right: 0.5rem; }
.anchor { font-family: var(--font-text); font-size: 0.85em; letter-spacing: 0; color: var(--muted); margin-left: 0.3em; opacity: 0; }
h2:hover .anchor, .anchor:focus-visible { opacity: 1; }
@media (hover: none) { .anchor { opacity: 0.5; } }

/* Run-in entries: a work item, or an essay in the writing list (DESIGN.md, "Home page") */
.work, .entry { margin-bottom: 0.8rem; }
.work + .work, .entry + .entry, p.more, p.empty { text-indent: 0; }
.work .t, .entry .t { font-weight: 500; }
.work .m, .entry .m { font-style: italic; color: var(--muted); }
p.more { font-style: italic; }
p + .entries { margin-top: var(--space-3); }
.plain { list-style: none; margin: 0; padding: 0; }
.plain li { margin: 0 0 0.35rem; padding-left: 1.1rem; position: relative; }
.plain li::before { content: "\2013"; color: var(--red); position: absolute; left: 0; }
.plain .m { color: var(--muted); font-style: italic; }

/* Essay heading */
.essay-head { text-align: center; margin-bottom: var(--space-4); }
.essay-head h1 { font-weight: 500; font-size: var(--size-title); line-height: 1.2; margin: 0 0 var(--space-2); text-wrap: balance; }
.essay-head .by { font-style: italic; text-indent: 0; }
.essay-head .date { font-family: var(--font-sc); font-weight: 500; letter-spacing: 0.08em; color: var(--red); text-indent: 0; font-size: 0.9rem; }
.fleuron { text-align: center; color: var(--red); margin: 1.2rem 0; font-size: 1.1rem; text-indent: 0; }
.essay-foot { margin-top: var(--space-5); text-align: center; font-style: italic; color: var(--muted); }
.essay-foot p { text-indent: 0; }
.abstract { font-style: italic; margin: 0 1.5rem 1.6rem; text-align: center; color: var(--muted); }
@media (max-width: 640px) { .abstract { margin: 0 0 1.4rem; } }

/* Math */
math { font-family: var(--font-math); font-size: 1.04em; }
.eq { margin: 1rem 0; text-align: center; }
.eq.num { display: flex; align-items: center; }
.eq.num math { flex: 1; }
.eq .no { color: var(--muted); margin-left: 0.5rem; }
.nowrap { white-space: nowrap; }

/* Code: a fade appears at whichever edge has more code beyond it */
code, pre { font-family: var(--font-code); font-variant-numeric: normal; }
code { font-size: 0.86em; }
p code, li code { white-space: nowrap; }  /* inline code never splits; keep it short */
pre {
  tab-size: 4; font-size: var(--size-code); line-height: 1.5; padding: 0.9rem 1rem; margin: 1rem 0; overflow-x: auto;
  background:
    linear-gradient(to right, var(--code-bg) 40%, transparent) left center / 2.5rem 100% no-repeat local,
    linear-gradient(to left, var(--code-bg) 40%, transparent) right center / 2.5rem 100% no-repeat local,
    linear-gradient(to right, var(--code-shade), transparent) left center / 1.2rem 100% no-repeat scroll,
    linear-gradient(to left, var(--code-shade), transparent) right center / 1.2rem 100% no-repeat scroll,
    var(--code-bg);
}
pre code { font-size: inherit; }
/* Highlighting (lib/code_highlight.dart, Pandoc's token classes): keywords and control
   flow bold, comments and documentation italic in --muted; every other token keeps
   the text color, so code stays in the site's two colors. */
pre code :is(.kw, .cf) { font-weight: 700; }
pre code :is(.co, .do, .an, .cv, .in, .wa) { font-style: italic; color: var(--muted); }
.k { font-weight: 700; }
.c { color: var(--muted); font-style: italic; }

/* Table */
figure { margin: 1.4rem 0; }
.table-scroll { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: var(--size-note); font-variant-numeric: oldstyle-nums tabular-nums; }
caption { caption-side: top; text-align: left; font-style: italic; margin-bottom: 0.45rem; }
caption .sc { font-style: normal; color: var(--red); margin-right: 0.3em; letter-spacing: 0.05em; }
thead th { font-family: var(--font-sc); font-weight: 500; letter-spacing: 0.04em; border-top: var(--rule-table-outer); border-bottom: var(--rule-table-inner); }
tbody tr:last-child td { border-bottom: var(--rule-table-outer); }
th, td { text-align: left; padding: 0.3rem 0.7rem 0.3rem 0; vertical-align: top; }

/* Knuth-style algorithms, in red and black */
.algorithm { margin: 1.1rem 0 1.3rem; }
.algorithm .head { text-indent: 0; margin-bottom: 0.4rem; }
.algorithm .name { font-family: var(--font-sc); font-weight: 500; letter-spacing: 0.05em; color: var(--red); }
.algorithm ol { list-style: none; margin: 0; padding: 0; }
.algorithm li { padding-left: var(--hang); text-indent: calc(-1 * var(--hang)); margin-bottom: 0.3rem; }
.algorithm .step { display: inline-block; width: var(--hang); text-indent: 0; font-weight: 500; color: var(--red); }
.qed { color: var(--red); }

/* Exercises and answers */
h2.exercises { text-align: center; letter-spacing: 0.14em; font-size: 1rem; margin: 2.2rem 0 0.9rem; }
.ex { list-style: none; margin: 0; padding: 0; font-size: var(--size-small); }
.ex li { position: relative; padding-left: 2.4rem; margin-bottom: 0.6rem; }
.ex .no { position: absolute; left: 0; width: 1.9rem; text-align: right; color: var(--text); text-decoration: none; }
.ex .rec { position: absolute; left: -0.9rem; color: var(--red); }
.ex .rating { font-style: italic; color: var(--red); margin-right: 0.35em; }
.ex .rating .b { font-style: normal; }
.answers .back { margin-left: 0.3em; }

/* Notes */
sup.fn { font-size: 0.7em; line-height: 0; }
/* Footnote marks get a fingertip-sized target without moving the text */
sup.fn a { display: inline-block; line-height: 1; padding: 0.5em 0.7em; margin: -0.5em -0.55em; }
.footnotes { font-size: var(--size-note); }
.footnotes ol { margin: 0; padding-left: 1.4em; }
.footnotes li::marker { color: var(--red); }
.footnotes li { margin-bottom: 0.3rem; }

/* Briefly mark whatever a link just jumped to */
.footnotes li:target, .ex li:target, .algorithm li:target, h2:target {
  background: var(--highlight); outline: 0.3rem solid var(--highlight);
}

.site-foot { margin-top: 3.5rem; padding-top: 0.8rem; border-top: var(--rule-single); text-align: center; font-style: italic; display: flex; flex-wrap: wrap; justify-content: center; gap: 0.2rem 1.2rem; }

/* Footnotes as the markdown package renders them */
section.footnotes { margin-top: 0; }
.footnote-ref a, sup a[href^="#fn"] { display: inline-block; line-height: 1; padding: 0.5em 0.7em; margin: -0.5em -0.55em; }
sup { font-size: 0.7em; line-height: 0; }
a.footnote-backref { margin-left: 0.2em; }
.footnotes li p { text-indent: 0; display: inline; }

/* Résumé page (lib/components/resume_view.dart): run-in entries like the home page's */
.resume .contact { margin-top: 0; }
.resume .contact + .contact { margin-top: var(--space-1); }
.resume .summary { margin-top: var(--space-4); text-indent: 0; }
.resume .contact a { white-space: nowrap; }
.resume .contact .sep { margin: 0 0.2em 0 0.45em; }
.resume .run { text-indent: 0; }
.resume .run .t { font-weight: 500; }
.resume .run .m { font-style: italic; color: var(--muted); }
.resume p.run + p.run { margin-top: var(--space-1); }
.resume .role { margin-bottom: var(--space-3); }
.resume .role .plain { margin-top: var(--space-1); }
.resume .lead { font-style: italic; }
.resume .downloads .files { display: block; }
.resume .downloads .files a { white-space: nowrap; }
.resume .downloads .sep { color: var(--red); margin: 0 0.45em; }

/* Markdown output mapped onto design J */
.essay h2:first-of-type + p::first-letter { float: left; font-size: var(--size-initial); line-height: 0.82; padding: 0.06em 0.1em 0 0; color: var(--red); font-weight: 500; }
.page-title { font-weight: 500; font-size: var(--size-title); line-height: 1.2; text-align: center; margin: var(--space-6) 0 var(--space-4); }
main > ul { list-style: none; margin: 0; padding: 0; }
main > ul > li { margin: 0 0 0.35rem; padding-left: 1.1rem; position: relative; }
main > ul > li::before { content: "\2013"; color: var(--red); position: absolute; left: 0; }
main > ul .m { color: var(--muted); font-style: italic; }
main { padding-top: var(--space-5); }
main.essay, main:has(> .page-title) { padding-top: 0; }
.algorithm > .lead, .algorithm > .lead + p { display: inline; }
.algorithm > ol { margin-top: var(--space-2); }
.content > .table-scroll, main > table { margin: 1.4rem 0; }

/* Markdown inside a component arrives as a paragraph; keep it inline in the list item */
.algorithm li > p, .ex li > span > p { display: inline; text-indent: 0; }

/* Print: black ink on white, no masthead rules or navigation, URLs after links
   (DESIGN.md, "Print"). Written for the résumé page; other pages print the same way. */
@media print {
  @page { margin: 0.6in 0.7in; }
  :root { font-size: 10.5pt; }
  body { background: #fff; color: #000; }
  .wrap { max-width: none; padding: 0; }
  .skip, .masthead nav, .masthead .motto, .site-foot, .anchor, #downloads, .downloads, .resume .contact + .contact { display: none; }
  .masthead { border: 0; margin: 0; padding: 0 0 0.4rem; }
  main { padding-top: 0; }
  .page-title { display: none; }
  a, h2, .sep, .contact .sep, .plain li::before, .m, .contact { color: #000 !important; }
  a { text-decoration: none !important; }
  a[href^="http"]:not(.bare)::after { content: " (" attr(href) ")"; font-size: 0.9em; }
  h2 { margin: 1rem 0 0.3rem; break-after: avoid; }
  li, .run { break-inside: avoid; }
}
