/* booksthere — paper, type, a reading lamp. Shelves hold books, not scrollers. */
:root {
  --paper: #f4efe4;
  --paper-deep: #e7dcc8;
  --card: #fbf7ef;
  --ink: #2a2218;
  --ink-soft: #5e5346;
  --rule: #cbbba3;
  --rule-strong: #8d7156;
  --lamp: #7a2e2a;
  --lamp-soft: #a24b3a;
  --glow: rgba(214, 168, 92, 0.55);
  --spine: #6d3a2c;
  --shadow: 0 18px 40px rgba(74, 48, 24, 0.08);
  --display: "EB Garamond", "Iowan Old Style", Palatino, "Palatino Linotype", Georgia, serif;
  --text: Literata, "Iowan Old Style", Palatino, Georgia, serif;
  --mono: "IBM Plex Mono", "Source Code Pro", ui-monospace, monospace;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --paper: #1c1713;
  --paper-deep: #2a221b;
  --card: #261f19;
  --ink: #f3e7d4;
  --ink-soft: #cbb89f;
  --rule: #4a3b2e;
  --rule-strong: #b08960;
  --lamp: #e4b56a;
  --lamp-soft: #f0d7a4;
  --glow: rgba(228, 181, 106, 0.22);
  --spine: #c4895a;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: var(--text);
  font-size: 1.05rem;
  line-height: 1.65;
  background-color: var(--paper);
  background-image:
    radial-gradient(ellipse 90% 42% at 50% -8%, var(--glow), transparent 62%),
    linear-gradient(180deg, transparent, rgba(122, 46, 42, 0.03) 100%);
}
a { color: var(--lamp); text-underline-offset: 0.18em; }
a:hover { color: var(--lamp-soft); }
img { max-width: 100%; display: block; }
button { font: inherit; color: inherit; }
.skip {
  position: absolute;
  left: 12px;
  top: -48px;
  background: var(--lamp);
  color: #fffaf3;
  padding: 8px 12px;
  z-index: 20;
}
:root[data-theme="dark"] .skip { color: #1c1713; }
.skip:focus { top: 12px; }
.wrap { width: min(1320px, 85%); margin: 0 auto; }
.detail-wrap { width: min(1320px, 85%); }
.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  background: #f4efe4;
  border-bottom: 1px solid var(--rule);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.25);
}
:root[data-theme="dark"] .topbar {
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  backdrop-filter: blur(8px);
}
.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 52px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
  font-family: var(--display);
  font-size: 1.7rem;
  font-weight: 600;
  letter-spacing: 0;
  line-height: 1;
}
.brand-word {
  display: inline-block;
  font-size: clamp(1.45rem, 2.2vw, 1.8rem);
  letter-spacing: 0;
  white-space: nowrap;
}
.brand svg { flex: none; }
.brand-mark .bk { fill: #1A3054; }
.brand-mark .pg { fill: #E7DFD0; }
.brand-mark .edge { stroke: #1A3054; stroke-width: 1.6; }
.brand-mark .rib { fill: #C04B3A; }
:root[data-theme="dark"] .brand-mark .bk { fill: #E6EDF6; }
:root[data-theme="dark"] .brand-mark .pg { fill: #241C16; }
:root[data-theme="dark"] .brand-mark .edge { stroke: #E6EDF6; }
.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--rule-strong);
  background: var(--card);
  color: var(--ink);
  border-radius: 999px;
  padding: 7px 14px 7px 10px;
  cursor: pointer;
}
.theme-toggle:focus-visible, a:focus-visible, .card a:focus-visible {
  outline: 2px solid var(--lamp);
  outline-offset: 3px;
}
.lamp-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff4d2, var(--lamp) 55%, #4a2418);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--lamp) 25%, transparent);
}
.hero { padding: 0; }
.kicker {
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin: 0 0 10px;
}
h1 {
  font-family: var(--display);
  font-weight: 500;
  font-size: clamp(2.4rem, 5vw, 4.1rem);
  line-height: 1.05;
  letter-spacing: -0.02em;
  margin: 0 0 14px;
}
.hero h1 {
  font-size: clamp(1.05rem, 1.35vw, 1.28rem);
  line-height: 1.15;
  margin: 0 0 2px;
  max-width: none;
}
.hero .lede {
  font-size: 0.88rem;
  line-height: 1.3;
  margin: 0;
  max-width: none;
}
.lede { font-size: 1.02rem; max-width: 40rem; margin: 0 0 6px; }
.fine { color: var(--ink-soft); max-width: 40rem; }
.rule {
  border: 0;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  height: 4px;
  margin: 28px 0;
}
.shelf-label {
  font-family: var(--display);
  font-size: 1.7rem;
  font-weight: 500;
  margin: 0 0 12px;
}
.subjects, .author-index {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0;
  margin: 0 0 8px;
  list-style: none;
}
.subject-nav {
  margin: 10px 0 18px;
}
.subject-nav .subjects { margin: 0; }
.subjects a, .author-index a {
  text-decoration: none;
  border: 1px solid var(--rule);
  background: var(--card);
  color: var(--ink);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.95rem;
}
.subjects a:hover, .author-index a:hover { border-color: var(--lamp); color: var(--lamp); }
.find {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 4px 0 6px;
}
.find label { color: var(--ink-soft); font-size: 0.92rem; }
.find input {
  font: inherit;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 5px 10px;
  width: min(420px, 100%);
}
.catalog {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 8px;
}
.catalog .card {
  grid-template-columns: 52px minmax(0, 1fr);
  gap: 8px;
  padding: 8px;
  align-items: start;
}
.catalog .cover,
.catalog .cover-fallback {
  width: 52px;
  height: 62px;
}
.catalog .card h2 { font-size: 1rem; margin: 0 0 2px; }
.catalog .by,
.catalog .blurb { font-size: 0.8rem; line-height: 1.3; }
.catalog .blurb {
  margin: 4px 0 0;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr);
  gap: 8px;
  background: var(--card);
  border: 1px solid var(--rule);
  box-shadow: var(--shadow);
  padding: 12px;
  position: relative;
}
.card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 6px;
  background: var(--spine);
}
.cover, .cover-fallback {
  width: 56px;
  height: 66px;
  object-fit: cover;
  background: var(--paper-deep);
  border: 1px solid var(--rule);
}
.cover-fallback {
  display: grid;
  place-items: center;
  text-align: center;
  padding: 8px;
  font-family: var(--display);
  font-size: 0.95rem;
  line-height: 1.2;
  color: var(--ink-soft);
}
.cover-fallback[hidden] { display: none !important; }
.card h2, .book-list h2 {
  font-family: var(--display);
  font-size: 1.55rem;
  font-weight: 500;
  line-height: 1.15;
  margin: 2px 0 4px;
  overflow-wrap: anywhere;
}
.card h2 a, .book-list h2 a { color: var(--ink); text-decoration: none; }
.card h2 a:hover, .book-list h2 a:hover { color: var(--lamp); }
.by, .meta { margin: 0; color: var(--ink-soft); }
.meta a { color: var(--ink-soft); }
.blurb { margin: 8px 0 0; }
.crumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--ink-soft);
  font-size: 0.92rem;
  margin-top: 22px;
}
.crumbs a { color: var(--ink-soft); }
.book { padding-bottom: 12px; }
.book-top {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 28px;
  align-items: start;
}
.book-cover, .book-summary, .book-details { min-width: 0; }
.book .cover, .book .cover-fallback {
  width: 220px;
  height: 330px;
  font-size: 1.4rem;
}
.book h1 {
  font-size: clamp(2.2rem, 4vw, 3.4rem);
  overflow-wrap: anywhere;
}
.book-details { width: 100%; }
.ol-id {
  font-family: var(--mono);
  font-size: 0.82rem;
  letter-spacing: 0.02em;
  color: var(--ink-soft);
}
.where {
  margin: 18px 0 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.where a {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  font-family: var(--display);
  font-size: 1.25rem;
}
.note { color: var(--ink-soft); font-size: 0.95rem; }
.book-list { display: flex; flex-direction: column; gap: 18px; }
.book-list article { border-top: 1px solid var(--rule); padding-top: 12px; min-width: 0; }
.book-list h2 { overflow-wrap: anywhere; }
footer.colophon {
  margin: 36px 0 48px;
  padding-top: 16px;
  border-top: 1px solid var(--rule);
  color: var(--ink-soft);
  font-size: 0.92rem;
}
/* Detail content and its end block share the same centered rail. */
main.detail-wrap + footer.colophon {
  width: min(1320px, 85%);
  margin-left: auto;
  margin-right: auto;
}
footer.colophon p { margin: 0 0 8px; }
@media (max-width: 720px) {
  .book-top { grid-template-columns: 1fr; }
  .book .cover, .book .cover-fallback { width: 150px; height: 225px; }
  .topbar-inner { min-height: 48px; }
  .brand { font-size: 1.4rem; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

.letter-block h3 {
  font-family: var(--display);
  font-weight: 500;
  font-size: 1.6rem;
  margin: 22px 0 6px;
}
.shelf-index { list-style: none; padding: 0; margin: 0; }
.shelf-index li {
  padding: 7px 0;
  border-bottom: 1px solid var(--rule);
}
.shelf-index a { font-family: var(--display); font-size: 1.2rem; }
.author-index.dense {
  display: block;
  columns: 3;
  column-gap: 28px;
}
.author-index.dense li { break-inside: avoid; margin: 0 0 5px; }
.author-index.dense a {
  border: 0;
  background: none;
  padding: 0;
  border-radius: 0;
  font-size: 1rem;
}
@media (max-width: 720px) {
  .author-index.dense { columns: 1; }
}

.history { margin: 12px 0 0; }
.author-snippet { color: var(--ink-soft); }
.related { list-style: none; padding: 0; margin: 0 0 8px; }
.related li { padding: 6px 0; border-bottom: 1px solid var(--rule); min-width: 0; overflow-wrap: anywhere; }
.related a { font-family: var(--display); font-size: 1.15rem; overflow-wrap: anywhere; }


/* Home shelves: books standing on a paper/wood ledge — wrap grid, no scrollbar. */
.shelf {
  margin: 16px 0 30px;
  padding: 0 0 4px;
}
.shelf-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.shelf-head .shelf-label { margin: 0; font-size: 1.45rem; }
.see-all { font-family: var(--display); font-size: 1.15rem; white-space: nowrap; }

.home-rail {
  display: grid;
  grid-template-columns: repeat(9, minmax(0, 1fr));
  gap: 14px 12px;
  overflow: visible;
  padding: 8px 2px 6px;
  margin: 0 0 20px;
  align-items: end;
}
.shelf .home-rail:last-child { margin-bottom: 0; }

/* Wooden / paper reading ledge under each shelf board */
.home-rail::after {
  content: "";
  display: block;
  grid-column: 1 / -1;
  height: 18px;
  margin: 8px 0 0;
  border-radius: 2px 2px 6px 6px;
  background:
    linear-gradient(
      90deg,
      transparent 0%,
      rgba(255, 240, 210, 0.12) 12%,
      transparent 28%,
      rgba(60, 30, 10, 0.08) 55%,
      transparent 78%,
      rgba(255, 240, 210, 0.1) 100%
    ),
    linear-gradient(
      180deg,
      #e0c49a 0%,
      #c9a574 18%,
      #a67c4f 55%,
      #7d5532 82%,
      #5a3a20 100%
    );
  box-shadow:
    0 1px 0 rgba(255, 248, 230, 0.65),
    0 3px 0 rgba(90, 55, 30, 0.35),
    0 10px 22px rgba(74, 48, 24, 0.22),
    inset 0 1px 0 rgba(255, 236, 200, 0.55),
    inset 0 -4px 6px rgba(40, 22, 8, 0.3);
}
:root[data-theme="dark"] .home-rail::after {
  background:
    linear-gradient(180deg, #6a4a34 0%, #4a3222 40%, #2e1e14 100%);
  box-shadow:
    0 1px 0 rgba(228, 181, 106, 0.14),
    0 3px 0 rgba(0, 0, 0, 0.35),
    0 10px 22px rgba(0, 0, 0, 0.45),
    inset 0 1px 0 rgba(200, 160, 100, 0.14),
    inset 0 -4px 6px rgba(0, 0, 0, 0.4);
}

/* Book-spine cards: cover up, label under — not a text scroller card */
.home-rail .card {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  padding: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
  min-width: 0;
}
.home-rail .card::before { display: none; }
.home-rail .card > a {
  display: block;
  line-height: 0;
  text-decoration: none;
}
.thumb { position: relative; display: block; }

.home-rail .cover,
.home-rail .cover-fallback {
  width: 100%;
  aspect-ratio: 2 / 3;
  height: auto;
  max-height: none;
  object-fit: cover;
  object-position: center top;
  font-size: 0.78rem;
  padding: 8px 6px;
  border-radius: 1px 3px 2px 1px;
  border: 1px solid color-mix(in srgb, var(--rule-strong) 55%, var(--rule));
  background:
    linear-gradient(145deg, color-mix(in srgb, var(--card) 80%, #fff) 0%, var(--paper-deep) 100%);
  box-shadow:
    1px 0 0 color-mix(in srgb, var(--spine) 40%, transparent),
    2px 1px 0 color-mix(in srgb, var(--paper) 75%, transparent),
    4px 10px 18px rgba(74, 48, 24, 0.16),
    inset 0 1px 0 rgba(255, 255, 255, 0.4);
  transition: box-shadow 0.22s ease;
}
.home-rail .cover { padding: 0; display: block; }

/* Very slight book lean — nearly upright */
.home-rail .card:nth-child(6n+1) .thumb { transform: rotate(-1.1deg); }
.home-rail .card:nth-child(6n+2) .thumb { transform: rotate(0.7deg); }
.home-rail .card:nth-child(6n+3) .thumb { transform: rotate(-0.35deg); }
.home-rail .card:nth-child(6n+4) .thumb { transform: rotate(0.95deg); }
.home-rail .card:nth-child(6n+5) .thumb { transform: rotate(-0.6deg); }
.home-rail .card:nth-child(6n) .thumb { transform: rotate(0.4deg); }

.home-rail .thumb {
  transform-origin: 50% 100%;
  transition: transform 0.22s ease;
}
.home-rail .card:hover .thumb,
.home-rail .card:focus-within .thumb {
  transform: rotate(0deg) translateY(-5px);
}
.home-rail .card:hover .cover,
.home-rail .card:hover .cover-fallback,
.home-rail .card:focus-within .cover,
.home-rail .card:focus-within .cover-fallback {
  box-shadow:
    1px 0 0 color-mix(in srgb, var(--spine) 45%, transparent),
    4px 12px 22px rgba(74, 48, 24, 0.22),
    inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

/* Title / author as a small bookplate under the cover */
.home-rail .card > div {
  padding: 2px 2px 0;
  text-align: center;
}
.home-rail .card h2 {
  font-size: 0.86rem;
  line-height: 1.2;
  margin: 0 0 2px;
  font-weight: 600;
  letter-spacing: -0.01em;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.home-rail .by {
  font-size: 0.7rem;
  line-height: 1.25;
  margin: 0;
  font-style: italic;
  color: var(--ink-soft);
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.home-rail .by a { color: inherit; text-decoration: none; }
.home-rail .by a:hover { color: var(--lamp); text-decoration: underline; }
.home-rail .meta,
.home-rail .blurb { display: none; }

@media (max-width: 1000px) {
  .home-rail { grid-template-columns: repeat(6, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
  .home-rail {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px 10px;
  }
  .home-rail .card h2 { font-size: 0.8rem; }
}
@media (prefers-reduced-motion: reduce) {
  .home-rail .thumb,
  .home-rail .cover,
  .home-rail .cover-fallback {
    transform: none !important;
    transition: none;
  }
}
.find-results {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  display: grid;
  gap: 6px;
}
.find-results a { font-family: var(--display); font-size: 1.15rem; }
.find-results span { color: var(--ink-soft); }

.brand-accent { color: #C04B3A; }
:root[data-theme="dark"] .brand-accent { color: #F0A394; }
