/* on the shelf — white paper, #111 ink, 1px rules, air */

:root {
  --ink: #111;
  --paper: #fff;
  --cover-h: 180px;
  --cover-h-lg: 240px;
  --cover-h-sm: 72px;
  --max: 1120px;
  --rule: 1px solid var(--ink);
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--paper);
  color: var(--ink);
  font-size: 16px;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Avenir", "Avenir Next", Helvetica, Arial, sans-serif;
  font-weight: 400;
  line-height: 1.5;
  letter-spacing: 0.01em;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img {
  max-width: 100%;
  border: 0;
  display: block;
}

a {
  color: var(--ink);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

h1, h2, h3 {
  font-family: inherit;
  font-weight: 400;
  letter-spacing: 0.01em;
  color: var(--ink);
  margin: 0;
}

p {
  margin: 0;
}

.wrap {
  max-width: var(--max);
  margin: 0 auto;
  padding: 2rem 1.5rem 5.5rem;
}

@media (min-width: 800px) {
  .wrap {
    padding: 2.75rem 3.25rem 7rem;
  }
}

/* nav */

.nav {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  column-gap: 0;
  row-gap: 0.35rem;
  font-size: 0.92rem;
  letter-spacing: 0.02em;
  padding-bottom: 1.5rem;
  border-bottom: var(--rule);
}

.nav a {
  text-decoration: none;
}

.nav a:hover {
  text-decoration: underline;
  text-underline-offset: 4px;
}

.nav a[aria-current="page"] {
  text-decoration: underline;
  text-underline-offset: 4px;
}

.sep {
  margin: 0 0.55rem;
  user-select: none;
}

/* black dot before handed */

.mark {
  display: inline-block;
  width: 5px;
  height: 5px;
  background: var(--ink);
  border-radius: 50%;
  margin-right: 0.38em;
  vertical-align: middle;
  transform: translateY(-0.08em);
}

/* type */

.page-title {
  font-size: 1.28rem;
  margin: 2.25rem 0 1rem;
  line-height: 1.3;
}

.intro {
  max-width: 34rem;
  margin: 0 0 2.75rem;
  font-size: 1rem;
  line-height: 1.55;
}

.lede {
  max-width: 34rem;
  margin: 0 0 2.5rem;
  font-size: 1rem;
  line-height: 1.55;
}

.section-label {
  font-size: 0.82rem;
  letter-spacing: 0.04em;
  padding-bottom: 0.55rem;
  border-bottom: var(--rule);
  margin: 0 0 1rem;
}

/* catalog shelves — the one bold move */

.shelf {
  margin: 0 0 2.75rem;
}

.shelf-row {
  display: flex;
  gap: 1.15rem;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  scroll-padding-inline: 0;
  -webkit-overflow-scrolling: touch;
  padding: 0.15rem 0 1rem;
  scrollbar-width: thin;
  scrollbar-color: var(--ink) transparent;
  touch-action: pan-x;
  overscroll-behavior-x: contain;
}

.shelf-row::-webkit-scrollbar {
  height: 3px;
}

.shelf-row::-webkit-scrollbar-thumb {
  background: var(--ink);
}

.spine {
  flex: 0 0 auto;
  width: calc(var(--cover-h) * 2 / 3);
  scroll-snap-align: start;
  text-decoration: none;
  color: inherit;
}

.spine:hover {
  text-decoration: none;
}

.spine:hover .spine-title {
  text-decoration: underline;
  text-underline-offset: 2px;
}

.spine-title {
  margin-top: 0.5rem;
  font-size: 0.78rem;
  line-height: 1.28;
  width: 100%;
}

.spine-format {
  margin-top: 0.12rem;
  font-size: 0.72rem;
  line-height: 1.25;
  letter-spacing: 0.02em;
}

/* covers sit on the paper */

.cover {
  height: var(--cover-h);
  aspect-ratio: 2 / 3;
  width: calc(var(--cover-h) * 2 / 3);
  background: var(--paper);
}

.cover:not(:has(img)) {
  border: 1px solid var(--ink);
}

.cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cover-lg {
  height: var(--cover-h-lg);
  width: calc(var(--cover-h-lg) * 2 / 3);
}

.cover-sm {
  height: var(--cover-h-sm);
  width: calc(var(--cover-h-sm) * 2 / 3);
  flex: 0 0 auto;
}

@media (max-width: 640px) {
  :root {
    --cover-h: 165px;
  }

  .spine {
    width: calc(165px * 2 / 3);
  }
}

/* search */

.search-box {
  margin: 2.25rem 0 1.25rem;
}

.search-input {
  display: block;
  width: 100%;
  max-width: 36rem;
  border: 0;
  border-bottom: var(--rule);
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 1.35rem;
  padding: 0.4rem 0 0.55rem;
  outline: none;
  appearance: none;
  box-shadow: none;
}

.search-input::placeholder {
  color: var(--ink);
  opacity: 0.45;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.2rem 0;
  font-size: 0.88rem;
  margin: 0 0 2.25rem;
}

.filters button {
  font: inherit;
  color: var(--ink);
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  letter-spacing: 0.02em;
}

.filters button[aria-pressed="true"] {
  text-decoration: underline;
  text-underline-offset: 4px;
}

.letter {
  font-size: 0.82rem;
  letter-spacing: 0.06em;
  padding-bottom: 0.45rem;
  border-bottom: var(--rule);
  margin: 2rem 0 0.25rem;
}

.book-row {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  padding: 0.95rem 0;
  border-bottom: var(--rule);
  text-decoration: none;
  color: inherit;
}

.book-row:hover {
  text-decoration: none;
}

.book-row:hover .row-title {
  text-decoration: underline;
  text-underline-offset: 2px;
}

.row-text {
  min-width: 0;
  padding-top: 0.15rem;
}

.row-title {
  font-size: 1rem;
  line-height: 1.3;
}

.row-meta {
  margin-top: 0.2rem;
  font-size: 0.82rem;
  line-height: 1.35;
}

.empty-line {
  margin: 1.5rem 0;
  font-size: 0.95rem;
}

/* book page */

.book-layout {
  margin-top: 2.25rem;
}

.book-layout .cover-lg {
  margin-bottom: 1.5rem;
}

.book-title {
  font-size: 1.45rem;
  line-height: 1.25;
  max-width: 28rem;
  margin: 0 0 0.65rem;
}

.meta-line {
  font-size: 0.9rem;
  line-height: 1.5;
  margin: 0 0 2rem;
}

.meta-line a {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.meta-sep {
  margin: 0 0.45rem;
}

.buy {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.note {
  border: 1px solid var(--ink);
  padding: 1.15rem 1.25rem 1.25rem;
  margin: 0 0 2.5rem;
  max-width: 36rem;
}

.note h2 {
  font-size: 0.82rem;
  letter-spacing: 0.03em;
  margin: 0 0 0.65rem;
}

.note p {
  font-size: 0.98rem;
  line-height: 1.55;
  white-space: pre-wrap;
}

.block-title {
  font-size: 0.82rem;
  letter-spacing: 0.04em;
  padding-bottom: 0.5rem;
  border-bottom: var(--rule);
  margin: 0 0 1rem;
}

/* snippets */

.snippet-row {
  display: block;
  padding: 1.1rem 0;
  border-bottom: var(--rule);
  max-width: 38rem;
  color: inherit;
}

.quote {
  display: block;
  font-size: 1.02rem;
  line-height: 1.5;
  text-decoration: none;
  color: inherit;
}

a.quote:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.cite {
  display: block;
  margin-top: 0.35rem;
  font-size: 0.8rem;
  line-height: 1.3;
}

.cite a:hover {
  text-decoration: underline;
  text-underline-offset: 2px;
}

.snippet-page > .snippet-row {
  border-bottom: 0;
  padding-bottom: 0.35rem;
}

.related {
  margin: 0.15rem 0 0.5rem 0.15rem;
  padding-left: 1.1rem;
  border-left: 1px solid var(--ink);
}

.related .snippet-row {
  border-bottom: 0;
  padding: 0.85rem 0;
  max-width: none;
}

.related .snippet-row + .snippet-row {
  border-top: var(--rule);
}

/* contradictions: stacked rows, thin break between groups */

.contra-group {
  max-width: 38rem;
  padding: 0.25rem 0 1.5rem;
}

.contra-group + .contra-group {
  border-top: var(--rule);
  padding-top: 1.5rem;
  margin-top: 0.25rem;
}

.contra-group .snippet-row {
  border-bottom: 0;
  padding: 0.85rem 0;
}

.contra-group .snippet-row + .snippet-row {
  border-top: 0;
}

/* author page reuses shelf-row */

.author-shelf {
  margin-top: 0.5rem;
}

/* quiet empty */

.quiet {
  margin: 1.25rem 0;
  font-size: 0.95rem;
}

@media (max-width: 640px) {
  .page-title,
  .book-title {
    font-size: 1.2rem;
  }

  .search-input {
    font-size: 1.15rem;
  }

  .nav {
    font-size: 0.88rem;
  }

  .nav .sep {
    margin: 0 0.4rem;
  }
}
