/* Books: the shelf (/books/) and each book's page. Built by tools/books.py. */
:root {
  --reading: "neue-haas-grotesk-text", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --rule: rgba(0, 0, 0, .07);
  --ease: cubic-bezier(.22, .8, .24, 1);
  --peek: clamp(170px, 15vw, 260px);
}

/* Cross-page: the cover glides from the grid into the book's page and back. */
@view-transition { navigation: auto; }
::view-transition-group(*) { animation-duration: .5s; animation-timing-function: var(--ease); }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: .3s; }
@media (prefers-reduced-motion: reduce) {
  ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; }
}

/* ---------- the shelf ---------- */
main.shelf { max-width: none; font-size: clamp(17px, 1.55vw, 23px); line-height: 1.2; letter-spacing: 0; }
main.shelf > * + * { margin-top: 0; }
.shelf .intro { font-size: clamp(28px, 4.65vw, 64px); line-height: 1; letter-spacing: -0.01em; max-width: 14.5em; }
.ink { color: var(--ink); }

.bar {
  position: sticky; top: 0; z-index: 2;
  display: flex; flex-wrap: wrap; align-items: baseline; gap: .6em 2.2em;
  margin: clamp(32px, 5vw, 72px) calc(-1 * var(--gutter)) 0;
  padding: .7em var(--gutter);
  background: var(--bg);
}
.find {
  flex: 0 1 15em; min-width: 9em;
  font: inherit; color: var(--ink); background: transparent;
  border: 0; border-bottom: 2px solid var(--muted); border-radius: 0;
  padding: .05em 0 .1em; outline: none; -webkit-appearance: none; appearance: none;
  transition: border-color .2s;
}
.find:focus { border-bottom-color: var(--ink); }
.find::placeholder { color: var(--muted-small); opacity: 1; }
.find::-webkit-search-cancel-button { -webkit-appearance: none; }
.opts { display: flex; flex-wrap: wrap; gap: .4em 2.2em; }
.group { display: inline-flex; gap: .7em; white-space: nowrap; }
.label { color: var(--muted-small); }
.bar button {
  font: inherit; color: var(--ink); background: none; border: 0; padding: 0; cursor: pointer;
  text-decoration: underline 2px transparent; text-underline-offset: .22em;
  transition: text-decoration-color .25s, color .2s;
}
.bar button:hover, .bar button:active { color: var(--hot); }
.bar button[aria-pressed="true"] { text-decoration-color: currentColor; }
.count { margin-left: auto; color: var(--muted-small); }

.books { list-style: none; margin-top: .6em; }
.book a { color: var(--ink); }
.book .a, .book .y, .book .s { color: var(--muted-small); }

/* list */
.books[data-view="list"] .book a {
  display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 3.2fr) 6.2em minmax(0, 2.6fr);
  column-gap: 1em; padding: .34em 0; border-top: 1px solid var(--rule);
}
.books[data-view="list"] .cover { display: none; }
.book a:hover .t, .book a:active .t { color: var(--hot); }
.y { font-variant-numeric: tabular-nums; }

/* grid */
.books[data-view="grid"] {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(clamp(118px, 13.5vw, 196px), 1fr));
  gap: 2.4em var(--gutter); align-items: end; margin-top: 1.4em;
}
.books[data-view="grid"] .book a { display: block; font-size: .78em; line-height: 1.2; }
.books[data-view="grid"] .cover {
  display: block; width: 100%; height: auto; margin-bottom: .7em;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .1), 0 8px 24px -12px rgba(0, 0, 0, .25);
  transition: transform .45s var(--ease), box-shadow .45s var(--ease);
}
.cover, .jacket img { transition: opacity .6s var(--ease); }
.cover.loading, .jacket img.loading { opacity: 0; }
.books[data-view="grid"] .cover.blank { aspect-ratio: 2 / 3; background: #eee; }
.books[data-view="grid"] .book a:hover .cover {
  transform: translateY(-4px);
  box-shadow: 0 2px 4px rgba(0, 0, 0, .1), 0 18px 36px -16px rgba(0, 0, 0, .35);
}
.books[data-view="grid"] .t, .books[data-view="grid"] .a {
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden;
}
.books[data-view="grid"] .y, .books[data-view="grid"] .s { display: none; }

/* notes (default): cover, title, author, a paragraph; the qy.co reading list */
.books .n { display: none; }
.books[data-view="notes"] .book {
  display: grid; grid-template-columns: clamp(92px, 10vw, 148px) minmax(0, 36em);
  grid-template-rows: auto auto 1fr; column-gap: clamp(20px, 2.6vw, 40px); align-items: start;
  padding: clamp(28px, 3.4vw, 48px) 0; border-top: 1px solid var(--rule);
}
.books[data-view="notes"] .book > a { display: contents; }
.books[data-view="notes"] .cover {
  grid-column: 1; grid-row: 1 / span 3; display: block; width: 100%; height: auto;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .1), 0 8px 24px -12px rgba(0, 0, 0, .25);
  transition: transform .45s var(--ease), box-shadow .45s var(--ease), opacity .6s var(--ease);
}
.books[data-view="notes"] .cover.blank { aspect-ratio: 2 / 3; background: #eee; }
.books[data-view="notes"] .book > a:hover .cover { transform: translateY(-3px); }
.books[data-view="notes"] .t { grid-column: 2; font-size: 1.3em; line-height: 1.1; letter-spacing: -0.005em; }
.books[data-view="notes"] .a { grid-column: 2; margin-top: .25em; }
.books[data-view="notes"] .y, .books[data-view="notes"] .s { display: none; }
.books[data-view="notes"] .n {
  display: block; grid-column: 2; margin-top: 1em; color: var(--ink);
  font-family: var(--reading); font-weight: 400; font-size: .86em; line-height: 1.5;
}
.books[data-view="notes"] .n > * + * { margin-top: .8em; }
.books[data-view="notes"] .n a { text-decoration: underline 1px; text-underline-offset: .18em; }

/* subject headings, when sorted by subject */
.books .h { color: var(--ink); font-size: 1.5em; line-height: 1; letter-spacing: -0.01em; padding: 1.6em 0 .45em; }
.books .h:first-child { padding-top: .6em; }
.books[data-view="grid"] .h { grid-column: 1 / -1; padding: .9em 0 0; margin-bottom: -1em; }
.books[data-view="grid"] .h:first-child { padding-top: 0; }

.empty { margin-top: 1.5em; color: var(--muted-small); }
.machine { margin-top: clamp(64px, 9vw, 128px) !important; color: var(--muted-small); font-size: .8em; }

/* a cover follows the cursor's row in list view, on wide screens with a mouse */
.peek { display: none; }
@media (hover: hover) and (pointer: fine) and (min-width: 1100px) {
  .books[data-view="list"] { padding-right: calc(var(--peek) + var(--gutter) * 2); }
  .peek {
    display: block; position: fixed; right: var(--gutter); top: 50%; width: var(--peek); height: auto;
    transform: translateY(-46%); opacity: 0; pointer-events: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, .1), 0 18px 40px -16px rgba(0, 0, 0, .35);
    transition: opacity .3s var(--ease), transform .45s var(--ease);
  }
  .peek.on { opacity: 1; transform: translateY(-50%); }
}

