/* ═══════════════════════════════════════
   SHELF.CSS - 书架页
   ═══════════════════════════════════════ */

/* 书架顶部控制栏 */
#shelf-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--rule);
}

/* 排序切换 */
#shelf-sort {
  display: flex;
  gap: 14px;
}

.sort-btn {
  font-size: 0.72rem;
  font-weight: 300;
  color: var(--ink-faint);
  cursor: pointer;
  letter-spacing: 0.04em;
  border: none;
  background: none;
  font-family: var(--font-ui);
  transition: color 0.2s;
  padding: 0;
}

.sort-btn.active {
  color: var(--ink);
  font-weight: 400;
}

/* 视图切换 + 导入按钮 */
#shelf-actions {
  display: flex;
  gap: 14px;
  align-items: center;
}

.view-toggle-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  color: var(--ink-faint);
  cursor: pointer;
  border: none;
  background: none;
  padding: 0;
  transition: color 0.2s;
  flex-shrink: 0;
}

.view-toggle-btn.active {
  color: var(--ink);
}

.view-toggle-btn:hover {
  color: var(--ink-mid);
}

.import-btn {
  font-size: 0.72rem;
  font-weight: 300;
  color: var(--ink-faint);
  cursor: pointer;
  letter-spacing: 0.04em;
  border: none;
  background: none;
  font-family: var(--font-ui);
  transition: color 0.2s;
  padding: 0;
}

.import-btn:hover {
  color: var(--ink);
}

/* ─── 列表视图 ─── */
#shelf-list.list-view {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.book-item-list {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 0;
  border-bottom: 1px solid var(--rule);
  cursor: pointer;
  transition: opacity 0.2s;
}

.book-item-list:hover {
  opacity: 0.6;
}

.book-info {
  flex: 1;
  min-width: 0;
  padding-right: 12px;
}

.book-title {
  font-family: var(--font-title);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 5px;
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.book-meta {
  font-size: 0.68rem;
  font-weight: 300;
  color: var(--ink-faint);
  letter-spacing: 0.04em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.book-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-shrink: 0;
}

.book-progress {
  font-size: 0.72rem;
  font-weight: 300;
  color: var(--ink-mid);
  letter-spacing: 0.02em;
  min-width: 32px;
  text-align: right;
}

.book-delete {
  font-size: 0.68rem;
  font-weight: 300;
  color: var(--ink-faint);
  cursor: pointer;
  transition: color 0.2s;
  letter-spacing: 0.04em;
}

.book-delete:hover {
  color: #a0291f;
}

/* ─── 网格视图 ─── */
#shelf-list.grid-view {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
  gap: 12px;
  padding-bottom: 150px;
}

.book-cover {
  aspect-ratio: 2/3;
  border-radius: 4px;
  position: relative;
  cursor: pointer;
  transition: opacity 0.2s;
  overflow: hidden;
}

.book-cover:hover {
  opacity: 0.85;
}

.book-cover-title {
  font-family: var(--font-title);
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.4;
  word-break: break-all;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-shadow: 0 1px 3px rgba(0,0,0,0.25);
}

/* ═══════════════════════════════════════
   封面风格 A · 居中素白
═══════════════════════════════════════ */
[data-cover-style="a"] .book-cover {
  background: var(--bg) !important;
  border: 1px solid var(--rule);
  border-radius: 3px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 14px 10px;
  text-align: center;
  color: var(--ink);
}

[data-cover-style="a"] .book-cover .cover-title {
  font-family: var(--font-title);
  font-size: 11px;
  font-weight: 400;
  line-height: 1.5;
  color: var(--ink);
  margin-bottom: 6px;
  /* 书名过长时省略 */
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-all;
  width: 100%;
}

[data-cover-style="a"] .book-cover .cover-author {
  font-size: 9px;
  font-weight: 200;
  color: var(--ink-faint);
  letter-spacing: 0.04em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
  min-height: 1em; /* 无作者时保留占位，避免书名跑偏 */
}

[data-cover-style="a"] .book-cover .cover-progress {
  display: block;
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 2px;
  background: var(--ink-ghost);
  border-radius: 0 0 3px 3px;
}

[data-cover-style="a"] .book-cover .cover-progress-fill {
  height: 100%;
  background: var(--ink-faint);
  border-radius: inherit;
}

