/* Contents: the home page set as a book's contents page.

   Type. IM Fell English is Igino Marini's revival of the Fell types, a
   seventeenth-century face with uneven ink and soft serifs. It sets the name
   and the chapter heads. Its small-caps companion, IM Fell English SC, sets
   the contents entries, so the caps come from the cut and no text-transform
   is needed. Body text uses the reader's own old style serif (Palatino, or
   P052 on Linux) at 18 to 20px, sized for that face.

   Colour. The ground is paper because the page imitates a printed contents
   page; the noise tile in paper.png averages to #e9e4d6. Ink is a warm black.
   The one accent is rubric red, the red printers used for marks and initials,
   and it appears on the version mark and on hovered links only. This is not
   the cream, Didone and clay look: the face is a low-contrast old style, the
   red is a brick rubric, and there is no other decoration.

   Shape. No radius and no shadow anywhere; it is a sheet of paper.
   Motion. None. */

:root {
  --paper: #e9e4d6;
  --ink: #1a1714;
  --ink-2: #4a4239;
  --rule: #b9af99;
  --red: #b4352a;
  --display: "IM Fell English", "Iowan Old Style", "Palatino Linotype", Palatino, P052, Georgia, serif;
  --sc: "IM Fell English SC", "IM Fell English", Georgia, serif;
  --text: "Iowan Old Style", "Palatino Linotype", Palatino, "URW Palladio L", P052, "Book Antiqua", Georgia, serif;
  color-scheme: light;
}

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

body {
  margin: 0;
  background: var(--paper) url("paper.png");
  color: var(--ink);
  font-family: var(--text);
  font-size: clamp(1.125rem, 1rem + 0.4vw, 1.25rem);
  line-height: 1.55;
  font-variant-numeric: oldstyle-nums;
  font-kerning: normal;
  text-rendering: optimizeLegibility;
  overflow-wrap: break-word;
}

::selection {
  background: var(--red);
  color: var(--paper);
}

a {
  color: inherit;
  text-decoration-line: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}

a:hover {
  color: var(--red);
}

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

img {
  display: block;
  max-width: 100%;
  height: auto;
}

.vh {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* The opening spread: title and frontispiece on the left page, contents on
   the right. One column on a phone, in reading order. */

.spread {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "title" "toc" "plate";
  row-gap: 2.75rem;
  max-width: 82rem;
  margin: 0 auto;
  padding: 2.25rem max(1rem, 4vw) 3.5rem;
}

.title { grid-area: title; }
.toc { grid-area: toc; }
.frontis { grid-area: plate; }

h1 {
  margin: 0;
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(4.75rem, 2.75rem + 9vw, 10.5rem);
  line-height: 0.82;
  letter-spacing: -0.015em;
}

.descriptor {
  margin: 0.9rem 0 0;
  font-family: var(--display);
  font-style: italic;
  font-size: clamp(1.4rem, 1.1rem + 1vw, 1.9rem);
  line-height: 1.2;
}

.frontis {
  margin: 0;
  max-width: 28rem;
}

figcaption {
  margin-top: 0.6rem;
  font-style: italic;
  font-size: 0.9em;
  line-height: 1.4;
  color: var(--ink-2);
}

.plate-no {
  font-family: var(--sc);
  font-style: normal;
  letter-spacing: 0.04em;
  color: var(--ink);
}

/* The contents page */

.toc {
  display: flex;
  flex-direction: column;
}

.toc h2 {
  margin: 0 0 1.75rem;
  font-family: var(--sc);
  font-weight: 400;
  font-size: clamp(1.75rem, 1.4rem + 1vw, 2.25rem);
  letter-spacing: 0.14em;
  line-height: 1;
}

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

.toc li {
  margin: 0 0 1.35rem;
}

.toc li a {
  display: flex;
  align-items: flex-end;
  align-items: last baseline;
  gap: 0.45ch;
  font-family: var(--sc);
  font-size: clamp(1.35rem, 1.15rem + 0.6vw, 1.6rem);
  line-height: 1.2;
  letter-spacing: 0.03em;
  text-decoration: none;
}

.toc .t {
  flex: 0 1 auto;
}

/* Dot leaders. Set right to left so the dots start at the numeral and line
   up down the page, whatever the length of the name. */
.toc .leader {
  flex: 1 1 2rem;
  min-width: 2rem;
  overflow: hidden;
  white-space: nowrap;
  direction: rtl;
  color: var(--ink-2);
  font-family: var(--display);
  letter-spacing: 0.12em;
}

.toc .leader::before {
  content: ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .";
}

.toc .n {
  flex: none;
  width: 1.75em;
  text-align: right;
  font-family: var(--display);
  letter-spacing: 0;
}

.toc li a:hover,
.toc li a:hover .leader,
.toc li a:focus-visible,
.toc li a:focus-visible .leader {
  color: var(--red);
}

.gloss {
  margin: 0.3rem 2.4rem 0 0;
  font-style: italic;
  font-size: 0.95em;
  line-height: 1.4;
  color: var(--ink-2);
}

/* The version mark sits where a folio would. */
.imprint {
  margin: auto 0 0;
  padding-top: 1.5rem;
  text-align: right;
  font-family: var(--display);
  font-size: 1.35rem;
}

.version {
  color: var(--red);
  text-decoration: none;
  white-space: nowrap;
}

.version:hover {
  text-decoration: underline;
  text-decoration-thickness: 1px;
}

@media (min-width: 60rem) {
  .spread {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-rows: auto 1fr;
    grid-template-areas: "title toc" "plate toc";
    column-gap: 0;
    row-gap: 2.5rem;
    min-height: min(52rem, 100svh);
    box-sizing: border-box;
  }

  .title,
  .frontis {
    padding-right: clamp(2.5rem, 5vw, 5rem);
  }

  .frontis {
    align-self: end;
    max-width: 30rem;
  }

  /* the gutter between the two pages */
  .toc {
    border-left: 1px solid var(--rule);
    padding-left: clamp(2.5rem, 5vw, 5rem);
    padding-top: 0.6rem;
  }
}

/* The chapters share the spread's left edge. On wide screens the numerals
   sit in a 6rem column on that edge, under the name and the plate, and the
   text starts after it. Each chapter sets its own width. */

.book,
footer {
  max-width: 82rem;
  margin: 0 auto;
  padding: 0 max(1rem, 4vw);
}

.chapter {
  margin: 0 0 5.5rem;
  scroll-margin-top: 1.5rem;
}

.chapter h2 {
  position: relative;
  margin: 0 0 1.25rem;
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(2.1rem, 1.6rem + 1.6vw, 2.9rem);
  line-height: 1.05;
}

.chapter h2 .num {
  color: var(--ink-2);
  margin-right: 0.35em;
}

@media (min-width: 60rem) {
  .chapter,
  .history,
  footer > p {
    padding-left: 6rem;
  }

  .chapter h2 .num {
    position: absolute;
    left: -6rem;
    margin: 0;
    white-space: nowrap;
  }
}

.chapter p {
  margin: 0 0 1rem;
}

.sc {
  font-family: var(--sc);
  letter-spacing: 0.03em;
}

.preface { max-width: 37rem; }

.preface .lead .sc {
  font-size: 1.12em;
}

.workshop { max-width: 64rem; }

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

.works li {
  margin: 0 0 1.15rem;
}

.works h3 {
  display: inline;
  margin: 0;
  font-family: var(--sc);
  font-weight: 400;
  font-size: 1.08em;
  letter-spacing: 0.03em;
}

.works h3 + p {
  display: inline;
}

.plate {
  margin: 0 0 1.75rem;
  max-width: 28rem;
}

@media (min-width: 52rem) {
  .workshop {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 25rem);
    column-gap: 3.5rem;
    align-items: start;
  }

  .workshop h2,
  .workshop .intro { grid-column: 1 / -1; }

  .workshop .intro { max-width: 37rem; }

  .workshop .plate {
    grid-column: 2;
    grid-row: 3;
    margin: 0.35rem 0 0;
  }

  .works {
    grid-column: 1;
    grid-row: 3;
  }
}

