/*
 * SSR list pages -- blog, docs, pages and shop-category listings, all built
 * from the foundation's one generic list.qtpl (goatapp/app/webapp/ssr).
 * This file shadows goatcore's own /static/webapp/ssr-list.css (see
 * child/app/routes/routes.go) so the same markup renders in Pszczeli Park's
 * own visual system instead of the framework's generic one.
 *
 * The palette, reset, typography and shared primitives come from
 * /static/data/theme/{tokens,base,chrome}.css, loaded before this file --
 * see DESIGN.md. Nothing here declares a raw color; everything consumes a
 * token.
 *
 * The page's <main id="main-content"> carries no width constraint of its own
 * (only the article variant gets a .shell); every top-level block below
 * takes care of its own centering instead of relying on a wrapper the page
 * doesn't render.
 */

#main-content {
  padding-block: clamp(var(--space-6), 5vw, var(--space-8)) var(--space-9);
}

#main-content > .page-header,
#main-content > .list-controls,
#main-content > .search-summary,
#main-content > .resource-list,
#main-content > .empty-state,
#main-content > .pagination {
  width: min(calc(100% - 32px), var(--container-max));
  margin-inline: auto;
}

/* Header */

.page-header {
  display: grid;
  gap: var(--space-3);
  padding-bottom: var(--space-6);
  margin-bottom: var(--space-6);
  border-bottom: 1px solid var(--color-border);
}

.page-header h1 {
  max-width: 24ch;
  margin: 0;
  font-size: clamp(var(--text-3xl), 4vw, var(--text-4xl));
  line-height: 1.08;
  letter-spacing: -0.02em;
  text-wrap: balance;
}

.page-header p {
  max-width: var(--content-readable);
  margin: 0;
  color: var(--color-ink-700);
  font-size: var(--text-lg);
  line-height: 1.6;
}

/* Search + controls */

.list-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

.search-field {
  display: grid;
  flex: 1 1 260px;
  min-width: 0;
  gap: var(--space-2);
  color: var(--color-ink-700);
  font-size: var(--text-sm);
  font-weight: 700;
}

.search-field input {
  min-height: 44px;
  padding: 0 var(--space-4);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-pill);
  outline: 0;
  background: var(--color-surface);
  color: var(--color-ink-950);
  font: inherit;
}

.search-field input::placeholder { color: var(--color-ink-400); }

.search-field input:focus-visible {
  border-color: var(--focus);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 22%, transparent);
}

.search-action,
.clear-search,
.pagination a {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 var(--space-5);
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
}

.search-action {
  background: var(--color-brand-yellow-500);
  color: var(--color-ink-950);
}

.search-action:hover {
  background: color-mix(in srgb, var(--color-brand-yellow-500) 88%, var(--color-ink-950));
}

.clear-search,
.pagination a {
  border-color: var(--color-ink-400);
  background: transparent;
  color: var(--color-ink-950);
}

.clear-search:hover,
.pagination a:hover {
  background: var(--color-surface-muted);
  border-color: var(--color-ink-950);
}

.search-summary {
  margin: 0 0 var(--space-5);
  color: var(--color-ink-700);
  font-size: var(--text-sm);
}

/* Resource cards */

.resource-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr));
  gap: var(--space-5);
  margin: 0;
  padding: 0;
  list-style: none;
}

.resource-item {
  display: flex;
}

.resource-link {
  display: flex;
  flex-direction: column;
  width: 100%;
  padding: var(--space-5);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  color: inherit;
  text-decoration: none;
  transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.resource-link:hover {
  border-color: var(--color-honey-500);
  box-shadow: 0 12px 28px rgba(24, 22, 17, 0.1);
  transform: translateY(-2px);
}

.resource-link:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--focus) 45%, transparent);
  outline-offset: 3px;
}

.resource-image {
  order: -1;
  display: block;
  width: calc(100% + var(--space-5) * 2);
  margin: calc(var(--space-5) * -1) calc(var(--space-5) * -1) var(--space-4);
  aspect-ratio: 16 / 10;
  object-fit: cover;
  background: var(--color-surface-muted);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.resource-copy {
  display: grid;
  flex: 1;
  gap: var(--space-2);
  min-width: 0;
}

.resource-title {
  font-size: var(--text-lg);
  font-weight: 750;
  line-height: 1.3;
  letter-spacing: -0.01em;
  color: var(--color-ink-950);
  overflow-wrap: anywhere;
  transition: color 160ms ease;
}

.resource-link:hover .resource-title {
  color: var(--color-honey-700);
}

.resource-description {
  display: -webkit-box;
  margin: 0;
  overflow: hidden;
  color: var(--color-ink-700);
  font-size: var(--text-sm);
  line-height: 1.55;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow-wrap: anywhere;
}

.resource-arrow {
  display: inline-grid;
  align-self: flex-end;
  width: 2.25rem;
  height: 2.25rem;
  margin-top: var(--space-4);
  place-items: center;
  background: var(--color-surface-muted);
  border-radius: var(--radius-pill);
  color: var(--color-honey-700);
  transition: transform 160ms ease, background-color 160ms ease, color 160ms ease;
}

.resource-link:hover .resource-arrow {
  transform: translateX(3px);
  background: var(--color-brand-yellow-500);
  color: var(--color-ink-950);
}

.resource-arrow svg {
  width: 1.1rem;
  height: 1.1rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Empty state */

.empty-state {
  padding: var(--space-8) var(--space-5);
  background: var(--color-surface);
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-lg);
  text-align: center;
}

.empty-state h2 {
  margin: 0 0 var(--space-2);
  font-size: var(--text-xl);
}

.empty-state p {
  max-width: var(--content-readable);
  margin: 0 auto;
  color: var(--color-ink-700);
}

/* Pagination */

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-top: var(--space-7);
  padding-top: var(--space-5);
  border-top: 1px solid var(--color-border);
}

.pagination-status {
  color: var(--color-ink-700);
  font-size: var(--text-sm);
  font-weight: 700;
}

.pagination-spacer {
  min-width: 1px;
}

@media (max-width: 640px) {
  .page-header { padding-bottom: var(--space-5); margin-bottom: var(--space-5); }
  .page-header h1 { font-size: clamp(1.875rem, 10vw, 2.375rem); }
  .page-header p { font-size: var(--text-base); line-height: 1.55; }
  .list-controls { flex-direction: column; align-items: stretch; }
  .search-action { width: 100%; }
  .resource-list { grid-template-columns: 1fr; }
  .pagination { flex-wrap: wrap; }
}

@media (prefers-reduced-motion: reduce) {
  .resource-link,
  .resource-arrow {
    transition: none;
  }
}
