.community-collections-page {
  overflow-x: clip;
}

.community-collections-shell {
  padding-bottom: calc(100px + env(safe-area-inset-bottom));
}

.community-collection-group__header p,
.community-collections-all__header p {
  margin: 0 0 10px;
  color: var(--kh-accent);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.community-collections-statusbar {
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 0 4px;
}

.community-collections-statusbar:not(.is-visible) {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  margin: -1px;
  border: 0;
  padding: 0;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.community-collections-statusbar p {
  margin: 0;
  color: var(--kh-text-soft);
  font-size: 14px;
}

.community-collections-statusbar p.is-error {
  color: var(--kh-danger);
}

.community-collections-statusbar button,
.community-collections-pagination button,
.community-collection-group__controls button {
  min-width: 44px;
  min-height: 44px;
  border: 1px solid var(--kh-line);
  border-radius: 999px;
  color: var(--kh-text);
  background: var(--kh-surface-solid);
  box-shadow: var(--kh-shadow-sm);
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  transition: transform 160ms var(--kh-ease-out), border-color 160ms ease, background 160ms ease;
}

.community-collections-statusbar button,
.community-collections-pagination button {
  padding: 0 18px;
}

.community-collection-group,
.community-collections-all {
  margin-top: clamp(28px, 3vw, 44px);
  scroll-margin-top: 108px;
}

.community-collections-statusbar + .community-collection-group {
  margin-top: 0;
}

.community-collection-group__header,
.community-collections-all__header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
}

.community-collection-group__header h2,
.community-collections-all__header h2 {
  margin: 0;
  font-size: clamp(30px, 3.5vw, 48px);
  letter-spacing: -.035em;
  line-height: 1;
}

.community-collection-group__controls {
  display: flex;
  gap: 10px;
}

.community-collection-group__controls button {
  width: 48px;
  height: 48px;
  padding: 0;
  font-size: 22px;
}

.community-collection-group__controls button:last-child {
  color: var(--kh-accent-ink);
  border-color: transparent;
  background: var(--kh-accent);
}

.community-collection-track {
  min-width: 0;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: calc((100% - 72px) / 4);
  gap: 24px;
  overflow-x: auto;
  padding: 4px 2px 18px;
  scroll-padding-inline: 2px;
  scroll-snap-type: inline mandatory;
  scrollbar-width: none;
}

.community-collection-track::-webkit-scrollbar {
  display: none;
}

.community-collections-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 24px;
}

.community-collection-card {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--kh-line);
  border-radius: 26px;
  color: var(--kh-text);
  background: var(--kh-surface-solid);
  box-shadow: var(--kh-shadow-sm);
  scroll-snap-align: start;
  transition: transform 200ms var(--kh-ease-out), box-shadow 200ms var(--kh-ease-out), border-color 160ms ease;
}

.community-collection-card__link {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  color: inherit;
  text-decoration: none;
}

.community-collection-card__visual {
  position: relative;
  display: block;
  flex: none;
  min-height: 0;
  overflow: visible;
  aspect-ratio: 16 / 9;
  background: linear-gradient(145deg, var(--kh-surface-soft), var(--kh-section-well));
}

.community-collection-card__visual > img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  transition: transform 220ms var(--kh-ease-out);
}

.community-collection-card__visual::after {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 45%;
  background: linear-gradient(transparent, rgba(4, 7, 12, .32));
  pointer-events: none;
}

.community-collection-card__fallback {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--kh-text-faint);
  font-size: 46px;
  font-weight: 900;
  opacity: .48;
}

.community-collection-card__avatar {
  position: absolute;
  z-index: 2;
  right: 18px;
  bottom: -29px;
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  overflow: hidden;
  translate: none;
  border: 4px solid var(--kh-surface-solid);
  border-radius: 50%;
  color: var(--kh-accent-ink);
  background: var(--kh-accent);
  font-size: 17px;
  font-weight: 850;
  letter-spacing: -.03em;
}

.community-collection-card__avatar img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.community-collection-card__body {
  min-height: 190px;
  display: flex;
  flex: 1;
  flex-direction: column;
  padding: 38px 22px 20px;
}

.community-collection-card__author {
  max-width: calc(100% - 54px);
  overflow: hidden;
  color: var(--kh-accent);
  font-size: 13px;
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.community-collection-card h3 {
  min-height: 2.6em;
  margin: 15px 0 24px;
  overflow: hidden;
  font-size: clamp(18px, 1.5vw, 22px);
  font-weight: 780;
  letter-spacing: -.02em;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.community-collection-card__metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--kh-line);
}

.community-collection-card__metric {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--kh-text-soft);
  font-size: 12px;
}

.community-collection-card__metric strong {
  min-width: 0;
  overflow: hidden;
  color: var(--kh-text);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  text-overflow: ellipsis;
}

.community-collection-card__metric-icon {
  width: 16px;
  height: 16px;
  display: inline-flex;
  flex: 0 0 auto;
}

