/* Books: the book in hand, a sortable log of finished books, the year so far, and the want-to-read shelf. */

/* Reading now */

.reading-slot { margin-top: 56px; }

.reading { display: grid; grid-template-columns: 118px minmax(0, 1fr); align-items: center; gap: 28px; padding: 20px; }
.reading-cover { aspect-ratio: 2 / 3; border-radius: 4px; }

.reading-status { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.reading-since::before { content: "·"; margin-right: 8px; }

.reading-title { margin-top: 4px; font-size: 30px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.2; text-wrap: balance; }
.reading-byline { margin-top: 6px; color: var(--muted); font-size: 15px; }

.reading-note {
  display: -webkit-box;
  max-width: 64ch;
  margin-top: 18px;
  overflow: hidden;
  font-size: 15px;
  line-height: 1.5;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.reading-progress { display: flex; align-items: center; gap: 14px; margin-top: 18px; }
.reading-progress .progress { width: min(320px, 100%); }
.reading-progress .label { color: var(--soft); white-space: nowrap; }

/* More than one book on the go */

.also-title { margin: 20px 0 4px; color: var(--muted); font-size: 13px; }

.also-reading li {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 10px 0;
  border-bottom: 1px solid var(--hair);
}
.also-text { display: grid; min-width: 0; font-size: 15px; }
.also-text > * { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.also-author { color: var(--muted); font-size: 13px; }
.also-progress { display: flex; align-items: center; gap: 10px; color: var(--meta); font: 12px var(--mono); white-space: nowrap; }

/* Finished: a table sorted by whichever column header was clicked. It adapts to its own
   width (the panel is narrow next to the sidebar on small laptops), not the viewport's. */

.finished-wrap { container-type: inline-size; }

.finished { width: 100%; border-collapse: collapse; table-layout: fixed; font-size: 15px; }

.finished th {
  padding: 0 0 12px;
  border-bottom: 1px solid var(--line);
  color: var(--meta);
  font-size: 13px;
  font-weight: 400;
  text-align: left;
}
.finished th button { display: inline-flex; align-items: center; gap: 4px; padding: 0; background: none; border: 0; color: inherit; cursor: pointer; }
.finished th button:hover { color: var(--text); }
.finished th[aria-sort] { color: var(--text); font-weight: 500; }
.finished:has(.htmx-request) { opacity: 0.6; }
.sort-arrow { font-size: 12px; }

.finished td { height: 65px; padding: 8px 0; border-bottom: 1px solid var(--hair); }

/* Column widths come from the header row (table-layout: fixed) */
th.fin-cover { width: 54px; }
th.fin-author { width: 198px; }
th.fin-rating { width: 110px; }
th.fin-pages { width: 64px; }
th.fin-finished { width: 124px; }

.finished .thumb-book { width: 32px; height: 48px; }

.finished .fin-title { padding-right: 20px; }
.fin-title > * { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fin-title > .fin-byline { display: none; }
.finished .fin-author { padding-right: 16px; overflow: hidden; color: var(--soft); text-overflow: ellipsis; white-space: nowrap; }

.finished .fin-pages, .finished .fin-finished { text-align: right; }
td.fin-pages, td.fin-finished { color: var(--meta); font: 12px var(--mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
.fin-none { color: var(--faint); font: 12px var(--mono); }

/* Rating dots: full, half, or an empty ring */
.rating { display: inline-flex; gap: 3px; vertical-align: middle; }
.rating i { width: 5px; height: 5px; border-radius: 50%; background: var(--ch); }
.rating i.half { background: linear-gradient(90deg, var(--ch) 50%, transparent 50%); box-shadow: inset 0 0 0 1px var(--ch); }
.rating i.empty { background: none; box-shadow: inset 0 0 0 1px var(--ch); }

.fin-more {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 8px 16px;
  padding-top: 14px;
  color: var(--muted);
  font-size: 13px;
}

/* Narrower: the author moves under the title. Narrower still: pages drop out. */
@container (max-width: 780px) {
  th.fin-author, td.fin-author { display: none; }
  .fin-title > .fin-byline { display: block; color: var(--muted); font-size: 13px; }
}

@container (max-width: 520px) {
  th.fin-pages, td.fin-pages { display: none; }
  .finished { font-size: 14px; }
  .finished .fin-title { padding-right: 12px; }
  th.fin-cover { width: 40px; }
  th.fin-rating { width: 50px; }
  th.fin-finished { width: 86px; }
  .finished .thumb-book { width: 28px; height: 42px; }
  .rating { gap: 2px; }
}

.finished-loading { display: grid; grid-template-columns: 54px minmax(0, 1fr); align-items: center; height: 65px; border-bottom: 1px solid var(--hair); }
.finished-loading .thumb-book { width: 32px; height: 48px; }

/* This year: stat tiles, then books finished per month */

.months {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 2px;
  padding: 18px 24px 16px;
  border-top: 1px solid var(--hair);
}

.month { position: relative; display: grid; justify-items: center; gap: 8px; }

.month-bar { display: flex; justify-content: center; align-items: flex-end; width: 100%; height: 48px; border-bottom: 1px solid var(--line); }
.month-bar i {
  position: relative;
  width: min(24px, 70%);
  height: max(4px, calc(var(--h) * 1%));
  background: var(--ch);
  border-radius: 4px 4px 0 0;
}
/* The busiest month's count sits on its cap */
.month-bar b { position: absolute; bottom: 100%; left: 50%; margin-bottom: 3px; color: var(--soft); font: 11px var(--mono); transform: translateX(-50%); }

.month-name { color: var(--meta); font: 11px var(--mono); }
.month--now .month-name { color: var(--text); }
.month--future .month-bar { border-bottom-color: var(--hair); }
.month--future .month-name { color: var(--faint); }

/* Hover tooltip. Hidden with display so it never widens the page at the edges. */
.month::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  z-index: 1;
  display: none;
  padding: 3px 8px;
  background: var(--raised);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  color: var(--text);
  font: 12px var(--mono);
  white-space: nowrap;
  transform: translateX(-50%);
  pointer-events: none;
}
.month:hover::after { display: block; }
.month:nth-child(-n+2)::after { left: 0; transform: none; }
.month:nth-last-child(-n+2)::after { left: auto; right: 0; transform: none; }

.goal-meter { width: 100%; max-width: 160px; margin-top: 6px; }

/* Want to read */

.shelf { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 20px 16px; }
.shelf-book { display: grid; min-width: 0; }
.shelf-cover { aspect-ratio: 2 / 3; border-radius: 3px; }
.shelf-title {
  display: -webkit-box;
  margin-top: 10px;
  overflow: hidden;
  font-size: 14px;
  line-height: 1.35;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}
.shelf-author { margin-top: 2px; overflow: hidden; color: var(--muted); font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }

@media (max-width: 860px) {
  .reading-slot { margin-top: 40px; }
  .shelf { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 560px) {
  .reading { grid-template-columns: 84px minmax(0, 1fr); align-items: start; gap: 16px; padding: 16px; }
  .reading-title { font-size: 22px; }
  .reading-byline, .reading-note { font-size: 14px; }
  .reading-note { margin-top: 12px; }
  .reading-progress { flex-wrap: wrap; gap: 8px 12px; margin-top: 14px; }
  .also-progress .progress { display: none; }

  .months { padding: 16px 12px 14px; }
  .month-name { font-size: 10px; }
  .shelf { gap: 16px 12px; }
}
