/* 電子刊物 — 書架 + 翻頁閱讀器 */

.pub-page {
  padding-bottom: 3rem;
}

.pub-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  margin: 0 0 1.5rem;
}

.pub-search {
  border: 1px solid var(--color-line);
  background: #f3f3f3;
  border-radius: 999px;
  padding: 0.45rem 1rem;
  min-width: min(100%, 220px);
  font-size: 0.9rem;
}

.pub-sort {
  display: inline-flex;
  gap: 0.4rem;
}

.pub-sort button {
  border: 1px solid var(--color-line);
  background: #f5f5f5;
  border-radius: 999px;
  padding: 0.35rem 0.85rem;
  font-size: 0.8rem;
  cursor: pointer;
  color: var(--color-ink-muted);
}

.pub-sort button.is-active {
  border-color: var(--color-red);
  color: var(--color-red);
  background: #fff;
}

/* Bookshelf */
.bookshelf {
  position: relative;
  min-height: 320px;
  padding: 2rem 0 3.5rem;
}

.bookshelf__shelf {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 1.5rem;
  height: 14px;
  background: linear-gradient(180deg, #d8d8d8, #bdbdbd 55%, #a8a8a8);
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.12);
  border-radius: 2px;
}

.bookshelf__books {
  display: flex;
  flex-wrap: wrap;
  gap: 1.75rem 2rem;
  align-items: flex-end;
  justify-content: center;
  position: relative;
  z-index: 1;
  padding-bottom: 1.25rem;
}

.book-cover {
  width: 140px;
  border: 0;
  background: transparent;
  padding: 0;
  cursor: pointer;
  text-align: left;
  transition: transform 0.35s var(--ease);
  position: relative;
}

.book-cover:hover,
.book-cover:focus-visible {
  transform: translateY(-10px) rotate(-1deg);
  outline: none;
}

.book-cover__face {
  height: 190px;
  border-radius: 2px 6px 6px 2px;
  color: #f5ead6;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 1rem 0.75rem;
  box-shadow:
    inset -8px 0 12px rgba(0, 0, 0, 0.18),
    4px 8px 18px rgba(0, 0, 0, 0.2);
  position: relative;
  overflow: hidden;
  font-family: var(--font-display);
}

.book-cover__face::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  width: 10px;
  bottom: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.35));
}

.book-cover__face--a {
  background: linear-gradient(155deg, #6b1524, #c41e3a 55%, #8b1e2d);
}
.book-cover__face--b {
  background: linear-gradient(155deg, #1a2a4a, #3d5a80 60%, #1a2a4a);
}
.book-cover__face--c {
  background: linear-gradient(155deg, #5c4a32, #8b7355 55%, #3d2f1f);
}

.book-cover__year {
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  opacity: 0.85;
}

.book-cover__title {
  font-size: 1.05rem;
  letter-spacing: 0.08em;
  line-height: 1.35;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}

.book-cover__caption {
  margin-top: 0.55rem;
  font-size: 0.8rem;
  color: var(--color-ink-muted);
  text-align: center;
  font-family: var(--font-body);
}

.bookshelf__empty {
  text-align: center;
  color: var(--color-ink-muted);
  padding: 3rem 1rem;
}

/* Reader overlay */
.reader {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 300;
  background:
    linear-gradient(180deg, rgba(60, 40, 25, 0.25), rgba(40, 25, 15, 0.45)),
    repeating-linear-gradient(
      90deg,
      #c4a574 0px,
      #d2b48c 8px,
      #b8956a 16px,
      #c9a87a 24px
    );
  flex-direction: column;
}

.reader.is-open {
  display: flex;
  animation: fadeIn 0.3s var(--ease);
}

.reader__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.65rem 1rem;
  background: rgba(45, 30, 18, 0.88);
  color: #f5ead6;
  font-size: 0.88rem;
}

.reader__top a {
  color: #9ec9ff;
}

.reader__stage-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  position: relative;
  overflow: hidden;
}

.reader__nav-side {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.35);
  color: #fff;
  cursor: pointer;
  font-size: 1.4rem;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
}

.reader__nav-side:hover {
  background: rgba(0, 0, 0, 0.55);
}

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

.flip-spread {
  width: min(920px, 94vw);
  height: min(560px, 68vh);
  display: grid;
  grid-template-columns: 1fr 1fr;
  position: relative;
  perspective: 1800px;
  filter: drop-shadow(0 18px 35px rgba(0, 0, 0, 0.35));
}

.flip-page {
  background: #fffef8;
  padding: 1.5rem 1.35rem;
  overflow: auto;
  position: relative;
  box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.04);
}

.flip-page--left {
  border-radius: 4px 0 0 4px;
  box-shadow: inset -12px 0 20px rgba(0, 0, 0, 0.06);
}

.flip-page--right {
  border-radius: 0 4px 4px 0;
  box-shadow: inset 12px 0 20px rgba(0, 0, 0, 0.06);
  transform-origin: left center;
}

.flip-spread.is-turning .flip-page--right {
  animation: pageTurn 0.55s var(--ease);
}

@keyframes pageTurn {
  0% { transform: rotateY(0); }
  45% { transform: rotateY(-70deg); box-shadow: -20px 0 40px rgba(0,0,0,0.2); }
  100% { transform: rotateY(0); }
}

.flip-page__label {
  font-family: var(--font-display);
  color: var(--color-red);
  font-size: 1.25rem;
  letter-spacing: 0.1em;
  margin: 0 0 1rem;
}

.flip-page__body {
  color: #222;
  font-size: 0.92rem;
  line-height: 1.85;
  text-align: justify;
}

.flip-page__num {
  position: absolute;
  bottom: 0.65rem;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 0.8rem;
  color: #888;
}

.reader__thumbs {
  display: none;
  gap: 0.5rem;
  overflow-x: auto;
  padding: 0.65rem 1rem;
  background: rgba(45, 30, 18, 0.82);
}

.reader__thumbs.is-open {
  display: flex;
}

.reader__thumb {
  flex: 0 0 auto;
  width: 52px;
  height: 70px;
  border: 2px solid transparent;
  background: #fffef8;
  color: #333;
  font-size: 0.7rem;
  cursor: pointer;
  padding: 0.25rem;
}

.reader__thumb.is-active {
  border-color: #5dade2;
}

.reader__bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.5rem 0.75rem;
  padding: 0.65rem 1rem;
  background: rgba(45, 30, 18, 0.92);
  color: #f5ead6;
}

.reader__bar button {
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  padding: 0.35rem 0.55rem;
  font-size: 0.9rem;
  border-radius: var(--radius-sm);
}

.reader__bar button:hover {
  background: rgba(255, 255, 255, 0.12);
}

.reader__page-input {
  width: 4.5rem;
  text-align: center;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: #fff;
  color: #222;
  padding: 0.25rem;
  border-radius: 2px;
  font-size: 0.85rem;
}

@media (max-width: 700px) {
  .flip-spread {
    grid-template-columns: 1fr;
    height: min(70vh, 520px);
  }
  .flip-page--right {
    display: none;
  }
  .book-cover {
    width: 120px;
  }
  .book-cover__face {
    height: 165px;
  }
}
