/* library.css */

.library-page {
  width: var(--site-shell);
  margin: 0 auto;
  padding: 52px 0 72px;
}

.library-hero {
  max-width: 760px;
  margin-bottom: 30px;
}

.library-eyebrow {
  margin: 0 0 8px;
  color: var(--blue);
  font-weight: 800;
}

.library-hero h1,
.library-detail-header h1 {
  margin: 0 0 12px;
  color: var(--mauve);
  font-size: clamp(2.2rem, 5vw, 3.8rem);
  line-height: 1;
}

.library-hero p,
.library-detail-header p {
  max-width: 680px;
  color: var(--sub);
}

.library-filters {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(170px, 220px) minmax(150px, 190px) auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 24px;
  padding-bottom: 22px;
  border-bottom: 1px solid color-mix(in srgb, var(--surface) 76%, transparent);
}

.library-filters label {
  display: grid;
  gap: 6px;
  color: var(--sub);
  font-weight: 700;
}

.library-filters input,
.library-filters select {
  min-width: 0;
}

.library-filters button,
.library-install summary {
  border-color: color-mix(in srgb, var(--mauve) 72%, var(--surface));
}

.library-owner-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 18px;
  color: var(--sub);
}

.library-owner-filter a,
.library-pagination a,
.library-readme-content a {
  color: var(--blue);
  text-decoration: none;
}

.library-list {
  display: grid;
  gap: 0;
}

.library-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 20px;
  padding: 18px 0;
  border-bottom: 1px solid color-mix(in srgb, var(--surface) 72%, transparent);
  color: inherit;
}

.library-card:first-child {
  border-top: 1px solid color-mix(in srgb, var(--surface) 72%, transparent);
}

.library-card-main {
  min-width: 0;
  color: inherit;
  text-decoration: none;
}

.library-card-main:hover h2,
.library-more-item:hover strong {
  color: var(--blue);
}

.library-card-heading,
.library-title-row {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  min-width: 0;
}

.library-card h2 {
  margin: 0;
  color: var(--text);
  font-size: 1.22rem;
}

.library-card p {
  margin: 0;
}

.library-card-title-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  align-items: center;
}

.library-card-description {
  margin-top: 8px;
  color: var(--sub);
}

.library-icon {
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  display: inline-grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--text) 14%, transparent);
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--mantle) 78%, transparent);
  color: var(--mauve);
  font-weight: 900;
}

.library-icon-initial {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  font-size: 1.15rem;
  line-height: 1;
}

.library-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.library-meta-row,
.library-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  align-items: center;
}

.library-meta-row {
  margin-top: 10px;
}

.library-card-actions {
  justify-content: flex-end;
  align-content: center;
}

.library-meta-row span,
.library-meta-row code,
.library-hypes,
.library-version-list a {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  color: var(--sub);
  font-size: 0.82rem;
  font-weight: 800;
}

.library-meta-row span,
.library-meta-row code,
.library-version-list a {
  padding: 0 8px;
  background: color-mix(in srgb, var(--surface) 58%, transparent);
}

.library-meta-row code {
  color: var(--blue);
}

.library-hypes {
  gap: 5px;
  color: var(--text);
}

.library-hypes img {
  width: 15px;
  height: 15px;
}

.library-empty {
  padding: 22px 0;
  border-top: 1px solid color-mix(in srgb, var(--surface) 76%, transparent);
  border-bottom: 1px solid color-mix(in srgb, var(--surface) 76%, transparent);
}

.library-detail-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 24px;
  align-items: end;
  margin-bottom: 28px;
  padding-bottom: 22px;
  border-bottom: 1px solid color-mix(in srgb, var(--surface) 76%, transparent);
}

.library-detail-meta-row {
  margin-top: 16px;
}

.library-detail-card {
  display: grid;
  gap: 12px;
  justify-items: end;
}

.library-detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(240px, 320px);
  gap: 28px;
  align-items: start;
}

.library-detail-main,
.library-side {
  display: grid;
  gap: 28px;
  min-width: 0;
}

.library-panel {
  min-width: 0;
}

.library-readme,
.library-source {
  padding-bottom: 26px;
  border-bottom: 1px solid color-mix(in srgb, var(--surface) 72%, transparent);
}

.library-section-heading h2,
.library-panel h2 {
  margin: 0 0 10px;
  color: var(--mauve);
  font-size: 1.2rem;
}

.library-section-heading p,
.library-changelog {
  margin: 0 0 14px;
  color: var(--sub);
}

.library-readme-content > :first-child {
  margin-top: 0;
}

.library-readme-content code {
  color: var(--blue);
  background: color-mix(in srgb, var(--surface) 70%, transparent);
  border-radius: 6px;
  padding: 2px 6px;
}

.library-readme-content pre,
.library-source pre,
.library-install pre {
  overflow-x: hidden;
  overflow-y: auto;
  margin: 0;
  padding: 16px;
  border: 1px solid color-mix(in srgb, var(--surface) 80%, transparent);
  border-radius: var(--radius-md);
  background: var(--mantle);
}

.library-readme-content pre code,
.library-source pre code,
.library-install pre code {
  display: block;
  padding: 0;
  color: var(--text);
  background: transparent;
  white-space: inherit;
}

.library-version-list {
  display: grid;
  gap: 6px;
}

.library-version-list a {
  justify-content: space-between;
  gap: 10px;
  min-height: 32px;
  color: inherit;
  text-decoration: none;
}

.library-version-list a.current {
  background: color-mix(in srgb, var(--mauve) 24%, transparent);
  color: var(--text);
}

.library-version-list small {
  min-width: 0;
  overflow: hidden;
  color: var(--sub);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.library-more-list {
  display: grid;
}

.library-more-item {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 10px 0;
  border-top: 1px solid color-mix(in srgb, var(--surface) 62%, transparent);
  color: inherit;
  text-decoration: none;
}

.library-more-item .library-icon {
  width: 36px;
  height: 36px;
  flex-basis: 36px;
}

.library-more-item strong,
.library-more-item small {
  display: block;
}

.library-more-item small {
  overflow: hidden;
  color: var(--sub);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.library-install {
  position: relative;
}

.library-install summary {
  display: inline-flex;
  align-items: center;
  list-style: none;
}

.library-install summary::-webkit-details-marker {
  display: none;
}

.library-install-popover {
  position: absolute;
  right: 0;
  z-index: 20;
  width: min(340px, calc(100vw - 32px));
  margin-top: 8px;
  padding: 16px;
  border: 1px solid color-mix(in srgb, var(--surface) 80%, transparent);
  border-radius: var(--radius-md);
  background: var(--mantle);
}

.library-install-popover p {
  margin: 0 0 12px;
  color: var(--text);
}

.library-install-popover label {
  display: grid;
  gap: 6px;
  margin-top: 10px;
  color: var(--sub);
  font-size: 0.86rem;
  font-weight: 800;
}

.library-pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 18px;
  margin-top: 24px;
  color: var(--sub);
}

@media (max-width: 820px) {
  .library-filters,
  .library-card,
  .library-detail-header,
  .library-detail-grid {
    grid-template-columns: 1fr;
  }

  .library-card-actions,
  .library-detail-card {
    justify-content: flex-start;
    justify-items: start;
  }

  .library-install-popover {
    left: 0;
    right: auto;
  }
}
