.tsai-projects {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.5rem;
  margin: 2rem 0;
}

.tsai-projects--empty {
  display: block;
  color: inherit;
  opacity: 0.8;
}

.tsai-projects__card {
  display: flex;
  flex-direction: column;
  border: 1px solid rgba(128, 128, 128, 0.3);
  border-radius: 10px;
  padding: 1.25rem 1.5rem 1.5rem;
  background: rgba(128, 128, 128, 0.04);
}

.tsai-projects__header {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.tsai-projects__logo-link {
  display: inline-block;
  line-height: 0;
}

.tsai-projects__logo {
  width: 64px;
  height: 64px;
  object-fit: contain;
  border-radius: 8px;
}

.tsai-projects__title {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1.2;
}

.tsai-projects__title a {
  text-decoration: none;
  color: inherit;
}

.tsai-projects__title a:hover {
  color: #8A6EFF;
}

/* Sites on different servers can share a display name, so the host is the
   disambiguator — quiet, but always present so cards stay consistent. */
.tsai-projects__host {
  margin: 0;
  font-size: 0.8rem;
  line-height: 1.3;
  color: inherit;
  opacity: 0.65;
  word-break: break-all;
}

.tsai-projects__tagline {
  margin: 0;
  font-size: 0.85rem;
  color: inherit;
  opacity: 0.8;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.tsai-projects__articles {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.tsai-projects__article {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding-top: 0.6rem;
  border-top: 1px solid rgba(128, 128, 128, 0.2);
}

.tsai-projects__article:first-child {
  border-top: none;
  padding-top: 0;
}

.tsai-projects__article-title {
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.3;
  text-decoration: none;
  color: inherit;
}

.tsai-projects__article-title:hover {
  color: #8A6EFF;
}

.tsai-projects__article-meta {
  font-size: 0.78rem;
  color: inherit;
}

.tsai-projects__empty {
  margin: 0;
  font-size: 0.85rem;
  color: inherit;
  opacity: 0.8;
}

/* ------------------------------------------------------------------
   Filter toolbar and pagination.

   The grid itself is unchanged above; everything here wraps it. Keep in
   step with scike_affiliates/css/scike-affiliates.css.
   ------------------------------------------------------------------ */

.tsai-projects__toolbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin: 2rem 0 0;
}

.tsai-projects__search {
  flex: 1 1 18rem;
  min-width: 0;
  padding: 0.55rem 0.85rem;
  font: inherit;
  font-size: 0.95rem;
  color: inherit;
  background: rgba(128, 128, 128, 0.06);
  border: 1px solid rgba(128, 128, 128, 0.3);
  border-radius: 8px;
}

.tsai-projects__search:focus {
  outline: 2px solid #8a6eff;
  outline-offset: 1px;
}

.tsai-projects__count {
  margin: 0;
  font-size: 0.85rem;
  opacity: 0.7;
}

/* The grid already carries its own top margin, so the results region adds
   none of its own. */
.tsai-projects__results[aria-busy='true'] {
  opacity: 0.55;
  transition: opacity 120ms ease-in;
}

.tsai-projects__pagination {
  display: flex;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
  font-size: 0.9rem;
}

/* The top copy sits under the filter box, so its rule goes underneath it and
   the grid's own top margin supplies the gap below. */
.tsai-projects__pagination--top {
  margin-top: 0.85rem;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid rgba(128, 128, 128, 0.2);
}

.tsai-projects__pagination--bottom {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid rgba(128, 128, 128, 0.2);
}

/* With a pager above it, the grid no longer needs its own leading margin. */
.tsai-projects__pagination--top + .tsai-projects {
  margin-top: 1.5rem;
}

.tsai-projects__page {
  opacity: 0.65;
}

/* On the first and last page there is only one link, and it should sit on
   the side it navigates towards rather than jumping to the left. */
.tsai-projects__pagination .tsai-projects__next:only-of-type {
  margin-left: auto;
}

/* The Preview Edition pill sits on its own line between the headline and the
   meta row. The article <li> is already a flex column, so all this has to do
   is stop the inline-flex pill stretching to the card's full width.
   Keep in step with scike_affiliates/css/scike-affiliates.css. */
.tsai-projects__article .tsai-preview-edition--compact {
  align-self: flex-start;
}