.essays { max-width: 46rem; }

.essay-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--rule);
}

.essay-list li {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  padding: 0.7rem 0 0.8rem;
  border-bottom: 1px solid var(--rule);
}

.essay-list time {
  font-style: italic;
  font-size: 0.9em;
  color: var(--ink-2);
}

.essay-list .et {
  font-family: var(--display);
  font-size: 1.3em;
  line-height: 1.25;
}

@media (min-width: 40rem) {
  .essay-list li {
    grid-template-columns: 11.5rem minmax(0, 1fr);
    align-items: baseline;
  }
}

.notebook {
  max-width: 31rem;
  font-size: 0.95em;
}

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

.notes li {
  margin: 0 0 1rem;
}

.notes time {
  font-family: var(--sc);
  letter-spacing: 0.03em;
}

.correspondence { max-width: 44rem; }

.address {
  font-family: var(--display);
  font-size: clamp(1.4rem, 1rem + 2.2vw, 2.4rem);
  line-height: 1.2;
  overflow-wrap: anywhere;
}

/* Back matter: smaller, set after a rule */

.history {
  max-width: 40rem;
  margin: 0 0 4rem;
  padding-top: 2.25rem;
  border-top: 1px solid var(--rule);
  font-size: 0.95em;
  scroll-margin-top: 1.5rem;
}

.history h2 {
  margin: 0 0 1rem;
  font-family: var(--sc);
  font-weight: 400;
  font-size: 1.6rem;
  letter-spacing: 0.1em;
}

.history p {
  margin: 0 0 1rem;
}

.impressions {
  list-style: none;
  margin: 0 0 1.75rem;
  padding: 0;
}

.impressions li {
  margin: 0 0 0.9rem;
  padding-left: 1.4rem;
  border-left: 2px solid var(--rule);
}

.impressions .when {
  display: block;
  font-style: italic;
  color: var(--ink-2);
}

.impressions .imp {
  font-family: var(--sc);
  letter-spacing: 0.03em;
}

footer {
  padding-bottom: 3rem;
  font-size: 0.85em;
  font-style: italic;
  color: var(--ink-2);
}

footer p {
  max-width: 40rem;
  margin: 0 0 0.4rem;
}

@media print {
  body { background: none; }
  .toc li a:hover { color: inherit; }
}
