/* 阅读器书架样式 (css/modules/reader_shelf.css)
   淡色简约：粉彩渐变封面站在一条细细的悬浮搁板上。放在 reader.css 之后，覆盖旧的卡片式书架 */

.reader-bookshelf-content {
    --shelf-top: 22px;         /* 封面顶部留白 */
    --shelf-cover-h: 158px;    /* 封面高度 */
    --shelf-ledge-h: 9px;      /* 搁板厚度 */
    --shelf-label-h: 64px;     /* 搁板下面放书名/进度 */
    --shelf-row-h: calc(var(--shelf-top) + var(--shelf-cover-h) + var(--shelf-ledge-h) + var(--shelf-label-h));
    --shelf-ledge-y: calc(var(--shelf-top) + var(--shelf-cover-h));

    --shelf-page1: #fbf8f4;
    --shelf-page2: #f4efe9;
    --shelf-ledge-hi: #ffffff;
    --shelf-ledge1: #e7dccb;
    --shelf-ledge2: #cdbfa9;
    --shelf-ledge-shadow: rgba(110, 85, 60, .28);
    --shelf-ink: #3f3a46;
    --shelf-sub: #a39cab;
    --shelf-bar-bg: rgba(120, 110, 140, .14);
    --shelf-bar-fill1: #b9c9e8;
    --shelf-bar-fill2: #c9bde8;
    --shelf-accent: #e29aa8;

    background: linear-gradient(180deg, var(--shelf-page1), var(--shelf-page2));
    padding: 6px 16px 32px;
    min-height: 100%;
}
html[data-ui="dark"] .reader-bookshelf-content {
    --shelf-page1: #1b1a1f;
    --shelf-page2: #161519;
    --shelf-ledge-hi: #4a4654;
    --shelf-ledge1: #3a3642;
    --shelf-ledge2: #2c2933;
    --shelf-ledge-shadow: rgba(0, 0, 0, .5);
    --shelf-ink: #ece8f2;
    --shelf-sub: #9a94a6;
    --shelf-bar-bg: rgba(255, 255, 255, .14);
    --shelf-bar-fill1: #7fa6e8;
    --shelf-bar-fill2: #9b82e0;
    --shelf-accent: #f3a0b6;
}

/* ───── 顶部小统计 ───── */
.shelf-summary {
    display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
    padding: 10px 2px 6px;
    color: var(--shelf-ink);
}
.shelf-summary b { font-size: 20px; font-weight: 700; letter-spacing: .5px; }
.shelf-summary span { font-size: 12px; color: var(--shelf-sub); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ───── 书架：一排一条悬浮搁板 ───── */
.reader-bookshelf-content .bookshelf-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-auto-rows: var(--shelf-row-h);
    gap: 0 10px;
    padding: 0;
    background:
        linear-gradient(to bottom,
            transparent 0,
            transparent var(--shelf-ledge-y),
            var(--shelf-ledge-hi) var(--shelf-ledge-y),
            var(--shelf-ledge1) calc(var(--shelf-ledge-y) + 1.5px),
            var(--shelf-ledge2) calc(var(--shelf-ledge-y) + var(--shelf-ledge-h)),
            var(--shelf-ledge-shadow) calc(var(--shelf-ledge-y) + var(--shelf-ledge-h)),
            rgba(0, 0, 0, 0) calc(var(--shelf-ledge-y) + var(--shelf-ledge-h) + 16px),
            transparent 100%) 0 0 / 100% var(--shelf-row-h) repeat-y;
    border: none;
    border-radius: 0;
    box-shadow: none;
    min-height: calc(var(--shelf-row-h) * 3);
    min-height: max(calc(var(--shelf-row-h) * 3), round(down, calc(100dvh - 130px), var(--shelf-row-h)));
}
@media (min-width: 560px) {
    .reader-bookshelf-content .bookshelf-grid { grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); }
}

/* ───── 单本书 ───── */
.reader-bookshelf-content .book-item {
    background: transparent;
    box-shadow: none;
    border-radius: 0;
    padding: 0;
    height: var(--shelf-row-h);
    align-items: center;
    justify-content: flex-start;
    -webkit-tap-highlight-color: transparent;
}
.reader-bookshelf-content .book-item:active { transform: none; }

