:root {
  --paper: #faf6ef;
  --ink: #2b2420;
  --accent: #7a3e2c;
  --accent-light: #c98a63;
  --border: #dcd0bd;
  --muted: #8a7f6d;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: Georgia, 'Times New Roman', serif;
}

.home-body {
  background-image: url('../images/bg-home.jpg');
  background-size: cover;
  background-position: center top;
  background-attachment: fixed;
  background-repeat: no-repeat;
  min-height: 100vh;
}

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

/* ---------- Home page ---------- */

.home {
  max-width: 780px;
  margin: 0 auto;
  padding: 4rem 1.5rem 3rem;
  text-align: center;
}

.home h1 {
  font-size: 2.4rem;
  margin-bottom: 0.4rem;
}

.subtitle {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.2rem 1.5rem;
  margin-bottom: 2.5rem;
  text-align: left;
  font-style: normal;
  line-height: 1.6;
  font-size: 0.98rem;
}

.book-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  text-align: left;
}

.book-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.1rem 1.4rem;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  transition: box-shadow 0.15s, transform 0.15s;
}

.book-card:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.12);
  transform: translateY(-1px);
}

.book-title {
  font-size: 1.15rem;
  font-weight: bold;
  color: var(--ink);
}

.book-count {
  color: var(--muted);
  font-size: 0.9rem;
  white-space: nowrap;
  margin-left: 1rem;
}

.loading {
  text-align: center;
  color: var(--muted);
}

/* ---------- Book viewer ---------- */

.topbar, .subbar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 0.7rem 1rem;
  border-bottom: 1px solid var(--border);
  background: #fff;
  flex-wrap: wrap;
}

.subbar { border-bottom: 1px solid var(--border); background: #fdfaf5; }

.topbar-spacer { flex: 0 0 0; }

.book-heading {
  flex: 1 1 auto;
  text-align: center;
  min-width: 0;
}

.book-title-text {
  display: block;
  font-weight: bold;
  font-size: 1.1rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.page-indicator {
  display: block;
  color: var(--muted);
  font-size: 0.85rem;
}

.btn {
  display: inline-block;
  padding: 0.45rem 0.9rem;
  border: 1px solid var(--accent-light);
  border-radius: 6px;
  background: #fff;
  color: var(--accent);
  font-size: 0.9rem;
  white-space: nowrap;
  cursor: pointer;
}

.btn:hover { background: #f3e6da; }

.btn[disabled], .btn.disabled {
  opacity: 0.4;
  pointer-events: none;
}

.btn-arrow {
  padding: 0.45rem 0.75rem;
  font-size: 1rem;
  line-height: 1;
}

.viewer {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 0;
  min-height: 62vh;
}

.image-stage {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 0 4rem;
}

.page-image {
  max-width: 100%;
  max-height: 78vh;
  object-fit: contain;
  border: 1px solid var(--border);
  box-shadow: 0 2px 10px rgba(0,0,0,0.15);
  cursor: zoom-in;
  background: #fff;
}

.nav-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255,255,255,0.85);
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 3rem;
  height: 3rem;
  font-size: 1.3rem;
  color: var(--accent);
  cursor: pointer;
  z-index: 5;
}

.nav-arrow:hover { background: #fff; }
.nav-arrow:disabled { opacity: 0.25; cursor: default; }

.nav-prev { left: 0.75rem; }
.nav-next { right: 0.75rem; }

.caption {
  max-width: 700px;
  margin: 1rem auto 3rem;
  padding: 0 1.6rem;
  color: var(--ink);
  font-size: 1.02rem;
  line-height: 1.55;
}

.caption:not(:empty) {
  padding-top: 1.1rem;
  padding-bottom: 1.1rem;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.caption-text {
  margin: 0;
  text-align: left;
  white-space: pre-line;
}

.caption-text.short {
  text-align: center;
  font-style: italic;
}

.caption-note {
  margin: 0.9rem 0 0;
  padding-top: 0.9rem;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-style: italic;
  white-space: pre-line;
}

.caption-note a {
  color: var(--accent);
}

/* ---------- Lightbox (actual size) ---------- */

.lightbox {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(20, 16, 12, 0.92);
  z-index: 50;
  overflow: auto;
  text-align: center;
  cursor: zoom-out;
}

.lightbox.open {
  display: block;
}

.lightbox-image {
  display: inline-block;
  margin: 2rem auto;
  max-width: none;
  cursor: zoom-out;
}

@media (max-width: 640px) {
  .image-stage { padding: 0 2.6rem; }
  .nav-arrow { width: 2.3rem; height: 2.3rem; font-size: 1.05rem; }
  .page-image { max-height: 68vh; }
  .book-title-text { font-size: 1rem; }
  .home h1 { font-size: 1.8rem; }
}
