/* better reads. Cloth-bound spines are the one loud thing; everything else stays quiet. */

:root {
  --paper: #f4f6f9;
  --surface: #ffffff;
  --ink: #1b2232;
  --ink-soft: #545d70;
  --rule: #d8dde6;
  --action: #2e6b50;
  --action-hover: #23553f;
  --action-ink: #ffffff;
  --star: #b7862c;
  --error: #9b2c2c;
  --spine-ink: #f3f1ea;
  --shelf: #2a3142;
  /* Book cloth: oxblood, bottle green, navy, mustard, plum, teal, olive, slate */
  --cloth-1: #7b2d2d;
  --cloth-2: #2e5e4e;
  --cloth-3: #2a3f66;
  --cloth-4: #a2761f;
  --cloth-5: #5a3b5e;
  --cloth-6: #2d6d78;
  --cloth-7: #5d6328;
  --cloth-8: #474d5c;
  --serif: "Literata", Georgia, serif;
  --sans: "Instrument Sans", system-ui, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #131925;
    --surface: #1a2130;
    --ink: #e6e9ef;
    --ink-soft: #a2aabb;
    --rule: #2c3547;
    --action: #6cb592;
    --action-hover: #86c7a7;
    --action-ink: #0d1912;
    --star: #d9a940;
    --error: #f08b8b;
    --shelf: #3a455c;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 1rem/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
}

main { max-width: 60rem; margin: 0 auto; padding: 1rem 1rem 5rem; }
body.narrow main { max-width: 26rem; padding-top: 3rem; }

a { color: inherit; text-underline-offset: 0.2em; }
a:hover { color: var(--action); }
:focus-visible { outline: 2px solid var(--action); outline-offset: 2px; }

