/**
 * Bookshelf and widget.
 */

.br-shelf-container {
    position: relative;
    max-width: 980px;
    margin: 28px auto;
    padding: clamp(20px, 3vw, 34px) clamp(16px, 3vw, 32px) clamp(28px, 4vw, 42px);
    border: 1px solid rgba(92, 76, 54, 0.2);
    border-radius: 18px;
    background:
        radial-gradient(700px 280px at 50% -10%, rgba(176, 138, 79, 0.16), transparent 65%),
        linear-gradient(180deg, #fbf6ec 0%, #f0e6d4 100%);
    box-shadow: 0 2px 0 rgba(255, 255, 255, 0.6) inset, 0 24px 55px rgba(48, 35, 20, 0.12);
}

.br-shelf-container::after {
    position: absolute;
    right: 24px;
    bottom: 14px;
    left: 24px;
    height: 8px;
    border-radius: 50%;
    background: rgba(48, 35, 20, 0.12);
    filter: blur(7px);
    content: "";
    pointer-events: none;
}

.br-shelf-heading {
    margin: 0 0 20px;
    color: var(--br-ink);
    font-family: var(--br-serif);
    font-size: 1.2rem;
    text-align: center;
}

.br-shelf {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 220px));
    justify-content: center;
    gap: clamp(14px, 3vw, 28px);
    max-width: 760px;
    margin: 0 auto;
}

.br-book-item {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    min-width: 0;
    padding: 9px 9px 12px;
    border: 1px solid rgba(92, 76, 54, 0.14);
    border-radius: 9px 9px 5px 5px;
    background: rgba(255, 253, 248, 0.48);
    transition: transform 0.24s var(--br-ease), box-shadow 0.24s var(--br-ease), background 0.24s var(--br-ease);
    animation: br-shelf-in 0.55s var(--br-ease) both;
    animation-delay: calc(var(--i, 0) * 45ms);
}

