/* ReadFinda styles. Direction: "Modern Library" (docs/design-brief.md).
   Calm, content-first: covers bring the colour, the interface stays quiet. */

@font-face { font-family: "Inter"; src: url("/static/fonts/inter-latin-wght-5.2.8.woff2") format("woff2");
  font-weight: 100 900; font-style: normal; font-display: swap; }
@font-face { font-family: "Source Serif 4"; src: url("/static/fonts/source-serif-4-latin-wght-5.2.9.woff2") format("woff2");
  font-weight: 200 900; font-style: normal; font-display: swap; }

:root {
  --bg: #f8f8f4; --surface: #ffffff; --ink: #222722; --muted: #626962; --line: #dee2db;
  --accent: #315c49; --accent-ink: #ffffff; --accent-subtle: #e7ede7; --negative: #a44940;
  --cover-shadow: 0 1px 2px rgba(34, 39, 34, .12), 0 2px 8px rgba(34, 39, 34, .06);
  --serif: "Source Serif 4", "Iowan Old Style", Georgia, serif;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --radius: 8px; --radius-sm: 6px;
  --space: 64px;   /* between page sections */
  --gutter: 24px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121513; --surface: #1a1e1b; --ink: #e6eae5; --muted: #a3aba3; --line: #2e3530;
    --accent: #8fc2a8; --accent-ink: #0f1a14; --accent-subtle: #22302a; --negative: #e08a80;
    --cover-shadow: 0 1px 2px rgba(0, 0, 0, .5);
  }
}
@media (max-width: 640px) { :root { --space: 48px; --gutter: 16px; } }

/* base */
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.6 var(--sans); }
a { color: var(--accent); text-underline-offset: 3px; }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.2; letter-spacing: -.01em; }
h1 { font-size: clamp(2rem, 4vw, 2.75rem); margin: 0 0 .4em; }
h2 { font-size: 1.5rem; margin: 0 0 .8em; }
p { margin: 0 0 1em; }
.wrap { max-width: 1280px; margin: 0 auto; padding: 0 var(--gutter); }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.skip { position: absolute; left: -999px; } .skip:focus { left: 8px; top: 8px; background: var(--surface); padding: 8px; z-index: 10; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.icon { width: 1em; height: 1em; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; scroll-behavior: auto !important; } }

/* header */
.top { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.top-row { display: flex; align-items: center; gap: 24px; min-height: 64px; flex-wrap: wrap; padding-top: 8px; padding-bottom: 8px; }
.logo { font-family: var(--serif); font-size: 1.45rem; font-weight: 700; color: var(--ink); text-decoration: none; }
.logo span { color: var(--accent); }
.hsearch { position: relative; flex: 1 1 240px; max-width: 420px; }
input[type=search], input[type=number], select {
  width: 100%; min-height: 44px; padding: 10px 14px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); color: var(--ink); font: inherit; font-size: .95rem;
}
.hsearch input { padding-left: 40px; background: var(--bg); }
.hsearch .icon { position: absolute; left: 14px; top: 14px; width: 16px; height: 16px; color: var(--muted); pointer-events: none; }
.nav { display: flex; gap: 4px; margin-left: auto; }
.nav a { color: var(--ink); text-decoration: none; font-weight: 500; font-size: .95rem; padding: 10px 12px; border-radius: var(--radius); }
.nav a[aria-current=page] { color: var(--accent); background: var(--accent-subtle); }
.nav a:hover { color: var(--accent); }
@media (max-width: 640px) {
  .top { position: static; }
  .top-row { gap: 8px 12px; }
  .nav { margin-left: auto; }
  .nav a { padding: 10px 8px; }
  .hsearch { max-width: none; order: 3; flex-basis: 100%; }
}

/* typeahead */
.typeahead { list-style: none; margin: 6px 0 0; padding: 4px 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 6px 20px rgba(34, 39, 34, .08); overflow: hidden; }
.typeahead:empty { display: none; }
.hsearch .typeahead { position: absolute; left: 0; right: 0; z-index: 20; }
.typeahead li { padding: 10px 14px; min-height: 44px; cursor: pointer; display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.typeahead li[aria-selected=true], .typeahead li:hover { background: var(--accent-subtle); }
.typeahead .ta-author { color: var(--muted); font-size: .85rem; text-align: right; }

/* buttons, tags */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; white-space: nowrap; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); border-radius: var(--radius); padding: 9px 18px; font: inherit; font-size: .95rem; font-weight: 500;
  cursor: pointer; text-decoration: none; }
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.08); color: var(--accent-ink); }
.btn.small { min-height: 36px; padding: 6px 12px; font-size: .85rem; }
.btn.on, .btn.primary.on { background: var(--accent-subtle); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.btn.on::before { content: "✓"; }
.linklike { background: none; border: 0; padding: 0; color: var(--accent); font: inherit; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; min-height: 36px; background: transparent; color: var(--ink); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 6px 12px; text-decoration: none; font-size: .875rem; }
a.chip:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-subtle); }
.chip.ghost { color: var(--accent); border-style: dashed; }

