/* Goosey's Book Club — a library card catalogue.
   Aged paper, letterpress ink, rubber stamps. */

:root {
  --paper: #efe5d3;
  --paper-deep: #e5d8c2;
  --card: #fbf6ea;
  --ink: #24201c;
  --ink-soft: #6c6155;
  --ink-faint: #a2968550;
  --stamp: #b0392c;
  --thread: #3f6b60;
  --rule: #24201c1f;

  --display: "Fraunces", Georgia, serif;
  --mono: "Courier Prime", ui-monospace, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  background:
    radial-gradient(120% 80% at 15% 0%, #f7efe0 0%, transparent 55%),
    radial-gradient(100% 70% at 90% 10%, #f3e9d8 0%, transparent 50%),
    var(--paper);
  color: var(--ink);
  font-family: var(--display);
  font-optical-sizing: auto;
  font-weight: 400;
  line-height: 1.55;
  min-height: 100vh;
  padding: 0 clamp(16px, 5vw, 64px) 96px;
  overflow-x: hidden;
}

/* Paper tooth, so the background is never flat. */
.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 999;
  opacity: 0.32;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23n)' opacity='0.55'/%3E%3C/svg%3E");
}

/* ── Masthead ─────────────────────────────────────────────────────────── */

.masthead {
  max-width: 1180px;
  margin: 0 auto;
  padding: clamp(48px, 9vw, 104px) 0 clamp(28px, 4vw, 44px);
  animation: rise 0.9s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}

.kicker {
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.34em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-bottom: clamp(14px, 2vw, 22px);
}

.masthead h1 {
  font-weight: 300;
  font-size: clamp(3.1rem, 13vw, 9.5rem);
  line-height: 0.82;
  letter-spacing: -0.035em;
  display: flex;
  flex-direction: column;
}

.masthead h1 span {
  font-variation-settings: "SOFT" 0, "WONK" 1;
  font-weight: 300;
  /* The hyphen is part of the name — never let it double as a line break. */
  white-space: nowrap;
}

.masthead h1 em {
  font-style: italic;
  font-weight: 700;
  color: var(--stamp);
  font-variation-settings: "SOFT" 40, "WONK" 1;
  margin-left: 0.06em;
}

.rule {
  height: 2px;
  margin: clamp(26px, 4vw, 44px) 0 0;
  background: repeating-linear-gradient(90deg, var(--ink) 0 28px, transparent 28px 34px);
  opacity: 0.5;
}

.stats {
  display: flex;
  flex-wrap: wrap;
  gap: clamp(24px, 5vw, 64px);
  margin-top: clamp(20px, 3vw, 30px);
}

.stats dt {
  font-size: clamp(1.6rem, 3.4vw, 2.5rem);
  font-weight: 600;
  line-height: 1;
  font-variant-numeric: lining-nums;
}

.stats dd {
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-top: 6px;
}

/* ── Shelves ──────────────────────────────────────────────────────────── */

main { max-width: 1180px; margin: 0 auto; }

.shelf { margin-top: clamp(52px, 8vw, 96px); }

.shelf-head {
  display: flex;
  align-items: baseline;
  gap: 18px;
  flex-wrap: wrap;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--rule);
  margin-bottom: clamp(26px, 4vw, 40px);
}

.shelf-head h2 {
  font-size: clamp(1.3rem, 2.6vw, 1.9rem);
  font-weight: 600;
  letter-spacing: -0.02em;
}

