/* ── Tokens ─────────────────────────────────────────────────────────────── */
:root {
  --paper: #f6f1e7;
  --paper-2: #efe6d4;
  --card: #fffdf8;
  --ink: #2a2521;
  --ink-soft: #6b6158;
  --line: #e2d7c3;
  --accent: #7a2e38;
  --accent-hover: #63232c;
  --accent-ink: #fff8f0;
  --shadow: 0 1px 2px rgba(60, 40, 20, 0.12), 0 8px 24px -12px rgba(60, 40, 20, 0.35);

  --font-display: 'Fraunces', Georgia, serif;
  --font-body: 'Literata', Georgia, serif;
  --font-ui: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #1b1917;
    --paper-2: #23201c;
    --card: #26221e;
    --ink: #ece4d6;
    --ink-soft: #a89e90;
    --line: #3a342e;
    --accent: #e0939c;
    --accent-hover: #eaa9b0;
    --accent-ink: #1b1917;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 10px 28px -12px rgba(0, 0, 0, 0.8);
    color-scheme: dark;
  }
}

/* ── Base ───────────────────────────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 80px;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
}

img {
  display: block;
  max-width: 100%;
}

.wrap {
  width: min(1180px, 100% - 32px);
  margin-inline: auto;
}

.narrow {
  width: min(760px, 100% - 32px);
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.skip-link {
  position: absolute;
  left: 16px;
  top: -60px;
  background: var(--accent);
  color: var(--accent-ink);
  padding: 8px 14px;
  border-radius: 6px;
  font-family: var(--font-ui);
  z-index: 100;
}
.skip-link:focus {
  top: 12px;
}

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

/* ── Header ─────────────────────────────────────────────────────────────── */
.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 22px;
  letter-spacing: -0.01em;
  white-space: nowrap;
  flex-shrink: 0;
}

.brand-mark {
  width: 30px;
  height: 30px;
  color: var(--accent);
}
.brand-fold {
  fill: var(--paper-2);
}

.site-nav {
  display: flex;
  gap: 4px;
  font-family: var(--font-ui);
  font-size: 15px;
}
.site-nav a {
  color: var(--ink-soft);
  text-decoration: none;
  padding: 8px 12px;
  border-radius: 8px;
}
.site-nav a:hover {
  color: var(--ink);
  background: var(--paper-2);
}

.file-notice {
  width: min(1180px, 100% - 32px);
  margin: 16px auto 0;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  background: var(--card);
  font: 14px/1.5 var(--font-ui);
  color: var(--ink-soft);
}
.file-notice code {
  font-size: 13px;
  background: var(--paper-2);
  padding: 1px 5px;
  border-radius: 4px;
  overflow-wrap: anywhere;
}

/* ── Hero ───────────────────────────────────────────────────────────────── */
.hero {
  padding: clamp(48px, 9vw, 104px) 0 clamp(36px, 6vw, 64px);
  background:
    radial-gradient(1200px 400px at 50% -10%, color-mix(in srgb, var(--accent) 10%, transparent), transparent 70%),
    var(--paper);
}

.hero-inner {
  text-align: center;
  max-width: 820px;
}

.eyebrow {
  margin: 0 0 14px;
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
}

h1,
h2,
h3 {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.015em;
  margin: 0;
}

h1 {
  font-size: clamp(34px, 6vw, 60px);
}
h1 em {
  font-weight: 500;
  font-size: 0.75em;
  color: var(--ink-soft);
  /* its own line box, so wrapped lines are spaced for the smaller size */
  display: block;
  line-height: 1.2;
  margin-top: 0.2em;
}

.lede {
  margin: 20px auto 26px;
  max-width: 620px;
  font-size: clamp(17px, 2vw, 19px);
  color: var(--ink-soft);
}

/* What Classic Book Reader saves you from: two columns on wide screens, one on phones. */
.benefits {
  list-style: none;
  margin: 30px auto;
  padding: 0;
  max-width: 700px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 28px;
  text-align: left;
  font: 15px/1.45 var(--font-ui);
  color: var(--ink-soft);
}
.benefits li {
  position: relative;
  padding-left: 30px;
}
.benefits li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 1px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--accent) 14%, transparent)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='M5.5 10.5l3 3 6-7' fill='none' stroke='%237a2e38' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E")
    center / 14px no-repeat;
}
.benefits strong {
  color: var(--ink);
  font-weight: 600;
}
@media (prefers-color-scheme: dark) {
  .benefits li::before {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='M5.5 10.5l3 3 6-7' fill='none' stroke='%23e0939c' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  }
}
@media (max-width: 600px) {
  .benefits {
    grid-template-columns: 1fr;
    gap: 10px;
    margin: 22px auto 24px;
    font-size: 14.5px;
    max-width: 420px;
  }
}