/* ═══════════════════════════════════════
   封面风格 B · 书脊线
═══════════════════════════════════════ */
[data-cover-style="b"] .book-cover {
  background: var(--bg) !important;
  border: 1px solid var(--rule);
  border-left: 3px solid var(--ink-ghost);
  border-radius: 0 3px 3px 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 12px 10px 10px 11px;
  color: var(--ink);
}

[data-cover-style="b"] .book-cover .cover-title {
  font-family: var(--font-title);
  font-size: 11px;
  font-weight: 400;
  line-height: 1.5;
  color: var(--ink);
  margin-bottom: 4px;
  /* 书名过长时省略 */
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-all;
}

[data-cover-style="b"] .book-cover .cover-author {
  font-size: 9px;
  font-weight: 200;
  color: var(--ink-mid);
  letter-spacing: 0.03em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-height: 1em;
}

[data-cover-style="b"] .book-cover .cover-top {
  flex: 1;
  overflow: hidden;
}

[data-cover-style="b"] .book-cover .cover-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 7px;
  border-top: 1px solid var(--rule);
  flex-shrink: 0;
}

[data-cover-style="b"] .book-cover .cover-pct {
  font-size: 9px;
  font-weight: 200;
  color: var(--ink-faint);
  letter-spacing: 0.04em;
}

/* ═══════════════════════════════════════
   封面风格 C · 底栏分割
═══════════════════════════════════════ */
[data-cover-style="c"] .book-cover {
  background: var(--bg) !important;
  border: 1px solid var(--rule);
  border-radius: 3px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  color: var(--ink);
}

[data-cover-style="c"] .book-cover .cover-body {
  display: flex;
  flex: 1;
  flex-direction: column;
  justify-content: flex-end;
  padding: 10px 9px 8px;
  overflow: hidden;
}

[data-cover-style="c"] .book-cover .cover-title {
  font-family: var(--font-title);
  font-size: 11px;
  font-weight: 400;
  line-height: 1.5;
  color: var(--ink);
  /* 书名过长时省略 */
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-all;
}

[data-cover-style="c"] .book-cover .cover-footer {
  display: flex;
  padding: 6px 9px;
  border-top: 1px solid var(--rule);
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

[data-cover-style="c"] .book-cover .cover-author {
  font-size: 9px;
  font-weight: 200;
  color: var(--ink-faint);
  letter-spacing: 0.04em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
  padding-right: 6px;
}

[data-cover-style="c"] .book-cover .cover-bar {
  display: block;
  width: 32px;
  height: 2px;
  background: var(--ink-ghost);
  border-radius: 1px;
  overflow: hidden;
  flex-shrink: 0;
}

[data-cover-style="c"] .book-cover .cover-bar-fill {
  height: 100%;
  background: var(--ink-mid);
  border-radius: inherit;
}

/* ─── 图片封面（有 coverImage 时覆盖文字风格） ─── */
.book-cover .cover-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
  display: block;
  border-radius: inherit;
  pointer-events: none; /* 不拦截点击，让事件穿透到父级或删除按钮 */
  z-index: 0;
}

/* 图片封面底部遮罩（用于显示进度条） */
.book-cover .cover-img-overlay {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  z-index: 1;
}

/* 图片封面进度条 */
.book-cover .cover-img-progress {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 3px;
  background: rgba(255,255,255,0.25);
  border-radius: 0 0 3px 3px;
}

.book-cover .cover-img-progress-fill {
  height: 100%;
  background: rgba(255,255,255,0.75);
  border-radius: inherit;
  transition: width 0.3s ease;
}

/* ─── 网格视图删除按钮 ─── */
.book-del-btn {
  position: absolute;
  top: 5px;
  right: 6px;
  font-size: 14px;
  line-height: 1;
  color: var(--ink-faint);
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 2;
}

.book-cover:hover .book-del-btn {
  opacity: 1;
}

/* ─── 空状态 ─── */
.empty-shelf {
  padding: 80px 20px;
  text-align: center;
  font-size: 0.82rem;
  font-weight: 300;
  color: var(--ink-ghost);
  letter-spacing: 0.08em;
  line-height: 2.2;
}