h1, h2 { font-family: var(--serif); font-weight: 500; line-height: 1.2; letter-spacing: -0.01em; }
h1 { font-size: 2.25rem; margin: 1.5rem 0 0.75rem; }
h2 { font-size: 1.5rem; margin: 3rem 0 0.75rem; }
p { margin: 0 0 0.75rem; }
.meta { color: var(--ink-soft); font-size: 0.875rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* --- Masthead --- */

.masthead {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem 1.5rem;
  max-width: 60rem; margin: 0 auto; padding: 1rem;
}
.wordmark {
  display: inline-flex; align-items: flex-end; gap: 0.5rem;
  font: 600 1.375rem/1 var(--serif); letter-spacing: -0.02em; text-decoration: none;
}
.wordmark svg { width: 1.4rem; height: 1.2rem; }
.wordmark-large { font: 600 1.75rem/1 var(--serif); letter-spacing: -0.02em; margin: 0; }
.search { flex: 1 1 14rem; }
.search input { width: 100%; }
.masthead nav { display: flex; gap: 1.25rem; }
.masthead nav a { color: var(--ink-soft); font-weight: 500; text-decoration: none; white-space: nowrap; }
.masthead nav a:hover { color: var(--ink); }
.masthead nav a[aria-current="page"] { color: var(--ink); text-decoration: underline 2px; text-underline-offset: 0.4em; }

/* --- Controls --- */

input, select, textarea {
  font: inherit; color: inherit; background: var(--surface);
  border: 1px solid var(--rule); border-radius: 6px; padding: 0.5rem 0.625rem;
}
textarea { width: 100%; resize: vertical; font-family: var(--serif); line-height: 1.6; }

button {
  font: 500 0.9375rem/1 var(--sans); cursor: pointer;
  padding: 0.625rem 1rem; border-radius: 6px;
  border: 1px solid var(--action); background: var(--action); color: var(--action-ink);
}
button:hover { background: var(--action-hover); border-color: var(--action-hover); }
button:disabled { opacity: 0.6; cursor: progress; }
button.secondary { background: transparent; color: var(--ink); border-color: var(--rule); }
button.secondary:hover { border-color: var(--ink-soft); }
button.link { background: none; border: 0; padding: 0; color: var(--ink-soft); text-decoration: underline; font-size: 0.875rem; }
button.link:hover { color: var(--ink); }

.pill {
  display: inline-block; padding: 0.4375rem 0.75rem; border-radius: 999px; white-space: nowrap;
  font: 500 0.875rem/1 var(--sans); text-decoration: none;
}
button.pill { background: transparent; color: var(--action); border: 1px solid var(--action); }
button.pill:hover { background: var(--action); color: var(--action-ink); }
.pill.on { border: 1px solid var(--rule); color: var(--ink-soft); }

.stack { display: grid; gap: 1rem; max-width: 26rem; }
.stack label, label.block { display: grid; gap: 0.25rem; font-weight: 500; font-size: 0.9375rem; }
.stack button { justify-self: start; }
.inline { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0.75rem; }
.inline .grow { display: grid; gap: 0.25rem; flex: 1 1 18rem; font-weight: 500; font-size: 0.9375rem; }
.big-search { display: flex; gap: 0.5rem; max-width: 36rem; }
.big-search input { flex: 1; font-size: 1.125rem; }

.flash { background: var(--surface); border-left: 3px solid var(--action); padding: 0.75rem 1rem; }
.error { color: var(--error); font-weight: 500; }
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { display: inline; }

/* --- The shelf: one spine per book, width from page count --- */

.shelf {
  display: flex; align-items: flex-end; gap: 3px;
  height: 13rem; padding: 0.75rem 0.5rem 0;
  border-bottom: 10px solid var(--shelf);
  overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: thin;
}
.spine {
  flex: none; width: var(--w); height: var(--h);
  display: flex; justify-content: center; padding: 0.75rem 0;
  background: var(--c); color: var(--spine-ink); text-decoration: none;
  border-radius: 2px 2px 0 0;
  box-shadow: inset 2px 0 rgb(255 255 255 / 0.12), inset -2px 0 rgb(0 0 0 / 0.18);
}
.spine:hover { color: var(--spine-ink); }
.spine span {
  writing-mode: vertical-rl; font: 500 0.75rem/1 var(--serif); letter-spacing: 0.02em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.spine.thin span { display: none; }
.spine.gold {
  background:
    linear-gradient(var(--star), var(--star)) 0 0.5rem / 100% 3px no-repeat,
    linear-gradient(var(--star), var(--star)) 0 calc(100% - 0.5rem) / 100% 3px no-repeat,
    var(--c);
}
.spine:hover, .spine:focus-visible { translate: 0 -0.5rem; }
@media (prefers-reduced-motion: no-preference) {
  .spine { transition: translate 0.15s ease-out; }
}

/* --- Book rows --- */

.row {
  display: grid; grid-template-columns: 3.5rem 1fr auto; gap: 0.25rem 1rem; align-items: start;
  padding: 1rem 0; border-top: 1px solid var(--rule);
}
.row:last-of-type { border-bottom: 1px solid var(--rule); }
.row ~ p { margin-top: 1rem; }
.row-cover { display: block; }
.row-body { min-width: 0; }
.row .title { font: 500 1.125rem/1.3 var(--serif); text-decoration: none; }
.row .title:hover { text-decoration: underline; }
.row .by { margin: 0.125rem 0 0; color: var(--ink-soft); }
.row .meta { margin: 0.25rem 0 0; }
.reason { font-family: var(--serif); line-height: 1.6; margin: 0.5rem 0 0; max-width: 62ch; }
.row-aside { display: grid; justify-items: end; gap: 0.5rem; text-align: right; }
.tags { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 0.25rem 0.625rem; margin: 0; font-size: 0.8125rem; }
.tags a { color: var(--ink-soft); }
@media (max-width: 36rem) {
  .row { grid-template-columns: 3rem 1fr; }
  .row-aside { grid-column: 2; justify-items: start; text-align: left; }
  .tags { justify-content: flex-start; }
}

/* --- Covers --- */

.cover {
  display: block; width: 100%; aspect-ratio: 2 / 3; object-fit: cover;
  border-radius: 2px; background: var(--rule);
  outline: 1px solid rgb(0 0 0 / 0.08); outline-offset: -1px;
}
.cover-blank {
  display: flex; align-items: flex-end; padding: 0.375rem; overflow: hidden;
  background: var(--c); color: var(--spine-ink); font: 500 0.6875rem/1.2 var(--serif);
}
.cover-blank span { overflow: hidden; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; }
.cover-l.cover-blank { font-size: 1.125rem; padding: 1rem; }

.cover-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(8.5rem, 1fr)); gap: 1.25rem 1rem; }
.cover-grid a { display: grid; gap: 0.125rem; text-decoration: none; }
.cover-grid .cover { margin-bottom: 0.375rem; }
.cover-grid-title { font: 500 0.875rem/1.3 var(--serif); }
.cover-grid-by { color: var(--ink-soft); font-size: 0.8125rem; }

