:root {
  color-scheme: light;
  --bg: #fff;
  --ink: #111;
  --muted: #666;
  --line: #eee;
  --focus: #174ea6;
  --max: 64rem;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  background: var(--bg);
  color: var(--ink);
  display: flex;
  flex-direction: column;
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.55;
  margin: 0;
  min-height: 100vh;
}

a {
  color: inherit;
  text-underline-offset: 0.18em;
}

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

.skip-link {
  background: var(--ink);
  color: var(--bg);
  left: 0.75rem;
  padding: 0.4rem 0.55rem;
  position: absolute;
  top: 0.75rem;
  transform: translateY(-160%);
}

.skip-link:focus {
  transform: translateY(0);
}

.site-header,
main,
.site-footer {
  margin: 0 auto;
  max-width: var(--max);
  padding: 1rem;
  width: 100%;
}

.site-header {
  align-items: flex-start;
  display: flex;
  gap: 1rem;
  justify-content: space-between;
  padding-top: 1.25rem;
}

.brand {
  color: var(--ink);
  font-size: 0.85rem;
  font-weight: 500;
  text-decoration: none;
}

.tagline {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.35;
  margin: 0;
  text-align: right;
  white-space: nowrap;
}

main {
  flex: 1;
}

.bookcase {
  padding: 1.75rem 0 3rem;
  overflow: hidden;
  width: 100%;
}

.bookcase-shelf {
  margin: 0 0 4rem;
  position: relative;
}

.shelf-hit-area {
  inset: 0;
  position: absolute;
  z-index: 1;
}

.shelf-hit-area:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 4px;
}

.shelf-copy {
  margin: 0 auto 1.1rem;
  max-width: 42rem;
  pointer-events: none;
  position: relative;
  text-align: center;
  z-index: 2;
}

.shelf-copy a {
  pointer-events: auto;
  text-decoration: none;
}

.book-spines {
  align-items: flex-end;
  display: flex;
  gap: 0.28rem;
  justify-content: center;
  list-style: none;
  margin: 0;
  min-height: 7rem;
  overflow: hidden;
  padding: 0 0.25rem 0.45rem;
  pointer-events: none;
  position: relative;
  z-index: 2;
}

.book-spines::after {
  background: var(--ink);
  bottom: 0;
  content: "";
  height: 2px;
  left: 0;
  opacity: 0.9;
  position: absolute;
  width: 100%;
}

.book-spine {
  align-items: center;
  background: var(--bg);
  border: 1px solid var(--ink);
  border-bottom: 0;
  display: flex;
  flex: 0 0 var(--spine-width);
  height: var(--spine-height);
  justify-content: center;
  min-height: 4.9rem;
  padding: 0.35rem 0.18rem;
}

.book-spine span {
  display: block;
  font-size: var(--title-scale);
  line-height: 1.05;
  max-height: calc(var(--spine-height) - 0.65rem);
  overflow: hidden;
  text-align: center;
  text-overflow: ellipsis;
  writing-mode: vertical-rl;
}

.page {
  margin: 2.5rem 0 4rem;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 1rem;
  font-weight: 500;
  line-height: 1.3;
  margin-bottom: 1.25rem;
}

h2 {
  font-size: 0.85rem;
  font-weight: 500;
  line-height: 1.35;
  margin-top: 1.5rem;
}

.book-list h2 {
  margin-top: 0;
}

.book-list h2 a {
  text-decoration: none;
}

p {
  color: var(--muted);
  margin-top: 0.75rem;
}

.meta {
  color: var(--muted);
  font-size: 0.78rem;
}

.score-button {
  appearance: none;
  background: transparent;
  border: 0;
  color: inherit;
  cursor: pointer;
  font: inherit;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 0.18em;
}

.score-popover {
  border: 1px solid var(--line);
  box-shadow: none;
  color: var(--muted);
  font: inherit;
  max-width: min(24rem, calc(100vw - 2rem));
  padding: 1rem;
}

.score-popover p + p {
  margin-top: 0.75rem;
}

.book-list {
  list-style: none;
  margin: 2rem 0 0;
  padding: 0;
}

.book-list li {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: 2rem minmax(0, 1fr);
  padding: 1rem 0;
}

.book-rank {
  color: var(--muted);
  font-size: 0.78rem;
  padding-top: 0.12rem;
}

.book-entry {
  display: grid;
  gap: 1rem;
  grid-template-columns: 4.5rem minmax(0, 1fr) auto;
  width: 100%;
}

.book-copy {
  min-width: 0;
}

.book-cover-link {
  display: block;
}

.book-cover {
  aspect-ratio: 2 / 3;
  border: 1px solid var(--line);
  display: block;
  object-fit: cover;
  width: 4.5rem;
}

.book-link {
  text-align: right;
}

.site-footer {
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.78rem;
  margin-top: auto;
  padding-bottom: 1.25rem;
  text-align: center;
}

.site-footer p {
  margin: 0;
}

.site-footer .affiliate-disclaimer {
  margin: 0 auto 2rem;
  max-width: none;
}

.site-footer a {
  margin: 0 0.35rem;
}

@media (min-width: 700px) {
  body {
    font-size: 15px;
  }

  .site-header,
  main,
  .site-footer {
    padding-left: 1.5rem;
    padding-right: 1.5rem;
  }

  .page {
    margin-top: 4rem;
  }
}

@media (max-width: 620px) {
  .site-header {
    flex-direction: column;
  }

  .tagline {
    text-align: left;
    white-space: normal;
  }

  .book-entry {
    grid-template-columns: 4rem minmax(0, 1fr);
  }

  .book-cover {
    width: 4rem;
  }

  .book-link {
    grid-column: 2;
    text-align: left;
  }

  .book-spines {
    gap: 0.18rem;
    justify-content: space-between;
    padding-left: 0;
    padding-right: 0;
  }

  .book-spine {
    flex-basis: 8.6%;
    min-width: 0;
  }

  .book-spine span {
    font-size: 0.58rem;
  }
}
