/* dek-vita. Text-first and typographically plain, in keeping with the subject.
   Good Unicode coverage matters more than anything else here: the entries carry
   Latin Extended, Greek, Cyrillic and a few CJK characters, so the stack is
   built from fonts that ship with operating systems rather than anything
   loaded over the network. No external requests of any kind. */

:root {
  --ink: #16150f;
  --dim: #5c584c;
  --faint: #8a8577;
  --rule: #ded9c9;
  --bg: #fbfaf5;
  --panel: #f3f0e5;
  --link: #1b4d7a;
  --mark: #8a3a12;
  --measure: 40rem;
  color-scheme: light;
}
/* Dark is opt-in, never automatic: a reader asks for it with the footer
   button, and the choice is remembered. color-scheme comes along so that the
   selects, the number fields and the scrollbars follow the page. */
:root[data-theme="dark"] {
  --ink: #e8e4d8; --dim: #a9a394; --faint: #7d7768; --rule: #35332c;
  --bg: #14130f; --panel: #1d1c16; --link: #8fbde4; --mark: #e0a074;
  color-scheme: dark;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua",
               Charter, "Bitstream Charter", Georgia, "Noto Serif", "DejaVu Serif",
               "Liberation Serif", serif;
  font-size: 1.05rem;
  line-height: 1.55;
  text-rendering: optimizeLegibility;
}

a { color: var(--link); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }

code, .tt { font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, "DejaVu Sans Mono", monospace; font-size: .92em; }
/* A URL has no spaces, so without this it is one unbreakable word: the widest
   one (82 characters, in Q225) set the width of the whole papers page and gave
   a phone a horizontal scrollbar across every entry, not just that line.
   "anywhere" rather than "break-word" because only "anywhere" also lowers the
   min-content width, and min-content is what the grid was sizing itself to;
   "break-word" wraps the word and leaves the page just as wide. The text is
   untouched -- the full URL is still there, still selectable, still the link. */
code { overflow-wrap: anywhere; }

.skip { position: absolute; left: -9999px; }
.skip:focus { left: 1rem; top: .5rem; background: var(--panel); padding: .4rem .7rem; z-index: 10; }

/* ---- frame ---------------------------------------------------------- */
header.site, footer.site, main { max-width: var(--measure); margin: 0 auto; padding: 0 1rem; }
main { padding-bottom: 4rem; }
/* The nav on the left, the theme button at the top right, both starting at
   the top so the button sits on the site title's line. */
header.site { display: grid; grid-template-columns: 1fr auto; align-items: start; border-bottom: 1px solid var(--rule); margin-bottom: 2rem; padding-top: 1.2rem; }

/* Which of the two the button shows is a CSS question, so the script has only
   one attribute to set and neither icon nor label is ever built at runtime.
   display:none also takes the wrong label out of the accessibility tree, so
   the button is named by whichever one is showing. */
#theme {
  display: inline-flex; align-items: center; justify-content: center;
  width: 2rem; height: 2rem; padding: 0; cursor: pointer; border-radius: .25rem;
  background: none; color: var(--faint); border: 1px solid transparent;
}
#theme:hover { color: var(--ink); border-color: var(--rule); background: var(--panel); }
#theme:focus-visible { outline: 2px solid var(--link); outline-offset: 1px; }
#theme .icon { display: block; }
#theme .when-dark { display: none; }
:root[data-theme="dark"] #theme .when-light { display: none; }
:root[data-theme="dark"] #theme .when-dark { display: inline; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
header.site nav > a { font-weight: 600; text-decoration: none; color: var(--ink); }
header.site ul { list-style: none; display: flex; flex-wrap: wrap; gap: 1rem; padding: 0; margin: .5rem 0 1rem; }
footer.site { border-top: 1px solid var(--rule); padding-top: 1rem; margin-top: 3rem; color: var(--dim); font-size: .9rem; }


h1 { font-size: 1.7rem; line-height: 1.2; margin: 0 0 .6rem; font-weight: 600; }
h2 { font-size: 1.22rem; margin: 2.2rem 0 .6rem; font-weight: 600; }
h3 { font-size: 1rem; margin: 0; font-weight: 600; }
.lede { color: var(--dim); margin-top: 0; }

/* ---- the page's own contents ---------------------------------------- */
nav.toc { display: flex; flex-wrap: wrap; gap: .4rem; margin: 0 0 1rem; }
nav.toc a {
  display: inline-block; padding: .2rem .6rem; border: 1px solid var(--rule);
  border-radius: .2rem; text-decoration: none; color: var(--ink); background: var(--panel);
}
nav.toc a:hover { border-color: var(--faint); }
nav.toc .n { color: var(--dim); font-variant-numeric: tabular-nums; }
.group > h2 { scroll-margin-top: .5rem; }
/* A year heading is a marker in a running list, not a section title. */
.group.year > h2 { font-size: 1rem; color: var(--dim); font-variant-numeric: tabular-nums; margin: 1.6rem 0 0; }

