/* 读完墙 · 堆叠翻卷（reading-wall.js 配套，纯 CSS，无外部依赖） */

.rw-wall {
  --rw-w: min(180px, 42vw);
  --rw-edge-x: 8px;
  --rw-edge-y: 7px;
  --rw-rank: 0;
  padding: 4px 2px 10px;
}

.rw-head {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  margin-bottom: 10px;
}

.rw-count {
  font-size: 12px;
  color: var(--muted, #4a5a4e);
  font-variant-numeric: tabular-nums;
  letter-spacing: .02em;
}

.rw-stage {
  position: relative;
  isolation: isolate;
  perspective: 1100px;
  display: grid;
  justify-items: center;
  /* 兜底高度：JS 量准后会以内联高度覆盖；万一量不到，舞台也不会塌成 0 而叠住下方内容 */
  min-height: calc(var(--rw-w) * 1.5 + 72px);
}

.rw-card {
  position: absolute;
  left: 50%;
  top: 0;
  width: var(--rw-w);
  margin: 0;
  background: var(--surface, #fbf8f1);
  border: 1px solid var(--line-soft, #e6e1d5);
  transform:
    translate(-50%, 0)
    translate(
      calc(var(--rw-rank) * var(--rw-edge-x)),
      calc(var(--rw-rank) * var(--rw-edge-y))
    )
    scale(calc(1 - var(--rw-rank) * 0.025));
  z-index: calc(50 - var(--rw-rank));
  transform-origin: left center;
  filter: brightness(calc(1 - var(--rw-rank) * 0.09)) saturate(.92);
  transition:
    transform .4s cubic-bezier(.25, .9, .3, 1),
    filter .4s ease,
    opacity .4s ease,
    box-shadow .3s ease;
  pointer-events: none;
  border-radius: 10px;
  overflow: hidden;
}

.rw-card.rw-front {
  pointer-events: auto;
  filter: brightness(1) saturate(1);
  box-shadow: 0 12px 28px rgba(31, 53, 61, .18);
}

.rw-card.rw-behind {
  box-shadow: 1px 0 0 var(--line-soft, #e6e1d5), inset -6px 0 10px -8px rgba(31, 53, 61, .35);
}

/* 后层只露边，不露出书名 / 作者 / 评分 */
.rw-behind .rw-meta { display: none; }

/* 翻卷：绕左侧书脊折起，随角度压暗并投影 */
.rw-card.rw-going {
  z-index: 200;
  transform: translate(-50%, 0) rotateY(-168deg) translateX(-26%);
  transform-origin: left center;
  filter: brightness(.42) saturate(.65);
  box-shadow: -18px 10px 30px rgba(31, 53, 61, .28);
}

.rw-card.rw-coming {
  z-index: 150;
}

.rw-card::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(to right, rgba(20, 30, 24, .55), transparent 55%);
  opacity: 0;
  transition: opacity .4s ease;
  pointer-events: none;
}

.rw-card.rw-going::after { opacity: 1; }

.rw-cover {
  position: relative;
  width: 100%;
  aspect-ratio: 2 / 3;
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface-3, #eee7db);
  border: 1px solid var(--line-soft, #e6e1d5);
}

.rw-cover-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  user-select: none;
}

/* 无封面：书名兜底，居中、可折行、自动缩小，无花纹无破图 */
.rw-cover-fallback {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  padding: 12px;
  background: var(--surface-3, #eee7db);
}

.rw-fb-title {
  text-align: center;
  line-height: 1.45;
  overflow-wrap: anywhere;
  color: var(--ink-soft, #2b3a30);
  font-size: clamp(13px, 2.4vw, 17px);
  font-weight: 600;
}

.rw-fb-long .rw-fb-title {
  font-size: clamp(11px, 2vw, 14px);
}

.rw-meta {
  padding: 8px 2px 0;
  text-align: center;
}

.rw-title {
  margin: 0;
  font-size: 13px;
  font-weight: 650;
  color: var(--ink, #12211a);
  overflow-wrap: anywhere;
  line-height: 1.4;
}

.rw-author {
  margin-top: 3px;
  font-size: 11px;
  color: var(--muted, #4a5a4e);
  overflow-wrap: anywhere;
}

.rw-rating {
  margin-top: 3px;
  font-size: 12px;
  color: var(--accent, #2f7d55);
  letter-spacing: 1px;
}

/* 底部「下一本」翻页带：唯一的点击翻页热区，高度不小于 36px */
.rw-next {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  width: calc(100% - 2px);
  height: 36px;
  min-height: 36px;
  margin: 10px 1px 2px;
  padding: 0 10px;
  border: 0;
  border-top: 1px solid var(--line-soft, #e6e1d5);
  background: transparent;
  color: var(--muted, #4a5a4e);
  font-family: inherit;
  font-size: 12px;
  letter-spacing: .03em;
  cursor: pointer;
}

.rw-next svg { flex: 0 0 auto; }

.rw-next:hover,
.rw-next:focus-visible {
  color: var(--ink, #12211a);
  background: color-mix(in srgb, var(--surface-2, #f5f0e7) 60%, transparent);
}

/* 后层卡片只露边，不显示翻页带 */
.rw-behind .rw-next { display: none; }

.rw-zoom {
  position: absolute;
  right: 6px;
  top: 6px;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  border: 1px solid var(--line-soft, #e6e1d5);
  background: color-mix(in srgb, var(--surface, #fbf8f1) 82%, transparent);
  color: var(--ink-soft, #2b3a30);
  display: grid;
  place-items: center;
  cursor: pointer;
  opacity: 0;
  transition: opacity .15s ease, background .15s ease;
  padding: 0;
}

.rw-front .rw-zoom { opacity: .9; }
.rw-zoom:hover, .rw-zoom:focus-visible { opacity: 1; }

/* 封面放大浮层：只显示封面大图，不可编辑 */
.rw-lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  opacity: 0;
  transition: opacity .18s ease;
}

.rw-lightbox.rw-open { opacity: 1; }

.rw-lightbox-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 22, 18, .62);
}

.rw-lightbox-body {
  position: relative;
  z-index: 1;
  margin: 0;
}

.rw-lightbox-cover {
  width: min(72vw, 240px);
  aspect-ratio: 2 / 3;
  border-radius: 10px;
  overflow: hidden;
  background: var(--surface-2, #f5f0e7);
  box-shadow: 0 18px 50px rgba(0, 0, 0, .35);
}

.rw-lightbox-cover .rw-cover-img { object-fit: contain; }

.rw-lightbox-cover .rw-cover-fallback { background: var(--surface-3, #eee7db); }

/* 移动端 390 宽 */
@media (max-width: 420px) {
  .rw-wall { --rw-w: min(168px, 46vw); --rw-edge-x: 6px; --rw-edge-y: 6px; }
  .rw-lightbox-cover { width: min(76vw, 210px); }
}
