/*
 * Insights articles block (wpta/insights-list), as in the Insights wireframe:
 *
 * 1. The filters as pills ("All" filled in deep teal when chosen), with the search at the end of the row.
 * 2. The featured article: its photo beside the words on laptops, above them on tablets and phones.
 * 3. The other articles as cards, in three columns on laptops and bigger, two on tablets and one on phones, so
 *    each step of nine fills its rows. On two columns, an odd last card runs across both, its photo beside it.
 * 4. "Load more articles", centred and outlined.
 *
 * Empty photos show as a soft grey block of the same size, so the cards line up until photos are chosen.
 */

.insights-list {
  display: flex;
  flex-direction: column;
  gap: 28px;
}

/* 1. Filters and search */

.insights-list__tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
}

.insights-list__filters {
  display: flex;
  flex: 1 1 auto;
  flex-wrap: wrap;
  gap: 8px;
}

.insights-list__filter {
  padding: 10px 16px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--white);
  color: var(--teal-darker);
  font-size: 14px;
  line-height: 1.2;
  text-decoration: none;
  transition: border-color 0.2s ease, background-color 0.2s ease;
}

.insights-list__filter:hover,
.insights-list__filter:focus-visible {
  border-color: var(--teal);
  background: var(--teal-pale);
}

.insights-list__filter[aria-current="page"] {
  border-color: #0d3d39;
  background: #0d3d39;
  color: var(--white);
  font-weight: 600;
}

.insights-list__search {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 0 auto;
  color: var(--text-muted);
  font-size: 14px;
}

.insights-list__search input[type="search"] {
  width: 220px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--white);
  color: var(--text);
  font: inherit;
  font-size: 14px;
}

.insights-list__search input[type="search"]:focus-visible {
  border-color: var(--teal-dark);
  outline: 2px solid var(--teal-light);
}

.insights-list__empty {
  margin: 0;
  color: var(--text-muted);
  font-size: 16px;
}

/* 2. The featured article */

.insights-list__featured {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--white);
  color: var(--text);
  text-decoration: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.insights-list__featured-image {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 340px;
  object-fit: cover;
}

.insights-list__featured-words {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 14px;
  padding: 36px;
}

.insights-list__featured-label,
.insights-list__card-label {
  align-self: flex-start;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--teal-light);
  color: var(--teal-darker);
  font-size: 12px;
  font-weight: 600;
}

.insights-list__featured-title {
  color: #0d3d39;
  font-family: "DM Serif Display", Georgia, serif;
  font-size: clamp(28px, 3vw, 34px);
  line-height: 1.15;
}

.insights-list__featured-excerpt {
  color: var(--text-muted);
  font-size: 16px;
  line-height: 1.55;
}

.insights-list__featured-meta,
.insights-list__card-meta {
  color: var(--text-muted);
  font-size: 13px;
}

.insights-list__featured-more {
  color: var(--teal-darker);
  font-weight: 600;
}

/* 3. The other articles */

.insights-list__cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 24px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.insights-list__cards > li {
  display: flex;
  margin: 0;
}

.insights-list__card {
  display: flex;
  flex: 1;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--white);
  color: var(--text);
  text-decoration: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.insights-list__featured:hover,
.insights-list__featured:focus-visible,
.insights-list__card:hover,
.insights-list__card:focus-visible {
  border-color: var(--teal);
  box-shadow: 0 10px 24px rgba(21, 89, 82, 0.1);
}

.insights-list__card-image {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 7;
  object-fit: cover;
}

.insights-list__featured-image--empty,
.insights-list__card-image--empty {
  background: #e8ebe5;
}

.insights-list__card-words {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 10px;
  padding: 20px;
}

.insights-list__card-title {
  color: #0d3d39;
  font-size: 18px;
  font-weight: 600;
  line-height: 1.35;
}

.insights-list__card-excerpt {
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.5;
}

.insights-list__card-meta {
  margin-top: auto;
}

/* 4. Load more */

.insights-list__more {
  align-self: center;
  padding: 13px 22px;
  border: 1.5px solid var(--teal-darker);
  border-radius: 8px;
  background: var(--white);
  color: var(--teal-darker);
  font-weight: 600;
  text-decoration: none;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.insights-list__more:hover,
.insights-list__more:focus-visible {
  background: var(--teal-darker);
  color: var(--white);
}

/* Tablets: the featured photo above its words, and the cards in two columns */

@media (max-width: 1023px) {
  .insights-list__featured {
    grid-template-columns: minmax(0, 1fr);
  }

  .insights-list__featured-image {
    height: auto;
    min-height: 0;
    aspect-ratio: 16 / 7;
  }

  .insights-list__featured-words {
    padding: 28px;
  }

  .insights-list__cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  /* An odd last card runs across both columns, its photo beside its words, so no card sits alone */

  .insights-list__cards > li:last-child:nth-child(odd) {
    grid-column: 1 / -1;
  }

  .insights-list__cards > li:last-child:nth-child(odd) .insights-list__card {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .insights-list__cards > li:last-child:nth-child(odd) .insights-list__card-image {
    height: 100%;
    aspect-ratio: auto;
    min-height: 200px;
  }
}

/* Phones: one card a row, and the search the full width */

@media (max-width: 640px) {
  .insights-list__search {
    flex: 1 1 100%;
    margin: 0;
  }

  .insights-list__search input[type="search"] {
    flex: 1;
    width: auto;
    min-width: 0;
  }

  .insights-list__featured-words {
    padding: 22px;
  }

  .insights-list__cards {
    grid-template-columns: minmax(0, 1fr);
  }

  .insights-list__cards > li:last-child:nth-child(odd) .insights-list__card {
    display: flex;
  }

  .insights-list__cards > li:last-child:nth-child(odd) .insights-list__card-image {
    height: auto;
    min-height: 0;
    aspect-ratio: 16 / 7;
  }
}