.shelf-head p {
  font-family: var(--mono);
  font-size: 0.76rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

/* What the club is doing now, beside what it does next. */
.now {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(20px, 3vw, 34px);
  align-items: start;
}

.now .cards { grid-template-columns: 1fr; }

@media (max-width: 900px) {
  .now { grid-template-columns: 1fr; }
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
  gap: clamp(20px, 3vw, 34px);
  /* Cards keep their natural height — a stretched row leaves dead paper under
     the shorter entries. */
  align-items: start;
}

/* ── Index card ───────────────────────────────────────────────────────── */

.card {
  position: relative;
  display: grid;
  grid-template-columns: 108px 1fr;
  gap: 20px;
  padding: 22px 22px 20px;
  background:
    linear-gradient(var(--card), var(--card)) padding-box,
    linear-gradient(160deg, #ffffffcc, #d9cbb2) border-box;
  border: 1px solid transparent;
  border-radius: 3px;
  box-shadow:
    0 1px 0 #ffffffb0 inset,
    0 12px 24px -18px #241c1266,
    0 2px 6px -3px #241c1233;
  transform: rotate(var(--tilt));
  transition: transform 0.35s cubic-bezier(0.2, 0.7, 0.2, 1), box-shadow 0.35s ease;
  animation: deal 0.7s cubic-bezier(0.2, 0.7, 0.2, 1) both;
  animation-delay: var(--delay);
}

.card:hover {
  transform: rotate(0deg) translateY(-5px);
  box-shadow:
    0 1px 0 #ffffffb0 inset,
    0 26px 44px -26px #241c1275,
    0 4px 10px -4px #241c1230;
}

.card-no {
  position: absolute;
  top: 14px;
  right: 18px;
  font-family: var(--mono);
  font-size: 0.66rem;
  letter-spacing: 0.16em;
  color: var(--ink-soft);
  opacity: 0.75;
}

/* ── Cover ────────────────────────────────────────────────────────────── */

.cover {
  position: relative;
  aspect-ratio: 2 / 3;
  border-radius: 2px;
  overflow: hidden;
  background: linear-gradient(150deg, #cbb99c, #a8927a);
  box-shadow: 0 6px 14px -8px #241c1288, 0 0 0 1px #24201c1a;
  align-self: start;
}

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

.cover-fallback {
  display: none;
  position: absolute;
  inset: 0;
  align-items: flex-end;
  padding: 10px;
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.2;
  color: #fdf8ef;
  text-shadow: 0 1px 2px #0006;
}

.cover-missing .cover-fallback { display: flex; }

/* A pick that hasn't happened yet: an empty card slot with a question mark
   where the cover goes. */
.card-blank { opacity: 0.72; }

.cover-blank {
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: 2px dashed var(--ink-faint);
  box-shadow: none;
}

.cover-blank span {
  font-size: 2.6rem;
  font-weight: 300;
  color: var(--ink-soft);
  opacity: 0.55;
  line-height: 1;
}

.card-blank .title { color: var(--ink-soft); font-style: italic; }

/* ── Card body ────────────────────────────────────────────────────────── */

.card-body { min-width: 0; }

/* Ruled line under the heading, like a real catalogue card. It hangs off the
   header rather than sitting at a fixed offset, so titles can run to any
   number of lines without the rule striking through them. */
.card-head {
  padding-bottom: 9px;
  border-bottom: 1px solid var(--rule);
}

.title {
  font-size: 1.16rem;
  font-weight: 600;
  line-height: 1.18;
  letter-spacing: -0.015em;
  font-variation-settings: "SOFT" 20, "WONK" 1;
  padding-right: 46px;
}

.author {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--ink-soft);
  margin-top: 5px;
}

.meta {
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-soft);
  opacity: 0.85;
  margin-top: 16px;
}

.note {
  font-size: 0.9rem;
  line-height: 1.5;
  margin-top: 12px;
  color: #3b332b;
}

.note p + p { margin-top: 8px; }
.note a { color: var(--thread); text-underline-offset: 2px; }

/* ── Verdict ──────────────────────────────────────────────────────────── */

.verdict {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px dashed var(--ink-faint);
}

.score {
  display: flex;
  align-items: baseline;
  gap: 9px;
}

.score b {
  font-size: 1.32rem;
  font-weight: 700;
  color: var(--stamp);
  font-variant-numeric: lining-nums;
}

.score span {
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--ink-soft);
}

.stars {
  position: relative;
  display: inline-block;
  font-size: 0.95rem;
  letter-spacing: 0.08em;
  line-height: 1;
}

.stars-empty { color: #24201c2e; }

.stars-full {
  position: absolute;
  inset: 0;
  overflow: hidden;
  white-space: nowrap;
  color: var(--stamp);
}

.tally-label {
  font-family: var(--mono);
  font-size: 0.64rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-top: 8px;
}

/* Reviews sit folded away until asked for, and carry no attribution. */
.reviews { margin-top: 12px; }

.reviews summary {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  list-style: none;
  cursor: pointer;
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--thread);
  border-bottom: 1px solid #3f6b6055;
  padding-bottom: 2px;
  transition: color 0.2s, border-color 0.2s;
}

