/* --------- Latest insights block (blocks/latest-insights) --------- */

/* A desktop shows the first two of the six. */
@media (min-width: 782px) {
  .latest-insights-track {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--wp--preset--spacing--30);
  }

  .latest-insight:nth-child(n + 3) {
    display: none;
  }
}

/* A phone shows them one at a time, in a row swiped sideways. */
@media (max-width: 781px) {
  /* Positioned, so a card's offsetLeft (view.js) is measured from it. */
  .latest-insights-track {
    position: relative;
    display: flex;
    gap: var(--wp--preset--spacing--30);
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
  }

  .latest-insights-track::-webkit-scrollbar {
    display: none;
  }

  .latest-insight {
    flex: 0 0 100%;
    scroll-snap-align: start;
  }
}

/* The dots, from view.js, on a phone only: a 24px button around each,
   for the finger. */
.latest-insights-dots {
  display: flex;
  justify-content: center;
  gap: 4px;
  margin-top: var(--wp--preset--spacing--40);
}

@media (min-width: 782px) {
  .latest-insights-dots {
    display: none;
  }
}

.latest-insights-dot {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
}

.latest-insights-dot::before {
  content: "";
  box-sizing: border-box;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background-color: var(--wp--preset--color--heading);
}

.latest-insights-dot[aria-current="true"]::before {
  width: 14px;
  height: 14px;
  border: 2px solid var(--wp--preset--color--heading);
  background-color: var(--wp--preset--color--secondary);
}

.latest-insights-dot:focus-visible {
  outline: 2px solid var(--wp--preset--color--primary);
  outline-offset: 0;
  border-radius: 50%;
}

.latest-insight {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: clamp(16px, 1vw + 12.3px, 27px);
  border-radius: clamp(24px, 0.75vw + 21.6px, 36px);
  background-color: var(--wp--preset--color--primary);
  color: var(--wp--preset--color--base);
}

.latest-insight-image img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 2.07;
  border-radius: 24px;
  object-fit: cover;
}

/* The text sits further in than the photo, as the mockup draws it. */
.latest-insight-body {
  display: flex;
  flex: 1;
  flex-direction: column;
  padding: var(--wp--preset--spacing--50) clamp(8px, 0.6vw + 6px, 16px) clamp(8px, 0.6vw + 6px, 16px);
}

.latest-insight .latest-insight-label {
  margin: 0;
  color: var(--wp--preset--color--secondary);
  font-size: var(--wp--preset--font-size--small);
  font-weight: 500;
  letter-spacing: 0.1em;
  line-height: 1.4;
  text-transform: uppercase;
}

/* Lifted over the title's link, which covers the whole card. */
.latest-insight-label a {
  position: relative;
  z-index: 1;
  color: inherit;
  text-decoration: none;
}

.latest-insight-label a:hover {
  text-decoration: underline;
}

.latest-insight .latest-insight-title {
  margin: var(--wp--preset--spacing--30) 0 var(--wp--preset--spacing--50);
  color: inherit;
  font-size: var(--wp--preset--font-size--normal);
  font-weight: 400;
  line-height: 1.35;
  /* Fills each line, as the mockup does: undoes the headings' balance (blocks.css). */
  text-wrap: wrap;
}

.latest-insight-title a {
  color: inherit;
  text-decoration: none;
  transition: color 0.2s ease;
}

.latest-insight-title a::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
}

.latest-insight-title a:focus-visible {
  outline: none;
}

.latest-insight:has(.latest-insight-title a:focus-visible) {
  outline: 2px solid var(--wp--preset--color--primary);
  outline-offset: 2px;
}

.latest-insight-arrow {
  display: block;
  width: 16px;
  height: 16px;
  margin-top: auto;
  background-color: var(--wp--preset--color--secondary);
  mask: url(../../assets/img/arrow-down-right.svg) no-repeat center / contain;
  -webkit-mask: url(../../assets/img/arrow-down-right.svg) no-repeat center / contain;
}

@media (hover: hover) {
  .latest-insight:hover .latest-insight-title a {
    color: var(--wp--preset--color--secondary);
  }
}