/* covers: the publisher's artwork from Open Library, kept whole at 2:3; a plain
   title card when there's no cover or it fails to load */
.cover { position: relative; aspect-ratio: 2 / 3; border-radius: 4px; overflow: hidden; background: var(--accent-subtle);
  border: 1px solid var(--line); box-shadow: var(--cover-shadow); padding: 14px 12px 12px; display: flex; flex-direction: column; justify-content: space-between; color: var(--ink); }
/* the title card stays visible until the image has loaded */
.cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; opacity: 0; transition: opacity .25s; }
.cover img.ok { opacity: 1; background: var(--surface); }
.cover.has-img { border-color: transparent; }
.cover-title { font-family: var(--serif); font-weight: 600; font-size: .95rem; line-height: 1.2; display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical; overflow: hidden; }
.cover-author { font-size: .72rem; color: var(--muted); }
.cover.sm { width: 44px; padding: 5px; flex: none; } .cover.sm .cover-title { font-size: .5rem; -webkit-line-clamp: 4; } .cover.sm .cover-author { display: none; }
.cover.xl { width: 220px; flex: none; padding: 20px 16px 16px; } .cover.xl .cover-title { font-size: 1.35rem; } .cover.xl .cover-author { font-size: .8rem; }

/* sections */
.section { padding-top: var(--space); }
.cta { margin-top: 32px; }

/* home */
.hero { padding: calc(var(--space) * .9) 0 0; }
.hero h1 { max-width: 16em; }
.lede { font-size: 1.125rem; color: var(--muted); max-width: 34em; margin-bottom: 28px; }
.seed-box { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; max-width: 680px; }
.seed-label { display: block; font-weight: 600; margin-bottom: 10px; }
.seed-row { display: flex; gap: 10px; flex-wrap: wrap; }
.seed-row input { flex: 1 1 240px; }
.picks { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.picks:empty { display: none; }
.pick { display: inline-flex; align-items: center; gap: 4px; background: var(--accent-subtle); border-radius: var(--radius-sm); padding: 4px 4px 4px 10px; font-size: .875rem; }
.pick button { background: none; border: 0; color: var(--muted); cursor: pointer; width: 32px; height: 32px; font-size: 1.1rem; border-radius: var(--radius-sm); }
.pick button:hover { color: var(--negative); }
.paths { display: flex; flex-wrap: wrap; gap: 6px 24px; margin-top: 16px; font-size: .95rem; }
.paths a { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; text-decoration: none; font-weight: 500; }
.paths a:hover { text-decoration: underline; }
.quick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 40px 28px; }
.quick { display: flex; flex-direction: column; gap: 10px; }
.quick-link { display: flex; flex-direction: column; gap: 10px; color: var(--ink); text-decoration: none; line-height: 1.3; }
.quick-link:hover .card-title { color: var(--accent); }
.quick .btn { align-self: flex-start; }
.steps { padding-left: 1.3em; max-width: 40em; margin: 0; } .steps li { margin: 0 0 1em; padding-left: .3em; }
@media (min-width: 1100px) { .quick-grid { grid-template-columns: repeat(6, 1fr); } }
@media (max-width: 520px) { .quick-grid { grid-template-columns: repeat(2, 1fr); gap: 32px 16px; } .quick-grid .quick:nth-child(n+7) { display: none; } }

/* recommendations page */
.finder { display: grid; grid-template-columns: 300px 1fr; gap: 56px; padding-top: 48px; padding-bottom: 24px; align-items: start; }
@media (max-width: 860px) { .finder { grid-template-columns: 1fr; gap: 40px; padding-top: 28px; } }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; position: sticky; top: 88px; }
@media (max-width: 860px) { .panel { position: static; } }
.panel-title { font-size: 1.3rem; margin: 0 0 16px; }
.seeds { margin-top: 16px; display: flex; flex-direction: column; gap: 8px; }
.seed { display: flex; align-items: center; gap: 10px; background: var(--bg); border-radius: var(--radius-sm); padding: 6px 6px 6px 12px; font-size: .9rem; line-height: 1.4; }
.seed .t { flex: 1; min-width: 0; }
.seed button { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 1.1rem; width: 36px; height: 36px; border-radius: var(--radius-sm); flex: none; }
.seed button:hover { color: var(--negative); }
.seed-group { margin: 14px 0 0; font-size: .85rem; color: var(--muted); }
.filters { margin-top: 20px; border-top: 1px solid var(--line); padding-top: 16px; }
.filters summary { cursor: pointer; font-weight: 600; min-height: 32px; }
.field { display: block; margin-top: 14px; font-size: .9rem; } .field span { display: block; color: var(--muted); margin-bottom: 6px; }
.check { display: flex; gap: 10px; align-items: center; margin-top: 14px; font-size: .9rem; min-height: 32px; }
.results-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.results-head h2 { margin: 0; }