.br-book-item::after {
    position: absolute;
    right: 7px;
    bottom: -7px;
    left: 7px;
    height: 7px;
    border-radius: 0 0 3px 3px;
    background: linear-gradient(180deg, #b08a4f, #8d6a37);
    box-shadow: 0 5px 12px rgba(48, 35, 20, 0.18);
    content: "";
}

.br-book-item:hover {
    background: rgba(255, 253, 248, 0.9);
    box-shadow: 0 20px 34px rgba(48, 35, 20, 0.18);
    transform: translateY(-5px);
}

@keyframes br-shelf-in {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
}

.br-book-item > a {
    display: flex;
    flex-direction: column;
    min-width: 0;
    color: inherit;
    text-decoration: none;
}

.br-book-cover {
    position: relative;
    display: block;
    width: 100%;
    aspect-ratio: 3 / 4;
    overflow: hidden;
    border-radius: 4px 7px 7px 4px;
    background: #e5d8c1;
    box-shadow: 0 8px 18px rgba(48, 35, 20, 0.2);
}

.br-book-cover img,
.br-book-cover svg,
.br-book-cover .br-empty-cover {
    position: absolute;
    inset: 0;
    display: block;
    width: 100% !important;
    height: 100% !important;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    object-fit: cover !important;
    object-position: center;
    background: #e5d8c1;
    box-shadow: none;
}

/* 兼容旧模板直接输出 img / svg 的情况，避免 height 属性把封面拉长。 */
.br-book-item > a > img,
.br-book-item > a > svg {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 3 / 4;
    border-radius: 4px 7px 7px 4px;
    object-fit: cover;
    background: #e5d8c1;
    box-shadow: 0 8px 18px rgba(48, 35, 20, 0.2);
}

.br-book-item img {
    max-width: 100%;
    aspect-ratio: 3 / 4;
    object-fit: cover;
    transition: transform 0.3s var(--br-ease);
}

.br-book-item:hover img {
    transform: scale(1.015);
}

.br-cover-svg {
    overflow: hidden;
}

.br-book-title {
    display: -webkit-box;
    margin-top: 9px;
    overflow: hidden;
    color: var(--br-ink);
    font-family: var(--br-serif);
    font-size: 0.82rem;
    font-weight: 700;
    line-height: 1.45;
    text-align: center;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

.br-book-rating {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    margin-top: 4px;
    color: var(--br-muted);
    font-size: 0.66rem;
}

.br-book-words {
    display: block;
    margin-top: 3px;
    color: var(--br-muted);
    font-size: 0.64rem;
    text-align: center;
}

.br-book-status-mini {
    position: absolute;
    top: 7px;
    left: 7px;
    z-index: 2;
    display: inline-flex;
    align-items: center;
    padding: 2px 7px;
    border-radius: 999px;
    background: rgba(25, 21, 16, 0.62);
    color: #fff;
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    backdrop-filter: blur(4px);
}

.br-book-status-mini.is-completed {
    background: rgba(47, 107, 95, 0.86);
}

.br-book-status-mini.is-paused {
    background: rgba(128, 112, 91, 0.86);
}

.br-empty-placeholder {
    border-style: dashed;
    background: transparent;
    box-shadow: none;
    opacity: 0.4;
    animation: none;
}

.br-empty-placeholder::after {
    display: none;
}

.br-empty-cover {
    background: rgba(92, 76, 54, 0.06);
    box-shadow: none;
}

.br-empty-placeholder .br-book-title {
    color: var(--br-muted);
    font-family: var(--br-ui);
    font-size: 0.7rem;
    font-weight: 400;
}

/* Widget */

.br-widget-title > i {
    margin-right: .25rem !important;
    color: #111;
    font-size: 0.95em;
    line-height: 1;
}

.br-widget-title-text {
    display: inline;
}

.widget_br_bookshelf .br-shelf-container,
.widget .br-shelf-container {
    margin: 8px 0 0;
    padding: 10px 10px 18px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    box-shadow: none;
}

.widget_br_bookshelf .br-shelf-container::after,
.widget .br-shelf-container::after {
    right: 10px;
    bottom: 4px;
    left: 10px;
}

.widget_br_bookshelf .br-shelf,
.widget .br-shelf-container .br-shelf {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    justify-content: stretch;
    gap: 8px;
}

.widget_br_bookshelf .br-book-item,
.widget .br-shelf-container .br-book-item {
    padding: 4px 4px 8px;
    border: 0;
    background: transparent;
    box-shadow: none;
}

.widget_br_bookshelf .br-book-item::after,
.widget .br-shelf-container .br-book-item::after {
    display: none;
}

.widget_br_bookshelf .br-book-item:hover,
.widget .br-shelf-container .br-book-item:hover {
    background: transparent;
    box-shadow: none;
    transform: translateY(-2px);
}

.widget_br_bookshelf .br-book-title,
.widget .br-shelf-container .br-book-title {
    margin-top: 4px;
    font-size: 0.66rem;
    -webkit-line-clamp: 1;
}

.widget_br_bookshelf .br-book-rating,
.widget .br-shelf-container .br-book-rating {
    display: none;
}

.widget_br_bookshelf .br-shelf-container .br-book-cover,
.widget .br-shelf-container .br-book-cover {
    box-shadow: 0 4px 9px rgba(48, 35, 20, 0.18);
}

@media (max-width: 680px) {
    .br-shelf-container {
        margin: 18px auto;
        padding: 16px 12px 24px;
    }

    .br-shelf {
        gap: 10px;
    }

    .br-book-item {
        padding: 6px 6px 9px;
    }

    .br-book-title {
        font-size: 0.72rem;
    }
}

@media (max-width: 420px) {
    .br-shelf {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (prefers-reduced-motion: reduce) {
    .br-book-item,
    .br-book-item img {
        animation: none !important;
        transition: none !important;
    }
}
