:root {
  --ink: #221d1a;
  --ink-2: #453c36;
  --cream: #f7f1e8;
  --cream-2: #efe5d7;
  --paper: #fffdf8;
  --line: #e3d8c5;
  --accent: #7a3b2e;
  --accent-2: #a05a3c;
  --gold: #b8893d;
  --muted: #8a7f72;
  --ok: #3f6b3f;
  --err: #a33a2f;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 0 rgba(34, 29, 26, 0.04), 0 10px 30px -18px rgba(34, 29, 26, 0.25);
  --shadow-lift: 0 1px 0 rgba(34, 29, 26, 0.06), 0 18px 40px -22px rgba(34, 29, 26, 0.4);
  --serif: "Fraunces", "Iowan Old Style", Georgia, serif;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--sans);
  color: var(--ink);
  background: var(--cream);
  background-image:
    radial-gradient(circle at 12% -10%, rgba(184, 137, 61, 0.10), transparent 40%),
    radial-gradient(circle at 92% 0%, rgba(122, 59, 46, 0.08), transparent 38%);
  line-height: 1.55;
  font-size: 16px;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.1; letter-spacing: -0.01em; }
h1 { font-size: clamp(2rem, 4.4vw, 3rem); }
h2 { font-size: clamp(1.4rem, 2.6vw, 1.9rem); }

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--accent-2);
  margin: 0 0 0.4rem;
}
.lede { color: var(--ink-2); font-size: 1.08rem; max-width: 48ch; }
.muted { color: var(--muted); }
.small { font-size: 0.86rem; }

/* ---------------- Header ---------------- */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.4rem 1.6rem;
  gap: 1rem;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font-family: var(--serif);
  font-size: 1.12rem;
  font-weight: 600;
  color: var(--ink);
  text-decoration: none;
}
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 34px; height: 34px;
  display: inline-grid; place-items: center;
  background: var(--ink);
  color: var(--cream);
  border-radius: 9px;
  box-shadow: var(--shadow);
}
.brand-name { letter-spacing: -0.01em; }
.site-nav { display: flex; gap: 1.4rem; font-size: 0.95rem; }
.site-nav a { color: var(--ink-2); }

/* ---------------- Layout ---------------- */
main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1rem 1.6rem 4rem;
}

/* ---------------- Hero ---------------- */
.hero {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  align-items: center;
  gap: 3rem;
  margin-top: 2.5rem;
  padding-bottom: 4rem;
  border-bottom: 1px solid var(--line);
}
.hero-copy h1 { margin: 0.4rem 0 1rem; }

.redeem-form {
  margin-top: 1.8rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  align-items: flex-end;
}
.field { display: flex; flex-direction: column; gap: 0.35rem; }
.field label { font-size: 0.78rem; font-weight: 600; color: var(--muted); letter-spacing: 0.05em; text-transform: uppercase; }
.field input {
  width: 280px;
  max-width: 80vw;
  padding: 0.85rem 1rem;
  font: inherit;
  letter-spacing: 0.02em;
  font-size: 1.05rem;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(122, 59, 46, 0.18);
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.85rem 1.2rem;
  font: inherit;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.06s ease, background 0.15s, color 0.15s, box-shadow 0.15s;
}
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: var(--ink);
  color: var(--cream);
  box-shadow: var(--shadow);
}
.btn-primary:hover:not([disabled]) { background: var(--accent); text-decoration: none; }
.btn-primary[disabled] { opacity: 0.45; cursor: not-allowed; }
.btn-ghost {
  background: transparent;
  color: var(--ink);
  border-color: var(--line);
}
.btn-ghost:hover { border-color: var(--accent-2); color: var(--accent-2); text-decoration: none; }

.hint { margin-top: 1.6rem; color: var(--muted); font-size: 0.92rem; }
.chip {
  font: inherit;
  background: var(--paper);
  border: 1px solid var(--line);
  color: var(--accent);
  padding: 0.3rem 0.6rem;
  margin: 0.2rem 0.2rem 0 0;
  border-radius: 999px;
  font-size: 0.82rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.chip:hover { background: var(--cream-2); border-color: var(--accent-2); }

/* ---------------- Hero art (bookshelf) ---------------- */
.hero-art { display: grid; place-items: center; }
.shelf {
  position: relative;
  display: flex;
  align-items: flex-end;
  gap: 0.45rem;
  padding: 2.4rem 1.2rem 1.1rem;
  background: linear-gradient(180deg, rgba(255,253,248,0) 0%, var(--cream-2) 100%);
  border-radius: 18px;
}
.shelf::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 0.4rem;
  height: 10px;
  background: var(--ink);
  border-radius: 4px;
}
.book {
  width: 30px;
  height: 130px;
  background: var(--spine);
  border-radius: 3px 3px 1px 1px;
  box-shadow: inset -4px 0 0 rgba(0,0,0,0.18), inset 4px 0 0 rgba(255,255,255,0.05), var(--shadow);
  position: relative;
  animation: sway 6s ease-in-out infinite;
}
.book::before {
  content: "";
  position: absolute; left: 50%; top: 14px; bottom: 14px;
  width: 2px; margin-left: -1px;
  background: rgba(255,255,255,0.16);
}
.book-tall  { height: 160px; }
.book-short { height: 104px; }
.book:nth-child(1) { animation-delay: 0.0s; }
.book:nth-child(2) { animation-delay: 0.6s; }
.book:nth-child(3) { animation-delay: 1.2s; }
.book:nth-child(4) { animation-delay: 0.3s; }
.book:nth-child(5) { animation-delay: 0.9s; }
.book:nth-child(6) { animation-delay: 1.5s; }
@keyframes sway {
  0%, 100% { transform: rotate(-1deg); }
  50%      { transform: rotate(1.4deg); }
}

