:root {
    --ink: #2f2a25;
    --muted: #756c64;
    --brown: #4b2e1f;
    --paper: #fffdf9;
    --cream: #f7f2eb;
    --line: rgba(75, 46, 31, 0.14);
    --active: #d2a431;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
}

body {
    background: transparent;
    color: var(--ink);
    font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
}

button,
a {
    -webkit-tap-highlight-color: transparent;
}

.bookshelf {
    width: min(1120px, 100%);
    margin: 0 auto;
    padding: 0 18px 24px;
    overflow: hidden;
}

.bookshelf-header {
    text-align: center;
    margin-bottom: 4px;
}

.eyebrow {
    margin: 0 0 6px;
    color: var(--muted);
    font-size: 0.72rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.bookshelf-header h1 {
    margin: 0;
    font-family: Fraunces, Georgia, serif;
    font-size: clamp(1.8rem, 4vw, 2.45rem);
    font-weight: 400;
    line-height: 1.1;
}

.intro {
    margin: 8px auto 0;
    color: var(--muted);
    font-size: 0.92rem;
}

.coverflow {
    position: relative;
    width: 100%;
    margin: 0 auto;
}

.coverflow-stage {
    position: relative;
    height: 410px;
    margin-top: -35px;
    overflow: hidden;
    isolation: isolate;
    touch-action: pan-y;
    user-select: none;
}

.book-cover {
    --x: 0px;
    --scale: 1;
    --opacity: 1;
    --z: 1;
    --y: 0px;

    appearance: none;
    position: absolute;
    left: 50%;
    bottom: 72px;
    z-index: var(--z);
    width: 220px;
    height: 318px;
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
    cursor: pointer;
    opacity: var(--opacity);
    transform:
        translateX(calc(-50% + var(--x)))
        translateY(var(--y))
        scale(var(--scale));
    transform-origin: 50% 88%;
    transition:
        transform 430ms cubic-bezier(.22,.72,.2,1),
        opacity 360ms ease,
        filter 360ms ease;
    will-change: transform, opacity;
    filter: saturate(0.92) brightness(0.99);
}

.book-cover.is-active {
    filter: saturate(1) brightness(1);
}

.book-cover.is-hidden {
    pointer-events: none;
}

.cover-shell {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

.cover-image {
    display: block;
    max-width: 205px;
    max-height: 308px;
    width: auto;
    height: auto;
    border-radius: 2px;
    background: #ece8e2;
    box-shadow:
        0 10px 19px rgba(36, 28, 22, 0.17),
        0 2px 5px rgba(36, 28, 22, 0.13);
    transition:
        box-shadow 350ms ease,
        outline-color 250ms ease;
}

.book-cover.is-active .cover-image {
    outline: 3px solid var(--active);
    outline-offset: 2px;
    box-shadow:
        0 16px 28px rgba(36, 28, 22, 0.20),
        0 4px 9px rgba(36, 28, 22, 0.15);
}

.cover-reflection {
    position: absolute;
    top: calc(100% - 4px);
    left: 50%;
    display: block;
    max-width: 205px;
    max-height: 308px;
    width: auto;
    height: auto;
    transform: translateX(-50%) scaleY(-1);
    transform-origin: top center;
    opacity: 0.17;
    filter: blur(0.45px) saturate(0.75);
    pointer-events: none;
    -webkit-mask-image: linear-gradient(to bottom, rgba(0,0,0,.65), transparent 27%);
    mask-image: linear-gradient(to bottom, rgba(0,0,0,.65), transparent 27%);
}

.book-cover.is-active .cover-reflection {
    opacity: 0.21;
}

/* Navigation lives with the book title rather than over the covers. */
.book-controls {
    display: grid;
    grid-template-columns: 54px minmax(0, 1fr) 54px;
    align-items: center;
    gap: 18px;
    width: min(760px, 100%);
    margin: -6px auto 0;
    padding: 0 8px;
}

.nav-arrow {
    appearance: none;
    width: 54px;
    height: 44px;
    margin: 0;
    padding: 0 0 3px;
    border: 1px solid var(--brown);
    border-radius: 6px;
    background: var(--brown);
    color: #fff;
    font-family: Georgia, "Times New Roman", serif;
    font-size: 2rem;
    font-weight: 400;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(52, 35, 25, 0.10);
    transition:
        background 140ms ease,
        transform 120ms ease,
        box-shadow 140ms ease;
}

.nav-arrow:hover,
.nav-arrow:focus-visible {
    background: #5b3927;
    outline: 2px solid rgba(75, 46, 31, 0.20);
    outline-offset: 2px;
    box-shadow: 0 4px 9px rgba(52, 35, 25, 0.14);
}

.nav-arrow:active {
    transform: translateY(1px) scale(0.97);
}

.book-details {
    min-width: 0;
    min-height: 92px;
    margin: 0;
    text-align: center;
}

.book-details h2 {
    margin: 0;
    font-family: Fraunces, Georgia, serif;
    font-size: clamp(1.25rem, 3vw, 1.62rem);
    font-weight: 400;
    line-height: 1.25;
}

.book-details p {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 0.9rem;
}

.book-link {
    display: inline-block;
    margin-top: 10px;
    color: var(--brown);
    font-size: 0.84rem;
    font-weight: 500;
    text-decoration: none;
    border-bottom: 1px solid rgba(75, 46, 31, 0.28);
}

.book-link:hover {
    border-bottom-color: var(--brown);
}

.hint {
    margin: 3px 0 0;
    text-align: center;
    color: #a39a91;
    font-size: 0.74rem;
}

.empty {
    padding: 40px 0;
    text-align: center;
    color: var(--muted);
}

@media (max-width: 800px) {
    .bookshelf {
        padding-inline: 8px;
    }

    .coverflow-stage {
        height: 420px;
    }

    .book-cover {
        bottom: 90px;
        width: 195px;
        height: 288px;
    }

    .cover-image,
    .cover-reflection {
        max-width: 184px;
        max-height: 278px;
    }

    .book-controls {
        grid-template-columns: 50px minmax(0, 1fr) 50px;
        gap: 14px;
    }

    .nav-arrow {
        width: 50px;
        height: 42px;
        font-size: 1.9rem;
    }
}

@media (max-width: 520px) {
    .bookshelf {
        padding-top: 16px;
    }

    .coverflow-stage {
        height: 374px;
    }

    .book-cover {
        bottom: 78px;
        width: 168px;
        height: 248px;
    }

    .cover-image,
    .cover-reflection {
        max-width: 158px;
        max-height: 238px;
    }

    .book-cover.is-active .cover-image {
        outline-width: 2px;
        outline-offset: 2px;
    }

    .book-controls {
        grid-template-columns: 44px minmax(0, 1fr) 44px;
        gap: 9px;
        padding-inline: 4px;
    }

    .nav-arrow {
        width: 44px;
        height: 40px;
        font-size: 1.8rem;
    }

    .book-details {
        min-height: 78px;
        padding: 0 4px;
    }

    .hint {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .book-cover,
    .nav-arrow,
    .cover-image {
        transition: none;
    }
}
