/* Didatec — bloc « news ».
   Chargé uniquement quand le bloc est présent (enqueue_style ACF). */

/* News section ----------------------------------------------------------- */

.news__title {
  margin-block-end: var(--wp--preset--spacing--50);
}

.news__viewport {
  position: relative;
}

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

.news-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 24px;
  min-width: 0;
}

.news-card__media {
  aspect-ratio: 640 / 390;
  border-radius: 5px;
  overflow: hidden;
  background-color: var(--wp--preset--color--field);
}

.news-card__media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.news-card:hover .news-card__media img {
  transform: scale(1.03);
}

.news-card__body {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
}

.news-card__ribbon {
  background-color: var(--wp--preset--color--white);
  border: 1px solid var(--wp--preset--color--blue-20);
  color: var(--wp--preset--color--blue);
}

.news-card__title {
  font-size: var(--wp--preset--font-size--h-3);
  font-weight: 500;
  line-height: 1.1;
  letter-spacing: -0.04em;
}

.news-card__title a {
  text-decoration-line: underline;
  text-decoration-color: transparent;
}

/* The title link covers the card: one link, one accessible name, and the whole
   tile is clickable. Only cards that carry a link get one. */
.news-card__title a::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 5px;
}

.news-card:hover .news-card__title a,
.news-card:focus-within .news-card__title a {
  text-decoration-color: currentColor;
}

@supports selector(:has(*)) {
  .news-card:has(:focus-visible) {
    outline: 2px solid var(--wp--preset--color--blue);
    outline-offset: 4px;
  }

  .news-card__title a:focus-visible {
    outline: none;
  }
}

.news-card__text {
  /* Trois lignes maximum : les accroches saisies en back-office varient, et
     au-delà les cartes de la rangée ne s'alignent plus. */
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  overflow: hidden;
  font-size: var(--wp--preset--font-size--small);
  line-height: 1.3;
  letter-spacing: -0.01em;
}

/* Figma 12078:2138: 33x33 blue square, white 17px arrow, radius 5.
   Le bouton se cale au milieu du visuel de la carte. Un pourcentage dans
   `inset-block-start` se résoudrait sur la hauteur de la piste ; dans une
   marge de bloc il se résout sur sa largeur, ce dont le ratio 640/390 a
   besoin. La valeur est donc posée par contexte, plus bas. */
.news__nav {
  position: absolute;
  inset-block-start: 0;
  display: none;
  align-items: center;
  justify-content: center;
  width: 33px;
  height: 33px;
  border: 1px solid var(--wp--preset--color--blue);
  border-radius: 5px;
  background-color: var(--wp--preset--color--blue);
  color: var(--wp--preset--color--white);
  cursor: pointer;
  transition:
    background-color 0.2s ease,
    border-color 0.2s ease;
}

.news__nav .icon {
  width: 17px;
  height: 17px;
}

.news__nav:hover,
.news__nav:focus-visible {
  background-color: var(--wp--preset--color--black);
  border-color: var(--wp--preset--color--black);
}

.news__prev {
  inset-inline-start: -16px;
}
.news__next {
  inset-inline-end: -16px;
}

/* The class lands on the section: the track knows whether it overflows. */
.news.is-scrollable .news__nav {
  display: inline-flex;
}

/* Beyond three cards the desktop row cannot hold them all: the list becomes a
   scroll track showing three at a time, like the mobile one. */
@media (min-width: 1024px) {
  .news--scroll .news__list {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
  }

  .news--scroll .news__list::-webkit-scrollbar {
    display: none;
  }

  .news--scroll .news__list > .news-card {
    /* Three tracks and the two 32px gaps between them. */
    flex: 0 0 calc((100% - 64px) / 3);
    scroll-snap-align: start;
  }

  .news--scroll .news__nav {
    margin-block-start: calc((100% - 64px) / 3 * 390 / 640 / 2 - 16.5px);
  }
}

@media (max-width: 1023px) {
  .news__list {
    display: flex;
    gap: 16px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
  }

  .news__list::-webkit-scrollbar {
    display: none;
  }

  .news__list > .news-card {
    flex: 0 0 100%;
    scroll-snap-align: start;
  }

  .news__nav {
    margin-block-start: calc(100% * 390 / 640 / 2 - 16.5px);
  }
  .news__prev {
    inset-inline-start: 8px;
  }
  .news__next {
    inset-inline-end: 8px;
  }
}