@media (max-width: 760px) {
  .count { margin-left: 0; }
  .books[data-view="list"] .book a { grid-template-columns: minmax(0, 1fr) auto; row-gap: .05em; }
  .books[data-view="list"] .a { grid-row: 2; }
  .books[data-view="list"] .y { grid-row: 1 / 3; grid-column: 2; align-self: center; }
  .books[data-view="list"] .s { display: none; }
}

/* ---------- a book ---------- */
main.book {
  max-width: none; font-size: inherit; line-height: 1.2; letter-spacing: 0;
  display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: clamp(28px, 5vw, 88px); align-items: start;
}
main.book > * + * { margin-top: 0; }
/* width/height auto + max-* keeps the box the cover's own shape, so the tint never shows beside it */
.jacket img { display: block; width: auto; height: auto; max-width: 100%; max-height: 86vh; }
.jacket { position: sticky; top: var(--gutter); }
.book .text { max-width: 36em; }
.book h1 { font-weight: 500; color: var(--ink); font-size: clamp(30px, 4.65vw, 64px); line-height: 1; letter-spacing: -0.01em; }
.book .by { font-size: clamp(22px, 2.6vw, 36px); line-height: 1.1; margin-top: .3em; }
.book .about, .book .notes {
  margin-top: clamp(28px, 3.4vw, 48px); color: var(--ink);
  font-family: var(--reading); font-weight: 400; font-size: clamp(18px, 1.45vw, 22px); line-height: 1.45;
}
.book .notes > * + * { margin-top: .9em; }
.book .notes a { text-decoration: underline 1px; text-underline-offset: .18em; }
.book-notes { margin-top: clamp(28px, 3.4vw, 48px); }
.book-notes h2 { font-weight: 500; font-size: clamp(16px, 1.2vw, 18px); color: var(--muted-small); }
.book-notes ul { list-style: none; margin-top: .4em; }
.book-notes li { display: flex; justify-content: space-between; gap: 1em; align-items: baseline; padding: .45em 0; border-top: 1px solid var(--rule); font-size: clamp(19px, 1.7vw, 26px); line-height: 1.15; }
.book-notes li span { color: var(--muted-small); font-size: .62em; white-space: nowrap; }
.facts {
  display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: .45em 1.6em;
  margin-top: clamp(28px, 3.4vw, 48px); padding-top: 1em; border-top: 1px solid var(--rule);
  font-size: clamp(16px, 1.2vw, 18px); line-height: 1.35;
}
.facts dt { color: var(--muted-small); }
.facts dd { color: var(--ink); }
.turn {
  display: grid; grid-template-columns: 1fr auto 1fr; gap: 1.6em; align-items: end;
  margin-top: clamp(48px, 6vw, 96px); font-size: clamp(16px, 1.2vw, 18px); line-height: 1.25;
}
.turn .label { display: block; font-size: .85em; color: var(--muted-small); }
.turn [rel="next"] { text-align: right; }
.turn .all { white-space: nowrap; }

@media (max-width: 760px) {
  main.book { grid-template-columns: 1fr; }
  .jacket { position: static; }
  .jacket img { max-width: 72%; max-height: 62vh; }
  .turn { grid-template-columns: 1fr 1fr; }
  .turn .all { grid-column: 1 / -1; grid-row: 2; }
}
