/* Book library and online reader styles. */
.book-library {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr));
    align-items: start;
    gap: clamp(18px, 3vw, 34px);
    margin-top: 24px;
}

.book-card {
    width: 100%;
    max-width: 520px;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow);
    transition: transform 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
}

.book-card:hover {
    transform: translateY(-4px);
    border-color: rgba(var(--primary-rgb), 0.32);
    box-shadow: 0 22px 46px rgba(var(--primary-rgb), 0.16);
}

.book-cover-link {
    display: block;
    color: inherit;
    text-decoration: none;
}

.book-cover {
    position: relative;
    display: flex;
    min-height: clamp(300px, 34vw, 430px);
    overflow: hidden;
    border-bottom: 1px solid rgba(var(--primary-rgb), 0.12);
    background:
        radial-gradient(circle at 78% 16%, rgba(239, 224, 143, 0.78) 0 34px, rgba(239, 224, 143, 0.12) 35px 74px, transparent 75px),
        linear-gradient(155deg, rgba(0, 78, 140, 0.92), rgba(2, 20, 34, 0.98) 54%, rgba(3, 32, 52, 0.96));
}

.book-cover::before {
    content: "";
    position: absolute;
    inset: auto -12% 16% 10%;
    height: 42%;
    border-radius: 50%;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.16), transparent 45%),
        repeating-linear-gradient(178deg, rgba(157, 219, 255, 0.18) 0 2px, transparent 2px 18px);
    opacity: 0.58;
    transform: rotate(-5deg);
}

.book-cover-spine {
    width: clamp(30px, 5vw, 48px);
    border-right: 1px solid rgba(255, 255, 255, 0.12);
    background:
        linear-gradient(90deg, rgba(0, 0, 0, 0.32), rgba(255, 255, 255, 0.1)),
        rgba(1, 18, 31, 0.72);
}

.book-cover-moon {
    position: absolute;
    top: 34px;
    right: 44px;
    width: 74px;
    height: 74px;
    border-radius: 50%;
    background: #f1df91;
    box-shadow: 0 0 38px rgba(241, 223, 145, 0.48);
}

.book-cover-lines {
    position: absolute;
    right: 24px;
    bottom: 34px;
    left: 78px;
    display: grid;
    gap: 11px;
    opacity: 0.75;
}

.book-cover-lines span {
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(157, 219, 255, 0.72), transparent);
}

.book-cover-lines span:nth-child(2) {
    width: 76%;
}

.book-cover-lines span:nth-child(3) {
    width: 62%;
}

.book-cover-content {
    position: relative;
    z-index: 1;
    display: flex;
    flex: 1;
    flex-direction: column;
    justify-content: flex-end;
    padding: clamp(26px, 4vw, 42px);
}

.book-cover-content p {
    margin: 0 0 12px;
    color: rgba(239, 224, 143, 0.88);
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.12em;
}

.book-cover-content h2 {
    margin: 0;
    color: #fff;
    font-family: var(--font-serif);
    font-size: clamp(42px, 6vw, 70px);
    line-height: 1.08;
    text-shadow: 0 10px 28px rgba(0, 0, 0, 0.42);
}

.book-cover-content span {
    margin-top: 16px;
    color: rgba(255, 255, 255, 0.72);
    font-size: 15px;
    font-weight: 700;
    line-height: 1.55;
}

.book-card-body {
    padding: clamp(20px, 3vw, 30px);
}

.book-format {
    display: inline-flex;
    width: fit-content;
    align-items: center;
    margin-bottom: 18px;
    border-radius: 6px;
    padding: 5px 10px;
    background: #46b35e;
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    line-height: 1.2;
}

.book-title {
    margin: 0 0 12px;
    color: var(--ink);
    font-family: var(--font-serif);
    font-size: clamp(26px, 3vw, 38px);
    line-height: 1.24;
}

.book-desc {
    margin: 0 0 20px;
    color: var(--ink-soft);
    font-size: 15px;
    line-height: 1.75;
}

.book-read-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 7px;
    padding: 10px 18px;
    background: var(--primary);
    color: #fff;
    font-size: 15px;
    font-weight: 700;
    text-decoration: none;
    transition: background 0.2s ease, transform 0.2s ease;
}

.book-read-btn:hover {
    background: #0f72bd;
    transform: translateY(-1px);
}

.book-shell {
    display: grid;
    grid-template-columns: minmax(260px, 310px) minmax(0, 1fr);
    width: min(1480px, 100%);
    min-height: calc(100vh - 68px);
    margin: 0 auto;
    border-top: 1px solid rgba(var(--primary-rgb), 0.12);
}

.book-sidebar {
    position: sticky;
    top: 68px;
    align-self: start;
    height: calc(100vh - 68px);
    overflow-y: auto;
    border-right: 1px solid rgba(var(--primary-rgb), 0.14);
    padding: 24px 18px;
    background: rgba(255, 255, 255, 0.74);
}

.book-sidebar-back {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 24px;
    color: var(--primary);
    font-size: 13px;
    font-weight: 700;
    text-decoration: none;
}