.community-collection-card__metric-icon svg {
  width: 100%;
  height: 100%;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.community-collection-card--skeleton {
  min-height: 376px;
  border-color: transparent;
  background: var(--kh-surface-solid);
}

.community-collection-card--skeleton span:first-child {
  display: block;
  aspect-ratio: 16 / 9;
  background: linear-gradient(100deg, var(--kh-surface-soft) 22%, var(--kh-bg-elevated) 42%, var(--kh-surface-soft) 62%);
  background-size: 240% 100%;
  animation: community-shimmer 1.35s linear infinite;
}

.community-collection-card--skeleton span:last-child {
  width: 68%;
  height: 18px;
  display: block;
  margin: 38px 22px;
  border-radius: 999px;
  background: var(--kh-surface-soft);
}

.community-collections-empty {
  min-height: 280px;
  place-items: center;
  padding: 42px;
  border: 1px dashed var(--kh-line-strong);
  border-radius: 28px;
  background: var(--kh-section-well);
  text-align: center;
}

.community-collections-empty:not([hidden]) {
  display: grid;
}

.community-collections-empty strong {
  font-size: clamp(24px, 3vw, 38px);
  letter-spacing: -.03em;
}

.community-collections-empty p {
  max-width: 52ch;
  margin: 10px 0 20px;
  color: var(--kh-text-soft);
  line-height: 1.55;
}

.community-collections-empty a {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  padding: 0 18px;
  border-radius: 999px;
  color: var(--kh-accent-ink);
  background: var(--kh-accent);
  font-weight: 750;
  text-decoration: none;
}

.community-collections-pagination {
  align-items: center;
  justify-content: center;
  gap: 18px;
  margin-top: 34px;
}

.community-collections-pagination:not([hidden]) {
  display: flex;
}

.community-collections-pagination span {
  min-width: 150px;
  color: var(--kh-text-soft);
  font-size: 14px;
  text-align: center;
}

.community-collections-pagination button:disabled {
  cursor: default;
  opacity: .42;
}

@keyframes community-shimmer {
  to { background-position: -240% 0; }
}

@media (hover: hover) and (pointer: fine) {
  .community-collection-card:hover {
    z-index: 1;
    border-color: color-mix(in srgb, var(--kh-accent) 28%, var(--kh-line));
    box-shadow: var(--kh-shadow-md);
    transform: translateY(-5px);
  }

  .community-collection-card:hover .community-collection-card__visual > img {
    transform: scale(1.025);
  }

  .community-collections-statusbar button:hover,
  .community-collections-pagination button:not(:disabled):hover,
  .community-collection-group__controls button:hover {
    transform: translateY(-2px);
  }
}

.community-collections-statusbar button:active,
.community-collections-pagination button:not(:disabled):active,
.community-collection-group__controls button:active {
  transform: scale(.97);
  transition-duration: 70ms;
}

.community-collection-card__link:focus-visible,
.community-collections-empty a:focus-visible,
.community-collections-statusbar button:focus-visible,
.community-collections-pagination button:focus-visible,
.community-collection-group__controls button:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--kh-accent) 72%, white);
  outline-offset: 4px;
}

@media (max-width: 1120px) {
  .community-collections-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .community-collection-track {
    grid-auto-columns: calc((100% - 48px) / 3);
  }
}

@media (max-width: 760px) {
  .community-collection-group,
  .community-collections-all {
    margin-top: 30px;
  }

  .community-collections-statusbar + .community-collection-group {
    margin-top: 0;
  }

  .community-collection-group__header,
  .community-collections-all__header {
    margin-bottom: 18px;
  }

  .community-collection-group__header h2,
  .community-collections-all__header h2 {
    font-size: 34px;
  }

  .community-collection-group__controls {
    display: none;
  }

  .community-collection-track {
    width: calc(100% + 12px);
    grid-auto-columns: minmax(278px, 82vw);
    gap: 14px;
    margin-right: -12px;
    padding-right: 12px;
  }

  .community-collections-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }

  .community-collection-card {
    border-radius: 20px;
  }

  .community-collections-grid .community-collection-card__avatar {
    right: 10px;
    bottom: -19px;
    width: 38px;
    height: 38px;
    border-width: 3px;
    font-size: 12px;
  }

  .community-collections-grid .community-collection-card__body {
    min-height: 145px;
    padding: 29px 12px 12px;
  }

  .community-collections-grid .community-collection-card__author {
    max-width: calc(100% - 32px);
    font-size: 11px;
  }

  .community-collections-grid .community-collection-card h3 {
    min-height: 2.55em;
    margin: 11px 0 14px;
    font-size: 15px;
  }

  .community-collections-grid .community-collection-card__metrics {
    gap: 4px;
    padding-top: 10px;
  }

  .community-collections-grid .community-collection-card__metric {
    gap: 3px;
  }

  .community-collections-grid .community-collection-card__metric-icon {
    width: 13px;
    height: 13px;
  }

  .community-collections-grid .community-collection-card__metric strong {
    font-size: 10px;
  }

  .community-collection-card--skeleton {
    min-height: 270px;
  }

  .community-collections-statusbar {
    align-items: flex-start;
    flex-direction: column;
    margin-inline: 0;
  }

  .community-collections-pagination {
    gap: 9px;
  }

  .community-collections-pagination span {
    min-width: 110px;
    font-size: 12px;
  }
}

@media (max-width: 374px) {
  .community-collections-grid {
    gap: 9px;
  }

  .community-collections-grid .community-collection-card__body {
    padding-inline: 10px;
  }

  .community-collections-grid .community-collection-card__metric-icon {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .community-collections-page *,
  .community-collections-page *::before,
  .community-collections-page *::after {
    scroll-behavior: auto !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }

  .community-collection-card:hover,
  .community-collection-card:hover .community-collection-card__visual > img {
    transform: none;
  }
}

@media (prefers-reduced-transparency: reduce) {
  .community-collection-card,
  .community-collections-statusbar button,
  .community-collections-pagination button,
  .community-collection-group__controls button {
    background-color: var(--kh-surface-solid);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
}

@media (prefers-contrast: more) {
  .community-collection-card,
  .community-collections-statusbar button,
  .community-collections-pagination button,
  .community-collection-group__controls button {
    border-color: currentColor;
  }
}