/* book grid: whitespace, not boxes */
.rec-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 44px 28px; margin-top: 20px; }
.rec-grid.static { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.card { display: flex; flex-direction: column; gap: 4px; }
.card-link { color: var(--ink); text-decoration: none; display: flex; flex-direction: column; gap: 12px; }
.card-link:hover .card-title { color: var(--accent); }
.card-title { font-family: var(--serif); font-size: 1.02rem; font-weight: 600; line-height: 1.25; margin: 0; }
.card-meta { margin: 0; font-size: .82rem; color: var(--muted); line-height: 1.45; }
.card-why { margin: 2px 0 0; font-size: .8rem; color: var(--muted); line-height: 1.4; }
.card-actions { display: flex; flex-wrap: wrap; gap: 0 14px; margin-top: 2px; }
.act { background: none; border: 0; padding: 0; min-height: 32px; color: var(--muted); font: inherit; font-size: .8rem; cursor: pointer; }
.act:hover { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.act.on { color: var(--accent); font-weight: 600; } .act.on::before { content: "✓ "; }
.feel { margin-top: calc(var(--space) * .9); padding-top: calc(var(--space) * .7); border-top: 1px solid var(--line); }
.more { text-align: center; margin: 40px 0 0; }
.empty .quick-grid { margin-top: 24px; }
@media (max-width: 520px) { .rec-grid, .rec-grid.static { grid-template-columns: repeat(2, 1fr); gap: 36px 16px; } }
.stars { color: var(--ink); white-space: nowrap; }
.stars::first-letter { color: var(--accent); }

/* book page */
.book { padding-top: 48px; }
.book-head { display: flex; gap: 56px; align-items: flex-start; }
.book-info { padding-top: 4px; min-width: 0; flex: 1; max-width: 680px; }
.byline { font-size: 1.1rem; margin: 0 0 10px; }
.facts { display: flex; flex-wrap: wrap; gap: 4px 20px; color: var(--muted); font-size: .9rem; margin: 0 0 20px; }
.book-info .chips { margin: 0 0 24px; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; }
.get { margin-top: 32px; padding-top: 24px; border-top: 1px solid var(--line); }
.get h2 { font-size: 1.15rem; margin: 0 0 14px; }
.stores { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.store { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 48px; padding: 10px 14px; border: 1px solid var(--line);
  border-radius: var(--radius); background: var(--surface); color: var(--ink); text-decoration: none; font-weight: 600; font-size: .95rem; }
.store .icon { color: var(--muted); width: 16px; height: 16px; }
.store:hover { border-color: var(--accent); color: var(--accent); }
.store:hover .icon { color: var(--accent); }
@media (max-width: 640px) {
  .book { padding-top: 28px; }
  .book-head { flex-direction: column; gap: 24px; }
  .cover.xl { width: 160px; }
  .stores { grid-template-columns: 1fr 1fr; }
}

/* browse: categories, sorting, pick one */
.shelves { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 44px 40px; margin-top: 40px; }
.shelf h2 { font-size: 1.2rem; margin: 0 0 10px; }
.shelf h2 a { color: var(--ink); text-decoration: none; }
.shelf h2 a:hover { color: var(--accent); }
.sublinks ul, ul.sublinks { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 0 18px; }
.shelf .sublinks { display: block; }
.sublinks a, .sublinks [aria-current] { display: inline-flex; align-items: center; min-height: 36px; font-size: .95rem; }
.sublinks a { color: var(--muted); text-decoration: none; }
.sublinks a:hover { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.sublinks [aria-current] { color: var(--accent); font-weight: 600; }
.browse nav.sublinks { margin: 4px 0 0; }
.pick-row { margin-top: 28px; }
.picked { margin-top: 24px; max-width: 200px; }
.sortbar { display: flex; flex-wrap: wrap; gap: 0 16px; align-items: center; margin-top: 36px; padding-bottom: 4px; border-bottom: 1px solid var(--line); }
.sortbar .act { font-size: .9rem; min-height: 40px; }
.sortbar .act.on::before { content: none; }
.more-row { text-align: center; margin: 44px 0 0; }

/* footer, toast */
.foot { border-top: 1px solid var(--line); margin-top: calc(var(--space) * 1.4); padding: 32px 0 48px; color: var(--muted); font-size: .875rem; }
.foot p { margin: 0 0 6px; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); background: var(--ink); color: var(--bg); padding: 12px 18px; border-radius: var(--radius);
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; font-size: .92rem; z-index: 30; max-width: calc(100% - 32px); }
.toast.show { opacity: 1; transform: translateX(-50%); pointer-events: auto; }
.toast a { color: var(--bg); font-weight: 600; margin-left: 8px; }