/* --- Book page --- */

.book { display: grid; grid-template-columns: 13rem 1fr; gap: 2.5rem; margin-top: 1.5rem; }
.book h1 { margin-top: 0; }
.by-large { font: 400 1.25rem/1.3 var(--serif); margin: 0 0 0.5rem; }
@media (max-width: 40rem) {
  .book { grid-template-columns: 1fr; gap: 1.5rem; }
  .book-cover { width: 9rem; }
}
.description { font: 400 1.0625rem/1.7 var(--serif); max-width: 65ch; white-space: pre-line; }
.subjects { display: flex; flex-wrap: wrap; gap: 0.375rem 0.875rem; margin-top: 1rem; font-size: 0.875rem; }
.subjects a { color: var(--ink-soft); }

.entry { display: grid; gap: 1.25rem; margin: 1.5rem 0 1rem; max-width: 34rem; }
.entry fieldset { border: 0; padding: 0; margin: 0; }
.status-pills { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.status-pills input { position: absolute; opacity: 0; pointer-events: none; }
.status-pills span {
  display: inline-block; padding: 0.5rem 0.875rem; border: 1px solid var(--rule); border-radius: 999px;
  cursor: pointer; font-weight: 500; font-size: 0.9375rem;
}
.status-pills span:hover { border-color: var(--ink-soft); }
.status-pills input:checked + span { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.status-pills input:focus-visible + span { outline: 2px solid var(--action); outline-offset: 2px; }
.rating { display: flex; align-items: center; gap: 1rem; }
.rating legend { float: left; font-weight: 500; font-size: 0.9375rem; margin-right: 0.25rem; }
.dates { display: flex; flex-wrap: wrap; gap: 1rem; }
.dates label { display: grid; gap: 0.25rem; font-weight: 500; font-size: 0.9375rem; }
.actions { display: flex; align-items: center; gap: 1rem; }
.saved { color: var(--action); font-weight: 500; }

/* Star display: whole, half, or empty. */
.stars { color: var(--star); letter-spacing: 0.05em; white-space: nowrap; font-size: 1rem; }
.star.empty { color: var(--rule); }
.star.half {
  background: linear-gradient(90deg, var(--star) 50%, var(--rule) 50%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}

/* Star input: ten radios, each a half star. DOM order is 5 down to 0.5, shown reversed,
   so "this one and everything after it" in the DOM is "this one and everything to its left". */
.stars-input { display: inline-flex; flex-direction: row-reverse; justify-content: flex-end; }
.stars-input input { position: absolute; opacity: 0; pointer-events: none; }
.stars-input label { width: 0.8rem; overflow: hidden; cursor: pointer; font-size: 1.6rem; line-height: 1; color: var(--rule); }
.stars-input label span { display: block; width: 1.6rem; }
.stars-input label.right span { margin-left: -0.8rem; }
.stars-input input:checked ~ label { color: var(--star); }
.stars-input:hover input ~ label { color: var(--rule); }
.stars-input:hover label:hover, .stars-input:hover label:hover ~ label { color: var(--star); }
.stars-input input:focus-visible + label { outline: 2px solid var(--action); outline-offset: 1px; }

/* --- Lists --- */

.tabs { display: flex; gap: 1.5rem; border-bottom: 1px solid var(--rule); margin-bottom: 1rem; overflow-x: auto; }
.tabs a { padding: 0.625rem 0; color: var(--ink-soft); text-decoration: none; white-space: nowrap; font-weight: 500; }
.tabs a:hover { color: var(--ink); }
.tabs a[aria-current="page"] { color: var(--ink); box-shadow: inset 0 -2px var(--ink); }
.count { font-variant-numeric: tabular-nums; color: var(--ink-soft); font-weight: 400; }
.list-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem 1.5rem; margin-bottom: 0.5rem; }
.list-controls label { font-size: 0.875rem; color: var(--ink-soft); }
.list-controls .meta { margin: 0; }

.invites { border-collapse: collapse; width: 100%; margin-top: 1.5rem; font-size: 0.9375rem; }
.invites th { text-align: left; font-weight: 500; color: var(--ink-soft); padding: 0.5rem 1rem 0.5rem 0; border-bottom: 1px solid var(--rule); }
.invites td { padding: 0.5rem 1rem 0.5rem 0; border-bottom: 1px solid var(--rule); }
.invites input { width: 100%; font-size: 0.8125rem; }