.search {
  position: relative;
  display: flex;
  max-width: 620px;
  margin: 0 auto;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: var(--shadow);
  padding: 6px;
}
.search:focus-within {
  border-color: var(--accent);
}
.search-icon {
  position: absolute;
  left: 20px;
  top: 50%;
  width: 20px;
  height: 20px;
  transform: translateY(-50%);
  color: var(--ink-soft);
  pointer-events: none;
}
.search input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: 17px var(--font-ui);
  padding: 10px 12px 10px 44px;
  outline: none;
}
.search input::-webkit-search-cancel-button {
  cursor: pointer;
}
.search button {
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
  font: 600 15px var(--font-ui);
  padding: 0 22px;
  cursor: pointer;
}
.search button:hover {
  background: var(--accent-hover);
}

.try {
  margin: 18px 0 0;
  font-family: var(--font-ui);
  font-size: 14px;
  color: var(--ink-soft);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  align-items: center;
}
.chip {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  font: inherit;
  padding: 5px 12px;
  border-radius: 999px;
  cursor: pointer;
}
.chip:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ── Shelves ────────────────────────────────────────────────────────────── */
.shelf {
  padding: 40px 0;
}
.shelf[hidden] {
  display: none;
}

.shelf-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}
.shelf-head h2 {
  font-size: clamp(24px, 3.2vw, 32px);
}
.shelf-note,
.results-meta {
  margin: 0;
  font-family: var(--font-ui);
  font-size: 14px;
  color: var(--ink-soft);
}
.results-meta {
  margin: -12px 0 20px;
}

.link-btn {
  border: 0;
  background: none;
  color: var(--accent);
  font: 14px var(--font-ui);
  cursor: pointer;
  padding: 4px 0;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.book-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 32px 24px;
}
@media (max-width: 520px) {
  .book-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 24px 16px;
  }
}

.book-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: inherit;
  text-decoration: none;
}

.cover {
  display: block;
  aspect-ratio: 2 / 3;
  border-radius: 3px 6px 6px 3px;
  overflow: hidden;
  background: var(--paper-2);
  box-shadow: var(--shadow);
  margin-bottom: 10px;
  position: relative;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}
/* spine highlight so covers read as physical books */
.cover::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(0, 0, 0, 0.18), rgba(255, 255, 255, 0.12) 3%, transparent 7%);
  pointer-events: none;
}
.cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.book-card:hover .cover,
.book-card:focus-visible .cover {
  transform: translateY(-4px) rotate(-0.6deg);
  box-shadow: 0 2px 4px rgba(60, 40, 20, 0.15), 0 18px 32px -14px rgba(60, 40, 20, 0.5);
}

/* Quick "Read" button on a card's cover; the card itself opens the book page. */
.book-grid > li {
  position: relative;
}
.card-read {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2;
  padding: 5px 12px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
  font: 600 13px var(--font-ui);
  text-decoration: none;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}
.card-read:hover {
  background: var(--accent-hover);
}
@media (hover: hover) {
  .card-read {
    opacity: 0;
    transition: opacity 0.15s ease;
  }
  .book-grid > li:hover .card-read,
  .book-grid > li:focus-within .card-read {
    opacity: 1;
  }
}

