/*=============== COLLECTIONS SHELF ===============*/
.library-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
}

.library-card {
    display: block;
    padding: 1.75rem;
    background: var(--deep-charcoal);
    border: var(--border-subtle);
    border-radius: var(--radius-medium);
    text-decoration: none;
    transition: var(--transition-medium);
}

.library-card:hover {
    border-color: var(--antique-gold);
    transform: translateY(-3px);
}

.library-card__title {
    font-family: var(--serif-font);
    font-size: 1.3rem;
    color: var(--ivory-text);
    margin-bottom: 0.6rem;
}

.library-card__desc {
    font-size: 0.9rem;
    line-height: 1.65;
    color: var(--muted-text);
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

@media (max-width: 900px) {
    .library-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 560px) {
    .library-grid { grid-template-columns: 1fr; }
}

/*=============== EMPTY / ERROR STATE ===============*/
.library-empty {
    max-width: 480px;
    margin: 0 auto;
    padding: 2.5rem;
    text-align: center;
    background: var(--deep-charcoal);
    border: var(--border-subtle);
    border-radius: var(--radius-large);
}

.library-empty p {
    color: var(--muted-text);
    font-size: 0.95rem;
    line-height: 1.7;
}

/*=============== BACK LINK ===============*/
.library-back {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-family: var(--mono-font);
    font-size: 0.85rem;
    color: var(--muted-text);
    margin-bottom: 2rem;
    transition: var(--transition-fast);
}

.library-back:hover {
    color: var(--antique-gold);
}

/*=============== BOOK READER ===============*/
/* Two columns: a persistent left index (sticky — stays put as you scroll,
   so jumping between poems never means scrolling back to the top) and the
   actual reading column on the right. Below 900px it collapses to a single
   stacked column, since there's no room for a persistent rail. */
.book-layout {
    display: grid;
    grid-template-columns: 200px 1fr;
    gap: 3.5rem;
    align-items: start;
}

.book-sidebar {
    position: sticky;
    top: calc(var(--header-height) + 2rem);
}

.book-sidebar__label {
    font-family: var(--mono-font);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--muted-text);
    margin-bottom: 1rem;
}

.book-sidebar__toc {
    list-style: none;
    counter-reset: poem-toc;
    display: flex;
    flex-direction: column;
    border-left: 1px solid var(--dark-slate);
}

.book-sidebar__toc li {
    counter-increment: poem-toc;
}

.book-sidebar__toc a {
    display: block;
    padding: 0.55rem 0 0.55rem 1rem;
    margin-left: -1px;
    border-left: 1px solid transparent;
    color: var(--muted-text);
    font-size: 0.88rem;
    line-height: 1.4;
    text-decoration: none;
    transition: var(--transition-fast);
}

.book-sidebar__toc a::before {
    content: counter(poem-toc, decimal-leading-zero) "  ";
    font-family: var(--mono-font);
    font-size: 0.75rem;
    color: var(--subtle-text);
}

.book-sidebar__toc a:hover {
    color: var(--ivory-text);
}

.book-sidebar__toc a.active {
    color: var(--antique-gold);
    border-left-color: var(--antique-gold);
}

.book-sidebar__toc a.active::before {
    color: var(--antique-gold);
}

.book-main {
    min-width: 0;
}

.book-header {
    max-width: 640px;
    margin-bottom: 3rem;
}

.book-header__title {
    font-size: clamp(2rem, 4.5vw, 2.8rem);
    margin-bottom: 0.6rem;
}

.book-header__subtitle {
    font-family: var(--serif-font);
    font-style: italic;
    color: var(--antique-gold);
    font-size: 1.1rem;
}

.poem-entries {
    display: flex;
    flex-direction: column;
    gap: 3rem;
    max-width: 680px;
}

/* A quiet "new page" marker between poems — a divider, not a flip mode.
   It's just a visual beat while scrolling; there's still exactly one way
   to move through the collection. */
.poem-divider {
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

.poem-divider::before,
.poem-divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--dark-slate);
}

.poem-divider__index {
    font-family: var(--mono-font);
    font-size: 0.72rem;
    letter-spacing: 0.15em;
    color: var(--subtle-text);
    white-space: nowrap;
}

@media (max-width: 900px) {
    .book-layout {
        grid-template-columns: 1fr;
        gap: 0;
    }

    .book-sidebar {
        position: static;
        margin-bottom: 2rem;
        padding-bottom: 1.5rem;
        border-bottom: var(--border-subtle);
    }

    .book-sidebar__toc {
        flex-direction: row;
        flex-wrap: wrap;
        border-left: none;
        gap: 0.5rem;
    }

    .book-sidebar__toc a {
        padding: 0.4rem 0.8rem;
        border: var(--border-subtle);
        border-radius: var(--radius-small);
    }

    .book-sidebar__toc a.active {
        border-color: var(--antique-gold);
    }
}

.poem-entry {
    scroll-margin-top: calc(var(--header-height) + 1.5rem);
}

.poem-entry__title {
    font-size: 1.6rem;
    margin-bottom: 0.4rem;
}

.poem-entry__epigraph {
    font-family: var(--serif-font);
    font-style: italic;
    color: var(--muted-text);
    font-size: 0.95rem;
    margin-bottom: 1.5rem;
}

.poem-entry__body {
    font-family: var(--serif-font);
    font-size: 1.1rem;
    line-height: 1.9;
    color: var(--parchment-text);
}

.poem-entry__body p {
    margin-bottom: 0.3rem;
}

.poem-entry__body .stanza-break {
    height: 1.4rem;
}
