/** Card proportions come from the research and topic-navigation artboards. */
.link-collection {
  --link-collection-gap: clamp(1.25rem, 2.083vw, 2.5rem);
}

.link-collection h2 {
  margin-block-end: var(--space-4);
  font-size: var(--font-section);
  font-weight: 400;
}

.link-collection__layout,
.link-collection__items {
  display: grid;
  gap: var(--link-collection-gap);
  min-inline-size: 0;
}

.link-card,
.content-card {
  min-inline-size: 0;
}

.content-card__link {
  position: relative;
  display: grid;
  aspect-ratio: 364 / 626;
  overflow: hidden;
  color: var(--color-paper);
  background: var(--color-dark);
  border-radius: var(--radius-card);
  text-decoration: none;
}

.content-card__media {
  grid-area: 1 / 1;
}

.content-card__media .media-image,
.content-card__media img {
  inline-size: 100%;
  block-size: 100%;
  object-fit: cover;
  object-position: center;
}

/* A gradient preserves text contrast when an editor replaces the photo. */
.content-card__link::after {
  grid-area: 1 / 1;
  content: '';
  background: linear-gradient(transparent 35%, rgb(0 0 0 / 0.65));
}

.content-card__body {
  z-index: 1;
  grid-area: 1 / 1;
  align-self: end;
  padding: clamp(1.25rem, 2.344vw, 2.8125rem);
}

.content-card__title {
  margin: 0;
  font-size: clamp(1.4rem, 2.083vw, 2.5rem);
  font-weight: 400;
  line-height: 1.1;
}

.content-card__summary {
  margin-block-start: 1.25rem;
  font-size: clamp(1rem, 1.302vw, 1.5625rem);
  line-height: 1.4;
}

.link-collection--research :is(.content-card__title, .content-card__summary),
.link-collection--home-navigation .content-card__title,
.link-collection--horizontal.link-collection--overlay.surface--soft :is(h2, .content-card__title, .content-card__more),
.content-page--lesson .link-collection--link-list :is(h2, .content-card__title) {
  letter-spacing: var(--tracking-open);
}

.content-card__arrow {
  position: absolute;
  inset-block-start: clamp(1rem, 1.875vw, 2.25rem);
  inset-inline-end: clamp(1rem, 1.875vw, 2.25rem);
  display: grid;
  place-items: center;
  inline-size: clamp(2.25rem, 4.74vw, 5.6875rem);
  aspect-ratio: 1;
  color: var(--color-ink);
  background: var(--color-paper);
  border-radius: 50%;
}

/* The arrow inherits the foreground color of its card variant. */
.content-card__arrow::before,
.link-collection--link-list .content-card__title::before {
  content: '';
  aspect-ratio: 38.791 / 34.879;
  background-color: currentColor;
  mask: url('../../images/design/content-card-arrow.svg') center / contain no-repeat;
}

.content-card__arrow::before {
  inline-size: 45%;
}

.content-card__more {
  display: block;
  margin-block-start: 1rem;
  padding: 0.3rem 0.75rem;
  color: var(--color-paper);
  background: var(--color-dark);
  border-radius: 3rem;
  font-size: clamp(0.75rem, 0.938vw, 1.125rem);
  line-height: 1.5;
  text-align: center;
  text-decoration: none;
}

/* The overview links directly from each tile. Text can grow beyond the photo ratio. */
.page-heading + .link-collection--research {
  padding-block: 0;
}

.link-collection--research .content-card__link {
  aspect-ratio: 489 / 769;
}

.link-collection--research .content-card__media {
  position: absolute;
  inset: 0;
}

.link-collection--research .content-card__link::after {
  /* Paint the contrast layer above the photo and below the text. */
  position: absolute;
  inset: 0;
  background: linear-gradient(transparent 40%, rgb(0 0 0 / 0.62) 67%, rgb(0 0 0 / 0.8));
}