.reader-bookshelf-content .book-cover {
    --c1: #ebe6f2; --c2: #d9d3e7; --ink: #5d5675;
    position: relative;
    width: calc(var(--shelf-cover-h) * .70);
    max-width: 100%;
    height: var(--shelf-cover-h);
    margin: var(--shelf-top) 0 var(--shelf-ledge-h);
    border-radius: 4px 9px 9px 4px;
    background: linear-gradient(150deg, var(--c1), var(--c2));
    box-shadow:
        inset 0 0 0 1px rgba(255, 255, 255, .55),
        0 1px 2px rgba(60, 50, 70, .14),
        0 12px 14px -9px rgba(70, 55, 80, .38);
    color: var(--ink);
    font-weight: 400;
    font-size: inherit;
    display: block;
    transition: transform .22s cubic-bezier(.3, 1.4, .5, 1), box-shadow .22s;
    transform-origin: 50% 100%;
}
/* 书脊折痕 */
.book-cover .book-spine {
    position: absolute; left: 0; top: 0; bottom: 0; width: 14px;
    border-radius: 4px 0 0 4px;
    background:
        linear-gradient(90deg, transparent 10px, rgba(0, 0, 0, .07) 10px, rgba(0, 0, 0, .07) 11px, rgba(255, 255, 255, .6) 11px, rgba(255, 255, 255, .6) 12px, transparent 12px),
        linear-gradient(90deg, rgba(0, 0, 0, .07), rgba(255, 255, 255, .15) 70%, transparent);
    pointer-events: none;
}
/* 柔光 */
.reader-bookshelf-content .book-item:not(.upload-book-btn) .book-cover::after {
    content: '';
    position: absolute; inset: 0;
    border-radius: inherit;
    background:
        radial-gradient(120% 70% at 15% 0%, rgba(255, 255, 255, .45), rgba(255, 255, 255, 0) 60%),
        linear-gradient(180deg, rgba(255, 255, 255, 0) 60%, rgba(80, 60, 90, .06));
    pointer-events: none;
}
.book-cover-inner {
    position: absolute; inset: 0;
    border-radius: inherit;
    overflow: hidden;
    padding: 22px 11px 13px 21px;
    display: flex; flex-direction: column; align-items: flex-start; justify-content: space-between;
    text-align: left;
}
/* 封面大字水印（取书名第一个字） */
.book-cover-mark {
    position: absolute; right: -8px; bottom: -22px;
    font-family: "Songti SC", "STSong", "Noto Serif CJK SC", "Noto Serif SC", serif;
    font-size: 104px; font-weight: 800; line-height: 1;
    color: var(--ink);
    opacity: .1;
    pointer-events: none;
    user-select: none;
}
.book-cover-title {
    position: relative; z-index: 1;
    font-family: "PingFang SC", "HarmonyOS Sans SC", "Noto Sans CJK SC", "Microsoft YaHei", sans-serif;
    font-weight: 700;
    line-height: 1.4;
    letter-spacing: .6px;
    display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden;
    word-break: normal; overflow-wrap: anywhere;
}
.book-cover-foot { position: relative; z-index: 1; width: 100%; }
.book-cover-line { width: 20px; height: 2px; margin: 0 0 6px; border-radius: 1px; background: var(--ink); opacity: .45; }
.book-cover-author {
    font-size: 10px; letter-spacing: .4px; opacity: .75; max-width: 100%;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
/* 书签（最近在读的那本） */
.book-ribbon {
    position: absolute; top: -5px; right: 11px; width: 12px; height: 25px; z-index: 3;
    background: var(--shelf-accent);
    clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 78%, 0 100%);
    filter: drop-shadow(0 2px 2px rgba(0, 0, 0, .25));
}

/* 按下时把书"抽出来"一点 */
.reader-bookshelf-content .book-item:not(.edit-mode):not(.upload-book-btn):active .book-cover {
    transform: translateY(-7px) rotate(-1.5deg);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .55), 0 1px 2px rgba(60, 50, 70, .14), 0 18px 16px -10px rgba(70, 55, 80, .38);
}

/* ───── 搁板下面的信息 ───── */
.book-meta {
    width: 100%;
    height: var(--shelf-label-h);
    padding: 9px 2px 0;
    box-sizing: border-box;
    text-align: left;
}
.reader-bookshelf-content .book-meta .book-title {
    font-size: 12.5px; font-weight: 600; line-height: 1.3;
    color: var(--shelf-ink);
    margin: 0 0 6px;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
    word-break: normal; overflow-wrap: anywhere;
}
.book-progress-row { display: flex; align-items: center; gap: 6px; }
.book-bar { flex: 1; height: 4px; border-radius: 2px; background: var(--shelf-bar-bg); overflow: hidden; }
.book-bar i { display: block; height: 100%; border-radius: 2px; background: linear-gradient(90deg, var(--shelf-bar-fill1), var(--shelf-bar-fill2)); }
.book-pct { font-size: 10px; color: var(--shelf-sub); min-width: 28px; text-align: right; font-variant-numeric: tabular-nums; }
.book-corread {
    display: inline-block;
    margin-top: 4px; padding: 0 7px;
    font-size: 10px; line-height: 15px;
    color: var(--shelf-accent);
    background: color-mix(in srgb, var(--shelf-accent) 14%, transparent);
    border-radius: 8px;
    max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ───── 导入：搁板上的空位 ───── */
.reader-bookshelf-content .upload-book-btn { border: none; background: transparent; }
.reader-bookshelf-content .upload-book-btn .book-cover {
    background: transparent;
    border: 1.5px dashed rgba(140, 125, 170, .5);
    border-radius: 9px;
    box-shadow: none;
    color: var(--shelf-sub);
    font-size: 36px;
    font-weight: 300;
    display: flex; align-items: center; justify-content: center;
}
.reader-bookshelf-content .upload-book-btn .book-title { font-size: 12px; color: var(--shelf-sub); margin: 8px 0 2px; text-align: center; }
.reader-bookshelf-content .upload-book-btn .book-author { font-size: 10px; color: var(--shelf-sub); opacity: .8; text-align: center; }

/* ───── 管理模式 ───── */
.reader-bookshelf-content .book-delete-btn {
    top: -8px; right: -8px;
    width: 22px; height: 22px;
    background: #ef6a73;
    box-shadow: 0 2px 6px rgba(0, 0, 0, .28);
    z-index: 5;
    padding: 0;
}
.reader-bookshelf-content .book-delete-btn svg { display: block; }
.reader-bookshelf-content .book-item.edit-mode .book-delete-btn { animation: none; }
.reader-bookshelf-content .book-item.edit-mode:not(.upload-book-btn) .book-cover { animation: shelf-wiggle .45s ease-in-out infinite; }
.reader-bookshelf-content .book-item.edit-mode.upload-book-btn { opacity: .4; }
@keyframes shelf-wiggle {
    0%, 100% { transform: rotate(-1.4deg); }
    50% { transform: rotate(1.4deg); }
}
