/*
 * Top Lists showcase - shared styles for the /top/ archive and the
 * Elementor "Top Lists" widget. Scoped under .civi-tls (archive) and
 * .tls-widget (widget). Brand accents use --civi-color-accent.
 */

/* ── Archive header ── */
.civi-tls {
    padding-bottom: 64px;
}

/* Archive H1 (mirrors the theme's archive top-filter title) */
.archive-company-top .tls-archive-title {
    font-size: 25px;
    margin-top: 24px;
    margin-bottom: 24px;
}

/* Search button loading indicator (CSS spinner, no icon-font dependency) */
.tls-search .btn-top-filter .btn-loading {
    display: none !important;
}

.tls-search.is-loading .btn-top-filter {
    position: relative;
    pointer-events: none;
    opacity: .9;
    padding-right: 40px;
}

.tls-search.is-loading .btn-top-filter::after {
    content: "";
    position: absolute;
    right: 14px;
    top: 50%;
    width: 14px;
    height: 14px;
    margin-top: -7px;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: tls-spin .6s linear infinite;
}

/* Our /top/ archive wraps only the filter bar in .archive-layout, so drop the
 * theme's archive bottom padding (it would leave a large gap under the search).
 * Scoped to this CPT archive body class so real archives are untouched. */
.post-type-archive-top_lists .archive-layout {
    padding-bottom: 0;
}

/* Title + search bar reuse the theme's archive top-filter markup/classes
 * (.archive-filter-top / .form-archive-top-filter), so no custom styles here. */

/* ── Results count ── */
.civi-tls .tls-count {
    margin: 28px 0 18px;
    font-size: 14px;
    color: #64748b;
}

.tls-hidden {
    display: none;
}

/* ── Items container (grid / list) ── */
.tls-items--grid {
    display: grid;
    grid-template-columns: repeat(var(--tls-cols, 3), minmax(0, 1fr));
    gap: 24px;
}

.tls-items--list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.tls-cols-1 { --tls-cols: 1; }
.tls-cols-2 { --tls-cols: 2; }
.tls-cols-3 { --tls-cols: 3; }
.tls-cols-4 { --tls-cols: 4; }
.tls-cols-5 { --tls-cols: 5; }

/* ── Card ── */
.tls-card {
    position: relative;
    display: flex;
    flex-direction: column;
    height: 100%;
    background: #ffffff;
    border: 1px solid rgb(5 105 255 / .8);
    border-radius: 14px;
    padding: 22px;
    transition: box-shadow .15s ease, transform .12s ease;
}

.tls-card:hover {
    box-shadow: 0 10px 26px rgb(16 24 40 / .08);
    transform: translateY(-2px);
}

/* Recently updated list: same card border + a tab badge on the corner */
.tls-card--updated {
    border-color: rgb(5 105 255 / .8);
}

/* Card head: optional "Updated" eyebrow above the full-width title */
.tls-card-head {
    padding-bottom: 16px;
    margin-bottom: 16px;
    border-bottom: 1px solid #eef0f7;
}

.tls-card-title {
    margin: 0;
    font-size: 17px;
    font-weight: 700;
    line-height: 1.3;
}

.tls-badge-updated {
    position: absolute;
    top: -11px;
    right: 18px;
    z-index: 3;
    pointer-events: none;
    padding: 3px 12px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: #ffffff;
    background: #2958ff;
}

/* Whole-card click target (stretched link) to the list. */
.tls-card-link {
    text-decoration: none;
    color: inherit;
}

.tls-card-link::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 1;
}

.tls-card-link:hover {
    color: var(--civi-color-accent, #4d4ed4);
}

/* Short description (2 lines, both grid and list) */
.tls-card-desc {
    margin: 0 0 16px;
    font-size: 14px;
    line-height: 1.55;
    color: #475569;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Ranked preview */
.tls-rank {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex: 0 0 auto;
}

.tls-rank-item {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.tls-rank-num {
    flex: 0 0 auto;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    color: #ffffff;
    background: var(--civi-color-accent, #4d4ed4);
}

.tls-rank-item:nth-child(1) .tls-rank-num { background: #f59e0b; }
.tls-rank-item:nth-child(2) .tls-rank-num { background: #94a3b8; }
.tls-rank-item:nth-child(3) .tls-rank-num { background: #b45309; }

.tls-rank-logo {
    flex: 0 0 auto;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    overflow: hidden;
    background: #f1f5f9;
    border: 1px solid #eef0f7;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    color: var(--civi-color-accent, #4d4ed4);
}

.tls-rank-logo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.tls-rank-name {
    position: relative;
    z-index: 2;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 14px;
    text-decoration: none;
}

.tls-rank-name:hover {
    color: var(--civi-color-accent, #4d4ed4);
}

/* Rank movement caret (only for companies whose position changed) */
.tls-move {
    flex: 0 0 auto;
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    font-size: 14px;
    line-height: 1;
}

.tls-move--up {
    color: #16a34a;
}

.tls-move--down {
    color: #dc2626;
}

.tls-move--new {
    padding: 1px 9px;
    border-radius: 999px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--civi-color-accent, #4d4ed4);
    background: rgb(77 78 212 / .1);
}

/* "More" teaser: faded next company + a crisp "+N more" chip. Signals there
 * is more to see, so the whole (clickable) card reads as the call to action. */
.tls-rank-more .tls-rank-num,
.tls-rank-more .tls-rank-logo,
.tls-rank-more .tls-rank-name {
    opacity: .4;
}

/* The teaser name is plain text, so let the card-wide click overlay cover it. */
.tls-rank-more .tls-rank-name {
    position: static;
    z-index: auto;
}

.tls-more-badge {
    flex: 0 0 auto;
    margin-left: auto;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    color: var(--civi-color-accent, #4d4ed4);
    background: #f1f5f9;
}

/* Load more (matches the employer single-page button) */
.tls-loadmore-wrap {
    text-align: center;
    margin-top: 32px;
}

.tls-loadmore {
    display: inline-block;
    padding: 11px 26px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    color: var(--civi-color-accent, #4d4ed4);
    background: transparent;
    border: 1px solid var(--civi-color-accent, #4d4ed4);
    cursor: pointer;
    transition: background .15s ease, color .15s ease, opacity .15s ease;
}

.tls-loadmore:hover {
    color: #ffffff;
    background: var(--civi-color-accent, #4d4ed4);
}

.tls-loadmore.is-loading {
    pointer-events: none;
    position: relative;
    padding-right: 46px;
}

.tls-loadmore.is-loading::after {
    content: "";
    position: absolute;
    right: 18px;
    top: 50%;
    width: 14px;
    height: 14px;
    margin-top: -7px;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: tls-spin .6s linear infinite;
}

@keyframes tls-spin {
    to { transform: rotate(360deg); }
}

.tls-empty {
    margin: 0;
    font-size: 15px;
    color: #94a3b8;
}

/* ── Elementor widget wrapper ── */
.tls-widget.tls-items--grid,
.tls-widget.tls-items--list {
    margin: 0;
}

.tls-widget-cta {
    margin-top: 28px;
    text-align: center;
}

/* ── Responsive ── */
@media (max-width: 991px) {
    .tls-items--grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 600px) {
    .tls-items--grid {
        grid-template-columns: minmax(0, 1fr);
    }
}
