/* BookShuff — v1 grid styles */

:root {
  --bg: #f4f2ee;
  --card-bg: #ffffff;
  --ink: #2a2a2a;
  --muted: #6b6b6b;
  --accent: #7a4f2b;      /* warm book-brown */
  --accent-ink: #ffffff;
  --border: #e2ddd4;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.45;
}

header.site { text-align: center; padding: 1.5rem 1rem 0.25rem; }
header.site h1 { margin: 0; font-size: 2rem; letter-spacing: -0.02em; }
header.site .tagline { color: var(--muted); margin: 0.25rem 0 0; }

.controls {
  display: flex; flex-direction: column; align-items: center;
  gap: 0.5rem; padding: 1rem;
}
.reshuffle-btn {
  background: var(--accent); color: var(--accent-ink);
  border: 0; border-radius: 999px; padding: 0.7rem 1.6rem;
  font-size: 1rem; font-weight: 600; cursor: pointer;
  transition: filter .15s;
}
.reshuffle-btn:hover { filter: brightness(1.08); }
.reshuffle-btn:disabled { opacity: .6; cursor: default; }
.stats { color: var(--muted); font-size: .9rem; min-height: 1.2em; }

main { max-width: 1400px; margin: 0 auto; padding: 0 1rem 3rem; }

.book-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 1.25rem;
}
@media (max-width: 600px) {
  .book-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .75rem; }
}

.book-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  display: flex; flex-direction: column;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
  transition: box-shadow .15s, transform .15s;
}
.book-card:hover { box-shadow: 0 6px 18px rgba(0,0,0,.12); transform: translateY(-2px); }

.book-cover {
  position: relative;
  width: 100%;
  aspect-ratio: 2 / 3;   /* catalog covers cluster tightly on 2:3 (measured median) */
  overflow: hidden;
  background: #efeae1;
}
/* Real cover sits on top of the placeholder; its solid background matte hides the
   placeholder in the letterboxed areas left by object-fit: contain. On load error,
   onerror removes the img and the faux-cover placeholder shows through. */
.book-cover img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: contain;
  background: #efeae1;
}
/* Placeholder: a sepia matte holding a faux "plain cover", so coverless books read
   as books rather than a repeat of the metadata below the cover. */
.book-cover-placeholder {
  position: absolute; inset: 0;
  display: flex;
  padding: 9%;
  background: linear-gradient(160deg, #efe9dd, #e2dac9);
}
.faux-cover {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: .45rem; padding: 1rem .8rem; text-align: center; overflow: hidden;
  background: #fbfaf6;
  border: 1px solid #b09a76;
  box-shadow: inset 0 0 0 6px #fbfaf6, inset 0 0 0 7px #b09a76; /* thin inset frame */
}
.ph-title {
  font-family: Georgia, 'Times New Roman', serif;
  font-weight: 700; font-size: 1rem; line-height: 1.25; color: #3a2f20;
  display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical; overflow: hidden;
}
.ph-author {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: .8rem; color: #6b5a3e;
  padding-top: .4rem; border-top: 1px solid #d8c7a6;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}

.book-info { padding: .75rem .85rem 1rem; display: flex; flex-direction: column; flex: 1; gap: .3rem; }
.book-title { font-weight: 700; font-size: 1rem; line-height: 1.25; }
.book-author { color: var(--muted); font-size: .9rem; }
.book-year { color: var(--muted); font-size: .8rem; }
.book-subjects { display: flex; flex-wrap: wrap; gap: .3rem; margin: .15rem 0; }
.book-subject {
  font-size: .7rem; background: #f0ebe2; color: #6a5a44;
  padding: .1rem .45rem; border-radius: 999px; white-space: nowrap;
}
.book-description {
  font-size: .85rem; color: #444; flex: 1;
  display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden;
}
.book-actions { margin-top: .6rem; }
.amazon-link {
  display: inline-block; text-decoration: none;
  background: #ff9900; color: #111; font-weight: 600; font-size: .85rem;
  padding: .45rem .8rem; border-radius: 6px;
}
.amazon-link:hover { filter: brightness(1.05); }

/* loader + states */
.loader { text-align: center; padding: 3rem 0; }
.spinner {
  display: inline-block; width: 42px; height: 42px;
  border: 5px solid #ddd; border-top-color: var(--accent);
  border-radius: 50%; animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.state-msg { text-align: center; color: var(--muted); padding: 2rem; }
.hidden { display: none !important; }
