/* ===== Biblo Interesting Books v2.3 ===== */

.bib-interesting-books {
    margin: 26px 0 36px;
    padding: 0;
    box-sizing: border-box;
}

.bib-section-title-wrap {
    margin: 0 0 20px;
    padding: 0 0 12px;
    border-bottom: 1px solid rgba(80, 70, 55, 0.16);
}

.bib-section-title {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin: 0 !important;
    padding: 0 !important;
    font-size: 28px !important;
    line-height: 1.25 !important;
    font-weight: 800 !important;
    color: #2b261f !important;
}

.bib-section-title::before {
    content: "";
    width: 10px;
    height: 28px;
    border-radius: 999px;
    background: linear-gradient(180deg, #3f8f72, #2f5d50);
}

/* ПК: книги идут в ряд, как книжная полка */
.bib-book-list {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 22px;
    align-items: stretch;
}

.bib-book-item {
    display: flex;
    flex-direction: column;
    min-width: 0;
    padding: 14px 14px 16px;
    border-radius: 20px;
    background: #ffffff;
    border: 1px solid rgba(90, 80, 65, 0.12);
    box-shadow: 0 10px 28px rgba(25, 35, 55, 0.08);
    box-sizing: border-box;
    transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}

.bib-book-item:hover {
    transform: translateY(-3px);
    box-shadow: 0 16px 36px rgba(25, 35, 55, 0.13);
    border-color: rgba(63, 143, 114, 0.26);
}

.bib-book-cover {
    display: block;
    width: 100%;
    aspect-ratio: 2 / 3;
    border-radius: 14px;
    overflow: hidden;
    background: #f4efe7;
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.14);
    text-decoration: none !important;
}

.bib-book-cover img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: var(--bib-cover-fit, cover);
    object-position: center top;
    background: #f4efe7;
}