/* ---- entries -------------------------------------------------------- */
.entry { display: grid; grid-template-columns: 4.2rem 1fr; gap: .2rem .6rem; padding: .75rem 0; border-top: 1px solid var(--rule); }
.entry h3 { color: var(--faint); font-variant-numeric: tabular-nums; }
.entry .permalink { color: var(--faint); text-decoration: none; }
.entry:target { background: var(--panel); }
.entry .body p { margin: 0; }
.entry .body .title { font-weight: 600; }
/* A first sentence that swallowed its own citation is not a title (P96, Q171,
   the fourteen forewords): it is set plain rather than claimed as one. */
.entry .body .title.plain { font-weight: 400; }
/* A leading "(with ...)" is attribution, not title, so the bold stops at it
   and it takes the citation's colour. Knuth's word order is untouched. */
.entry .body .title .by { font-weight: 400; color: var(--dim); }
.entry .body .cite, .entry .body .note { color: var(--dim); }
.entry .star { color: var(--mark); }

/* The republication history is most of a long entry and is rarely what a
   reader came for, so it is present but folded away. */
.reprints { margin: .4rem 0 0; font-size: .92rem; color: var(--dim); }
.reprints > summary { cursor: pointer; color: var(--dim); width: max-content; }
.reprints > summary:hover { color: var(--ink); }
.reprints > ul { margin: .3rem 0 0; padding-left: 1.1rem; }
.reprints > ul > li { margin: .15rem 0; }

/* The chip sits under the entry by default and, on a screen wide enough to
   spare the room, in a column of its own. That column is hung in the right
   margin rather than carved out of the text, so the entries keep their
   measure: 308 of the 520 entries have no chip at all, and narrowing every
   line of the page to make room for them would be a poor trade. */
.entry > .chips { grid-column: 2; align-self: start; }
@media (min-width: 58rem) {
  /* 7.5rem of column and .6rem of gap are given back by the negative margin,
     so the 1fr text column stays exactly the 33.2rem it was. */
  .entry { grid-template-columns: 4.2rem 1fr 7.5rem; margin-right: -8.1rem; }
  .entry > .chips { grid-column: 3; margin-top: .15rem; }
}

.chips { margin: .4rem 0 0; display: flex; flex-wrap: wrap; gap: .3rem; }
.chip {
  display: inline-block; font-size: .8rem; line-height: 1.4; padding: .1rem .45rem;
  border: 1px solid var(--rule); border-radius: .8rem; background: var(--panel);
  color: var(--dim); text-decoration: none;
}
.chip:hover { color: var(--ink); border-color: var(--faint); }
.chip.excerpt { border-style: dashed; }

/* ---- books ---------------------------------------------------------- */
.shelf > .lede { margin-bottom: 0; }
.book { border-top: 1px solid var(--rule); padding: 1rem 0; }
.book h3 { margin: 0 0 .3rem; font-size: 1.05rem; }
.book .text { margin: 0; }
.isbn, .note { color: var(--dim); font-size: .88rem; }
.more { font-size: .92rem; }
details summary { cursor: pointer; color: var(--dim); font-size: .9rem; margin-top: .4rem; }
ul.subs { list-style: none; padding-left: 0; margin: .6rem 0 0; }
ul.subs li { border-left: 2px solid var(--rule); padding: .35rem 0 .35rem .7rem; margin-bottom: .2rem; }
.tag { display: block; font-size: .76rem; text-transform: lowercase; letter-spacing: .03em; color: var(--faint); }

/* ---- volume contents ------------------------------------------------ */
table.toc { width: 100%; border-collapse: collapse; margin-top: .5rem; }
table.toc th { text-align: left; font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--faint); font-weight: 600; border-bottom: 1px solid var(--rule); padding: .3rem .4rem; }
table.toc td { vertical-align: baseline; border-bottom: 1px solid var(--rule); padding: .45rem .4rem; }
table.toc td.num { text-align: right; color: var(--faint); font-variant-numeric: tabular-nums; white-space: nowrap; width: 3rem; }
/* Same bug, same fix: automatic table layout sizes a column to its longest
   unbreakable word, and "Communications" is wider than this column on a 320px
   screen, so the contents table scrolled the page sideways. Scoped to the
   source column on purpose -- applying it to the whole row broke chapter
   titles into "developme/nt of programm/ing languages", and they are not what
   overflows. table-layout: fixed also removes the scrollbar, but by lapping
   the title column over this one, which is worse than the scrollbar was. */