.book-title {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 16px;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.book-author {
  font-family: var(--font-ui);
  font-size: 13.5px;
  color: var(--ink-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cover-fallback {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 10px;
  padding: 14% 12%;
  text-align: center;
  color: #f4e6c8;
  background:
    linear-gradient(rgba(255, 255, 255, 0.05), rgba(0, 0, 0, 0.18)),
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.025) 0 2px, transparent 2px 4px),
    var(--cloth, #7a2e38);
  border: 1px solid rgba(0, 0, 0, 0.2);
}
.cover-fallback::before,
.cover-fallback::after {
  content: '';
  height: 1px;
  background: rgba(244, 230, 200, 0.55);
  margin-inline: 10%;
}
.cf-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(13px, 1.4vw, 16px);
  line-height: 1.2;
  display: -webkit-box;
  -webkit-line-clamp: 5;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.cf-author {
  font-family: var(--font-ui);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.85;
}

.more-row {
  display: flex;
  justify-content: center;
  margin-top: 32px;
}
.btn {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  font: 600 15px var(--font-ui);
  padding: 10px 22px;
  border-radius: 999px;
  cursor: pointer;
}
.btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.btn[hidden] {
  display: none;
}

/* ── Continue reading ───────────────────────────────────────────────────── */
.continue-row {
  list-style: none;
  margin: 0;
  padding: 4px 0 12px;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(280px, 340px);
  gap: 16px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
}
.continue-item {
  position: relative;
  scroll-snap-align: start;
}
.continue-card {
  display: grid;
  grid-template-columns: 76px 1fr;
  grid-template-rows: auto auto 1fr;
  column-gap: 16px;
  row-gap: 2px;
  padding: 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  height: 100%;
}
.continue-card:hover {
  border-color: var(--accent);
}
.continue-card .cover {
  grid-row: 1 / 4;
  margin: 0;
}
.continue-card:hover .cover {
  transform: none;
}
.continue-card .book-title {
  padding-right: 18px;
}
.continue-meta {
  align-self: end;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px 10px;
  font-family: var(--font-ui);
  font-size: 13px;
  color: var(--ink-soft);
}
.continue-where {
  grid-column: 1 / -1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.progress {
  align-self: center;
  height: 5px;
  border-radius: 99px;
  background: var(--paper-2);
  overflow: hidden;
}
.progress span {
  display: block;
  height: 100%;
  background: var(--accent);
  border-radius: inherit;
}
.remove-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--ink-soft);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}
.remove-btn:hover {
  background: var(--paper-2);
  color: var(--ink);
}

/* ── About & FAQ ────────────────────────────────────────────────────────── */
.about,
.faq {
  padding: clamp(48px, 8vw, 88px) 0;
  border-top: 1px solid var(--line);
}
.about {
  background: var(--paper-2);
}
.about h2,
.faq h2 {
  font-size: clamp(28px, 4vw, 38px);
  margin-bottom: 20px;
}
.about p {
  margin: 0 0 16px;
}

.features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  margin-top: 36px;
}
.feature {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 20px;
}
.feature h3 {
  font-size: 19px;
  margin-bottom: 6px;
}
.feature p {
  margin: 0;
  font-size: 15.5px;
  color: var(--ink-soft);
}

.faq details {
  border-bottom: 1px solid var(--line);
}
.faq summary {
  cursor: pointer;
  list-style: none;
  padding: 18px 36px 18px 0;
  position: relative;
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 19px;
}
.faq summary::-webkit-details-marker {
  display: none;
}
.faq summary::after {
  content: '+';
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  font: 400 26px var(--font-ui);
  color: var(--accent);
  transition: transform 0.2s ease;
}
.faq details[open] summary::after {
  transform: translateY(-50%) rotate(45deg);
}
.faq details p {
  margin: 0 0 20px;
  color: var(--ink-soft);
}

/* ── Footer ─────────────────────────────────────────────────────────────── */
.site-footer {
  border-top: 1px solid var(--line);
  padding: 28px 0 40px;
  font-family: var(--font-ui);
  font-size: 14px;
  color: var(--ink-soft);
}
.footer-inner {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.footer-inner p {
  margin: 0;
}

@media (max-width: 560px) {
  .site-nav a {
    padding: 8px;
  }
  /* Tighter hero so the first books are visible sooner on phones. */
  .hero {
    padding: 32px 0 24px;
  }
  .eyebrow {
    margin-bottom: 10px;
  }
  .lede {
    margin: 14px auto 22px;
    font-size: 16px;
  }
  .try {
    margin-top: 14px;
  }
  .shelf {
    padding: 28px 0;
  }
  .search button {
    padding: 0 16px;
  }
  .search input {
    padding-left: 40px;
  }
  .search-icon {
    left: 16px;
  }
}

/* Phones: the name gets its own row with the links centered underneath, and
   the header scrolls away instead of taking up reading space. */
@media (max-width: 560px) {
  .site-header {
    position: static;
  }
  .header-inner {
    height: auto;
    flex-wrap: wrap;
    justify-content: center;
    padding: 12px 0 6px;
    row-gap: 4px;
  }
  .site-nav {
    width: 100%;
    justify-content: center;
  }
}

/* Phones: tighter nav spacing. */
@media (max-width: 440px) {
  .header-inner {
    gap: 12px;
  }
  .site-nav {
    font-size: 14px;
    gap: 0;
  }
  .site-nav a {
    padding: 8px 6px;
  }
}

/* Very small phones (iPhone SE, 320px) */
@media (max-width: 360px) {
  .brand {
    font-size: 20px;
    gap: 8px;
  }
  .site-nav {
    font-size: 14px;
    gap: 0;
  }
  .site-nav a {
    padding: 8px 6px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  .cover {
    transition: none;
  }
}
