/* === Container & grid === */

.be-book-ref-grid {
    display: grid;
    grid-gap: 24px;
    margin: 0 0 2rem;
}

.be-book-ref-grid--cols-1 {
    grid-template-columns: 1fr;
}

.be-book-ref-grid--cols-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.be-book-ref-grid--cols-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

/* Breakpoints */
@media (max-width: 1024px) {
    .be-book-ref-grid--cols-3 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 768px) {
    .be-book-ref-grid--cols-2,
    .be-book-ref-grid--cols-3 {
        grid-template-columns: 1fr;
    }
}

/* === Card base === */

.be-book-ref {
    display: flex;
    align-items: flex-start;
    gap: 18px;
    padding: 18px 22px;
    background: #ffffff;
    border-radius: 18px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.06);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.be-book-ref:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 26px rgba(0, 0, 0, 0.08);
}

/* === Image wrapper === */

/* Portrait by default (100x150) */
.be-book-ref__image {
    flex: 0 0 auto;
    width: 100px;
    height: 150px;
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.be-book-ref__image img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover; /* Avoids random stretching */
}

/* Circle image (100x100) */
.be-book-ref--circle .be-book-ref__image {
    width: 100px;
    height: 100px;
    border-radius: 50%;
}

.be-book-ref--circle .be-book-ref__image img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

/* === Body === */

.be-book-ref__body {
    flex: 1 1 auto;
}

.be-book-ref__title {
    margin: 0 0 0.35rem;
    font-weight: 700;
    font-size: 1.1rem;
}

.be-book-ref__title a {
    text-decoration: none;
}

.be-book-ref__title a:hover {
    text-decoration: underline;
}

.be-book-ref__ref-text {
    margin: 0 0 0.5rem;
    line-height: 1.55;
    font-size: 16px;
}

.be-book-ref__author {
    font-size: 0.9em;
    color: #555;
}

.be-book-ref__by {
    font-style: italic;
    margin-right: 0.35em;
}

/* Make the block-width titles break nicely on small devices */
@media (max-width: 600px) {
    .be-book-ref {
        padding: 16px 18px;
    }
}

/* === Indented chain (timeline-style) – only when numColumns = 1 === */

/* Wrapper around contiguous indented children */
.be-book-ref-grid--cols-1 .be-book-ref-chain {
    position: relative;
    margin-left: 32px;    /* distance from main content */
    margin-top: -10px;    /* pull chain closer to parent box */
    margin-bottom: -4px;  /* pull last child closer to next section */
    padding: 0;
}

/* Vertical spine – subtle grey */
.be-book-ref-grid--cols-1 .be-book-ref-chain::before {
    content: "";
    position: absolute;
    left: 0;
    top: 1px;            /* starts near first connector */
    bottom: 15px;         /* ends near last connector (no big tail) */
    width: 2px;
    background: #857676;
}

/* Cards inside a chain – much tighter stack */
.be-book-ref-grid--cols-1 .be-book-ref-chain .be-book-ref {
    margin-bottom: 6px;   /* was 12px – this removes most of the gap */
}

.be-book-ref-grid--cols-1 .be-book-ref-chain .be-book-ref:last-child {
    margin-bottom: 0;
}

/* Indentation + horizontal connector from spine */
.be-book-ref-grid--cols-1 .be-book-ref--indented {
    position: relative;
    margin-left: 52px;
}

.be-book-ref-grid--cols-1 .be-book-ref-chain .be-book-ref--indented::before {
    content: "";
    position: absolute;
    left: -52px;          /* from card back to spine */
    top: 50%;
    width: 50px;
    height: 3px;
    background: #857676;
    transform: translateY(-50%);
}

/* Small screens – keep proportions slightly tighter */
@media (max-width: 600px) {
    .be-book-ref-grid--cols-1 .be-book-ref-chain {
        margin-left: 24px;
        margin-top: -8px;
        margin-bottom: -4px;
    }

    .be-book-ref-grid--cols-1 .be-book-ref-chain::before {
        left: 0;
        top: 16px;
        bottom: 16px;
    }

    .be-book-ref-grid--cols-1 .be-book-ref--indented {
        margin-left: 44px;
    }

    .be-book-ref-grid--cols-1 .be-book-ref-chain .be-book-ref--indented::before {
        left: -28px;
        width: 20px;
    }
}