.link-collection--research .content-card__body {
  padding-block-start: 5.5rem;
}

.link-collection--research .content-card__summary {
  font-size: clamp(0.9375rem, 1.042vw, 1.25rem);
}

.link-collection--research .content-card__link:not(:has(.content-card__media img)) {
  color: var(--color-text);
  background: var(--color-yellow);
}

.link-collection--research .content-card__link:not(:has(.content-card__media img))::after,
.link-collection--research .content-card__more {
  display: none;
}

.link-collection--research .content-card__link:focus-visible {
  outline-offset: 4px;
}

/* Horizontal collections scroll natively, with no automatic movement. */
.link-collection--horizontal .link-collection__items {
  grid-auto-flow: column;
  grid-auto-columns: minmax(15rem, 24%);
  align-items: start;
  overflow-x: auto;
  padding-block-end: 2rem;
  scroll-snap-type: x proximity;
  scrollbar-color: var(--color-ink) transparent;
}

.link-collection--horizontal .link-card {
  scroll-snap-align: start;
}

/* Topic cards reveal more of the photograph by growing horizontally, not scaling.
 * A stable image height keeps the row and the page below it from jumping. */
.link-collection--horizontal.link-collection--overlay .link-collection__items {
  display: flex;
  align-items: stretch;
}

.link-collection--horizontal.link-collection--overlay .link-card {
  flex: 0 0 var(--link-card-basis, max(15rem, 24%));
  transition: flex-basis 350ms ease;
}

.link-collection--horizontal.link-collection--overlay .content-card__link {
  block-size: clamp(24rem, 32.604vw, 39.125rem);
  aspect-ratio: auto;
}

.link-collection--horizontal.link-collection--overlay .content-card__media {
  /* Keep intrinsic image dimensions from setting the flex item's minimum size. */
  position: absolute;
  inset: 0;
}

.link-collection--horizontal.link-collection--overlay .content-card__more {
  inline-size: min(100%, clamp(15rem, 18.958vw, 22.75rem));
}

.link-collection--horizontal.link-collection--overlay.surface--soft .content-card__more {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75em;
  min-block-size: clamp(2.25rem, 2.865vw, 3.4375rem);
  margin-block-start: clamp(1rem, 1.98vw, 2.375rem);
  padding: 0.35em clamp(0.75rem, 1.3vw, 1.5625rem);
  line-height: 1.2;
  text-align: start;
}

.link-collection--horizontal.link-collection--overlay.surface--soft .content-card__more::after {
  flex: 0 0 clamp(1.25rem, 1.77vw, 2.125rem);
  aspect-ratio: 34 / 26;
  background-color: currentColor;
  mask: url('../../images/design/arrow-right.svg') center / contain no-repeat;
  content: '';
}

.link-collection--horizontal.surface--soft .link-collection__items {
  padding-block-end: clamp(2.5rem, 8.33vw, 10rem);
  scrollbar-color: var(--color-text) #a3a3a3;
}