.book-sidebar-brand {
    border-bottom: 1px solid rgba(var(--primary-rgb), 0.12);
    padding-bottom: 18px;
}

.book-sidebar-brand p {
    margin: 0 0 8px;
    color: var(--gold);
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.08em;
}

.book-sidebar-brand h2 {
    margin: 0 0 8px;
    color: var(--ink);
    font-family: var(--font-serif);
    font-size: 24px;
    line-height: 1.25;
}

.book-sidebar-brand span {
    color: var(--ink-soft);
    font-size: 13px;
}

.book-sidebar-nav {
    display: grid;
    gap: 6px;
    margin-top: 18px;
}

.book-sidebar-group {
    display: grid;
    gap: 3px;
}

.book-sidebar-group > a {
    display: grid;
    grid-template-columns: 34px minmax(0, 1fr);
    gap: 9px;
    align-items: baseline;
    border-radius: 8px;
    padding: 9px 10px;
    color: var(--ink-soft);
    font-size: 14px;
    line-height: 1.5;
    text-decoration: none;
}

.book-sidebar-group > a span {
    color: var(--gold);
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: 700;
}

.book-sidebar-group > a:hover {
    background: rgba(var(--primary-rgb), 0.08);
    color: var(--primary);
}

.book-sidebar-group > a.active {
    background: rgba(var(--primary-rgb), 0.12);
    color: var(--primary);
    font-weight: 700;
}

.book-sidebar-sections {
    display: grid;
    gap: 2px;
    margin: 2px 0 8px 43px;
}

.book-sidebar-sections a {
    border-left: 1px solid rgba(var(--primary-rgb), 0.14);
    padding: 6px 8px 6px 12px;
    color: var(--ink-soft);
    font-size: 13px;
    line-height: 1.45;
    text-decoration: none;
}

.book-sidebar-sections a:hover {
    color: var(--primary);
}

.book-sidebar-sections a.active {
    color: var(--primary);
    font-weight: 700;
}

.book-sidebar-sections a.book-sidebar-subsection {
    padding-left: 22px;
    font-size: 12px;
    opacity: 0.86;
}

.book-main {
    min-width: 0;
    background: rgba(255, 255, 255, 0.54);
}

.book-reader-header {
    max-width: 860px;
    margin: 0 auto;
    padding: clamp(34px, 5vw, 66px) clamp(22px, 5vw, 56px) clamp(24px, 4vw, 44px);
    text-align: left;
}

.book-reader-title {
    margin: 0 0 14px;
    color: var(--ink);
    font-family: var(--font-serif);
    font-size: clamp(34px, 5vw, 58px);
    line-height: 1.16;
}

.book-reader-subtitle {
    max-width: 720px;
    margin: 0;
    color: var(--ink-soft);
    font-size: 16px;
    line-height: 1.8;
}

.book-reader-layout {
    padding: clamp(26px, 5vw, 58px) clamp(22px, 5vw, 56px);
}

.book-content {
    max-width: 820px;
    margin: 0 auto;
}

.book-content :is(h2, h3, h4, h5, h6) {
    scroll-margin-top: 86px;
}

.book-reader-actions {
    display: flex;
    max-width: 860px;
    gap: 12px;
    flex-wrap: wrap;
    margin: 0 auto;
    border-top: 1px solid rgba(var(--primary-rgb), 0.12);
    padding: 0 clamp(22px, 5vw, 56px) clamp(30px, 5vw, 48px);
}

[data-theme='dark'] .book-card,
[data-theme='dark'] .book-sidebar,
[data-theme='dark'] .book-main {
    border-color: var(--line) !important;
    background: var(--surface) !important;
}

[data-theme='dark'] .book-title,
[data-theme='dark'] .book-reader-title,
[data-theme='dark'] .book-sidebar-brand h2 {
    color: #fff !important;
}

[data-theme='dark'] .book-shell {
    border-top-color: var(--line);
}

@media print {
    .top-nav,
    .footer,
    .book-sidebar,
    .book-content,
    .book-reader-actions {
        display: none !important;
    }

    .book-main::after {
        content: "本书仅提供在线阅读，不提供打印或下载。";
        display: block;
        padding: 48px;
        color: #333;
        font-size: 18px;
        text-align: center;
    }
}

@media (max-width: 980px) {
    .book-shell {
        display: block;
    }

    .book-sidebar {
        position: relative;
        top: auto;
        height: auto;
        border-right: 0;
        border-bottom: 1px solid rgba(var(--primary-rgb), 0.14);
    }

    .book-sidebar-nav {
        max-height: 300px;
        overflow-y: auto;
    }
}

@media (max-width: 860px) {
    .book-sidebar-nav a {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 560px) {
    .book-sidebar {
        padding: 20px 14px;
    }

    .book-reader-layout,
    .book-reader-header {
        padding-right: 18px;
        padding-left: 18px;
    }

    .book-cover {
        min-height: 310px;
    }

    .book-cover-content h2 {
        font-size: 40px;
    }
}
