/* Creator Recommendations — карточки «Авторы для вас».
 * BEM-like prefix `cr-rec-*` чтобы не пересекаться с .post-* / .lib-*.
 *
 * Vertical layout: аватар сверху по центру, name/username/meta центрированы,
 * reason-pill всегда прижат к низу через mt:auto — карточки выравниваются
 * по высоте даже если у одних есть meta+reason, а у других только имя.
 *
 * Единый шаблон используется на /home, в feed empty-state и на профиле автора.
 */

.cr-rec-block {
    margin: 32px 0;
}

.cr-rec-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 16px;
}

.cr-rec-title {
    font-size: 18px;
    font-weight: 700;
    color: #0f172a;
    margin: 0;
    letter-spacing: -0.01em;
}

.cr-rec-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 14px;
    /* По умолчанию grid делает stretch — карточки получают равную высоту строки. */
    align-items: stretch;
}

.cr-rec-card {
    position: relative;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 18px;
    /* Верхний padding 0 — на этом месте cover. Нижний — обычный. */
    padding: 0 16px 18px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    overflow: hidden;
    transition: border-color 0.18s, box-shadow 0.18s, transform 0.18s;
}

.cr-rec-card:hover {
    border-color: var(--color-primary, #0a43ff);
    box-shadow: 0 8px 24px rgba(10, 67, 255, 0.10);
    transform: translateY(-2px);
}
.cr-rec-card:hover .cr-rec-cover img { transform: scale(1.04); }

/* Cover-фото профиля — баннер сверху карточки. Высота 76px (под половину
   аватара), object-fit:cover. Если у автора cover нет — fallback на
   gradient через class --empty.
   `align-self: stretch` + negative margin'ы растягивают блок на полную
   ширину карточки сквозь её padding (родитель — flex с align-items:center,
   который иначе сжимал бы cover). */
.cr-rec-cover {
    position: relative;
    align-self: stretch;
    margin: 0 -16px 0;
    height: 76px;
    flex-shrink: 0;
    overflow: hidden;
    background: linear-gradient(135deg, #c7d2fe, #e9d5ff 60%, #fbcfe8);
}
.cr-rec-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.25s ease;
}
.cr-rec-cover--empty {
    /* Нет ни cover, ни avatar — нежный gradient (как twitter X bookmark gradient). */
    background: linear-gradient(135deg, #dbeafe 0%, #ede9fe 50%, #fce7f3 100%);
}

/* Avatar как fallback-фон: blur + затемнение + насыщенность —
   каждый автор получает уникальный «цвет» карточки по своему аватару. */
.cr-rec-cover--avatar-bg img {
    filter: blur(18px) saturate(1.4) brightness(0.85);
    transform: scale(1.25);   /* убираем blur-edge артефакты по краям */
}
.cr-rec-card:hover .cr-rec-cover--avatar-bg img {
    transform: scale(1.30);
    filter: blur(18px) saturate(1.5) brightness(0.88);
}
/* Лёгкое затемнение cover'а снизу — чтобы аватар, который накладывается
   на нижний край cover, был с контрастом. */
.cr-rec-cover::after {
    content: "";
    position: absolute;
    inset: auto 0 0 0;
    height: 32px;
    background: linear-gradient(to bottom, rgba(0,0,0,0), rgba(0,0,0,0.18));
    pointer-events: none;
}

.cr-rec-link {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    flex: 1;                 /* растягивается, чтобы reason-pill прижимался к низу */
    text-decoration: none;
    color: inherit;
}

.cr-rec-avatar {
    position: relative;
    flex-shrink: 0;
    width: 76px;
    height: 76px;
    border-radius: 50%;
    overflow: hidden;
    background: #f1f5f9;
    /* Белое кольцо отделяет аватар от cover'а под ним. */
    box-shadow: 0 0 0 4px #fff, 0 4px 12px rgba(15, 23, 42, 0.10);
    /* Аватар висит наполовину поверх cover — поднимаем на 38px вверх
       (половина высоты аватара). */
    margin-top: -38px;
    margin-bottom: 10px;
    z-index: 1;
    transition: transform 0.2s ease;
}
.cr-rec-card:hover .cr-rec-avatar { transform: scale(1.04); }

.cr-rec-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.cr-rec-avatar-fallback {
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #94a3b8, #475569);
}

.cr-rec-body {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    /* Прижимаем reason-pill к низу карточки через auto-margin (см. .cr-rec-reason). */
    flex: 1;
}

.cr-rec-name {
    font-size: 15px;
    font-weight: 700;
    color: #0f172a;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    letter-spacing: -0.01em;
}

.cr-rec-username {
    font-size: 12.5px;
    color: #64748b;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cr-rec-meta {
    font-size: 12px;
    color: #475569;
    margin-top: 8px;
    line-height: 1.4;
    max-width: 100%;
}

/* Reason-pill — заметная плашка внизу карточки.
   `margin-top: auto` + `flex:1` на родителе прижимает её к низу — карточки
   с разной длиной meta выравниваются по нижнему краю pill'ы. */
.cr-rec-reason {
    font-size: 11.5px;
    font-weight: 600;
    color: var(--color-primary, #0a43ff);
    background: rgba(10, 67, 255, 0.08);
    border-radius: 999px;
    padding: 5px 12px;
    margin-top: auto;
    align-self: center;
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    letter-spacing: 0.01em;
}

/* «Популярный автор» — заметнее, как hero-badge. JS уже навешивает класс. */
.cr-rec-reason--popular {
    color: #fff;
    background: linear-gradient(135deg, #0a43ff, #7c3aed);
    box-shadow: 0 4px 10px rgba(10, 67, 255, 0.25);
}

.cr-rec-dismiss {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    border: none;
    color: #94a3b8;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    z-index: 2;
    transition: background 0.15s, color 0.15s, opacity 0.15s, transform 0.15s;
    opacity: 0;
}

.cr-rec-card:hover .cr-rec-dismiss {
    opacity: 1;
}

.cr-rec-dismiss:hover {
    background: #fff;
    color: #ef4444;
    transform: scale(1.05);
}

@media (max-width: 640px) {
    .cr-rec-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        gap: 10px;
    }
    .cr-rec-card {
        padding: 0 12px 14px;
        border-radius: 14px;
    }
    .cr-rec-cover {
        margin: 0 -12px 0;
        height: 60px;
    }
    .cr-rec-avatar {
        width: 64px;
        height: 64px;
        margin-top: -32px;
        box-shadow: 0 0 0 3px #fff, 0 3px 10px rgba(15, 23, 42, 0.10);
    }
    .cr-rec-name { font-size: 14px; }
    .cr-rec-dismiss { opacity: 1; }
}