.bib-no-cover {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px;
    box-sizing: border-box;
    text-align: center;
    background: linear-gradient(135deg, #efe3cf, #c9b18b);
    color: #3b2f25;
    font-size: 13px;
    line-height: 1.35;
    font-weight: 800;
}

.bib-book-content {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-width: 0;
    padding: 13px 2px 0;
    text-align: center;
}

.bib-book-title {
    margin: 0 0 8px !important;
    padding: 0 !important;
    font-size: 17px !important;
    line-height: 1.32 !important;
    font-weight: 800 !important;
    color: #1f2933 !important;
}

.bib-book-title a {
    color: inherit !important;
    text-decoration: none !important;
}

.bib-book-title a:hover {
    color: #2f5d50 !important;
}

.bib-book-meta {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 7px;
    margin: 0 0 9px;
}

.bib-book-meta span,
.bib-book-meta a,
.bib-book-cat {
    display: inline-flex;
    align-items: center;
    padding: 4px 9px;
    border-radius: 999px;
    background: #edf6f1;
    color: #2f5d50 !important;
    font-size: 12px;
    line-height: 1.2;
    font-weight: 700;
    text-decoration: none !important;
}

.bib-book-meta a:hover,
.bib-book-cat:hover {
    background: #dff0e8;
    color: #214f43 !important;
}

.bib-book-desc {
    margin: 0 0 13px;
    color: #4e5965;
    font-size: 14px;
    line-height: 1.52;
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.bib-book-read {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    align-self: center;
    margin-top: auto;
    padding: 10px 17px;
    border-radius: 999px;
    background: linear-gradient(135deg, #2f5d50 0%, #3f8f72 100%);
    color: #fff !important;
    font-size: 13px;
    line-height: 1;
    font-weight: 800;
    text-decoration: none !important;
    box-shadow: 0 8px 20px rgba(47, 93, 80, .23);
}

.bib-book-read:hover {
    transform: translateY(-1px);
    box-shadow: 0 12px 24px rgba(47, 93, 80, .32);
}

/* Скрываем стандартную ленту темы, если включена опция */
body.bib-books-hide-loop.bib-books-auto-page main article,
body.bib-books-hide-loop.bib-books-auto-page #content article,
body.bib-books-hide-loop.bib-books-auto-page .content article,
body.bib-books-hide-loop.bib-books-auto-page .main-content article,
body.bib-books-hide-loop.bib-books-auto-page .articles article,
body.bib-books-hide-loop.bib-books-auto-page .epcl-posts article,
body.bib-books-hide-loop.bib-books-auto-page .grid-posts article {
    display: none !important;
}

body.bib-books-hide-loop.bib-books-auto-page .bib-interesting-books,
body.bib-books-hide-loop.bib-books-auto-page .bib-interesting-books * {
    display: revert;
}

body.bib-books-hide-loop.bib-books-auto-page .bib-book-list {
    display: grid !important;
}

body.bib-books-hide-loop.bib-books-auto-page .bib-book-item {
    display: flex !important;
}

body.bib-books-hide-loop.bib-books-auto-page .bib-book-cover {
    display: block !important;
}

body.bib-books-hide-loop.bib-books-auto-page .bib-book-read,
body.bib-books-hide-loop.bib-books-auto-page .bib-book-cat {
    display: inline-flex !important;
}

/* Небольшие ПК / планшеты */
@media screen and (max-width: 1180px) {
    .bib-book-list {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 20px;
    }
}

@media screen and (max-width: 900px) {
    .bib-book-list {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 18px;
    }
}

/* Мобильные: оставляем удачный компактный список */
@media screen and (max-width: 767px) {
    .bib-interesting-books {
        margin: 18px 0 28px;
    }

    .bib-section-title-wrap {
        margin-bottom: 14px;
        text-align: left;
    }

    .bib-section-title {
        font-size: 24px !important;
    }

    .bib-book-list {
        grid-template-columns: 1fr;
        gap: 14px;
    }

    .bib-book-item {
        display: grid !important;
        grid-template-columns: 112px minmax(0, 1fr);
        gap: 13px;
        align-items: start;
        padding: 12px;
        border-radius: 16px;
        box-shadow: 0 8px 22px rgba(25, 35, 55, .08);
        text-align: left;
    }

    .bib-book-cover {
        width: 112px;
        aspect-ratio: 2 / 3;
        border-radius: 9px;
    }

    .bib-book-content {
        display: block;
        padding: 0;
        text-align: left;
    }

    .bib-book-title {
        font-size: 16px !important;
        line-height: 1.28 !important;
        margin-bottom: 6px !important;
        text-align: left;
    }

    .bib-book-meta {
        justify-content: flex-start;
        margin-bottom: 7px;
        gap: 6px;
    }

    .bib-book-meta span,
    .bib-book-meta a,
    .bib-book-cat {
        font-size: 11px;
        padding: 3px 7px;
    }

    .bib-book-desc {
        font-size: 13px;
        line-height: 1.45;
        margin-bottom: 10px;
        -webkit-line-clamp: 4;
    }

    .bib-book-read {
        align-self: flex-start;
        padding: 9px 13px;
        font-size: 12px;
    }
}

/* Очень узкие телефоны */
@media screen and (max-width: 380px) {
    .bib-book-item {
        grid-template-columns: 96px minmax(0, 1fr);
        gap: 11px;
        padding: 11px;
    }

    .bib-book-cover {
        width: 96px;
    }

    .bib-book-title {
        font-size: 15px !important;
    }

    .bib-book-desc {
        -webkit-line-clamp: 3;
    }
}

/* ===== v2.3: мобильный вид — обложка слева, текст справа ===== */
@media screen and (max-width: 767px) {
    .bib-interesting-books {
        margin: 18px 0 28px !important;
        padding: 0 !important;
        box-sizing: border-box !important;
    }

    .bib-section-title-wrap {
        margin: 0 0 14px !important;
        padding: 0 0 10px !important;
        text-align: left !important;
    }

    .bib-section-title {
        font-size: 23px !important;
        line-height: 1.25 !important;
        justify-content: flex-start !important;
    }

    .bib-book-list {
        display: grid !important;
        grid-template-columns: 1fr !important;
        gap: 14px !important;
        align-items: stretch !important;
    }

    .bib-book-item {
        display: grid !important;
        grid-template-columns: 112px minmax(0, 1fr) !important;
        grid-template-rows: auto !important;
        gap: 13px !important;
        align-items: start !important;
        width: 100% !important;
        min-width: 0 !important;
        padding: 12px !important;
        margin: 0 !important;
        border-radius: 16px !important;
        background: #ffffff !important;
        border: 1px solid rgba(90, 80, 65, 0.12) !important;
        box-shadow: 0 8px 22px rgba(25, 35, 55, .08) !important;
        text-align: left !important;
        box-sizing: border-box !important;
        transform: none !important;
    }

    .bib-book-item:hover {
        transform: none !important;
    }

    .bib-book-cover {
        grid-column: 1 !important;
        grid-row: 1 / span 6 !important;
        display: block !important;
        width: 112px !important;
        min-width: 112px !important;
        max-width: 112px !important;
        height: 168px !important;
        min-height: 168px !important;
        max-height: 168px !important;
        aspect-ratio: auto !important;
        margin: 0 !important;
        padding: 0 !important;
        border-radius: 10px !important;
        overflow: hidden !important;
        background: #f4efe7 !important;
        box-shadow: 0 6px 14px rgba(0, 0, 0, 0.12) !important;
        text-decoration: none !important;
    }

    .bib-book-cover img {
        width: 100% !important;
        height: 100% !important;
        display: block !important;
        object-fit: cover !important;
        object-position: center top !important;
        border-radius: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    .bib-no-cover {
        width: 100% !important;
        height: 100% !important;
        padding: 8px !important;
        font-size: 11px !important;
        line-height: 1.25 !important;
    }

    .bib-book-content {
        grid-column: 2 !important;
        display: block !important;
        min-width: 0 !important;
        width: 100% !important;
        padding: 0 !important;
        margin: 0 !important;
        text-align: left !important;
        box-sizing: border-box !important;
    }

    .bib-book-title {
        margin: 0 0 6px !important;
        padding: 0 !important;
        font-size: 16px !important;
        line-height: 1.28 !important;
        font-weight: 800 !important;
        text-align: left !important;
    }

    .bib-book-title a {
        text-decoration: none !important;
    }

    .bib-book-meta {
        display: flex !important;
        justify-content: flex-start !important;
        flex-wrap: wrap !important;
        gap: 6px !important;
        margin: 0 0 7px !important;
        padding: 0 !important;
        text-align: left !important;
    }

    .bib-book-meta span,
    .bib-book-meta a,
    .bib-book-cat {
        display: inline-flex !important;
        align-items: center !important;
        padding: 3px 7px !important;
        border-radius: 999px !important;
        font-size: 11px !important;
        line-height: 1.2 !important;
        font-weight: 700 !important;
        text-decoration: none !important;
        white-space: normal !important;
    }

    .bib-book-desc {
        display: -webkit-box !important;
        margin: 0 0 10px !important;
        padding: 0 !important;
        color: #4e5965 !important;
        font-size: 13px !important;
        line-height: 1.45 !important;
        text-align: left !important;
        -webkit-line-clamp: 4 !important;
        -webkit-box-orient: vertical !important;
        overflow: hidden !important;
    }

    .bib-book-read {
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        align-self: flex-start !important;
        width: auto !important;
        min-width: 0 !important;
        margin: 0 !important;
        padding: 9px 13px !important;
        border-radius: 999px !important;
        font-size: 12px !important;
        line-height: 1 !important;
        font-weight: 800 !important;
        text-decoration: none !important;
    }
}

@media screen and (max-width: 380px) {
    .bib-book-item {
        grid-template-columns: 96px minmax(0, 1fr) !important;
        gap: 11px !important;
        padding: 11px !important;
    }

    .bib-book-cover {
        width: 96px !important;
        min-width: 96px !important;
        max-width: 96px !important;
        height: 144px !important;
        min-height: 144px !important;
        max-height: 144px !important;
    }

    .bib-book-title {
        font-size: 15px !important;
    }

    .bib-book-desc {
        -webkit-line-clamp: 3 !important;
    }
}

/* ===== v2.4: вернуть первый удачный мобильный вид ===== */
@media screen and (max-width: 767px) {
    .bib-interesting-books {
        margin: 18px 0 28px !important;
    }

    .bib-section-title-wrap {
        margin-bottom: 14px !important;
        text-align: left !important;
    }

    .bib-section-title {
        font-size: 24px !important;
    }

    .bib-book-list {
        display: grid !important;
        grid-template-columns: 1fr !important;
        gap: 14px !important;
    }

    .bib-book-item,
    body.bib-books-hide-loop.bib-books-auto-page .bib-book-item {
        display: grid !important;
        grid-template-columns: 112px minmax(0, 1fr) !important;
        gap: 13px !important;
        align-items: start !important;
        padding: 12px !important;
        border-radius: 16px !important;
        box-shadow: 0 8px 22px rgba(25, 35, 55, .08) !important;
        text-align: left !important;
    }

    .bib-book-cover {
        display: block !important;
        width: 112px !important;
        aspect-ratio: 2 / 3 !important;
        border-radius: 9px !important;
        overflow: hidden !important;
        background: #f4efe7 !important;
        box-shadow: 0 8px 18px rgba(0, 0, 0, 0.16) !important;
    }

    .bib-book-cover img {
        width: 100% !important;
        height: 100% !important;
        display: block !important;
        object-fit: var(--bib-cover-fit, cover) !important;
        object-position: center top !important;
    }

    .bib-book-content {
        display: block !important;
        padding: 0 !important;
        text-align: left !important;
    }

    .bib-book-title {
        font-size: 16px !important;
        line-height: 1.28 !important;
        margin: 0 0 6px 0 !important;
        text-align: left !important;
    }

    .bib-book-meta {
        justify-content: flex-start !important;
        margin: 0 0 7px 0 !important;
        gap: 6px !important;
    }

    .bib-book-meta span,
    .bib-book-meta a,
    .bib-book-cat {
        font-size: 11px !important;
        padding: 3px 7px !important;
    }

    .bib-book-desc {
        font-size: 13px !important;
        line-height: 1.45 !important;
        margin: 0 0 10px 0 !important;
        display: -webkit-box !important;
        -webkit-line-clamp: 4 !important;
        -webkit-box-orient: vertical !important;
        overflow: hidden !important;
        text-align: left !important;
    }

    .bib-book-read {
        align-self: flex-start !important;
        padding: 9px 13px !important;
        font-size: 12px !important;
        margin-top: 0 !important;
    }
}

@media screen and (max-width: 380px) {
    .bib-book-item,
    body.bib-books-hide-loop.bib-books-auto-page .bib-book-item {
        grid-template-columns: 96px minmax(0, 1fr) !important;
        gap: 11px !important;
        padding: 11px !important;
    }

    .bib-book-cover {
        width: 96px !important;
    }

    .bib-book-title {
        font-size: 15px !important;
    }

    .bib-book-desc {
        -webkit-line-clamp: 3 !important;
    }
}

/* ===== v2.5: рекламные места ===== */
.bib-ad-slot {
    grid-column: 1 / -1;
    width: 100%;
    box-sizing: border-box;
    margin: 18px 0;
    padding: 12px;
    border-radius: 16px;
    background: rgba(246, 241, 232, 0.55);
    border: 1px dashed rgba(90, 80, 65, 0.18);
    text-align: center;
    clear: both;
}

.bib-ad-top {
    margin-top: 0;
    margin-bottom: 20px;
}

.bib-ad-after-title {
    margin-top: -4px;
    margin-bottom: 22px;
}

.bib-ad-after-items {
    margin: 6px 0 8px;
}

.bib-ad-bottom {
    margin-top: 22px;
    margin-bottom: 0;
}

.bib-ad-label {
    margin: 0 0 7px;
    color: #8a8175;
    font-size: 11px;
    line-height: 1;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
}

.bib-ad-inner {
    display: block;
    width: 100%;
    min-height: 1px;
    overflow: hidden;
}

.bib-ad-inner iframe,
.bib-ad-inner ins,
.bib-ad-inner img,
.bib-ad-inner > div {
    max-width: 100%;
}

body.bib-books-hide-loop.bib-books-auto-page .bib-ad-slot,
body.bib-books-hide-loop.bib-books-auto-page .bib-ad-inner,
body.bib-books-hide-loop.bib-books-auto-page .bib-ad-label {
    display: block !important;
}

@media screen and (max-width: 767px) {
    .bib-ad-slot {
        margin: 14px 0;
        padding: 10px;
        border-radius: 14px;
    }

    .bib-ad-after-items {
        margin: 0 0 2px;
    }
}