@supports selector(::-webkit-scrollbar) {
  /* Style the native control as a thin track with a taller pill-shaped thumb. */
  .link-collection--horizontal.surface--soft .link-collection__items {
    scrollbar-color: auto;
  }

  .link-collection--horizontal.surface--soft .link-collection__items::-webkit-scrollbar {
    height: clamp(0.875rem, 1.615vw, 1.9375rem);
  }

  .link-collection--horizontal.surface--soft .link-collection__items::-webkit-scrollbar-track {
    background: linear-gradient(#a3a3a3, #a3a3a3) center / 100% clamp(2px, 0.208vw, 4px) no-repeat;
  }

  .link-collection--horizontal.surface--soft .link-collection__items::-webkit-scrollbar-thumb {
    border-radius: 999px;
    background: var(--color-text);
  }
}

@media (min-width: 48rem) {
  .link-collection--horizontal.link-collection--overlay .link-card:focus-within {
    flex-basis: max(25rem, 42%);
  }
}

@media (min-width: 48rem) and (hover: hover) and (pointer: fine) {
  .link-collection--horizontal.link-collection--overlay .link-card:hover {
    flex-basis: max(25rem, 42%);
  }
}

@media (min-width: 75rem) {
  .link-collection--horizontal.link-collection--overlay > .container:has(.link-collection__items > .link-card:nth-child(4):last-child) {
    inline-size: auto;
    margin-inline-start: max(var(--page-gutter), calc((100% - var(--width-page)) / 2));
    margin-inline-end: 0;
  }

  /* Size the four cards to the reading width, then let an expanded card push
   * its neighbours into the right gutter and past the viewport edge. */
  .link-collection--horizontal.link-collection--overlay .link-collection__items:has(> .link-card:nth-child(4):last-child) {
    --link-collection-resting-width: min(var(--width-page), calc(100% - var(--page-gutter)));
    --link-card-basis: calc((var(--link-collection-resting-width) - 3 * var(--link-collection-gap)) / 4);

    padding-block: 0.5rem;
    scrollbar-width: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .link-collection--horizontal.link-collection--overlay .link-card {
    transition: none;
  }
}

.link-collection__illustration img {
  border-radius: var(--radius-card);
}

.link-collection--link-list {
  background: var(--color-lime-pale);
}

.link-collection--link-list .content-card__link {
  display: block;
  aspect-ratio: auto;
  overflow: visible;
  color: var(--color-text);
  background: none;
  border-radius: 0;
}

.link-collection--link-list .content-card__body {
  padding: 0;
}

.link-collection--link-list .content-card__title {
  font-size: clamp(1rem, 1.302vw, 1.5625rem);
  font-weight: 400;
}

.link-collection--link-list .content-card__title::before {
  display: inline-block;
  inline-size: 1em;
  margin-inline-end: 1rem;
  vertical-align: middle;
}

.content-page--lesson .link-collection--link-list .content-card__title {
  position: relative;
  max-inline-size: 40.625rem;
  padding-inline-start: 2.5em;
  color: var(--color-ink);
  font-size: clamp(1.125rem, 1.5625vw, 1.875rem);
  line-height: 1.4;
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

/* Keep wrapped article titles aligned with the first line of text. */
.content-page--lesson .link-collection--link-list .content-card__title::before {
  position: absolute;
  inset-block-start: 0.32em;
  inset-inline-start: 0.4em;
  inline-size: 1.13em;
  aspect-ratio: 34 / 23;
  margin: 0;
  background-color: var(--color-text);
  mask-image: url('../../images/design/lesson-article-arrow.svg');
}

@media (min-width: 48rem) {
  /* The lesson artboards align the heading with the links beside the photo. */
  .content-page--lesson .link-collection--link-list > .container:has(.link-collection__illustration) {
    display: grid;
    grid-template-columns: minmax(0, 46.5%) minmax(0, 1fr);
    grid-template-areas:
      "photo heading"
      "photo links";
    column-gap: 8.25%;
  }

  .content-page--lesson .link-collection--link-list .link-collection__layout:has(.link-collection__illustration) {
    display: contents;
  }

  .content-page--lesson .link-collection--link-list h2 {
    grid-area: heading;
  }

  .content-page--lesson .link-collection--link-list .link-collection__illustration {
    grid-area: photo;
  }

  .content-page--lesson .link-collection--link-list .link-collection__items {
    grid-area: links;
    align-content: start;
  }
}

.link-collection--link-list .content-card__media,
.link-collection--link-list .content-card__summary,
.link-collection--link-list .content-card__arrow,
.link-collection--link-list .content-card__more,
.link-collection--link-list .content-card__link::after {
  display: none;
}

/* Exhibition cards use the same fields with an editorial treatment. */
.link-collection--editorial .content-card__link {
  display: block;
  aspect-ratio: auto;
  overflow: visible;
  color: var(--color-text);
  background: transparent;
  border-radius: 0;
}

.link-collection--editorial .content-card__media img {
  aspect-ratio: 1.15;
  border-radius: var(--radius-card);
}

.link-collection--editorial .content-card__body {
  padding: 1.25rem 0 0;
}

.link-collection--editorial .content-card__title {
  font-size: var(--font-section);
}

.link-collection--editorial .content-card__arrow,
.link-collection--editorial .content-card__more,
.link-collection--editorial .content-card__link::after {
  display: none;
}

.link-collection--home-navigation .content-card__link {
  aspect-ratio: 1.6;
}

@media (min-width: 48rem) {
  .link-collection--grid .link-collection__items {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: clamp(2rem, 4.48vw, 5.375rem);
  }

  .link-collection--grid .content-card__link {
    aspect-ratio: 489 / 769;
  }

  /* Photo overlays keep the image clear. Editorial cards have room below it. */
  .link-collection--horizontal.link-collection--overlay .content-card__summary {
    display: none;
  }

  .link-collection--link-list .link-collection__layout:has(.link-collection__illustration) {
    grid-template-columns: 1fr 1.4fr;
    align-items: center;
    gap: 8%;
  }

  .link-collection--editorial .link-card:nth-child(2) {
    margin-block-start: 6%;
  }

  .link-collection--editorial .link-card:nth-child(3) {
    margin-block-start: 12%;
  }
}

/* Page 1 uses seven ordered destinations. The desktop composition overlays
 * three independent links while preserving the same reading order on phones. */
.link-collection--home-navigation {
  padding-block: 0 var(--home-gutter);
}

.link-collection--home-navigation > .container {
  inline-size: min(var(--width-page), calc(100% - 2 * var(--home-gutter)));
}

.link-collection--home-navigation .content-card__media {
  position: absolute;
  inset: 0;
}

.link-collection--home-navigation .content-card__link::after {
  position: absolute;
  inset: 0;
  background: linear-gradient(transparent 45%, rgb(0 0 0 / 0.18));
}

.link-collection--home-navigation .content-card__more,
.link-collection--home-navigation .content-card__summary,
.link-collection--home-navigation .content-card__arrow {
  display: none;
}

.link-collection--home-navigation .content-card__title {
  display: inline;
  padding: 0.4em 0.65em;
  color: var(--color-text);
  background: var(--color-paper);
  border-radius: 2rem;
  box-decoration-break: clone;
  font-size: clamp(1rem, 1.72vw, 2.0625rem);
  /* Center the label padding around the cap height and alphabetic baseline. */
  text-box: trim-both cap alphabetic;
}

.link-collection--home-navigation .link-card:nth-child(2) .content-card__link,
.link-collection--home-navigation .link-card:nth-child(n + 6) .content-card__link {
  place-items: center;
  aspect-ratio: 2.5;
  color: var(--color-text);
  background: var(--color-yellow);
  border-radius: 0.875rem;
}

.link-collection--home-navigation .link-card:nth-child(2) .content-card__link {
  background: #efa583;
}

.link-collection--home-navigation .link-card:nth-child(6) .content-card__link {
  background: #ffebaf;
}

.link-collection--home-navigation .link-card:nth-child(2) .content-card__body,
.link-collection--home-navigation .link-card:nth-child(n + 6) .content-card__body {
  align-self: center;
  padding: 0.75rem;
  text-align: center;
}

.link-collection--home-navigation .link-card:nth-child(2) .content-card__title,
.link-collection--home-navigation .link-card:nth-child(n + 6) .content-card__title {
  padding: 0;
  background: none;
}

.link-collection--home-navigation .link-card:nth-child(2) .content-card__media,
.link-collection--home-navigation .link-card:nth-child(n + 6) .content-card__media,
.link-collection--home-navigation .link-card:nth-child(2) .content-card__link::after,
.link-collection--home-navigation .link-card:nth-child(n + 6) .content-card__link::after,
.link-collection--home-navigation .link-card:nth-child(4) .content-card__link::after {
  display: none;
}

.link-collection--home-navigation .link-card:nth-child(4) .content-card__link {
  container-type: inline-size;
  background: #7b8b51;
}

.link-collection--home-navigation .link-card:nth-child(4) .content-card__media {
  inset: 0.75rem 0.75rem 0.75rem auto;
  inline-size: 35%;
  overflow: hidden;
  border-radius: calc(var(--radius-card) * 0.8);
}

.link-collection--home-navigation .link-card:nth-child(4) .content-card__body {
  align-self: center;
  max-inline-size: 65%;
  padding: clamp(0.75rem, 1.8vw, 2.125rem);
}

.link-collection--home-navigation .link-card:nth-child(5) .content-card__link::after {
  background: rgb(32 72 77 / 0.62);
}

.link-collection--home-navigation .link-card:nth-child(4) .content-card__title,
.link-collection--home-navigation .link-card:nth-child(5) .content-card__title {
  /* Keep the outline continuous if a title wraps. */
  display: inline-block;
  max-inline-size: 100%;
  color: #ffeb03;
  background: transparent;
  border: 1px solid currentColor;
}

.link-collection--home-navigation .link-card:nth-child(4) .content-card__title {
  /* The photo takes 35% of this tile even after the grid reaches its width cap. */
  font-size: clamp(1rem, 5.6cqi, 1.625rem);
}

@media (min-width: 64rem) {
  .link-collection--home-navigation .link-collection__items {
    grid-template-columns: repeat(8, minmax(0, 1fr)) repeat(2, minmax(0, 0.95fr)) repeat(2, minmax(0, 1.37fr));
    grid-template-rows: minmax(0, 2fr) minmax(0, 1fr);
    gap: clamp(0.625rem, 1.3vw, 1.5rem);
    aspect-ratio: 1800 / 900;
  }

  .link-collection--home-navigation .content-card,
  .link-collection--home-navigation .content-card__link {
    inline-size: 100%;
    block-size: 100%;
  }

  .link-collection--home-navigation .link-card:nth-child(1) {
    grid-area: 1 / 1 / 2 / 9;
  }

  .link-collection--home-navigation .link-card:nth-child(2) {
    z-index: 2;
    grid-area: 1 / 1 / 2 / 9;
    align-self: end;
    justify-self: end;
    inline-size: 29%;
    block-size: 36%;
    margin: 0.875rem;
  }

  .link-collection--home-navigation .link-card:nth-child(3) {
    grid-area: 2 / 1 / 3 / 5;
  }

  .link-collection--home-navigation .link-card:nth-child(4) {
    grid-area: 2 / 5 / 3 / 9;
  }

  .link-collection--home-navigation .link-card:nth-child(5) {
    grid-area: 1 / 9 / 3 / 13;
  }

  .link-collection--home-navigation .link-card:nth-child(5) .content-card__body {
    align-self: start;
    padding-block-start: 29%;
    text-align: center;
  }

  .link-collection--home-navigation .link-card:nth-child(6),
  .link-collection--home-navigation .link-card:nth-child(7) {
    z-index: 2;
    align-self: end;
    block-size: 72%;
    margin-block-end: 0.875rem;
  }

  .link-collection--home-navigation .link-card:nth-child(6) {
    grid-area: 2 / 9 / 3 / 11;
    margin-inline: 1.25rem 0;
  }

  .link-collection--home-navigation .link-card:nth-child(6) .content-card__body {
    padding-inline: 0.4rem;
  }

  .link-collection--home-navigation .link-card:nth-child(6) .content-card__title {
    font-size: clamp(0.875rem, 1.37vw, 1.6875rem);
  }

  .link-collection--home-navigation .link-card:nth-child(7) {
    grid-area: 2 / 11 / 3 / 13;
    margin-inline: 0 0.875rem;
  }
}
