/* Библиотека: вступление, липкий фильтр, лента-«свиток». */

/* Только вертикальные отступы: блок несёт ещё и класс .container, а тот даёт
   боковые 28px. Сокращённая запись padding их обнуляла — заголовок вставал
   на 28px левее фильтров, а на телефоне упирался в край экрана. */
.lib-intro {
    padding-top: 72px;
    padding-bottom: 40px;
}

.lib-intro .eyebrow {
    color: var(--accent);
    margin-bottom: 16px;
    display: block;
}

.lib-intro h1 {
    font-family: var(--serif);
    font-weight: 700;
    font-size: clamp(32px, 4.4vw, 48px);
    line-height: 1.08;
    margin-bottom: 18px;
    max-width: 720px;
}

.lib-intro p {
    color: var(--text-muted);
    font-size: 17px;
    max-width: 560px;
}

/* ---------- Фильтр ---------- */
.filter-bar {
    position: sticky;
    /* 67px — высота шапки: 34px логотип + 16px паддингов сверху и снизу + 1px рамка */
    top: 67px;
    z-index: 40;
    background: rgba(234, 248, 247, 0.94);
    backdrop-filter: blur(6px);
    padding: 18px 0;
    border-bottom: 1px solid rgba(var(--rule-rgb), 0.08);
    margin-bottom: 8px;
}

/* В ленте неактивные кнопки лежат на «бумаге», а не на фоне страницы.
   :not(.active) обязателен: без него этот селектор перебивает по каскаду
   .filter-pill.active из base.css и активная кнопка теряет заливку. */
.filter-bar .filter-pill:not(.active) {
    background: var(--surface-raised);
}

/* ---------- Лента ---------- */
.feed {
    max-width: 640px;
    margin: 0 auto;
    padding: 48px 0 100px;
    position: relative;
}

.feed::before {
    content: "";
    position: absolute;
    left: 20px;
    top: 8px;
    bottom: 40px;
    width: 1px;
    background: repeating-linear-gradient(180deg, rgba(var(--rule-rgb), 0.16) 0 6px, transparent 6px 12px);
}

.feed-item {
    position: relative;
    padding-left: 56px;
    margin-bottom: 40px;
}

.feed-item:last-child {
    margin-bottom: 0;
}

.feed-dot {
    position: absolute;
    left: 14px;
    top: 34px;
    width: 13px;
    height: 13px;
    border-radius: 50%;
    background: var(--surface);
    border: 2px solid var(--accent);
}

.feed-card {
    position: relative;
    background: var(--surface-raised);
    border-radius: var(--radius);
    padding: 26px 28px 22px;
    box-shadow: 0 20px 40px -22px rgba(22, 26, 51, 0.35);
}

/* Лёгкий разнобой наклона — чтобы лента читалась как стопка рукописей.
   Считаем по позиции внутри ленты, а не по nth-child: при подгрузке
   через HTMX карточки приходят пачками и nth-child сбивался бы. */
.feed-item:nth-of-type(even) .feed-card {
    transform: rotate(-0.6deg);
}

.feed-item:nth-of-type(odd) .feed-card {
    transform: rotate(0.5deg);
}

.feed-card::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: var(--radius);
    background: repeating-linear-gradient(180deg, transparent 0 34px, rgba(var(--rule-rgb), 0.055) 34px 35px);
    pointer-events: none;
}

.feed-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.feed-tag {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: var(--mono);
    font-size: 11px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--accent);
}

.feed-tag svg {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
}

.feed-date {
    font-family: var(--mono);
    font-size: 11px;
    color: var(--text-muted);
    opacity: 0.7;
    white-space: nowrap;
}

.feed-text {
    font-family: var(--serif);
    font-style: italic;
    font-size: 19px;
    line-height: 1.6;
    margin-bottom: 16px;
    /* Стихи: переносы строк и ведущие пробелы значимы, текст хранится сырым. */
    white-space: pre-wrap;
}

.feed-bottom {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.feed-author {
    font-family: var(--mono);
    font-size: 12px;
    color: var(--text-muted);
}

.feed-share {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-muted);
    opacity: 0.8;
    transition: opacity .2s;
}

a.feed-share:hover {
    opacity: 1;
    color: var(--brand-dark);
}

.feed-share svg {
    width: 15px;
    height: 15px;
}

.feed-empty {
    text-align: center;
    padding: 44px 28px;
    border: 1.5px dashed rgba(var(--rule-rgb), 0.2);
    border-radius: var(--radius);
    color: var(--text-muted);
    font-size: 15px;
}

@media (prefers-reduced-motion: reduce) {

    .feed-item:nth-of-type(even) .feed-card,
    .feed-item:nth-of-type(odd) .feed-card {
        transform: none;
    }
}

@media (max-width:560px) {
    .lib-intro {
        padding-top: 48px;
        padding-bottom: 28px;
    }

    .feed {
        padding: 36px 0 64px;
    }

    /* Слева 44px под линию таймлайна, справа — чтобы карточка не упиралась
       в край экрана: лента шире 560px не бывает, а .feed боковых отступов не имеет. */
    .feed-item {
        padding-left: 44px;
        padding-right: 16px;
    }

    .feed::before {
        left: 16px;
    }

    .feed-dot {
        left: 10px;
    }

    .feed-card {
        padding: 20px 20px 18px;
    }

    .feed-item:nth-of-type(even) .feed-card,
    .feed-item:nth-of-type(odd) .feed-card {
        transform: none;
    }
}