.reviews summary::-webkit-details-marker { display: none; }
.reviews summary::after { content: "+"; font-size: 0.85rem; line-height: 1; }
.reviews[open] summary::after { content: "\2212"; }
.reviews summary:hover { color: var(--ink); border-color: var(--ink); }

.reviews ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 14px;
}

.reviews li {
  font-size: 0.875rem;
  line-height: 1.5;
  color: #3b332b;
  border-left: 2px solid var(--ink-faint);
  padding-left: 12px;
}

.reviews li p + p { margin-top: 7px; }

.pending {
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

/* Link and stamp share a row, so the stamp can never land on the text. */
.card-foot {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
  min-height: 34px;
}

.goodreads {
  display: inline-block;
  white-space: nowrap;
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--thread);
  text-decoration: none;
  border-bottom: 1px solid #3f6b6055;
  padding-bottom: 2px;
  transition: color 0.2s, border-color 0.2s;
}

.goodreads:hover { color: var(--ink); border-color: var(--ink); }

/* ── Rubber stamps ────────────────────────────────────────────────────── */

.stamp {
  margin-left: auto;
  flex-shrink: 0;
  font-family: var(--mono);
  font-weight: 700;
  font-size: 0.86rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  text-align: center;
  padding: 7px 13px 6px;
  border: 2.5px solid var(--stamp);
  border-radius: 4px;
  color: var(--stamp);
  opacity: 0.82;
  mix-blend-mode: multiply;
  transform: rotate(-11deg);
  animation: press 0.5s cubic-bezier(0.2, 1.5, 0.4, 1) both;
  animation-delay: calc(var(--delay) + 340ms);
  /* Ink never lands evenly. */
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='60'%3E%3Cfilter id='r'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.7' numOctaves='3'/%3E%3CfeColorMatrix type='matrix' values='0 0 0 0 0, 0 0 0 0 0, 0 0 0 0 0, 1 0 0 0 -0.18'/%3E%3C/filter%3E%3Crect width='120' height='60' fill='%23fff'/%3E%3Crect width='120' height='60' filter='url(%23r)'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='60'%3E%3Cfilter id='r'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.7' numOctaves='3'/%3E%3CfeColorMatrix type='matrix' values='0 0 0 0 0, 0 0 0 0 0, 0 0 0 0 0, 1 0 0 0 -0.18'/%3E%3C/filter%3E%3Crect width='120' height='60' fill='%23fff'/%3E%3Crect width='120' height='60' filter='url(%23r)'/%3E%3C/svg%3E");
}

.stamp-reading {
  border-color: var(--thread);
  color: var(--thread);
  font-size: 0.66rem;
  line-height: 1.15;
  letter-spacing: 0.16em;
  transform: rotate(-7deg);
}

.stamp-reading span { font-size: 0.58rem; opacity: 0.8; }

.card-shelf { background-color: #f7f1e4; }

/* ── Footer ───────────────────────────────────────────────────────────── */

footer {
  max-width: 1180px;
  margin: clamp(64px, 10vw, 120px) auto 0;
  padding-top: 22px;
  border-top: 1px solid var(--rule);
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

/* ── Motion ───────────────────────────────────────────────────────────── */

@keyframes rise {
  from { opacity: 0; transform: translateY(18px); }
  to { opacity: 1; transform: none; }
}

@keyframes deal {
  from { opacity: 0; transform: rotate(var(--tilt)) translateY(26px) scale(0.985); }
  to { opacity: 1; transform: rotate(var(--tilt)); }
}

@keyframes press {
  0% { opacity: 0; transform: rotate(-11deg) scale(1.7); }
  60% { opacity: 0.9; }
  100% { opacity: 0.82; transform: rotate(-11deg) scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

@media (max-width: 560px) {
  .card { grid-template-columns: 86px 1fr; gap: 16px; padding: 18px; }
  .stamp { font-size: 0.72rem; padding: 5px 10px 4px; }
  .title { padding-right: 40px; }
}
