/**
 * Hubs Library.
 *
 * The page header mirrors the Collections Library (.cl-header) so the listing
 * pages read as siblings. Each hub row is a compact take on the hub header band
 * (hub_header/css/hub-header.css): cover left, badges / title / subtitle /
 * counts in the middle, the join/open action on the right.
 */

.hl-library {
  --hl-purple: #5b2b6b;
  --hl-teal: #08b29f;
  --hl-text: #1f2328;
  --hl-text-muted: #5b6470;
  --hl-border: #e3e6ea;
  --hl-surface-muted: #f6f7f9;

  max-width: 1400px;
  margin-inline: auto;
  padding: 1.5rem 1rem 3rem;
}

/* -- Header (follows .cl-header) -- */

.hl-header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.hl-header__left {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.75rem;
}

.hl-header__title {
  margin: 0;
  color: var(--hl-text);
  font-size: 1.75rem;
  font-weight: 800;
  line-height: 1.2;
}

.hl-header__count {
  color: var(--hl-text-muted);
  font-size: 0.95rem;
}

.hl-header__right {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.hl-header__sort-label {
  color: var(--hl-text-muted);
  font-size: 0.9rem;
}

.hl-sort-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  border: none;
  background: none;
  color: var(--hl-text);
  font-size: 0.9rem;
  cursor: pointer;
}

.hl-sort-btn:hover {
  color: var(--hl-purple);
}

.hl-lede {
  margin: 0 0 1.25rem;
  color: var(--hl-text-muted);
}

.hl-rule {
  margin: 0 0 1.5rem;
  border: 0;
  border-top: 1px solid var(--hl-border);
  opacity: 1;
}

.hl-empty {
  padding: 3rem 0;
  color: var(--hl-text-muted);
  text-align: center;
}

/* -- Rows -- */

.hl-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin: 0;
}

.hub-row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 2rem;
  padding: 1.25rem;
  color: var(--hl-text);
  background-color: #fff;
  border: 1px solid var(--hl-border);
  border-radius: 1rem;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.hub-row:hover {
  transform: translateY(-2px);
  border-color: #d3d8de;
  box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.08);
}

.hub-row:focus-within {
  border-color: var(--hl-purple);
}

/* Same ratio as the hub header cover. */
.hub-row__cover {
  flex: 0 0 205px;
  aspect-ratio: 205 / 145;
  overflow: hidden;
  background-color: var(--hl-surface-muted);
  border-radius: 0.5rem;
}

.hub-row__cover-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.hub-row__placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  background: linear-gradient(135deg, #f3edf5, #e6f7f5);
  color: var(--hl-purple);
  font-size: 2.5rem;
  opacity: 0.5;
}

.hub-row__body {
  flex: 1 1 auto;
  min-width: 0;
}

.hub-row__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 0.75rem;
  margin: 0 0 0.375rem;
  font-size: 0.875rem;
  color: var(--hl-text-muted);
}

.hub-row__badge .bi,
.hub-row__role .bi {
  margin-right: 0.375rem;
}

.hub-row__type::before,
.hub-row__role::before {
  content: "·";
  margin-right: 0.75rem;
  color: var(--hl-text-muted);
}

.hub-row__role {
  color: var(--hl-teal);
  font-weight: 600;
}

.hub-row__title {
  margin: 0 0 0.375rem;
  font-size: 1.375rem;
  font-weight: 700;
  line-height: 1.2;
}

.hub-row__title a {
  color: var(--hl-text);
  text-decoration: none;
}

.hub-row:hover .hub-row__title a {
  color: var(--hl-purple);
}

.hub-row__title a:focus-visible {
  outline: none;
}

/* Clamped so long About text does not blow out the row height. */
.hub-row__summary {
  display: -webkit-box;
  overflow: hidden;
  margin: 0 0 0.75rem;
  color: var(--hl-text-muted);
  font-size: 0.975rem;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.hub-row__stats {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  margin: 0;
  font-size: 0.875rem;
  color: var(--hl-text-muted);
}

.hub-row__stats li + li {
  margin-left: 1rem;
  padding-left: 1rem;
  border-left: 1px solid var(--hl-border);
}

.hub-row__stats strong {
  color: var(--hl-text);
}

/* Lifted above the title's stretched link so the button stays clickable. */
.hub-row__actions {
  position: relative;
  z-index: 2;
  flex: 0 0 auto;
}

.hub-row__btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 1.25rem;
  font-weight: 500;
  white-space: nowrap;
}

/* Matches the hub header's "Invite & share" button. */
.hub-row .hub-row__btn--open {
  color: var(--hl-text);
  background-color: #fff;
  border: 1px solid #c9ced6;
  border-radius: 0.375rem;
  box-shadow: 0 1px 3px rgba(16, 24, 40, 0.1);
}

.hub-row .hub-row__btn--open:hover {
  background-color: var(--hl-surface-muted);
  border-color: #aeb5bf;
}

/* -- Small screens -- */

@media (max-width: 767.98px) {
  .hl-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .hub-row {
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 1rem 1.25rem;
    padding: 1rem;
  }

  .hub-row__cover {
    flex-basis: 96px;
  }

  .hub-row__body {
    flex-basis: calc(100% - 96px - 1.25rem);
  }

  .hub-row__title {
    font-size: 1.125rem;
  }

  .hub-row__actions {
    flex-basis: 100%;
  }

  .hub-row__btn {
    justify-content: center;
    width: 100%;
  }
}