table.toc td.sources { font-size: .88rem; color: var(--dim); overflow-wrap: anywhere; }
.src { margin-bottom: .15rem; }
.src .venue { font-style: italic; }
.src .mod, .remark { color: var(--faint); font-size: .95em; }
/* Not italic: in the source column italic already means "publication title"
   (.venue), and 11 of the 14 remarks are plain prose -- "never before
   published", "rejected sequel to P1". They are the same kind of aside as
   .mod's "with corrections", so they are set the same way. The three that do
   name a book ("from TeX: The Program") carry no markup of their own, so the
   italic was never marking the title anyway; it covered the "from" too. */
.remark { display: block; }
.warn { display: inline-block; font-size: .72rem; color: var(--mark); border: 1px solid var(--mark); border-radius: .8rem; padding: 0 .4rem; margin-left: .3rem; }
tr.differs td.num { border-left: 2px solid var(--mark); }

/* ---- home / about --------------------------------------------------- */
/* The front page's two lists: where the data comes from, and what is here.
   Scoped with `>` throughout, because ul.volumes nests inside ul.what and also
   uses a .what span of its own -- an unscoped `ul.what a` would bold all nine
   volume titles along with the two section links. */
ul.sources { margin: .6rem 0 0; padding-left: 1.1rem; }
ul.sources > li { margin: .35rem 0; }
ul.what { margin: 1rem 0 0; padding-left: 1.1rem; }
ul.what > li { margin: .45rem 0; }
ul.what > li > a { font-weight: 600; }
ul.what > li > .detail { color: var(--dim); }
ul.what ul.volumes { margin: .45rem 0 .2rem; }
/* Previous/next volume, at the foot of a volume page.
   A lone "next" (on Literate Programming, which has no previous) is pushed
   right by margin-left:auto, so "next" is always on the right whether or not
   it has a partner -- space-between alone would left-align it. */
nav.seq { display: flex; flex-wrap: wrap; gap: 1rem; justify-content: space-between;
  margin-top: 2.5rem; padding-top: 1rem; border-top: 1px solid var(--rule); }
nav.seq a { flex: 1 1 14rem; text-decoration: none; }
nav.seq .next { margin-left: auto; text-align: right; }
nav.seq .dir { display: block; color: var(--faint); font-size: .82rem; }
nav.seq .what { text-decoration: underline; }
nav.seq .code { color: var(--faint); font-size: .82rem; letter-spacing: .06em; font-weight: 600; }

ul.volumes { list-style: none; padding: 0; }
/* Two real columns, not a code with a min-width: on a narrow screen the title
   wraps, and inline flow put the second line -- and the year after it -- back
   under the code instead of under the title. */
ul.volumes li { display: grid; grid-template-columns: 2.2rem 1fr; gap: 0 .4rem; align-items: baseline; padding: .2rem 0; }
ul.volumes .code { color: var(--faint); font-size: .82rem; letter-spacing: .06em; font-weight: 600; }
ul.volumes .year, .src .year { color: var(--faint); font-variant-numeric: tabular-nums; }

/* ---- filters (revealed by JS only) ---------------------------------- */
.filters { background: var(--panel); border: 1px solid var(--rule); border-radius: .4rem; padding: .6rem .8rem; margin: 1rem 0 1.5rem; font-size: .9rem; }
.filters .row { display: flex; flex-wrap: wrap; gap: .5rem .9rem; align-items: baseline; margin: .35rem 0; }
.filters label { display: inline-flex; gap: .35rem; align-items: baseline; color: var(--dim); }
.filters .find { flex: 1; }
.filters .find input { flex: 1; min-width: 12rem; }
/* Choosing what to show is one thing; choosing how to arrange it is another,
   so a rule separates them and the count and the reset sit with the arranging. */
.filters .arrange { border-top: 1px solid var(--rule); padding-top: .5rem; margin-top: .5rem; }
.filters input, .filters select, .filters button { font: inherit; font-size: .95em; padding: .15rem .3rem; background: var(--bg); color: var(--ink); border: 1px solid var(--rule); border-radius: .25rem; }
/* A select is as wide as its widest option unless told otherwise, and one
   option reading "Reports of Limited Circulation" was pushing every other
   control onto a line of its own. */
.filters select { max-width: 11rem; }
.filters input[type="number"] { width: 4.4rem; }
.filters .to::before { content: "\2013"; color: var(--faint); }
.filters output { color: var(--faint); margin-left: auto; font-variant-numeric: tabular-nums; }

@media (max-width: 34rem) {
  .entry { grid-template-columns: 1fr; gap: .1rem; }
  .entry > .chips { grid-column: 1; }
  .filters input[type="search"] { min-width: 0; width: 100%; }
  table.toc td.sources { font-size: .84rem; }
}