/* ---------------- Steps ---------------- */
.steps { margin: 3.4rem 0 0; }
.steps h2 { margin: 0 0 2rem; }
.step-grid {
  list-style: none;
  margin: 0; padding: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.4rem;
}
.step-grid li {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.6rem 1.4rem 1.4rem;
  box-shadow: var(--shadow);
}
.step-num {
  display: inline-block;
  font-family: var(--serif);
  font-size: 1.1rem;
  color: var(--accent);
  background: var(--cream-2);
  border-radius: 999px;
  padding: 0.2rem 0.7rem;
  margin-bottom: 0.8rem;
}
.step-grid h3 { margin: 0 0 0.4rem; font-size: 1.18rem; }
.step-grid p  { margin: 0; color: var(--ink-2); font-size: 0.96rem; }

/* ---------------- Shelf header ---------------- */
.shelf-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1.2rem;
  margin: 2.5rem 0 2rem;
}
.shelf-header h1 { margin: 0.4rem 0 0.3rem; }
.badge {
  display: inline-block;
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--cream-2);
  border: 1px solid var(--line);
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
}

/* ---------------- Toolbar ---------------- */
.shelf-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  margin: 1.2rem 0 1.6rem;
  padding: 0.9rem 1rem;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.checkbox {
  display: inline-flex; align-items: center; gap: 0.55rem;
  cursor: pointer;
  font-weight: 500;
}
.checkbox input {
  appearance: none;
  width: 20px; height: 20px;
  border: 1.5px solid var(--line);
  background: var(--cream);
  border-radius: 6px;
  display: inline-grid; place-items: center;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.checkbox input:checked {
  background: var(--ink);
  border-color: var(--ink);
}
.checkbox input:checked::after {
  content: "";
  width: 11px; height: 6px;
  border: 2px solid var(--cream);
  border-top: 0; border-right: 0;
  transform: rotate(-45deg) translate(1px, -1px);
}
.checkbox.select-all { margin-right: 0.4rem; }
.counter {
  color: var(--muted);
  font-size: 0.92rem;
  font-variant-numeric: tabular-nums;
}
#redeem-btn { margin-left: auto; }

/* ---------------- Book grid ---------------- */
.book-grid {
  list-style: none;
  margin: 0; padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
}
.book-card { margin: 0; }
.book-card-inner {
  display: flex;
  flex-direction: column;
  cursor: pointer;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  height: 100%;
  transition: transform 0.12s ease, box-shadow 0.15s, border-color 0.15s;
  position: relative;
}
.book-card-inner:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lift);
  border-color: var(--accent-2);
}

.book-check:checked + .cover { box-shadow: 0 0 0 3px var(--accent); }
.book-check:checked ~ .book-meta .claim-tag {
  background: var(--ok);
  color: #fff;
}
.book-check:checked ~ .book-meta .claim-tag svg { color: #fff; }
.book-check:focus-visible + .cover {
  outline: 3px solid var(--accent-2);
  outline-offset: 3px;
}

.cover {
  position: relative;
  height: 150px;
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--spine) 78%, #fff 0%) 0%,
                            color-mix(in srgb, var(--spine) 92%, #000 0%) 100%);
  display: grid;
  place-items: center;
  color: rgba(255,255,255,0.9);
}
.cover-mark {
  font-family: var(--serif);
  font-size: 2.2rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-shadow: 0 1px 0 rgba(0,0,0,0.25);
}
.cover-edge {
  position: absolute;
  top: 0; bottom: 0; left: 12px;
  width: 3px;
  background: rgba(255,255,255,0.3);
  border-radius: 0 2px 2px 0;
}

.book-meta {
  padding: 0.95rem 1rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  flex: 1;
}
.book-genre {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-2);
}
.book-title {
  font-family: var(--serif);
  font-size: 1.18rem;
  font-weight: 600;
  line-height: 1.2;
  margin-top: 0.15rem;
}
.book-author { color: var(--ink-2); font-size: 0.93rem; }
.book-edition { color: var(--muted); font-size: 0.82rem; margin-top: 0.2rem; }
.claim-tag {
  margin-top: 0.7rem;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  align-self: flex-start;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--accent);
  background: var(--cream-2);
  padding: 0.3rem 0.6rem;
  border-radius: 999px;
  transition: background 0.15s, color 0.15s;
}
.claim-tag svg { color: currentColor; }

/* ---------------- Panels & alerts ---------------- */
.panel {
  margin: 3rem 0;
  padding: 2.4rem;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  text-align: center;
}
.panel h1 { margin: 0 0 0.6rem; font-size: 1.7rem; }
.panel .btn { margin-top: 1.2rem; }

.alert {
  margin-top: 1.5rem;
  padding: 0.9rem 1.1rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-weight: 500;
}
.alert-success { background: #eaf2ea; color: #2a4a2a; border-color: #c5dac5; }
.alert-error   { background: #f6e9e7; color: var(--err);     border-color: #e9c9c3; }

/* ---------------- Footer ---------------- */
.site-footer {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem 1.6rem 3rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
}
.site-footer p { margin: 0.2rem 0; }

/* ---------------- Responsive ---------------- */
@media (max-width: 880px) {
  .hero { grid-template-columns: 1fr; gap: 1.6rem; padding-bottom: 2.6rem; }
  .hero-art { order: -1; }
  .shelf { transform: scale(0.85); }
  .step-grid { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .site-nav { display: none; }
  .field input { width: 100%; }
  .redeem-form .btn { width: 100%; justify-content: center; }
  .shelf-toolbar { flex-direction: column; align-items: stretch; }
  #redeem-btn { margin-left: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .book { animation: none; }
  .book-card-inner:hover { transform: none; }
}