:root {
  --bg: #0f0c0a;
  --bg-2: #1a1613;
  --ink: #f6efe2;
  --ink-dim: #a89c8a;
  --radius: 20px;
  --gap: 10px;
  --font-head: "League Spartan", "Futura", "Century Gothic", sans-serif;
  --font-body: "Barlow", system-ui, sans-serif;
  --font-label: "League Spartan", "Futura", sans-serif;
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }
html:has(.detail[open]) { overflow: hidden; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: var(--font-body);
  background-color: var(--bg);
  background-image:
    radial-gradient(1200px 600px at 10% -10%, #3a2a20 0%, transparent 60%),
    radial-gradient(900px 500px at 110% 10%, #1f2a2b 0%, transparent 55%);
  background-attachment: fixed;
}

/* subtle grain */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.07;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  z-index: 50;
}

/* ---------- Header ---------- */
.top {
  position: sticky;
  top: 0;
  z-index: 10;
  pointer-events: none;
}

.top__inner {
  padding: 20px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

.top__actions {
  display: flex;
  align-items: center;
  pointer-events: auto;
  background: var(--bg-2);
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 14px;
  box-shadow: 0 3px 8px rgba(0,0,0,.24);
}

.top__actions::before {
  content: "";
  order: 1;
  height: 18px;
  width: 1px;
  background: rgba(255,255,255,.16);
}

.logo {
  pointer-events: auto;
  display: flex;
  gap: 4px;
  text-decoration: none;
  flex-shrink: 0;
}

.logo__pill {
  font-family: var(--font-head);
  font-weight: 800;
  text-transform: uppercase;
  font-size: 18px;
  line-height: 1;
  padding: 8px 12px 7px;
  border-radius: 12px;
  box-shadow: inset 0 2px 0 rgba(255,255,255,.35), inset 0 -3px 0 rgba(0,0,0,.25);
  transition: rotate 260ms var(--ease-out), translate 260ms var(--ease-out);
}
/* stuck on slightly crooked, like stickers */
/* SIMPLE stays anchored at its left edge and tips up; THOUGHTS tilts only a little so its end doesn't hang low */
.logo__pill--a { background: #ED1C26; color: #fff; transform-origin: left center; rotate: -4deg; }
.logo__pill--b { background: #FFCA0A; color: #2a1d06; transform-origin: left center; rotate: 2deg; translate: 0 -3px; }
/* straighten up on hover */
@media (hover: hover) and (pointer: fine) {
  .logo:hover .logo__pill { rotate: 0deg; translate: 0 0; }
}
.logo:focus-visible .logo__pill { rotate: 0deg; translate: 0 0; }
@media (prefers-reduced-motion: reduce) { .logo__pill { transition: none; } }

.logo:focus-visible, .card:focus-visible, .end__again:focus-visible {
  outline: 3px solid #FFCA0A;
  outline-offset: 2px;
}

/* ---------- Feed ---------- */
main {
  max-width: 1440px;
  margin: 0 auto;
  padding: 20px 20px 80px;
}

.intro {
  margin: 4px 2px 18px;
  font-family: var(--font-label);
  font-size: 13px;
  color: var(--ink-dim);
}
.count { color: var(--ink); }

.feed {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: var(--gap);
}

.card {
  --c: #ED1C26;
  --fg: #fff;
  --fg-dim: var(--fg);
  position: relative;
  height: 100%;
  min-height: 220px;
  display: flex;
  flex-direction: column;
  padding: 16px 16px 14px;
  border-radius: var(--radius);
  background: var(--c);
  color: var(--fg);
  cursor: pointer;
  overflow: hidden;
  isolation: isolate;
  box-shadow:
    inset 0 2px 0 rgba(255,255,255,.32),
    inset 0 -5px 0 rgba(0,0,0,.22),
    0 1px 0 rgba(0,0,0,.5),
    0 8px 18px -8px rgba(0,0,0,.6);
  transition: transform 220ms var(--ease-out), box-shadow 220ms var(--ease-out);
}

/* glossy sticker highlight */
.card::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: radial-gradient(120% 70% at 20% 0%, rgba(255,255,255,.22), transparent 55%);
  pointer-events: none;
}

@media (hover: hover) and (pointer: fine) {
  .feed .card:hover {
    transform: translateY(-3px) rotate(var(--tilt, -0.6deg));
    box-shadow:
      inset 0 2px 0 rgba(255,255,255,.32),
      inset 0 -5px 0 rgba(0,0,0,.22),
      0 1px 0 rgba(0,0,0,.5),
      0 16px 26px -10px rgba(0,0,0,.7);
  }
}
.feed .card:active { transform: scale(0.97); transition-duration: 100ms; }

.card__heading {
  margin: 0 0 8px;
  font-family: var(--font-head);
  font-weight: 800;
  text-transform: uppercase;
  font-size: 23px;
  line-height: 1;
  letter-spacing: -0.01em;
  text-wrap: balance;
}

.card__text {
  margin: 0 0 12px;
  font-size: 14px;
  line-height: 1.35;
  font-weight: 500;
  color: var(--fg-dim);
  text-wrap: pretty;
}

.card__from {
  margin: auto 0 0;
  font-family: var(--font-label);
  font-size: 11px;
  line-height: 1.3;
  color: var(--fg);
}
/* full colour for contrast; author vs. book is carried by weight, not fading */
.card__from b { font-weight: 700; display: block; }
.card__from span { font-weight: 500; }

/* entrance */
.card.is-new {
  animation: pop 420ms var(--ease-out) both;
  animation-delay: calc(var(--i, 0) * 28ms);
}
@keyframes pop {
  from { opacity: 0; transform: translateY(10px) scale(0.94); }
  to   { opacity: 1; transform: none; }
}

.sentinel { height: 1px; }

.end {
  text-align: center;
  font-family: var(--font-label);
  font-size: 13px;
  color: var(--ink-dim);
  margin-top: 40px;
}
.end__again {
  font: inherit;
  color: var(--ink);
  background: none;
  border: 0;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

/* ---------- Detail dialog ---------- */
.detail {
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--ink);
  width: min(520px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  max-height: calc(100dvh - 48px);
  overflow: auto;
  overscroll-behavior: contain;
}
.detail::backdrop {
  background: rgba(14, 11, 9, .72);
  backdrop-filter: blur(6px);
}
.detail[open] { animation: rise 280ms var(--ease-out); }
.detail[open]::backdrop { animation: fade 200ms ease; }
@keyframes rise { from { opacity: 0; transform: translateY(14px) scale(.96); } }
@keyframes fade { from { opacity: 0; } }

.detail__card {
  position: relative;
  padding: 28px 28px 24px;
  border-radius: 28px;
  background: var(--c);
  color: var(--fg);
  box-shadow:
    inset 0 3px 0 rgba(255,255,255,.32),
    inset 0 -7px 0 rgba(0,0,0,.22),
    0 30px 60px -20px rgba(0,0,0,.8);
}
.detail__heading {
  margin: 0 40px 14px 0;
  font-family: var(--font-head);
  font-weight: 800;
  text-transform: uppercase;
  font-size: clamp(32px, 7vw, 46px);
  line-height: 1;
}
.detail__text { margin: 0 0 20px; font-size: 19px; line-height: 1.4; font-weight: 500; }
.detail__from { margin: 0; font-family: var(--font-label); font-size: 13px; }

.detail__close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 0;
  font-size: 24px;
  line-height: 1;
  color: inherit;
  background: rgba(0,0,0,.18);
  cursor: pointer;
}

.detail__more { margin-top: 18px; }
.detail__more h3 {
  margin: 0 0 8px 4px;
  font-family: var(--font-label);
  font-weight: 500;
  font-size: 12px;
  color: var(--ink-dim);
  text-transform: uppercase;
  letter-spacing: .06em;
}
.detail__list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.detail__list button {
  font-family: var(--font-head);
  font-weight: 800;
  text-transform: uppercase;
  font-size: 14px;
  padding: 7px 12px 6px;
  border-radius: 12px;
  border: 0;
  cursor: pointer;
  background: var(--c);
  color: var(--fg);
  box-shadow: inset 0 2px 0 rgba(255,255,255,.3), inset 0 -3px 0 rgba(0,0,0,.22);
  transition: transform 120ms var(--ease-out);
}
.detail__list button:active { transform: scale(.95); }

/* ---------- Small screens ---------- */
@media (max-width: 640px) {
  .top__inner { padding: 12px; gap: 8px; }
  .collection-trigger span { display: none; }
  .top__actions .collection-trigger { width: 44px; padding: 0; }

  main { padding: 16px 16px 64px; }
  .feed { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .card { min-height: 170px; padding: 13px 12px 12px; border-radius: 16px; }
  .card__heading { font-size: 18px; }
  .card__text { font-size: 13px; }
}
@media (max-width: 520px) {
  .feed { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .card.is-new, .detail[open], .detail[open]::backdrop { animation: none; }
  .feed .card:hover { transform: none; }
}

/* ---------- Header actions ---------- */
.viewlink {
  flex-shrink: 0;
  font-family: var(--font-head);
  font-weight: 800;
  text-transform: uppercase;
  font-size: 13px;
  letter-spacing: 0.04em;
  text-decoration: none;
  color: var(--ink);
  background: transparent;
  border: 0;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 12px;
  line-height: 1;
  transition: transform 120ms var(--ease-out), background-color 160ms ease;
}
@media (hover: hover) and (pointer: fine) {
  .viewlink:hover { background-color: rgba(255,255,255,.08); }
}
.viewlink:active { transform: scale(0.95); }
.viewlink:focus-visible { outline: 3px solid #FFCA0A; outline-offset: 2px; }

/* ---------- Copy ---------- */
.detail__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.detail__copy {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: var(--font-head);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-size: 14px;
  line-height: 1;
  padding: 10px 14px 9px;
  border: 0;
  border-radius: 12px;
  cursor: pointer;
  color: var(--c);
  background: var(--fg);
  box-shadow: inset 0 2px 0 rgba(255,255,255,.35), inset 0 -3px 0 rgba(0,0,0,.18);
  transition: transform 120ms var(--ease-out);
}
.detail__copy:active { transform: scale(0.95); }
.detail__copy:focus-visible { outline: 3px solid var(--fg); outline-offset: 3px; }
/* while "Copied" shows, the checkmark takes the copy icon's place */
.detail__copy-check,
.detail__copy.is-done .detail__copy-icon { display: none; }
.detail__copy.is-done .detail__copy-check { display: block; }

/* Small check stamp on cards you've already uncovered */
.card.is-read::after {
  content: "✓";
  position: absolute;
  top: 10px;
  right: 10px;
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  border-radius: 50%;
  color: var(--c);
  background: var(--fg);
  opacity: 0.85;
}
.card.is-read .card__heading { padding-right: 24px; }

/* ---------- Favourites ---------- */
/* Star stamp next to the check stamp (or in its place if the card isn't read yet) */
.card__fav {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 20px;
  height: 20px;
  display: none;
  place-items: center;
  border-radius: 50%;
  color: var(--c);
  background: var(--fg);
}
.card.is-fav .card__fav { display: grid; }
.card.is-fav .card__heading { padding-right: 24px; }
.card.is-read.is-fav .card__fav { right: 34px; }
.card.is-read.is-fav .card__heading { padding-right: 48px; }
.card.is-fav-pop .card__fav { animation: fav-pop 380ms var(--ease-out); }
@keyframes fav-pop {
  0% { transform: scale(0.4); }
  60% { transform: scale(1.35); }
  100% { transform: scale(1); }
}

.detail__actions { display: flex; gap: 8px; }
.detail__fav {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: var(--font-head);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-size: 14px;
  line-height: 1;
  padding: 10px 14px 9px;
  border-radius: 12px;
  cursor: pointer;
  color: var(--fg);
  background: transparent;
  border: 2px solid var(--fg);
  transition: transform 120ms var(--ease-out);
}
.detail__fav:active { transform: scale(0.95); }
.detail__fav:focus-visible { outline: 3px solid var(--fg); outline-offset: 3px; }
.detail__fav[aria-pressed="true"] svg path { fill: currentColor; }
.detail__fav.is-pop svg { animation: fav-pop 380ms var(--ease-out); }

@media (prefers-reduced-motion: reduce) {
  .card.is-fav-pop .card__fav, .detail__fav.is-pop svg { animation: none; }
}

.collection-trigger { order: 2; cursor: pointer; }
.collection-trigger svg { color: #ffca0a; }
@media (max-width: 420px) {
  .logo__pill { padding-inline: 7px; font-size: 15px; }
  .viewlink { padding-inline: 8px; }
}
@media (max-width: 350px) {
  .logo__pill { padding-inline: 5px; font-size: 13px; }
}

/* Reset lives in the Books tab now */
.collection__reset {
  margin: -12px 0 18px;
  padding: 2px 0;
  font-family: var(--font-label);
  font-size: 12px;
  color: var(--ink-dim);
  background: none;
  border: 0;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.collection__reset:hover { color: var(--ink); }
.collection__reset:focus-visible { outline: 2px solid currentColor; outline-offset: 2px; }

/* ---------- Collection dialog ---------- */
.collection {
  border: 0;
  padding: 0;
  color: var(--ink);
  background: transparent;
  width: min(640px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
}
.collection::backdrop { background: rgba(10, 8, 6, 0.75); backdrop-filter: blur(6px); }
.collection[open] { animation: rise 280ms var(--ease-out); }

.collection__panel {
  position: relative;
  padding: 26px 24px 24px;
  border-radius: 26px;
  background: #1d1814;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 30px 60px -20px rgba(0, 0, 0, 0.9);
}
.collection__close { color: var(--ink); background: rgba(255, 255, 255, 0.08); }

.collection__title {
  margin: 0 40px 2px 0;
  font: 800 28px/1.1 var(--font-head);
}
.collection__progress {
  margin: 0 0 18px;
  color: var(--ink-dim);
  font-variant-numeric: tabular-nums;
}
.collection__sum {
  margin: 6px 0 22px;
  font-size: 15px;
  color: var(--ink-dim);
}
.collection__sum b { color: var(--ink); font-weight: 600; }

.collection__sub {
  margin: 0 0 10px;
  font-family: var(--font-label);
  font-weight: 500;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-dim);
}
.collection__books {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(260px, 100%), 1fr));
  gap: 8px;
}
.book {
  position: relative;
  padding: 11px 12px 10px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.06);
}
.book__title {
  display: block;
  font-family: var(--font-head);
  font-weight: 800;
  text-transform: uppercase;
  font-size: 15px;
  line-height: 1.05;
  padding-right: 42px;
}
.book__author { display: block; margin-top: 2px; font-family: var(--font-label); font-size: 11px; opacity: 0.7; }
.book__count {
  position: absolute;
  top: 11px;
  right: 12px;
  font-family: var(--font-head);
  font-weight: 800;
  font-size: 14px;
  opacity: 0.8;
}
.book__pips { display: flex; gap: 4px; margin-top: 9px; }
.book__pips i {
  flex: 1;
  height: 6px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.1);
}
.book__pips i.on { background: var(--c, #FFCA0A); }
.book.is-done {
  color: var(--fg);
  background: var(--c);
  border-color: transparent;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.3), inset 0 -4px 0 rgba(0, 0, 0, 0.2);
}
.book.is-done .book__pips i.on { background: var(--fg); opacity: 0.5; }
.book.is-done .book__count::before { content: "✓ "; }

@media (prefers-reduced-motion: reduce) {
  .collection[open] { animation: none; }
}

/* ---------- Collection tabs: Favorites | Books ---------- */
.ctabs {
  display: flex;
  gap: 6px;
  margin: 4px 0 20px;
  padding: 4px;
  width: fit-content;
  max-width: 100%;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.06);
}
.ctab {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 10px 14px 9px;
  border: 0;
  border-radius: 10px;
  cursor: pointer;
  font-family: var(--font-head);
  font-weight: 800;
  font-size: 15px;
  line-height: 1;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: var(--ink-dim);
  background: transparent;
  transition: background 160ms ease, color 160ms ease;
}
.ctab:hover { color: var(--ink); }
.ctab[aria-selected="true"] {
  color: #2a1d06;
  background: #FFCA0A;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.35), inset 0 -3px 0 rgba(0, 0, 0, 0.18);
}
.ctab:focus-visible { outline: 3px solid #FFCA0A; outline-offset: 2px; }
.ctab__n { font-size: 13px; opacity: 0.75; }
.ctab__n:empty { display: none; }
.cpanel[hidden] { display: none; }

/* ---------- Favorites: whole cards you can reread ---------- */
.favs__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 14px;
}
.favs__hint { margin: 0; font-size: 15px; color: var(--ink-dim); }
.favs__hint b { color: var(--ink); font-weight: 600; }
.favs__hint kbd { font-family: var(--font-label); }
.favs__copy {
  flex-shrink: 0;
  font-family: var(--font-head);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-size: 13px;
  line-height: 1;
  padding: 9px 13px 8px;
  border: 0;
  border-radius: 10px;
  cursor: pointer;
  color: #2a1d06;
  background: #FFCA0A;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.35), inset 0 -3px 0 rgba(0, 0, 0, 0.18);
  transition: transform 120ms var(--ease-out);
}
.favs__copy:active { transform: scale(0.95); }
.favs__copy:focus-visible { outline: 3px solid #FFCA0A; outline-offset: 3px; }
.favs__copy[hidden] { display: none; }

.favs {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
}
.fav {
  content-visibility: auto;
  contain-intrinsic-block-size: auto 160px;
  padding: 16px 16px 12px;
  border-radius: 16px;
  color: var(--fg);
  background: var(--c);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.3), inset 0 -4px 0 rgba(0, 0, 0, 0.2);
  transition: opacity 200ms ease, filter 200ms ease;
}
.fav.is-off { opacity: 0.45; filter: grayscale(0.8); }
.fav__title {
  margin: 0 0 8px;
  font-family: var(--font-head);
  font-weight: 800;
  text-transform: uppercase;
  font-size: 21px;
  line-height: 1;
}
.fav__text { margin: 0 0 12px; font-size: 16px; line-height: 1.4; font-weight: 500; max-width: 62ch; }
.fav__foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.fav__from { margin: 0; font-family: var(--font-label); font-size: 12px; }
.fav__star {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 2px solid var(--fg);
  border-radius: 10px;
  cursor: pointer;
  color: var(--c);
  background: var(--fg);
  transition: transform 120ms var(--ease-out);
}
.fav__star svg { width: 18px; height: 18px; }
.fav__star[aria-pressed="false"] { color: var(--fg); background: transparent; }
.fav__star:active { transform: scale(0.92); }
.fav__star:focus-visible { outline: 3px solid var(--fg); outline-offset: 2px; }

/* ---------- Crawlable pages (books/, generated by build.mjs) ---------- */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
h1.intro { font-weight: 500; }
.is-static .card { cursor: auto; }
.crumbs { margin: 4px 2px 10px; font-family: var(--font-label); font-size: 13px; color: var(--ink-dim); }
.crumbs a { color: var(--ink); }
.page-head { margin: 0 2px 20px; }
.page-head h1 {
  margin: 0; font-family: var(--font-head); font-weight: 800; text-transform: uppercase;
  font-size: clamp(32px, 6vw, 56px); line-height: 0.95; letter-spacing: -0.01em; text-wrap: balance;
}
.page-head__by { margin: 8px 0 0; font-family: var(--font-label); font-size: 15px; color: var(--ink-dim); }
.is-static .feed .card { min-height: 0; }
.more-books, .topic { margin: 40px 2px 0; }
.more-books h2, .topic h2, .all-books h2 {
  margin: 0 0 10px; font-family: var(--font-head); font-weight: 800; text-transform: uppercase;
  font-size: 18px; letter-spacing: 0.02em;
}
.all-books { margin: 72px 2px 0; padding-top: 24px; border-top: 1px solid rgba(255,255,255,.1); }
.all-books h2 a { color: var(--ink); text-decoration: none; }
.all-books .topic { margin-top: 20px; }
.all-books .topic h2 { font-size: 14px; color: var(--ink-dim); }
.book-links { list-style: none; margin: 0; padding: 0; columns: 3 260px; column-gap: 24px; }
.book-links li { break-inside: avoid; padding: 4px 0; font-size: 15px; line-height: 1.3; }
.book-links a { color: var(--ink); font-weight: 600; text-underline-offset: 3px; }
.book-links span { display: block; font-family: var(--font-label); font-size: 12px; color: var(--ink-dim); }
.is-static .top__actions::before { display: none; }
